2 #include "GVOShipRoute.h"
7 const float k_worldLoopThreshold = 0.5f;
9 inline POINT s_denormalizedPoint( const GVONormalizedPoint & point )
12 static_cast<long>(::round( point.x() * k_worldWidth )),
13 static_cast<long>(::round( point.y() * k_worldHeight )),
20 void GVOShipRoute::addRoutePoint( const GVONormalizedPoint & point )
22 _ASSERT( !isFixed() );
24 if ( m_lines.empty() ) {
25 m_lines.push_back( Line() );
28 Line & line = m_lines.back();
30 line.push_back( point );
34 GVOVector vector( s_denormalizedPoint( line.back() ), s_denormalizedPoint( point ) );
35 m_length += vector.length();
37 const GVONormalizedPoint & prevPoint = line.back();
38 if ( prevPoint.isEqualValue( point ) ) {
42 //
\90¢
\8aE
\82ð
\8c×
\82¢
\82¾
\8fê
\8d\87\82Í
\90ü
\82ð
\95ª
\8a\84\82·
\82é
43 if ( prevPoint.x() < point.x() && (k_worldLoopThreshold <= (point.x() - prevPoint.x())) ) {
44 //
\90¼
\82É
\8cü
\82©
\82Á
\82Ä
\8c×
\82¢
\82¾
\8fê
\8d\87
45 const GVONormalizedPoint leftSideSubPoint( point.x() - 1.0f, point.y() );
46 const GVONormalizedPoint rightSideSubPoint( prevPoint.x() + 1.0f, prevPoint.y() );
48 line.push_back( leftSideSubPoint );
49 m_lines.emplace( m_lines.end(), std::move( Line{ rightSideSubPoint, point } ) );
51 else if ( point.x() < prevPoint.x() && (k_worldLoopThreshold <= (prevPoint.x() - point.x())) ) {
52 //
\93\8c\82É
\8cü
\82©
\82Á
\82Ä
\8c×
\82¢
\82¾
\8fê
\8d\87
53 const GVONormalizedPoint rightSideSubPoint( point.x() + 1.0f, point.y() );
54 const GVONormalizedPoint leftSideSubPoint( prevPoint.x() - 1.0f, prevPoint.y() );
56 line.push_back( rightSideSubPoint );
57 m_lines.emplace( m_lines.end(), std::move( Line{ leftSideSubPoint, point } ) );
60 line.push_back( point );
65 void GVOShipRoute::jointPreviousLinesWithRoute( const GVOShipRoute & srcRoute )
67 //
\98A
\8c\8b\8c³
\82Ì
\8dq
\98H
\82ª
\90ü
\82ð
\95Û
\8e\9d\82µ
\82Ä
\82¢
\82È
\82¯
\82ê
\82Î
\96³
\8e\8b\82·
\82é
\81B
68 if ( srcRoute.isEmptyRoute() ) {
71 //
\98A
\8c\8b\90æ
\82Ì
\8dq
\98H
\82ª
\90ü
\82ð
\95Û
\8e\9d\82µ
\82Ä
\82¢
\82È
\82¯
\82ê
\82Î
\96³
\8e\8b\82·
\82é
\81B
72 if ( isEmptyRoute() ) {
73 m_lines = srcRoute.m_lines;
78 //
\82Q
\82Â
\82Ì
\8dq
\98H
\82Ì
\92·
\82³
\82ð
\91«
\82·
79 m_length += srcRoute.m_length;
82 Lines tmp = srcRoute.m_lines;
84 //
\91O
\82Ì
\8dq
\98H
\82Ì
\8fI
\93_
\82Æ
\8c»
\8dÝ
\82Ì
\8dq
\98H
\82Ì
\8en
\93_
\82ª
\98A
\8c\8b\89Â
\94\
\82È
\82ç
\83\89\83C
\83\93\82ð
\8cq
\82°
\82È
\82¯
\82ê
\82Î
\82È
\82ç
\82È
\82¢
86 Line & prevLine = tmp.back();
87 Line & nextLine = m_lines.front();
89 //
\82Q
\82Â
\82Ì
\90ü
\82ª
\93_
\82ð
\95Û
\8e\9d\82µ
\82Ä
\82¢
\82é
\82©
\8am
\94F
\82µ
\82Ä
\82¨
\82
90 if ( !prevLine.empty() && !nextLine.empty() ) {
91 GVONormalizedPoint prevPoint = prevLine.back();
92 GVONormalizedPoint nextPoint = nextLine.front();
94 //
\8dq
\98H
\8aÔ
\82Ì
\92·
\82³
\82ð
\91«
\82·
95 const double betweenLength = GVOVector( s_denormalizedPoint( prevPoint ), s_denormalizedPoint( nextPoint ) ).length();
96 m_length += betweenLength;
98 //
\90¢
\8aE
\82ð
\8c×
\82¢
\82Å
\82¢
\82È
\82¢
\82æ
\82¤
\82È
\82ç
\90ü
\82ð
\90Ú
\91±
\82·
\82é
99 if ( (std::max( prevPoint.x(), nextPoint.x() ) - std::min(prevPoint.x(), nextPoint.x())) < k_worldLoopThreshold ) {
100 prevLine.insert( prevLine.end(), nextLine.begin(), nextLine.end() );
101 m_lines.erase( m_lines.begin() );
105 tmp.insert( tmp.end(), m_lines.begin(), m_lines.end() );
108 //
\82Ç
\82¿
\82ç
\82©
\82ª
\82¨
\8bC
\82É
\93ü
\82è
\8dq
\98H
\82È
\82ç
\98A
\8c\8b\8cã
\82à
\82¨
\8bC
\82É
\93ü
\82è
\8dq
\98H
\82Æ
\8c©
\82È
\82·
109 setFavorite( isFavorite() | srcRoute.isFavorite() );