diff --git a/libs/kimath/src/geometry/shape.cpp b/libs/kimath/src/geometry/shape.cpp index 7d9902d63e..768709594d 100644 --- a/libs/kimath/src/geometry/shape.cpp +++ b/libs/kimath/src/geometry/shape.cpp @@ -62,14 +62,26 @@ int SHAPE::GetClearance( const SHAPE* aOther ) const /// Triangles check three vertices each but for the outline, we only need one. /// These are also fractured, so we don't need to worry about holes if( Type() == SHAPE_TYPE::SH_POLY_SET ) - a_shapes.push_back( &static_cast( this )->COutline( 0 ) ); + { + const SHAPE_POLY_SET* polySet = static_cast( this ); + if( polySet->OutlineCount() > 0 ) + a_shapes.push_back( &polySet->COutline( 0 ) ); + } else + { GetIndexableSubshapes( a_shapes ); + } if( aOther->Type() == SHAPE_TYPE::SH_POLY_SET ) - b_shapes.push_back( &static_cast( aOther )->COutline( 0 ) ); + { + const SHAPE_POLY_SET* polySet = static_cast( aOther ); + if( polySet->OutlineCount() > 0 ) + b_shapes.push_back( &polySet->COutline( 0 ) ); + } else + { aOther->GetIndexableSubshapes( b_shapes ); + } if( GetIndexableSubshapeCount() == 0 ) a_shapes.push_back( this );