Page 1 of 1

Bug in get inverse matrix

Posted: Fri Nov 14, 2008 5:18 am
by Zhu
In CMatrix4<T>::getInverse, when to determine whether the determinant of the matrix is zero, the tolerance, ROUNDING_ERROR_32 which is 0.000001f, is too big. Assumpt that one object is scaled to 1/1000, then the transform matrix is {0.001, 0, 0, 0, 0, 0.001, 0, 0, 0, 0, 0.001, 0, 0, 0, 0, 1}, then it's determinant is 1e-9. But it's not zero. Right?

You can test it with scene in which all of objects are scaled to 1/1000. Then use ISceneCollisionManager::getSceneNodeFromRayBB to select one object. The result is that nothing is selected. It's because getInverse is used in getSceneNodeFromRayBB.

But which value is suitable? :-)

Posted: Fri Nov 14, 2008 7:00 am
by vitek
That is the problem with having hard-coded tolerance values. The application has no control over the tolerance values used, and the values needed may vary for different uses.

This is also a problem when you scale everything down to 1/1000 of its original size. If your model is 1000 times bigger than you need it, you should probably scale the original model down before using it.

Travis

Posted: Fri Nov 14, 2008 11:01 am
by rogerborg
Any suggestions? AFAIK, we can't use FLT_EPSILON, since that falls apart for large or small floats. We could add an explicit comparison method for matrices (and vectors, quaternions) that takes a tolerance. Would that be sufficient, or is there a better fix?