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

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

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

Post by hedphelym » Wed Dec 06, 2017 5:20 pm

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).
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1093
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 40

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

Post by al2950 » Wed Dec 06, 2017 11:40 pm

Cant offer any answers but I have had this exact issue, it causes some amusing things to happen in my sims!
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3629
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 97
Contact:

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

Post by dark_sylinc » Thu Dec 07, 2017 3:57 am

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 pm
If I remember correctly it happens because the transformations are never normalized\reset
That's correct.
hedphelym wrote:
Wed Dec 06, 2017 5:20 pm
is 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 pm
Anyways - 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.
1 x

hedphelym
Gremlin
Posts: 150
Joined: Tue Nov 25, 2008 10:58 am
Location: Kristiansand, Norway
x 7
Contact:

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

Post by hedphelym » Thu Dec 07, 2017 6:49 am

Thank you for the quick fix!
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 527
Joined: Sun Mar 30, 2014 2:51 pm
x 73
Contact:

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

Post by paroj » Thu Dec 07, 2017 4:42 pm

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
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3629
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 97
Contact:

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

Post by dark_sylinc » Fri Dec 08, 2017 11:59 pm

paroj wrote:
Thu Dec 07, 2017 4:42 pm
we 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.
0 x

Post Reply