mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 20:53:50 -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
|
// faster than operator * since it writes result in place, avoiding extra copying
|
||||||
// this will fail if you try to mat.multiply(mat,other_mat)
|
// this will fail if you try to mat.multiply(mat,other_mat)
|
||||||
|
|
||||||
#ifdef _DEBUG
|
nassertv((&other1 != this) && (&other2 != this));
|
||||||
assert((&other1 != this) && (&other2 != this));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MATRIX3_PRODUCT((*this),other1,other2);
|
MATRIX3_PRODUCT((*this),other1,other2);
|
||||||
}
|
}
|
||||||
@ -981,9 +979,7 @@ rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis,
|
|||||||
|
|
||||||
// Normalize the axis.
|
// Normalize the axis.
|
||||||
FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
|
FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
|
||||||
#ifdef _DEBUG
|
|
||||||
nassertr(length_sq != 0.0f, ident_mat());
|
nassertr(length_sq != 0.0f, ident_mat());
|
||||||
#endif
|
|
||||||
FLOATTYPE recip_length = 1.0f/csqrt(length_sq);
|
FLOATTYPE recip_length = 1.0f/csqrt(length_sq);
|
||||||
|
|
||||||
axis_0 *= recip_length;
|
axis_0 *= recip_length;
|
||||||
@ -1207,6 +1203,11 @@ INLINE_LINMATH FLOATNAME(LMatrix3)
|
|||||||
invert(const FLOATNAME(LMatrix3) &a) {
|
invert(const FLOATNAME(LMatrix3) &a) {
|
||||||
FLOATNAME(LMatrix3) result;
|
FLOATNAME(LMatrix3) result;
|
||||||
bool nonsingular = result.invert_from(a);
|
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;
|
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
|
// faster than operator * since it writes result in place, avoiding extra copying
|
||||||
// this will fail if you try to mat.multiply(mat,other_mat)
|
// this will fail if you try to mat.multiply(mat,other_mat)
|
||||||
|
|
||||||
#ifdef _DEBUG
|
nassertv((&other1 != this) && (&other2 != this));
|
||||||
assert((&other1 != this) && (&other2 != this));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MATRIX4_PRODUCT((*this),other1,other2);
|
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;
|
FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2;
|
||||||
#ifdef _DEBUG
|
nassertr(length_sq != 0.0f, ident_mat());
|
||||||
nassertr(length_sq != 0.0f, ident_mat());
|
|
||||||
#endif
|
|
||||||
FLOATTYPE recip_length = 1.0f/csqrt(length_sq);
|
FLOATTYPE recip_length = 1.0f/csqrt(length_sq);
|
||||||
|
|
||||||
axis_0 *= recip_length;
|
axis_0 *= recip_length;
|
||||||
@ -1504,7 +1499,12 @@ INLINE_LINMATH FLOATNAME(LMatrix4)
|
|||||||
invert(const FLOATNAME(LMatrix4) &a) {
|
invert(const FLOATNAME(LMatrix4) &a) {
|
||||||
FLOATNAME(LMatrix4) result;
|
FLOATNAME(LMatrix4) result;
|
||||||
bool nonsingular = result.invert_from(a);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,12 @@ INLINE_LINMATH FLOATNAME(LQuaternion)
|
|||||||
invert(const FLOATNAME(LQuaternion) &a) {
|
invert(const FLOATNAME(LQuaternion) &a) {
|
||||||
FLOATNAME(LQuaternion) result;
|
FLOATNAME(LQuaternion) result;
|
||||||
bool nonsingular = result.invert_from(a);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user