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,13 +705,27 @@ void CN_VISITOR::checkZoneItemConnection( CN_ZONE_LAYER* aZoneLayer, CN_ITEM* aI
if( !aItem->Parent()->IsOnLayer( layer ) ) if( !aItem->Parent()->IsOnLayer( layer ) )
return; return;
if( aZoneLayer->Collide( aItem->Parent()->GetEffectiveShape( layer ).get() ) ) auto connect =
[&]()
{ {
aZoneLayer->Connect( aItem ); aZoneLayer->Connect( aItem );
aItem->Connect( aZoneLayer ); 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 ) void CN_VISITOR::checkZoneZoneConnection( CN_ZONE_LAYER* aZoneLayerA, CN_ZONE_LAYER* aZoneLayerB )
{ {
const ZONE* zoneA = static_cast<const ZONE*>( aZoneLayerA->Parent() ); const ZONE* zoneA = static_cast<const ZONE*>( aZoneLayerA->Parent() );