Restore clearance cache usage in PNS::NODE::NearestObstacle.

This (and the other commit) restores router performance to pre-7.0.3 levels.
This commit is contained in:
Alex Shvartzkop 2023-11-07 01:20:25 +03:00
parent d29c07a663
commit 5e93814283
1 changed files with 6 additions and 10 deletions

View File

@ -281,21 +281,17 @@ int NODE::QueryColliding( const ITEM* aItem, NODE::OBSTACLES& aObstacles,
NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aLine, NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aLine,
const COLLISION_SEARCH_OPTIONS& aOpts ) const COLLISION_SEARCH_OPTIONS& aOpts )
{ {
const int clearanceEpsilon = GetRuleResolver()->ClearanceEpsilon(); const int clearanceEpsilon = GetRuleResolver()->ClearanceEpsilon();
OBSTACLES obstacleList; OBSTACLES obstacleList;
std::vector<SEGMENT> tmpSegs;
tmpSegs.reserve( aLine->CLine().SegmentCount() );
for( int i = 0; i < aLine->CLine().SegmentCount(); i++ ) for( int i = 0; i < aLine->CLine().SegmentCount(); i++ )
{ {
// Note: Clearances between tmpSegs.back() and other items are cached, // Note: Clearances between &s and other items are cached,
// which means they'll be the same for all segments in the line. // which means they'll be the same for all segments in the line.
// Disabling the cache will lead to slowness. // Disabling the cache will lead to slowness.
tmpSegs.emplace_back( *aLine, aLine->CLine().CSegment( i ) ); const SEGMENT s( *aLine, aLine->CLine().CSegment( i ) );
QueryColliding( &tmpSegs.back(), obstacleList, aOpts ); QueryColliding( &s, obstacleList, aOpts );
} }
if( aLine->EndsWithVia() ) if( aLine->EndsWithVia() )