[fixed]Matrix Changes in irrlicht 1.7

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
pippy3
Posts: 155
Joined: Tue Dec 15, 2009 7:32 am

[fixed]Matrix Changes in irrlicht 1.7

Post by pippy3 »

I've been using the Free Flight (space flight) functions functions to calculate rotation in my game.

I ported my game to irrlicht 1.7.2 and it broke. I was wondering what changes would cause this code to fail:

Code: Select all

// this returns the incorrect result
irr::core::matrix4 m;
m.setRotationDegrees(core::vector3df (270.000000, 0.000000, 0.000000));
irr::core::matrix4 n;
n.setRotationDegrees(core::vector3df (-90.000000 0.000000 0.00000));
m *= n;
return m.getRotationDegrees();
// returns 360.000000 -0.000000 0.000000
// (should return 180, 0, 0)


// returns almost the correct result. 
irr::core::matrix4 m;
m.setRotationDegrees(core::vector3df (270.000000, 0.000000, 0.000000));
irr::core::matrix4 n;
n.setRotationDegrees(core::vector3df (-89.910004 0.000000 0.000000));
m *= n;
return m.getRotationDegrees();
// returns 180.089996 -0.000000 0.000000
Why does it get to -90 it snaps to 360 degrees? I've tried rotating the -90 to 270 and it does the same thing.

I don't really know an alternative to using matrices to rotate directions so I'm kinda stuck on this problem at the moment.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, maybe there's a sign problem somewhere. I'll add a test case for this situation and tell about the results.
pippy3
Posts: 155
Joined: Tue Dec 15, 2009 7:32 am

Post by pippy3 »

Swapping the floats with doubles seems to fix it. It may be an issue with matrix4, or a casting issue:

Code: Select all

irr::core::CMatrix4<f64> m, n;
m.setRotationDegrees(core::vector3d<f64> (rot.X, rot.Y,rot.Z));
n.setRotationDegrees(core::vector3d<f64> (mrot.X, mrot.Y,mrot.Z));
m *= n;
return core::vector3df ((f32)m.getRotationDegrees().X,
							  (f32)m.getRotationDegrees().Y,
							  (f32)m.getRotationDegrees().Z);
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Just added a test case to SVN/trunk. There's no issue with this code in that version. I cannot test it here under Irrlicht 1.7, though. Maybe it's one of the fixed errors with the getRotations clamping issues.
drewbacca
Posts: 38
Joined: Tue Jan 30, 2007 6:49 pm

Post by drewbacca »

This sounds just like the bug I noted at
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=39722

The fix was only applied to trunk at revision 3400. Copying the changes from that revision will probably solve your problem.
Post Reply