router: improved snap-to-clearance zone algorithm in highlight collisions mode
This commit is contained in:
parent
c777eac000
commit
a3d8ab911f
|
@ -413,24 +413,39 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead )
|
||||||
|
|
||||||
bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead )
|
bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead )
|
||||||
{
|
{
|
||||||
buildInitialLine( aP, m_head );
|
LINE newHead( m_head ), bestHead( m_head );
|
||||||
|
bool hasBest = false;
|
||||||
|
|
||||||
auto obs = m_currentNode->NearestObstacle( &m_head );
|
buildInitialLine( aP, newHead );
|
||||||
|
|
||||||
if( obs )
|
NODE::OBSTACLES obstacles;
|
||||||
|
|
||||||
|
m_currentNode->QueryColliding( &newHead, obstacles );
|
||||||
|
|
||||||
|
for( auto& obs : obstacles )
|
||||||
{
|
{
|
||||||
int cl = m_currentNode->GetClearance( obs->m_item, &m_head );
|
int cl = m_currentNode->GetClearance( obs.m_item, &newHead );
|
||||||
auto hull = obs->m_item->Hull( cl, m_head.Width() );
|
auto hull = obs.m_item->Hull( cl, newHead.Width() );
|
||||||
|
|
||||||
auto nearest = hull.NearestPoint( aP );
|
auto nearest = hull.NearestPoint( aP );
|
||||||
Dbg()->AddLine( hull, 2, 10000 );
|
Dbg()->AddLine( hull, 2, 10000 );
|
||||||
|
|
||||||
if( ( nearest - aP ).EuclideanNorm() < m_head.Width() )
|
if( ( nearest - aP ).EuclideanNorm() < newHead.Width() + cl )
|
||||||
{
|
{
|
||||||
buildInitialLine( nearest, m_head );
|
buildInitialLine( nearest, newHead );
|
||||||
|
if ( newHead.CLine().Length() > bestHead.CLine().Length() )
|
||||||
|
{
|
||||||
|
bestHead = newHead;
|
||||||
|
hasBest = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( hasBest )
|
||||||
|
m_head = bestHead;
|
||||||
|
else
|
||||||
|
m_head = newHead;
|
||||||
|
|
||||||
aNewHead = m_head;
|
aNewHead = m_head;
|
||||||
|
|
||||||
return static_cast<bool>( m_currentNode->CheckColliding( &m_head ) );
|
return static_cast<bool>( m_currentNode->CheckColliding( &m_head ) );
|
||||||
|
|
Loading…
Reference in New Issue