From c803c4c390e7368ac72402a553c487dce6795007 Mon Sep 17 00:00:00 2001 From: vossg Date: Fri, 29 Jan 2010 05:15:23 +0000 Subject: [PATCH] fixed: culling problems with infinite subtree volumes git-svn-id: https://external.lite3d.com/opensg/svn_repo/trunk@2278 4683daeb-ad0f-0410-a623-93161e962ae5 --- .../RenderAction/OSGRenderPartition.cpp | 24 ++++++++++++------- Source/WindowSystem/GLUT/testWindowGLUT.cpp | 18 ++++++++++---- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Source/System/Action/RenderAction/OSGRenderPartition.cpp b/Source/System/Action/RenderAction/OSGRenderPartition.cpp index 9f537a963..0d828542d 100644 --- a/Source/System/Action/RenderAction/OSGRenderPartition.cpp +++ b/Source/System/Action/RenderAction/OSGRenderPartition.cpp @@ -1146,6 +1146,9 @@ bool RenderPartition::isVisible(Node *pNode) // _oDrawEnv.getRTAction()->getStatistics()->getElem(statCullTestedNodes)->inc(); + if(pNode->getVolume().isInfinite() == true) + return true; + BoxVolume vol; pNode->updateVolume(); @@ -1191,21 +1194,26 @@ bool RenderPartition::pushVisibility(Node * const pNode) Color3f col; bool result = true; - pNode->updateVolume(); - - BoxVolume vol = pNode->getVolume(); FrustumVolume frustum = _oFrustum; + BoxVolume vol = pNode->getVolume(); + + // don't mess with infinite volumes + if(vol.isInfinite() == false) + { + pNode->updateVolume(); + + vol = pNode->getVolume(); #if 1 - vol.transform(topMatrix()); + vol.transform(topMatrix()); #else // not quite working - Matrix m = topMatrix(); - m.invert(); + Matrix m = topMatrix(); + m.invert(); - frustum.transform(m); + frustum.transform(m); #endif - + } if(_oDrawEnv.getStatCollector() != NULL) { diff --git a/Source/WindowSystem/GLUT/testWindowGLUT.cpp b/Source/WindowSystem/GLUT/testWindowGLUT.cpp index fa340ae7e..010c86edf 100644 --- a/Source/WindowSystem/GLUT/testWindowGLUT.cpp +++ b/Source/WindowSystem/GLUT/testWindowGLUT.cpp @@ -38,6 +38,7 @@ #include "OSGGraphOp.h" #include "OSGGraphOpFactory.h" #include "OSGMultiCore.h" +#include "OSGFrameHandler.h" #include "OSGTrackball.h" @@ -109,6 +110,8 @@ display(void) cam_trans->editSFMatrix()->setValue( m1 ); } + OSG::FrameHandler::the()->frame(); + OSG::commitChanges(); win->render(rentravact); @@ -212,6 +215,8 @@ void key(unsigned char key, int x, int y) switch ( key ) { case 27: + OSG::FrameHandler::the()->shutdown(); + root = NULL; file = NULL; cam = NULL; @@ -323,7 +328,9 @@ void key(unsigned char key, int x, int y) int init(int argc, char **argv) { OSG::osgInit(argc,argv); - + + OSG::setVBOUsageOnPropertyProtos(true); + // GLUT init glutInit(&argc, argv); @@ -344,7 +351,7 @@ int init(int argc, char **argv) // glEnable( GL_LIGHTING ); // glEnable( GL_LIGHT0 ); // glFrontFace(GL_CW); - glEnable(GL_CULL_FACE); +// glEnable(GL_CULL_FACE); // OSG @@ -403,6 +410,8 @@ int init(int argc, char **argv) } + OSG::Thread::getCurrentChangeList()->commitChanges(); + #if 0 OSG::GeometryPtr pGeo = cast_dynamic(file->getCore()); @@ -423,7 +432,6 @@ int init(int argc, char **argv) // createOptimizedPrimitives(pGeo); // createSharedIndex(pGeo); - OSG::Thread::getCurrentChangeList()->commitChanges(); // file->dump(); file->updateVolume(); @@ -498,7 +506,7 @@ int init(int argc, char **argv) // Background OSG::SolidBackgroundUnrecPtr bkgnd = OSG::SolidBackground::create(); - bkgnd->setColor(OSG::Color3f(1,0,0)); + bkgnd->setColor(OSG::Color3f(0.1,0.1,0.1)); // Viewport @@ -599,6 +607,8 @@ int init(int argc, char **argv) pGr = NULL; #endif + OSG::FrameHandler::the()->init(); + return 0; }