diff --git a/libs/kimath/src/geometry/shape_collisions.cpp b/libs/kimath/src/geometry/shape_collisions.cpp index 68e0dcf47b..45e41b5c3d 100644 --- a/libs/kimath/src/geometry/shape_collisions.cpp +++ b/libs/kimath/src/geometry/shape_collisions.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -192,6 +191,13 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_LINE_CHAIN_BASE& } } + if( aB.IsClosed() && aB.PointInside( aA.GetCenter() ) ) + { + closest_dist = 0; + nearest = aA.GetCenter(); + } + + if( closest_dist == 0 || closest_dist < aClearance ) { if( aLocation ) @@ -291,17 +297,6 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN_BASE& a { // TODO: why doesn't this handle MTV? - if( aB.IsClosed() && aB.PointInside( aA.Centre() ) ) - { - if( aLocation ) - *aLocation = aA.Centre(); - - if( aActual ) - *aActual = 0; - - return true; - } - int closest_dist = INT_MAX; VECTOR2I nearest; @@ -325,6 +320,12 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN_BASE& a } } + if( aB.IsClosed() && aB.PointInside( aA.Centre() ) ) + { + nearest = aA.Centre(); + closest_dist = 0; + } + if( closest_dist == 0 || closest_dist < aClearance ) { if( aLocation )