[fixed]Bug in matrix4::getRotationDegrees() due to scaling
Posted: Thu Aug 26, 2010 9:40 pm
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:
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.
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;
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.