Renamed the counter used to enable traversal order sorting

This commit is contained in:
Robert Osfield 2018-05-14 08:43:08 +01:00
parent 75b576bf83
commit 71f3bad57a
4 changed files with 18 additions and 14 deletions

View File

@ -354,8 +354,10 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
RenderBin* _currentRenderBin;
std::vector<RenderBin*> _renderBinStack;
value_type _computed_znear;
value_type _computed_zfar;
value_type _computed_znear;
value_type _computed_zfar;
unsigned int _traversalOrderNumber;
typedef std::vector< osg::ref_ptr<RenderLeaf> > RenderLeafList;
@ -472,12 +474,12 @@ inline RenderLeaf* CullVisitor::createOrReuseRenderLeaf(osg::Drawable* drawable,
if (_currentReuseRenderLeafIndex<_reuseRenderLeafList.size())
{
RenderLeaf* renderleaf = _reuseRenderLeafList[_currentReuseRenderLeafIndex++].get();
renderleaf->set(drawable,projection,matrix,depth,_traversalNumber++);
renderleaf->set(drawable,projection,matrix,depth,_traversalOrderNumber++);
return renderleaf;
}
// Otherwise need to create new renderleaf.
RenderLeaf* renderleaf = new RenderLeaf(drawable,projection,matrix,depth,_traversalNumber++);
RenderLeaf* renderleaf = new RenderLeaf(drawable,projection,matrix,depth,_traversalOrderNumber++);
_reuseRenderLeafList.push_back(renderleaf);
++_currentReuseRenderLeafIndex;
return renderleaf;

View File

@ -35,20 +35,20 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
public:
inline RenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalNumber=0):
inline RenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalOrderNumber=0):
osg::Referenced(false),
_parent(0),
_drawable(drawable),
_projection(projection),
_modelview(modelview),
_depth(depth),
_traversalNumber(traversalNumber)
_traversalOrderNumber(traversalOrderNumber)
{
_dynamic = (drawable->getDataVariance()==osg::Object::DYNAMIC);
}
inline void set(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalNumber=0)
inline void set(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalOrderNumber=0)
{
_parent = 0;
_drawable = drawable;
@ -56,7 +56,7 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
_modelview = modelview;
_depth = depth;
_dynamic = (drawable->getDataVariance()==osg::Object::DYNAMIC);
_traversalNumber = traversalNumber;
_traversalOrderNumber = traversalOrderNumber;
}
inline void reset()
@ -67,7 +67,7 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
_modelview = 0;
_depth = 0.0f;
_dynamic = false;
_traversalNumber = 0;
_traversalOrderNumber = 0;
}
virtual void render(osg::RenderInfo& renderInfo,RenderLeaf* previous);
@ -92,7 +92,7 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
osg::ref_ptr<osg::RefMatrix> _modelview;
float _depth;
bool _dynamic;
unsigned int _traversalNumber;
unsigned int _traversalOrderNumber;
private:
@ -104,7 +104,7 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
_projection(0),
_modelview(0),
_depth(0.0f),
_traversalNumber(0) {}
_traversalOrderNumber(0) {}
/// disallow copy construction.
RenderLeaf(const RenderLeaf&):osg::Referenced(false) {}

View File

@ -50,6 +50,7 @@ CullVisitor::CullVisitor():
_currentRenderBin(NULL),
_computed_znear(FLT_MAX),
_computed_zfar(-FLT_MAX),
_traversalOrderNumber(0),
_currentReuseRenderLeafIndex(0),
_numberOfEncloseOverrideRenderBinDetails(0)
{
@ -64,6 +65,7 @@ CullVisitor::CullVisitor(const CullVisitor& rhs):
_currentRenderBin(NULL),
_computed_znear(FLT_MAX),
_computed_zfar(-FLT_MAX),
_traversalOrderNumber(0),
_currentReuseRenderLeafIndex(0),
_numberOfEncloseOverrideRenderBinDetails(0),
_identifier(rhs._identifier)
@ -101,8 +103,8 @@ void CullVisitor::reset()
_numberOfEncloseOverrideRenderBinDetails = 0;
// reset the traversal number
_traversalNumber = 0;
// reset the traversal order number
_traversalOrderNumber = 0;
// reset the calculated near far planes.
_computed_znear = FLT_MAX;

View File

@ -334,7 +334,7 @@ struct TraversalOrderFunctor
{
bool operator() (const RenderLeaf* lhs,const RenderLeaf* rhs) const
{
return (lhs->_traversalNumber<rhs->_traversalNumber);
return (lhs->_traversalOrderNumber<rhs->_traversalOrderNumber);
}
};