Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFTOceanSurface::computeNoiseCoords() breaks on large time jumps #23

Open
GoogleCodeExporter opened this issue Mar 16, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Because FFTOceanSurface::computeNoiseCoords() simply keeps increasing a
static (not nice) float (not nice in combination) large time jumps can lead
to an unrecoverable state with not enough precision available in the
counter to provide smooth animation.

Although these time jumps are probably caused by a bug in my application I
still consider osgOcean's behaviour here a bug - locally I added a _time,
added a advanceTime(dt); call to update() and changed the logic to:

void FFTOceanSurface::advanceTime( const double& dt )
{
    float maxLength = 32.f * osg::Vec2f(2.f, 4.f).length();
    float maxTotalTime = maxLength / 2.0;    
    _time += dt * 0.0008;
    _time = fmod(_time, maxTotalTime);
}

osg::Vec3f FFTOceanSurface::computeNoiseCoords(float noiseSize, const
osg::Vec2f& movement, float speed)
{
    float length = noiseSize*movement.length();
    float tileScale = _tileResInv * noiseSize;
    osg::Vec2f velocity = movement * speed / length;
    osg::Vec2f pos = velocity * _time;
    osg::Vec3f x = osg::Vec3f( pos, tileScale );
    return x;
}

... now, due to the copied (from update()) magic constants in advanceTime()
(one obviously needs the largest used values) I realize this might not be
inclusion-worthy, but I don't know how to properly do this as I have no
idea where the magic constants in update() come from in the first place. :-)


Original issue reported on code.google.com by felix.nawothnig on 31 Mar 2010 at 8:57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant