Selaa lähdekoodia

add no-singular-invert

David Rose 14 vuotta sitten
vanhempi
sitoutus
49c1710712

+ 6 - 0
panda/src/linmath/config_linmath.cxx

@@ -38,6 +38,12 @@ ConfigVariableBool temp_hpr_fix
           "to the other two.  Set this false if you need compatibility with "
           "Panda's old hpr calculations."));
 
+ConfigVariableBool no_singular_invert
+("no-singular-invert", false,
+ PRC_DESC("Set this true to make singular-invert warning messages generate an "
+          "assertion failure instead of just a warning (which can then be "
+          "trapped with assert-abort)."));
+
 ////////////////////////////////////////////////////////////////////
 //     Function: init_liblinmath
 //  Description: Initializes the library.  This must be called at

+ 1 - 0
panda/src/linmath/config_linmath.h

@@ -23,6 +23,7 @@ NotifyCategoryDecl(linmath, EXPCL_PANDA_LINMATH, EXPTP_PANDA_LINMATH);
 
 extern EXPCL_PANDA_LINMATH ConfigVariableBool paranoid_hpr_quat;
 extern EXPCL_PANDA_LINMATH ConfigVariableBool temp_hpr_fix;
+extern EXPCL_PANDA_LINMATH ConfigVariableBool no_singular_invert;
 
 extern EXPCL_PANDA_LINMATH void init_liblinmath();
 

+ 2 - 1
panda/src/linmath/lmatrix3_src.I

@@ -920,7 +920,7 @@ determinant() const {
 //               place, see invert_in_place.
 //
 //               The return value is true if the matrix was
-//               successfully inverted, false if the was a
+//               successfully inverted, false if there was a
 //               singularity.
 ////////////////////////////////////////////////////////////////////
 INLINE_LINMATH bool FLOATNAME(LMatrix3)::
@@ -938,6 +938,7 @@ invert_from(const FLOATNAME(LMatrix3) &other) {
     linmath_cat.warning() << "Tried to invert singular LMatrix3.\n";
 #endif
     (*this) = ident_mat();
+    nassertr(!no_singular_invert, false);
     return false;
   }
 

+ 3 - 1
panda/src/linmath/lmatrix4_src.I

@@ -1130,6 +1130,8 @@ invert_from(const FLOATNAME(LMatrix4) &other) {
 #ifdef NDEBUG
     linmath_cat.warning() << "Tried to invert singular LMatrix4.\n";
 #endif
+    (*this) = ident_mat();
+    nassertr(!no_singular_invert, false);
     return false;
   }
 
@@ -1157,7 +1159,7 @@ invert_from(const FLOATNAME(LMatrix4) &other) {
 //               place, see invert_in_place.
 //
 //               The return value is true if the matrix was
-//               successfully inverted, false if the was a
+//               successfully inverted, false if there was a
 //               singularity.
 ////////////////////////////////////////////////////////////////////