Performance: check line ends first before doing collision.

This commit is contained in:
Jeff Young 2022-02-15 18:15:22 +00:00
parent 2172810600
commit 72a389e612
1 changed files with 17 additions and 3 deletions

View File

@ -705,11 +705,25 @@ void CN_VISITOR::checkZoneItemConnection( CN_ZONE_LAYER* aZoneLayer, CN_ITEM* aI
if( !aItem->Parent()->IsOnLayer( layer ) )
return;
if( aZoneLayer->Collide( aItem->Parent()->GetEffectiveShape( layer ).get() ) )
auto connect =
[&]()
{
aZoneLayer->Connect( aItem );
aItem->Connect( aZoneLayer );
};
// Try quick checks first...
for( int i = 0; i < aItem->AnchorCount(); ++i )
{
if( aZoneLayer->ContainsPoint( aItem->GetAnchor( i ) ) )
{
connect();
return;
}
}
if( aZoneLayer->Collide( aItem->Parent()->GetEffectiveShape( layer ).get() ) )
connect();
}
void CN_VISITOR::checkZoneZoneConnection( CN_ZONE_LAYER* aZoneLayerA, CN_ZONE_LAYER* aZoneLayerB )