Introduced dedicated VertexArrayStateList class to wrap up the VertexArrayState container with convinience methods to help initialize them.

Using the new VertexArrayStateList class fixed bug associated with setting new setTexCoord() array when a VertexArrayState is already assigned.
This commit is contained in:
Robert Osfield
2017-12-19 09:57:57 +00:00
parent d2bfde30f0
commit 5afd32b2d9
4 changed files with 212 additions and 18 deletions

View File

@@ -321,8 +321,6 @@ class OSG_EXPORT Drawable : public Node
/** Implementaion of Craeate tje VertexArrayState object.*/
virtual VertexArrayState* createVertexArrayStateImplementation(RenderInfo& renderInfo) const;
typedef buffered_object< osg::ref_ptr<VertexArrayState> > VertexArrayStateList;
void setVertexArrayStateList(VertexArrayStateList& vasl) { _vertexArrayStateList = vasl; }
VertexArrayStateList& getVertexArrayStateList() { return _vertexArrayStateList; }

View File

@@ -23,7 +23,7 @@ namespace osg {
class OSG_EXPORT VertexArrayState : public osg::Referenced
{
public:
public:
VertexArrayState(osg::State* state);
@@ -176,7 +176,7 @@ public:
void release();
public:
public:
// osg::GLBufferObject* getGLBufferObject(osg::Array* array);
@@ -208,6 +208,59 @@ public:
};
class OSG_EXPORT VertexArrayStateList
{
public:
VertexArrayStateList();
VertexArrayStateList& operator = (const VertexArrayStateList& rhs);
inline void clear() { _array.clear(); }
inline bool empty() const { return _array.empty(); }
inline unsigned int size() const { return _array.size(); }
inline void resize(unsigned int newSize) { _array.resize(newSize); }
inline ref_ptr<VertexArrayState>& operator[] (unsigned int pos)
{
// automatically resize array.
if (_array.size()<=pos)
_array.resize(pos+1,0);
return _array[pos];
}
inline const ref_ptr<VertexArrayState>& operator[] (unsigned int pos) const
{
// automatically resize array.
if (_array.size()<=pos)
_array.resize(pos+1,0);
return _array[pos];
}
void assignAllDispatchers();
void assignVertexArrayDispatcher();
void assignNormalArrayDispatcher();
void assignColorArrayDispatcher();
void assignSecondaryColorArrayDispatcher();
void assignFogCoordArrayDispatcher();
void assignTexCoordArrayDispatcher(unsigned int numUnits);
void assignVertexAttribArrayDispatcher(unsigned int numUnits);
protected:
typedef std::vector< osg::ref_ptr<VertexArrayState> > Array;
mutable Array _array;
};
inline void VertexArrayState::lazyDisablingOfVertexAttributes()
{
_activeDispatchers.swap(_previous_activeDispatchers);