Hi,

Oops sorry, the if condition was my first attempt to check and fix the bug. It 
turns out that it was not working and the bug was somewhere else. The whole 
method is this:


Code:

float FFTOceanSurface::getSurfaceHeightAt(float x, float y, osg::Vec3f* normal)
{
    if(_isDirty)
        build();

    // ocean surface coordinates
    float oceanX, oceanY;

    // translate x, y to oceanSurface origin coordinates
    oceanX = -_startPos.x() + x;
    oceanY =  _startPos.y() - y;

    // calculate the corresponding tile on the ocean surface
    unsigned int ix = oceanX/_tileResolution;
    unsigned int iy = oceanY/_tileResolution;

    unsigned int frame = _oldFrame;

    // Test if the tile is valid 
    if(ix < _numTiles && iy < _numTiles)
    {
                //++ BAWE-20101109: BUG FIX. 
                //NOTE: 20101112 - Not working but what the heck...
                if (_oldFrame < _mipmapData.size())
                {
                        const OceanTile& data = _mipmapData[_oldFrame][0];

                        float tile_x = oceanX - ix * _tileResolution;
                        float tile_y = oceanY - iy * _tileResolution;

                        //++ BAWE-20101119: BUG FIX
                        // Absolute value of dx & dy
                        tile_x = tile_x > 0 ? tile_x : -tile_x;

                        tile_y = tile_y > 0 ? tile_y : -tile_y;
                        //-- BAWE-20101119: BUG FIX

                        if (normal != 0)
                        {
                                *normal = data.normalBiLinearInterp(tile_x, 
tile_y);
                        }

                        return data.biLinearInterp(tile_x, tile_y);
                }
                //-- BAWE-20101109: BUG FIX
    }

    return 0.0f;
}




Thank you!

Cheers,
Bawenang

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=36211#36211





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to