Changeset 10935

Show
Ignore:
Timestamp:
01/08/10 12:37:35 (4 years ago)
Author:
robert
Message:

From Marius Heise, "osgShadow was using single precision variables for light positioning and orientation. This was causing precision problems (shadow jumping) with big databases (eg. geocentric created vpb). This patch fixes this by using double precision variables for light positioning and orientation. It works for all algorithms dreived form osgShadow::StandardShadowMap?.
"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgShadow/StandardShadowMap.cpp

    r10699 r10935  
    678678    if( light->getSpotCutoff() < 180.0f) // spotlight, no need for bounding box 
    679679    { 
    680         osg::Vec3 position(lightPos.x(), lightPos.y(), lightPos.z()); 
     680        osg::Vec3d position(lightPos.x(), lightPos.y(), lightPos.z()); 
    681681        float spotAngle = light->getSpotCutoff(); 
    682682 
     
    688688        if (lightPos[3]!=0.0)   // point light 
    689689        { 
    690             osg::Vec3 position(lightPos.x(), lightPos.y(), lightPos.z()); 
     690            osg::Vec3d position(lightPos.x(), lightPos.y(), lightPos.z()); 
    691691 
    692692            float centerDistance = (position-bs.center()).length(); 
     
    695695            float zfar  = centerDistance+bs.radius(); 
    696696            float zNearRatio = 0.001f; 
    697             if (znear<zfar*zNearRatio) znear = zfar*zNearRatio; 
     697            if (znear<zfar*zNearRatio) 
     698                znear = zfar*zNearRatio; 
    698699 
    699700            float top   = (bs.radius()/centerDistance)*znear; 
     
    709710            // set the position far away along the light direction 
    710711            float radius = bs.radius(); 
    711             osg::Vec3 position = bs.center() - lightDir * radius * 2; 
     712            osg::Vec3d position = bs.center() - lightDir * radius * 2; 
    712713 
    713714            float centerDistance = (position-bs.center()).length();