assert matrices are nonsingular

This commit is contained in:
David Rose 2001-09-17 19:28:10 +00:00
parent 6a5516b425
commit a31c8dd8ee
3 changed files with 35 additions and 1 deletions

View File

@ -26,6 +26,13 @@
Configure(config_sgmanip);
NotifyCategoryDef(sgmanip, "");
// Set this to true to generate an assertion failure whenever you
// first attempt to apply a singular transform matrix to the scene
// graph, or false to ignore this. The default is true, which makes
// it much easier to track down singular matrix errors. In NDEBUG
// mode, this is ignored and is effectively always false.
const bool check_singular_transform = config_sgmanip.GetBool("check-singular-transform", true);
ConfigureFn(config_sgmanip) {
NodePath::init_type();
PosLerpFunctor::init_type();

View File

@ -25,4 +25,7 @@
NotifyCategoryDecl(sgmanip, EXPCL_PANDA, EXPTP_PANDA);
// Configure variables for sgmanip package.
extern const bool EXPCL_PANDA check_singular_transform;
#endif

View File

@ -1410,7 +1410,19 @@ set_mat(const LMatrix4f &mat) {
<< "Setting transform on data graph arc.\n"
<< "(This is probably meaningless. Did you mean to do this to the bottom node?)\n";
}
#endif
#endif // NDEBUG
#ifndef NDEBUG
if (check_singular_transform) {
LMatrix4f inv_mat;
bool ok = inv_mat.invert_from(mat);
if (!ok) {
sgmanip_cat.error()
<< "Attempt to set a singular transform on " << *this << "\n";
nassertv(false);
}
}
#endif // NDEBUG
arc()->set_transition(new TransformTransition(mat));
}
@ -1859,6 +1871,18 @@ set_mat(const NodePath &other, const LMatrix4f &mat) {
new_mat_ptr = &new_mat;
}
#ifndef NDEBUG
if (check_singular_transform) {
LMatrix4f inv_mat;
bool ok = inv_mat.invert_from(*new_mat_ptr);
if (!ok) {
sgmanip_cat.error()
<< "Attempt to set a singular transform on " << *this << "\n";
nassertv(false);
}
}
#endif // NDEBUG
darc->set_transition(new TransformTransition(*new_mat_ptr));
}