mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-17 12:12:10 -04:00
better message for singular invert assertion
This commit is contained in:
parent
6ac53b826a
commit
67b9dc9367
@ -605,9 +605,7 @@ multiply(const FLOATNAME(LMatrix3) &other1, const FLOATNAME(LMatrix3) &other2) {
|
||||
// faster than operator * since it writes result in place, avoiding extra copying
|
||||
// this will fail if you try to mat.multiply(mat,other_mat)
|
||||
|
||||
#ifdef _DEBUG
|
||||
assert((&other1 != this) && (&other2 != this));
|
||||
#endif
|
||||
nassertv((&other1 != this) && (&other2 != this));
|
||||
|
||||
MATRIX3_PRODUCT((*this),other1,other2);
|
||||
}
|
||||
@ -981,9 +979,7 @@ rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis,
|
||||
|
||||
// Normalize the axis.
|
||||
FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
|
||||
#ifdef _DEBUG
|
||||
nassertr(length_sq != 0.0f, ident_mat());
|
||||
#endif
|
||||
FLOATTYPE recip_length = 1.0f/csqrt(length_sq);
|
||||
|
||||
axis_0 *= recip_length;
|
||||
@ -1207,6 +1203,11 @@ INLINE_LINMATH FLOATNAME(LMatrix3)
|
||||
invert(const FLOATNAME(LMatrix3) &a) {
|
||||
FLOATNAME(LMatrix3) result;
|
||||
bool nonsingular = result.invert_from(a);
|
||||
nassertr(nonsingular, FLOATNAME(LMatrix3)::ident_mat());
|
||||
#ifndef NDEBUG
|
||||
if (!nonsingular) {
|
||||
nassert_raise("Attempt to compute inverse of singular matrix!");
|
||||
return FLOATNAME(LMatrix3)::ident_mat();
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
@ -785,10 +785,7 @@ multiply(const FLOATNAME(LMatrix4) &other1, const FLOATNAME(LMatrix4) &other2) {
|
||||
// faster than operator * since it writes result in place, avoiding extra copying
|
||||
// this will fail if you try to mat.multiply(mat,other_mat)
|
||||
|
||||
#ifdef _DEBUG
|
||||
assert((&other1 != this) && (&other2 != this));
|
||||
#endif
|
||||
|
||||
nassertv((&other1 != this) && (&other2 != this));
|
||||
MATRIX4_PRODUCT((*this),other1,other2);
|
||||
}
|
||||
|
||||
@ -1227,9 +1224,7 @@ rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis,
|
||||
*/
|
||||
|
||||
FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
|
||||
#ifdef _DEBUG
|
||||
nassertr(length_sq != 0.0f, ident_mat());
|
||||
#endif
|
||||
nassertr(length_sq != 0.0f, ident_mat());
|
||||
FLOATTYPE recip_length = 1.0f/csqrt(length_sq);
|
||||
|
||||
axis_0 *= recip_length;
|
||||
@ -1504,7 +1499,12 @@ INLINE_LINMATH FLOATNAME(LMatrix4)
|
||||
invert(const FLOATNAME(LMatrix4) &a) {
|
||||
FLOATNAME(LMatrix4) result;
|
||||
bool nonsingular = result.invert_from(a);
|
||||
nassertr(nonsingular, FLOATNAME(LMatrix4)::ident_mat());
|
||||
#ifndef NDEBUG
|
||||
if (!nonsingular) {
|
||||
nassert_raise("Attempt to compute inverse of singular matrix!");
|
||||
return FLOATNAME(LMatrix4)::ident_mat();
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,12 @@ INLINE_LINMATH FLOATNAME(LQuaternion)
|
||||
invert(const FLOATNAME(LQuaternion) &a) {
|
||||
FLOATNAME(LQuaternion) result;
|
||||
bool nonsingular = result.invert_from(a);
|
||||
nassertr(nonsingular, FLOATNAME(LQuaternion)::ident_quat());
|
||||
#ifndef NDEBUG
|
||||
if (!nonsingular) {
|
||||
nassert_raise("Attempt to compute inverse of singular quaternion!");
|
||||
return FLOATNAME(LQuaternion)::ident_quat();
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user