Skip to content

Commit

Permalink
fixed: culling problems with infinite subtree volumes
Browse files Browse the repository at this point in the history
git-svn-id: https://external.lite3d.com/opensg/svn_repo/trunk@2278 4683daeb-ad0f-0410-a623-93161e962ae5
  • Loading branch information
vossg committed Jan 29, 2010
1 parent 3759691 commit c803c4c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
24 changes: 16 additions & 8 deletions Source/System/Action/RenderAction/OSGRenderPartition.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
{
Expand Down
18 changes: 14 additions & 4 deletions Source/WindowSystem/GLUT/testWindowGLUT.cpp
Expand Up @@ -38,6 +38,7 @@
#include "OSGGraphOp.h"
#include "OSGGraphOpFactory.h"
#include "OSGMultiCore.h"
#include "OSGFrameHandler.h"

#include "OSGTrackball.h"

Expand Down Expand Up @@ -109,6 +110,8 @@ display(void)
cam_trans->editSFMatrix()->setValue( m1 );
}

OSG::FrameHandler::the()->frame();

OSG::commitChanges();

win->render(rentravact);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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

Expand Down Expand Up @@ -403,6 +410,8 @@ int init(int argc, char **argv)

}

OSG::Thread::getCurrentChangeList()->commitChanges();

#if 0
OSG::GeometryPtr pGeo = cast_dynamic<OSG::GeometryPtr>(file->getCore());

Expand All @@ -423,7 +432,6 @@ int init(int argc, char **argv)
// createOptimizedPrimitives(pGeo);
// createSharedIndex(pGeo);

OSG::Thread::getCurrentChangeList()->commitChanges();

// file->dump();
file->updateVolume();
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -599,6 +607,8 @@ int init(int argc, char **argv)
pGr = NULL;
#endif

OSG::FrameHandler::the()->init();

return 0;
}

Expand Down

0 comments on commit c803c4c

Please sign in to comment.