diff --git a/include/osg/PrimitiveSet b/include/osg/PrimitiveSet index 08ed74399..a49f1809e 100644 --- a/include/osg/PrimitiveSet +++ b/include/osg/PrimitiveSet @@ -185,23 +185,7 @@ class PrimitiveSet : public Object virtual unsigned int getNumIndices() const = 0; virtual void offsetIndices(int offset) = 0; - virtual unsigned int getNumPrimitives() const - { - switch(_mode) - { - case(POINTS): return getNumIndices(); - case(LINES): return getNumIndices()/2; - case(TRIANGLES): return getNumIndices()/3; - case(QUADS): return getNumIndices()/4; - case(LINE_STRIP): - case(LINE_LOOP): - case(TRIANGLE_STRIP): - case(TRIANGLE_FAN): - case(QUAD_STRIP): - case(POLYGON): return 1; - } - return 0; - } + virtual unsigned int getNumPrimitives() const; /** Dirty the primitive, which increments the modified count, to force buffer objects to update. */ inline void dirty() { ++_modifiedCount; } @@ -356,23 +340,7 @@ class OSG_EXPORT DrawArrayLengths : public PrimitiveSet, public VectorGLsizei virtual unsigned int index(unsigned int pos) const { return _first+pos; } virtual void offsetIndices(int offset) { _first += offset; } - virtual unsigned int getNumPrimitives() const - { - switch(_mode) - { - case(POINTS): return getNumIndices(); - case(LINES): return getNumIndices()/2; - case(TRIANGLES): return getNumIndices()/3; - case(QUADS): return getNumIndices()/4; - case(LINE_STRIP): - case(LINE_LOOP): - case(TRIANGLE_STRIP): - case(TRIANGLE_FAN): - case(QUAD_STRIP): - case(POLYGON): return size(); - } - return 0; - } + virtual unsigned int getNumPrimitives() const; protected: diff --git a/src/osg/PrimitiveSet.cpp b/src/osg/PrimitiveSet.cpp index d5e3e9f59..4fcc33ea8 100644 --- a/src/osg/PrimitiveSet.cpp +++ b/src/osg/PrimitiveSet.cpp @@ -17,6 +17,24 @@ using namespace osg; +unsigned int PrimitiveSet::getNumPrimitives() const +{ + switch(_mode) + { + case(POINTS): return getNumIndices(); + case(LINES): return getNumIndices()/2; + case(TRIANGLES): return getNumIndices()/3; + case(QUADS): return getNumIndices()/4; + case(LINE_STRIP): + case(LINE_LOOP): + case(TRIANGLE_STRIP): + case(TRIANGLE_FAN): + case(QUAD_STRIP): + case(POLYGON): return 1; + } + return 0; +} + void DrawArrays::draw(State&, bool) const { glDrawArrays(_mode,_first,_count); @@ -32,6 +50,24 @@ void DrawArrays::accept(PrimitiveIndexFunctor& functor) const functor.drawArrays(_mode,_first,_count); } +unsigned int DrawArrayLengths::getNumPrimitives() const +{ + switch(_mode) + { + case(POINTS): return getNumIndices(); + case(LINES): return getNumIndices()/2; + case(TRIANGLES): return getNumIndices()/3; + case(QUADS): return getNumIndices()/4; + case(LINE_STRIP): + case(LINE_LOOP): + case(TRIANGLE_STRIP): + case(TRIANGLE_FAN): + case(QUAD_STRIP): + case(POLYGON): return size(); + } + return 0; +} + void DrawArrayLengths::draw(State&, bool) const { GLint first = _first;