recently (I can't unfortunately track the exact moment in which this issue has first appeared) the Irrlicht-based application I'm working on has started to behave weirdly. After a lot of debugging, the issues seems to be caused by the Matrix4 method getRotationDegrees(), which, from time to time, returns some NaN values without an apparent reason.
I've been able to write a simple application that reproduces the problem I'm experiencing on both my machines (running MacOS X 10.5 and 10.6 respectively, with Irrlicht 1.7).
I paste the code here:
Code: Select all
#include <irrlicht/irrlicht.h>
#include <nnfw/nnfw.h>
#include <iostream>
#include <ctime>
using namespace std;
using namespace irr;
using namespace irr::core;
matrix4 m, n;
vector3df MAV_currentRotation;
float yaw;
void rotate(vector3df rot) {
m.setRotationDegrees(MAV_currentRotation);
n.setRotationDegrees(rot);
m *= n;
MAV_currentRotation = m.getRotationDegrees();
}
int main(int argc, char *argv[]) {
nnfw::Random::setSeed(10);
MAV_currentRotation = vector3df(-90.0f, 10.0f, 0.0f);
for (int i=0; i<10000; i++) {
yaw = nnfw::Random::flatReal(0,1); // Generates real values within [0;1]
cout << "Original rotation: " << MAV_currentRotation.X << " " << MAV_currentRotation.Y << " " << MAV_currentRotation.Z << endl;
rotate(vector3df(0.0f, 0.0f, yaw));
cout << "New rotation: " << MAV_currentRotation.X << " " << MAV_currentRotation.Y << " " << MAV_currentRotation.Z << endl;
if (isnan(MAV_currentRotation.X)) cout << "Error on iteration " << i << " (" << yaw << " rotation applied)" << endl;
}
return 0;
}
Might be also interesting to note that if I cycle the application for a smaller number of iterations (let's say 100 or 1,000) no errors come out.