[fixed]Bug in matrix4::getRotationDegrees() due to scaling

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
drewbacca
Posts: 38
Joined: Tue Jan 30, 2007 6:49 pm

[fixed]Bug in matrix4::getRotationDegrees() due to scaling

Post by drewbacca »

I recently upgraded from irrlicht 1.5 to 1.7.1 and noticed that some transformations stopped working when they were rotated by exactly 180 degrees.

for example:

Code: Select all

    irr::core::matrix4 m;
    m.setRotationDegrees(irr::core::vector3df(0.f, 180.0f, 0.f));
    irr::core::vector3df result = m.getRotationDegrees();
    cout << result.X << ", " << result.Y << ", " << result.Z << endl;
this produces a result that has no rotation at all. The earlier version of irrlicht would return 180,0,180 which is the correct equivalent.

Looking at the changes to matrix4.h, it looks like there is now code to handle matrix scaling. So in getRotationDegrees() rotx & roty can possibly be calculated incorrectly because the scale vector's negative values will cancel out the negative values in the matrix.

The comments for matrix4::getScale() says it returns absolute values, but it does not.

I don't know if the bug is that getScale() shouldn't be returning negative elements, or that the getRotationDegrees() function needs to take the absolute value of the scale. I tried the latter, and it fixed my rotation issue.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, thanks. Fixed and test case added. Please note that the result is now 180,360,180, due to a rounding error in the computation. But the result is at least correct.
Post Reply