Added support for setting the fusion distance directly in SceneView, defaults
to the original behavior of using the values from the Camera if attached.
This commit is contained in:
parent
6ff24b338f
commit
f574d0dd68
@ -127,8 +127,8 @@ class SG_EXPORT DisplaySettings : public osg::Referenced
|
|||||||
bool getStencilBuffer() const { return _minimumNumberStencilBits!=0; }
|
bool getStencilBuffer() const { return _minimumNumberStencilBits!=0; }
|
||||||
|
|
||||||
|
|
||||||
void setMaxNumberOfGraphicsContexts(int num) { _maxNumOfGraphicsContexts = num; }
|
void setMaxNumberOfGraphicsContexts(unsigned int num) { _maxNumOfGraphicsContexts = num; }
|
||||||
int getMaxNumberOfGraphicsContexts() const { return _maxNumOfGraphicsContexts; }
|
unsigned int getMaxNumberOfGraphicsContexts() const { return _maxNumOfGraphicsContexts; }
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -152,7 +152,7 @@ class SG_EXPORT DisplaySettings : public osg::Referenced
|
|||||||
unsigned int _minimumNumberAlphaBits;
|
unsigned int _minimumNumberAlphaBits;
|
||||||
unsigned int _minimumNumberStencilBits;
|
unsigned int _minimumNumberStencilBits;
|
||||||
|
|
||||||
int _maxNumOfGraphicsContexts;
|
unsigned int _maxNumOfGraphicsContexts;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,6 +190,25 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
|||||||
/** Get the ComputeNearFarMode.*/
|
/** Get the ComputeNearFarMode.*/
|
||||||
CullVisitor::ComputeNearFarMode getComputeNearFarMode() const { return _computeNearFar;}
|
CullVisitor::ComputeNearFarMode getComputeNearFarMode() const { return _computeNearFar;}
|
||||||
|
|
||||||
|
/** FusionDistanceMode is used only when working in stereo.*/
|
||||||
|
enum FusionDistanceMode
|
||||||
|
{
|
||||||
|
/** Use fusion distance from the attached camera if one exist.*/
|
||||||
|
USE_CAMERA_FUSION_DISTANCE,
|
||||||
|
/** Use fusion distance from the value set on the SceneView.*/
|
||||||
|
USE_FUSION_DISTANCE_VALUE,
|
||||||
|
/** Compute the fusion distance by multiplying the screen distance by the fusion distance value.*/
|
||||||
|
PROPORTIONAL_TO_SCREEN_DISTANCE
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Set the FusionDistanceMode and Value. Note, is used only when working in stereo.*/
|
||||||
|
void setFusionDistance(FusionDistanceMode mode,float value=1.0f);
|
||||||
|
|
||||||
|
/** Get the FusionDistanceMode.*/
|
||||||
|
FusionDistanceMode getFusionDistanceMode() const { return _fusionDistanceMode; }
|
||||||
|
|
||||||
|
/** Get the FusionDistanceValue. Note, only used for USE_FUSION_DISTANCE_VALUE & PROPORTIONAL_TO_SCREEN_DISTANCE modes.*/
|
||||||
|
float getFusionDistanceValue() const { return _fusionDistanceValue; }
|
||||||
|
|
||||||
|
|
||||||
/** set whether the draw method should call renderer->prioritizeTexture.*/
|
/** set whether the draw method should call renderer->prioritizeTexture.*/
|
||||||
@ -291,20 +310,23 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
|||||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraphRight;
|
osg::ref_ptr<osgUtil::RenderGraph> _rendergraphRight;
|
||||||
osg::ref_ptr<osgUtil::RenderStage> _renderStageRight;
|
osg::ref_ptr<osgUtil::RenderStage> _renderStageRight;
|
||||||
|
|
||||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||||
|
|
||||||
osg::Vec4 _backgroundColor;
|
osg::Vec4 _backgroundColor;
|
||||||
|
|
||||||
CullVisitor::ComputeNearFarMode _computeNearFar;
|
CullVisitor::ComputeNearFarMode _computeNearFar;
|
||||||
osg::CullStack::CullingMode _cullingMode;
|
osg::CullStack::CullingMode _cullingMode;
|
||||||
float _LODBias;
|
float _LODBias;
|
||||||
float _smallFeatureCullingPixelSize;
|
float _smallFeatureCullingPixelSize;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Viewport> _viewport;
|
FusionDistanceMode _fusionDistanceMode;
|
||||||
|
float _fusionDistanceValue;
|
||||||
|
|
||||||
LightingMode _lightingMode;
|
osg::ref_ptr<osg::Viewport> _viewport;
|
||||||
|
|
||||||
|
LightingMode _lightingMode;
|
||||||
|
|
||||||
bool _prioritizeTextures;
|
bool _prioritizeTextures;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@ SceneView::SceneView(DisplaySettings* ds)
|
|||||||
_LODBias = 1.0f;
|
_LODBias = 1.0f;
|
||||||
_smallFeatureCullingPixelSize = 3.0f;
|
_smallFeatureCullingPixelSize = 3.0f;
|
||||||
|
|
||||||
|
_fusionDistanceMode = USE_CAMERA_FUSION_DISTANCE;
|
||||||
|
_fusionDistanceValue = 1.0f;
|
||||||
|
|
||||||
_lightingMode=HEADLIGHT;
|
_lightingMode=HEADLIGHT;
|
||||||
|
|
||||||
_prioritizeTextures = false;
|
_prioritizeTextures = false;
|
||||||
@ -217,12 +220,22 @@ void SceneView::cull()
|
|||||||
{
|
{
|
||||||
|
|
||||||
float fusionDistance = _displaySettings->getScreenDistance();
|
float fusionDistance = _displaySettings->getScreenDistance();
|
||||||
|
switch(_fusionDistanceMode)
|
||||||
if (_camera.valid())
|
|
||||||
{
|
{
|
||||||
fusionDistance = _camera->getFusionDistance();
|
case(USE_CAMERA_FUSION_DISTANCE):
|
||||||
|
if (_camera.valid())
|
||||||
|
{
|
||||||
|
fusionDistance = _camera->getFusionDistance();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case(USE_FUSION_DISTANCE_VALUE):
|
||||||
|
fusionDistance = _fusionDistanceValue;
|
||||||
|
break;
|
||||||
|
case(PROPORTIONAL_TO_SCREEN_DISTANCE):
|
||||||
|
fusionDistance *= _fusionDistanceValue;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
float iod = _displaySettings->getEyeSeparation();
|
float iod = _displaySettings->getEyeSeparation();
|
||||||
float sd = _displaySettings->getScreenDistance();
|
float sd = _displaySettings->getScreenDistance();
|
||||||
float es = 0.5f*iod*(fusionDistance/sd);
|
float es = 0.5f*iod*(fusionDistance/sd);
|
||||||
|
Loading…
Reference in New Issue
Block a user