Added osg::Geometry::configureBufferObjects() and ConfigureBufferObjectsVisitor visitor to help with setting up buffer objects in a coherent fashion.

This commit is contained in:
Robert Osfield
2016-11-14 17:59:25 +00:00
parent 99cb8ebacf
commit 5b375124cc
2 changed files with 68 additions and 0 deletions

View File

@@ -129,6 +129,9 @@ class OSG_EXPORT Geometry : public Drawable
unsigned int getPrimitiveSetIndex(const PrimitiveSet* primitiveset) const;
/** Convinience method that checks all the vertex arrays to make sure that the buffer objects are all assigned appropriate.*/
void configureBufferObjects();
/** return true if any arrays are shared.*/
bool containsSharedArrays() const;
@@ -276,6 +279,21 @@ class OSG_EXPORT Geometry : public Drawable
#endif
};
/** Convinience visitor for making sure that any BufferObjects that might be required are set up in the scene graph.*/
class ConfigureBufferObjectsVisitor : public osg::NodeVisitor
{
public:
ConfigureBufferObjectsVisitor():
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
void apply(osg::Geometry& geometry)
{
geometry.configureBufferObjects();
}
};
/** Convenience function to be used for creating quad geometry with texture coords.
* Tex coords go from left bottom (l,b) to right top (r,t).
*/