Rotating objects for a loong time warps the scaling (floating point issue).

Minor issues with the Ogre API that can be trivial to fix
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23

Rotating objects for a loong time warps the scaling (floating point issue).

Post by hedphelym »

Rotating objects for a long time warps the scaling (floating point issue), happens in 1.9 and newer.
If you for example take the HDR sample with rotating cubes, run it for a long time (over night is best) then the object
is wobbly and scale gets messed up, warping the mesh when rotating.
If I remember correctly it happens because the transformations are never normalized\reset, is it that way because of performance?
Anyways - it causes issues with software that runs for a long time (simulators for example).
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: Rotating objects for a loong time warps the scaling (floating point issue).

Post by al2950 »

Cant offer any answers but I have had this exact issue, it causes some amusing things to happen in my sims!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5429
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1337

Re: Rotating objects for a loong time warps the scaling (floating point issue).

Post by dark_sylinc »

When you say HDR sample, you mean 2.1's sample?

Edit: Oh my God, Node::rotate does not renormalize, this behavior could totally happen.
hedphelym wrote: Wed Dec 06, 2017 5:20 pmIf I remember correctly it happens because the transformations are never normalized\reset
That's correct.
hedphelym wrote: Wed Dec 06, 2017 5:20 pmis it that way because of performance?
I don't know. It could be that, or it could be because of a simple oversight, or underestimating the effect over time.
This issue for example would be hidden if rotate() is called after some call to setOrientation(). It would only show up after enough successive calls to rotate().
hedphelym wrote: Wed Dec 06, 2017 5:20 pmAnyways - it causes issues with software that runs for a long time (simulators for example).
As a general guideline, if the simulation is mission critical, I always suggest to do the math yourself to guarantee the stability of the math. Particularly setting quaternion/position/scale externally. As an extreme example, that's why NASA is extremely strict on third party code.
But of course, that's no excuse for us to ship poor quality code :)
Since al2950 seems to also have seen this behavior, I am pushing it a fix. Performance is nothing if the routine is unreliable.

Edit 2: Fix pushed. Thanks for the report!
Btw the error was easily reproducible on the sample by modifying it:

Code: Select all

static long repeat = 10000000;
if( mAnimateObjects )
{
    for( int j=0; j<repeat; ++j )
    {
        for( int i=0; i<16; ++i )
            mSceneNode[i]->yaw( Ogre::Radian(timeSinceLast * i * 0.125f) );
        //timeSinceLast += 0.1;
    }
}

if( repeat != 1 && timeSinceLast > 8.0 / 1000.0 )
    repeat = 1;
Without the fix, the cubes get all giant and wonky (shear). After the fix they remain correct.
hedphelym
Gremlin
Posts: 180
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 23

Re: Rotating objects for a loong time warps the scaling (floating point issue).

Post by hedphelym »

Thank you for the quick fix!
paroj
OGRE Team Member
OGRE Team Member
Posts: 2087
Joined: Sun Mar 30, 2014 2:51 pm
x 1127

Re: Rotating objects for a loong time warps the scaling (floating point issue).

Post by paroj »

this was fixed in 1.10 two years ago:
https://github.com/OGRECave/ogre/commit ... 7c07d0dbae

we should work out a way to share more code between 1.x and 2.x
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5429
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1337

Re: Rotating objects for a loong time warps the scaling (floating point issue).

Post by dark_sylinc »

paroj wrote: Thu Dec 07, 2017 4:42 pmwe should work out a way to share more code between 1.x and 2.x
I agree. With a few exceptions, I'd like to merge your CMake changes (specially iOS stuff), as well as the Ogre Config dialog changes.