Bug in get inverse matrix

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Zhu
Posts: 3
Joined: Thu Nov 13, 2008 8:21 am

Bug in get inverse matrix

Post 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? :-)
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply