Fixed a bug in the Optimizer::RemoveDuplicateNodesVisitor which was prevent

removal of node which could have been removed.

Added so extra convinience methods to ClippingVolume and utilized them in the
CullVisitor to push and pop only culling planes that are active.
This commit is contained in:
Robert Osfield
2002-05-23 15:35:12 +00:00
parent 5ce4a54c0d
commit 09121a1583
3 changed files with 16 additions and 7 deletions

View File

@@ -46,7 +46,7 @@ class SG_EXPORT ClippingVolume
/** Create a ClippingVolume with is cube, centered at 0,0,0, with sides of 2 units.*/
void setToUnitFrustum()
{
_planeList.clear();
_planeList.erase(_planeList.begin(),_planeList.end());
_planeList.push_back(Plane(1.0f,0.0f,0.0f,1.0f)); // left plane.
_planeList.push_back(Plane(-1.0f,0.0f,0.0f,1.0f)); // right plane.
_planeList.push_back(Plane(0.0f,1.0f,0.0f,1.0f)); // bottom plane.
@@ -58,7 +58,7 @@ class SG_EXPORT ClippingVolume
void setToUnitFrustumWithoutNearFar()
{
_planeList.clear();
_planeList.erase(_planeList.begin(),_planeList.end());
_planeList.push_back(Plane(1.0f,0.0f,0.0f,1.0f)); // left plane.
_planeList.push_back(Plane(-1.0f,0.0f,0.0f,1.0f)); // right plane.
_planeList.push_back(Plane(0.0f,1.0f,0.0f,1.0f)); // bottom plane.
@@ -68,6 +68,7 @@ class SG_EXPORT ClippingVolume
inline void set(const ClippingVolume& cs, const unsigned int mask)
{
_planeList.erase(_planeList.begin(),_planeList.end());
unsigned int selector_mask = 0x1;
for(PlaneList::const_iterator itr=cs._planeList.begin();
itr!=cs._planeList.end();
@@ -97,6 +98,8 @@ class SG_EXPORT ClippingVolume
_localMask = (_localMask<<1) | 1;
}
}
unsigned int getLocalMask() const { return _localMask; }
/** Check whether a vertex is contained with clipping set.*/

View File

@@ -169,8 +169,13 @@ void CullVisitor::reset()
void CullVisitor::pushClippingVolume()
{
_modelviewClippingVolumeStack.push_back(_projectionClippingVolumeStack.back());
if (!_modelviewStack.empty()) _modelviewClippingVolumeStack.back().transformProvidingInverse(*_modelviewStack.back());
_modelviewClippingVolumeStack.push_back(osg::ClippingVolume());
osg::ClippingVolume& cv = _modelviewClippingVolumeStack.back();
//cv.set(_projectionClippingVolumeStack.back());
cv.set(_projectionClippingVolumeStack.back(),_cullingModeStack.back());
_cullingModeStack.push_back(cv.getLocalMask() | (_cullingModeStack.back()&SMALL_FEATURE_CULLING));
if (!_modelviewStack.empty()) cv.transformProvidingInverse(*_modelviewStack.back());
_MVPW_Stack.push_back(0L);
@@ -181,7 +186,8 @@ void CullVisitor::popClippingVolume()
{
_modelviewClippingVolumeStack.pop_back();
_MVPW_Stack.pop_back();
_cullingModeStack.pop_back();
_windowToModelFactorDirty = true;
}

View File

@@ -527,7 +527,7 @@ void Optimizer::FlattenStaticTransformsVisitor::removeTransforms()
osg::ref_ptr<osg::Transform> transform = titr->first;
osg::ref_ptr<osg::Group> group = osgNew osg::Group;
group->setDataVariance(osg::Object::STATIC);
for(unsigned int i=0;i<transform->getNumChildren();++i)
{
for(unsigned int j=0;j<transform->getNumParents();++j)
@@ -562,7 +562,7 @@ void Optimizer::RemoveRedundentNodesVisitor::apply(osg::Group& group)
if (!group.getUserData() &&
!group.getAppCallback() &&
!group.getStateSet() &&
group.getNodeMask()!=0xffffffff)
group.getNodeMask()==0xffffffff)
{
_redundentNodeList.insert(&group);
}