Page 1 of 1

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

Posted: Wed Dec 06, 2017 5:20 pm
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).

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

Posted: Wed Dec 06, 2017 11:40 pm
by al2950
Cant offer any answers but I have had this exact issue, it causes some amusing things to happen in my sims!

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

Posted: Thu Dec 07, 2017 3:57 am
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 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.

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

Posted: Thu Dec 07, 2017 6:49 am
by hedphelym
Thank you for the quick fix!

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

Posted: Thu Dec 07, 2017 4:42 pm
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

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

Posted: Fri Dec 08, 2017 11:59 pm
by dark_sylinc
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.