From 78742d6698450d7b13ec11af47f2f67770888b13 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 8 Jun 2006 11:58:56 +0000 Subject: [PATCH] From Gustavo Wagner, addition of trim method to TemplateArray class. From Robert Osfield, made trim method a virtual method of the base Array class and added a trim implementation to TemplateIndexArray. --- include/osg/Array | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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(); }