Removed CullViewState from the distribution, moved CullViewState::CullingMode

into CullVisitor, and then removed all references to CullViewState from other
parts of the scene graph.
This commit is contained in:
Robert Osfield
2002-04-24 20:24:10 +00:00
parent 7880fd3354
commit f0e7e8e48b
8 changed files with 51 additions and 173 deletions

View File

@@ -463,7 +463,7 @@ public:
if(_hudSceneView.valid())
{
_hudSceneView->getRenderStage()->setClearMask(0);
_hudSceneView->getCullVisitor()->setCullingMode(osgUtil::CullViewState::NO_CULLING);
_hudSceneView->getCullVisitor()->setCullingMode(osgUtil::CullVisitor::NO_CULLING);
_hudSceneView->setCalcNearFar(false);
_hudCam = osgNew osg::Camera;

View File

@@ -1017,9 +1017,9 @@ void Viewer::keyboard(unsigned char key, int x, int y)
case 'c' :
_smallFeatureCullingActive = !_smallFeatureCullingActive;
sceneView->getCullVisitor()->setCullingMode((osgUtil::CullViewState::CullingMode)
((_smallFeatureCullingActive ? osgUtil::CullViewState::SMALL_FEATURE_CULLING : osgUtil::CullViewState::NO_CULLING) |
(_viewFrustumCullingActive ? osgUtil::CullViewState::VIEW_FRUSTUM_CULLING : osgUtil::CullViewState::NO_CULLING)));
sceneView->getCullVisitor()->setCullingMode((osgUtil::CullVisitor::CullingMode)
((_smallFeatureCullingActive ? osgUtil::CullVisitor::SMALL_FEATURE_CULLING : osgUtil::CullVisitor::NO_CULLING) |
(_viewFrustumCullingActive ? osgUtil::CullVisitor::VIEW_FRUSTUM_CULLING : osgUtil::CullVisitor::NO_CULLING)));
if (_smallFeatureCullingActive)
{
osg::notify(osg::NOTICE) << "Small feature culling switched on "<< std::endl;
@@ -1040,9 +1040,9 @@ void Viewer::keyboard(unsigned char key, int x, int y)
{
osg::notify(osg::NOTICE) << "View frustum culling switched off "<< std::endl;
}
sceneView->getCullVisitor()->setCullingMode((osgUtil::CullViewState::CullingMode)
((_smallFeatureCullingActive ? osgUtil::CullViewState::SMALL_FEATURE_CULLING : osgUtil::CullViewState::NO_CULLING) |
(_viewFrustumCullingActive ? osgUtil::CullViewState::VIEW_FRUSTUM_CULLING : osgUtil::CullViewState::NO_CULLING)));
sceneView->getCullVisitor()->setCullingMode((osgUtil::CullVisitor::CullingMode)
((_smallFeatureCullingActive ? osgUtil::CullVisitor::SMALL_FEATURE_CULLING : osgUtil::CullVisitor::NO_CULLING) |
(_viewFrustumCullingActive ? osgUtil::CullVisitor::VIEW_FRUSTUM_CULLING : osgUtil::CullVisitor::NO_CULLING)));
break;
case 'P' :
@@ -1065,25 +1065,18 @@ void Viewer::keyboard(unsigned char key, int x, int y)
case 'O' :
{
osg::Viewport* viewport = sceneView->getViewport();
if (viewport)
{
osg::ref_ptr<osg::Viewport> viewport = osgNew osg::Viewport;
viewport->setViewport(_wx,_wy,_ww,_wh);
std::string filename("screenshot.bmp");
std::string filename("screenshot.bmp");
glReadBuffer(GL_FRONT);
osg::ref_ptr<Image> image = osgNew osg::Image;
image->readPixels(viewport->x(),viewport->y(),viewport->width(),viewport->height(),
GL_RGB,GL_UNSIGNED_BYTE);
glReadBuffer(GL_FRONT);
osg::ref_ptr<Image> image = osgNew osg::Image;
image->readPixels(viewport->x(),viewport->y(),viewport->width(),viewport->height(),
GL_RGB,GL_UNSIGNED_BYTE);
osgDB::writeImageFile(*image,filename);
osgDB::writeImageFile(*image,filename);
osg::notify(osg::NOTICE) << "Saved screen image to `"<<filename<<"`"<< std::endl;
}
else
{
osg::notify(osg::NOTICE) << "Cannot create snapshot of screen, no valid viewport attached"<< std::endl;
}
osg::notify(osg::NOTICE) << "Saved screen image to `"<<filename<<"`"<< std::endl;
}
break;
case 'i' :

View File

@@ -1,33 +0,0 @@
#include <osg/Transform>
#include <osg/Geode>
#include <osg/LOD>
#include <osg/Billboard>
#include <osg/LightSource>
#include <osg/Impostor>
#include <osg/Notify>
#include <osgUtil/CullViewState>
#include <float.h>
using namespace osg;
using namespace osgUtil;
//#define USE_OLD_CULL
CullViewState::CullViewState()
{
_projection = NULL;
_matrix = NULL;
_inverse = NULL;
_ratio2 = 0.002f*0.002f;
_bbCornerNear = 8; // note this is an error value, valid range is 0..7
_bbCornerFar = 8; // these error values are used to show a unset corner.
}
CullViewState::~CullViewState()
{
}

View File

@@ -86,7 +86,7 @@ CullVisitor::CullVisitor()
// is a least this one value on the stack, therefore they never
// check whether the stack is empty. This shouldn't be a problem
// unless there is bug somewhere...
_cullingModeStack.push_back(CullViewState::ENABLE_ALL_CULLING);
_cullingModeStack.push_back(ENABLE_ALL_CULLING);
//_tsm = LOOK_VECTOR_DISTANCE;
@@ -335,20 +335,20 @@ void CullVisitor::updateCalculatedNearFar(const osg::Vec3& pos)
if (d>_computed_zfar) _computed_zfar = d;
}
void CullVisitor::setCullingMode(CullViewState::CullingMode mode)
void CullVisitor::setCullingMode(CullingMode mode)
{
_cullingModeStack.back()=mode;
}
CullViewState::CullingMode CullVisitor::getCullingMode() const
CullVisitor::CullingMode CullVisitor::getCullingMode() const
{
return _cullingModeStack.back();
}
void CullVisitor::apply(Node& node)
{
CullViewState::CullingMode mode = _cullingModeStack.back();
CullingMode mode = _cullingModeStack.back();
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
@@ -375,7 +375,7 @@ void CullVisitor::apply(Geode& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
CullingMode mode = _cullingModeStack.back();
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
@@ -444,7 +444,7 @@ void CullVisitor::apply(Geode& node)
void CullVisitor::apply(Billboard& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
CullingMode mode = _cullingModeStack.back();
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
@@ -535,7 +535,7 @@ void CullVisitor::apply(LightSource& node)
void CullVisitor::apply(Group& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
CullingMode mode = _cullingModeStack.back();
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
@@ -560,7 +560,7 @@ void CullVisitor::apply(Group& node)
void CullVisitor::apply(Transform& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
CullingMode mode = _cullingModeStack.back();
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
@@ -591,7 +591,7 @@ void CullVisitor::apply(Transform& node)
void CullVisitor::apply(Projection& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
CullingMode mode = _cullingModeStack.back();
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
@@ -639,7 +639,7 @@ void CullVisitor::apply(Switch& node)
void CullVisitor::apply(LOD& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
CullingMode mode = _cullingModeStack.back();
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
@@ -687,7 +687,7 @@ void CullVisitor::apply(Impostor& node)
const BoundingSphere& bs = node.getBound();
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
CullingMode mode = _cullingModeStack.back();
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
@@ -952,7 +952,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
// switch off the view frustum culling, since we will have
// the whole subgraph in view.
_cullingModeStack.push_back((_cullingModeStack.back() & ~CullViewState::VIEW_FRUSTUM_CULLING));
_cullingModeStack.push_back((_cullingModeStack.back() & ~VIEW_FRUSTUM_CULLING));
{

View File

@@ -5,7 +5,6 @@ include $(TOPDIR)/Make/makedefs
CXXFILES = \
AppVisitor.cpp\
CameraManipulator.cpp\
CullViewState.cpp\
CullVisitor.cpp\
DepthSortedBin.cpp\
DisplayListVisitor.cpp\