From f6d2164cb03bea380e754e42c53de2a5376e3048 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 28 Jul 2022 09:36:31 -0700 Subject: [PATCH] Fix crash in PNS walkaround Placing via in walkaround mode and colliding with an arc triggered an unneeded assertion. Also fixes the bad assertion format that did not receive strings (cherry picked from commit df9cf0a0c39ed99527b0c04e3892e8dd7ed603e7) --- libs/kimath/include/geometry/shape.h | 5 +++ libs/kimath/src/geometry/shape_collisions.cpp | 44 +++++++++---------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/libs/kimath/include/geometry/shape.h b/libs/kimath/include/geometry/shape.h index 056ceb3b9c..e08751bd7a 100644 --- a/libs/kimath/include/geometry/shape.h +++ b/libs/kimath/include/geometry/shape.h @@ -97,6 +97,11 @@ public: return m_type; } + wxString TypeName() const + { + return SHAPE_TYPE_asString( m_type ); + } + virtual bool HasIndexableSubshapes() const { return false; diff --git a/libs/kimath/src/geometry/shape_collisions.cpp b/libs/kimath/src/geometry/shape_collisions.cpp index 4a34931b7d..033d6a380d 100644 --- a/libs/kimath/src/geometry/shape_collisions.cpp +++ b/libs/kimath/src/geometry/shape_collisions.cpp @@ -290,8 +290,8 @@ static inline bool Collide( const SHAPE_LINE_CHAIN_BASE& aA, const SHAPE_LINE_CH int aClearance, int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); int closest_dist = INT_MAX; VECTOR2I nearest; @@ -372,8 +372,8 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN_BASE& a int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); int closest_dist = INT_MAX; VECTOR2I nearest; @@ -429,8 +429,8 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_SEGMENT& aB, int a int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); bool rv = aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2, aActual, aLocation ); @@ -445,8 +445,8 @@ static inline bool Collide( const SHAPE_SEGMENT& aA, const SHAPE_SEGMENT& aB, in int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); bool rv = aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2, aActual, aLocation ); @@ -461,8 +461,8 @@ static inline bool Collide( const SHAPE_LINE_CHAIN_BASE& aA, const SHAPE_SEGMENT int aClearance, int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); bool rv = aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2, aActual, aLocation ); @@ -494,8 +494,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_RECT& aB, int aClea int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); const SHAPE_LINE_CHAIN lc( aA ); @@ -511,10 +511,6 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_RECT& aB, int aClea static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_CIRCLE& aB, int aClearance, int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { - wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); - const SHAPE_LINE_CHAIN lc( aA ); bool rv = Collide( aB, lc, aClearance + aA.GetWidth() / 2, aActual, aLocation, aMTV ); @@ -530,8 +526,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_LINE_CHAIN& aB, int int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); int closest_dist = INT_MAX; VECTOR2I nearest; @@ -602,8 +598,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_SEGMENT& aB, int aC int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); const SHAPE_LINE_CHAIN lc( aA ); @@ -620,8 +616,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_LINE_CHAIN_BASE& aB int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); int closest_dist = INT_MAX; VECTOR2I nearest; @@ -677,8 +673,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_ARC& aB, int aClear int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - SHAPE_TYPE_asString( aA.Type() ), - SHAPE_TYPE_asString( aB.Type() ) ) ); + aA.TypeName(), + aB.TypeName() ) ); SEG mediatrix( aA.GetCenter(), aB.GetCenter() );