diff --git a/include/osg/Array b/include/osg/Array index 0d981a4d9..3bbf3a4ea 100644 --- a/include/osg/Array +++ b/include/osg/Array @@ -101,6 +101,9 @@ class OSG_EXPORT Array : public Object virtual unsigned int getTotalDataSize() const = 0; virtual unsigned int getNumElements() const = 0; + /** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/ + virtual void trim() {} + /** Dirty the primitive, which increments the modified count, to force buffer objects to update. */ inline void dirty() { ++_modifiedCount; } @@ -168,6 +171,12 @@ class TemplateArray : public Array, public std::vector if (elem_rhs( *this ).swap( *this ); + } virtual const GLvoid* getDataPointer() const { if (!this->empty()) return &this->front(); else return 0; } virtual unsigned int getTotalDataSize() const { return this->size()*sizeof(T); } @@ -247,6 +256,12 @@ class TemplateIndexArray : public IndexArray, public std::vector return 0; } + /** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/ + virtual void trim() + { + std::vector( *this ).swap( *this ); + } + virtual const GLvoid* getDataPointer() const { if (!this->empty()) return &this->front(); else return 0; } virtual unsigned int getTotalDataSize() const { return this->size()*sizeof(T); } virtual unsigned int getNumElements() const { return this->size(); }