Various fixes to the flt loader, and knock on changes to the osgUtil::Optimizer

to better support removal of seperate osg::Geometry instances where they
share the same state and bindings.
This commit is contained in:
Robert Osfield
2002-07-18 00:53:03 +00:00
parent 735b9d2318
commit 09bdb10af5
15 changed files with 609 additions and 230 deletions

View File

@@ -58,9 +58,10 @@ class SG_EXPORT Array : public Object
Type getType() const { return _arrayType; }
GLint dataSize() const { return _dataSize; }
GLenum dataType() const { return _dataType; }
virtual const GLvoid* dataPointer() const = 0;
GLint getDataSize() const { return _dataSize; }
GLenum getDataType() const { return _dataType; }
virtual const GLvoid* getDataPointer() const = 0;
virtual unsigned int getNumElements() const = 0;
protected:
@@ -101,7 +102,8 @@ class TemplateArray : public Array, public std::vector<T>
virtual Object* clone(const CopyOp& copyop) const { return osgNew TemplateArray(*this,copyop); }
virtual void accept(ArrayVisitor& av) { av.apply(*this); }
virtual const GLvoid* dataPointer() const { if (!empty()) return &front(); else return 0; }
virtual const GLvoid* getDataPointer() const { if (!empty()) return &front(); else return 0; }
virtual unsigned int getNumElements() const { return size(); }
protected:

View File

@@ -54,13 +54,13 @@ class SG_EXPORT Geode : public Node
/** return the number of geoset's.*/
inline const int getNumDrawables() const { return _drawables.size(); }
inline const unsigned int getNumDrawables() const { return _drawables.size(); }
/** return geoset at position i.*/
inline Drawable* getDrawable( const int i ) { return _drawables[i].get(); }
inline Drawable* getDrawable( const unsigned int i ) { return _drawables[i].get(); }
/** return geoset at position i.*/
inline const Drawable* getDrawable( const int i ) const { return _drawables[i].get(); }
inline const Drawable* getDrawable( const unsigned int i ) const { return _drawables[i].get(); }
/** return true if geoset is contained within Geode.*/
inline const bool containsDrawable(const Drawable* gset) const

View File

@@ -80,6 +80,10 @@ class SG_EXPORT Geometry : public Drawable
void addPrimitive(Primitive* primitive) { if (primitive) _primitives.push_back(primitive); dirtyDisplayList(); }
bool verifyBindings() const;
void computeCorrectBindingsAndArraySizes();
/** draw Geometry directly ignoring an OpenGL display list which could be attached.
* This is the internal draw method which does the drawing itself,

View File

@@ -124,6 +124,8 @@ class Primitive : public Object
virtual void draw() const = 0;
virtual void applyPrimitiveOperation(Drawable::PrimitiveFunctor&) {}
virtual void offsetIndices(int offset) = 0;
protected:
@@ -174,6 +176,8 @@ class SG_EXPORT DrawArrays : public Primitive
virtual void applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor);
virtual void offsetIndices(int offset) { _first += offset; }
protected:
GLint _first;
@@ -223,6 +227,8 @@ class SG_EXPORT DrawArrayLengths : public Primitive, public VectorSizei
virtual void applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor);
virtual void offsetIndices(int offset) { _first += offset; }
protected:
GLint _first;
@@ -261,6 +267,8 @@ class SG_EXPORT DrawElementsUByte : public Primitive, public VectorUByte
virtual void draw() const ;
virtual void applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor);
virtual void offsetIndices(int offset);
};
@@ -297,6 +305,8 @@ class SG_EXPORT DrawElementsUShort : public Primitive, public VectorUShort
virtual void draw() const;
virtual void applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor);
virtual void offsetIndices(int offset);
};
class SG_EXPORT DrawElementsUInt : public Primitive, public VectorUInt
@@ -333,6 +343,7 @@ class SG_EXPORT DrawElementsUInt : public Primitive, public VectorUInt
virtual void applyPrimitiveOperation(Drawable::PrimitiveFunctor& functor);
virtual void offsetIndices(int offset);
};
// backwards compatibility with first incarnation of DrawElements nameing convention.

View File

@@ -73,7 +73,7 @@ class OSGUTIL_EXPORT AppVisitor : public osg::NodeVisitor
else if (node.getNumChildrenRequiringAppTraversal()>0) traverse(node);
// call the app callbacks on the drawables.
for(int i=0;i<node.getNumDrawables();++i)
for(unsigned int i=0;i<node.getNumDrawables();++i)
{
osg::Drawable::AppCallback* callback = node.getDrawable(i)->getAppCallback();
if (callback) callback->app(this,node.getDrawable(i));

View File

@@ -7,6 +7,7 @@
#include <osg/NodeVisitor>
#include <osg/Matrix>
#include <osg/Geometry>
#include <osgUtil/Export>
@@ -315,7 +316,22 @@ class OSGUTIL_EXPORT Optimizer
StateSetMap _statesets;
};
class OSGUTIL_EXPORT MergeGeometryVisitor : public osg::NodeVisitor
{
public:
/// default to traversing all children.
MergeGeometryVisitor() : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) {}
virtual void apply(osg::Geode& geode) { mergeGeode(geode); }
virtual void apply(osg::Billboard& billboard) { /* don't do anything*/ }
static bool mergeGeode(osg::Geode& geode);
static bool mergeGeometry(osg::Geometry& lhs,osg::Geometry& rhs);
};
};
}