Only search pads when the position hits module

On large boards with high pad-count modules, searching each pad for hits
becomes expensive.  We eliminate many of the pad searches by first
checking the module's bounding box before iterating over pads to look
for hits.
This commit is contained in:
Seth Hillbrand 2018-05-22 15:37:24 -07:00
parent 8c5037a48b
commit b625d29151
1 changed files with 5 additions and 11 deletions

View File

@ -1556,7 +1556,10 @@ D_PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerSet )
for( MODULE* module = m_Modules; module; module = module->Next() )
{
D_PAD* pad = module->GetPad( aPosition, aLayerSet );
D_PAD* pad = NULL;
if( module->HitTest( aPosition ) )
pad = module->GetPad( aPosition, aLayerSet );
if( pad )
return pad;
@ -1572,16 +1575,7 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint )
LSET lset( aTrace->GetLayer() );
for( MODULE* module = m_Modules; module; module = module->Next() )
{
D_PAD* pad = module->GetPad( aPosition, lset );
if( pad )
return pad;
}
return NULL;
return GetPad( aPosition, lset );
}