From 1dcb923c15a6cf8f37ed56f8baf9148204815faf Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 15 May 2006 11:48:05 +0000 Subject: [PATCH] From Daniel Trastenjak, added checking of binding modes to ensure that changes are only applied when the binding mode changes, thereby avoiding uncessary calls to dirtyDisplayList. Note, from Robert Osfield, moved bodies of set*Binding() into Geometry.cpp to avoid clutter in the header. --- include/osg/Geometry | 8 ++++---- src/osg/Geometry.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/include/osg/Geometry b/include/osg/Geometry index 44361a9ae..813bb58ea 100644 --- a/include/osg/Geometry +++ b/include/osg/Geometry @@ -158,7 +158,7 @@ class OSG_EXPORT Geometry : public Drawable const ArrayData& getVertexData() const { return _vertexData; } - void setNormalBinding(AttributeBinding ab) { _normalData.binding = ab; computeFastPathsUsed(); dirtyDisplayList(); } + void setNormalBinding(AttributeBinding ab); AttributeBinding getNormalBinding() const { return _normalData.binding; } void setNormalArray(Array* array) { _normalData.array = array; if (!_normalData.array.valid()) _normalData.binding=BIND_OFF; computeFastPathsUsed(); dirtyDisplayList(); } @@ -173,7 +173,7 @@ class OSG_EXPORT Geometry : public Drawable ArrayData& getNormalData() { return _normalData; } const ArrayData& getNormalData() const { return _normalData; } - void setColorBinding(AttributeBinding ab) { _colorData.binding = ab; computeFastPathsUsed(); dirtyDisplayList(); } + void setColorBinding(AttributeBinding ab); AttributeBinding getColorBinding() const { return _colorData.binding; } void setColorArray(Array* array) { _colorData.array = array; if (!_colorData.array.valid()) _colorData.binding=BIND_OFF; computeFastPathsUsed(); dirtyDisplayList(); } @@ -189,7 +189,7 @@ class OSG_EXPORT Geometry : public Drawable const ArrayData& getColorData() const { return _colorData; } - void setSecondaryColorBinding(AttributeBinding ab) { _secondaryColorData.binding = ab; computeFastPathsUsed(); dirtyDisplayList(); } + void setSecondaryColorBinding(AttributeBinding ab); AttributeBinding getSecondaryColorBinding() const { return _secondaryColorData.binding; } void setSecondaryColorArray(Array* array) { _secondaryColorData.array = array; if (!_secondaryColorData.array.valid()) _secondaryColorData.binding=BIND_OFF; computeFastPathsUsed(); dirtyDisplayList(); } @@ -205,7 +205,7 @@ class OSG_EXPORT Geometry : public Drawable const ArrayData& getSecondaryColorData() const { return _secondaryColorData; } - void setFogCoordBinding(AttributeBinding ab) { _fogCoordData.binding = ab; computeFastPathsUsed(); dirtyDisplayList(); } + void setFogCoordBinding(AttributeBinding ab); AttributeBinding getFogCoordBinding() const { return _fogCoordData.binding; } void setFogCoordArray(Array* array) { _fogCoordData.array = array; if (!_fogCoordData.array.valid()) _fogCoordData.binding=BIND_OFF; computeFastPathsUsed(); dirtyDisplayList(); } diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index 9240ce4d2..bf8baf718 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -479,6 +479,42 @@ bool Geometry::empty() const return true; } +void Geometry::setNormalBinding(AttributeBinding ab) +{ + if (_normalData.binding == ab) return; + + _normalData.binding = ab; + computeFastPathsUsed(); + dirtyDisplayList(); +} + +void Geometry::setColorBinding(AttributeBinding ab) +{ + if (_colorData.binding == ab) return; + + _colorData.binding = ab; + computeFastPathsUsed(); + dirtyDisplayList(); +} + +void Geometry::setSecondaryColorBinding(AttributeBinding ab) +{ + if (_secondaryColorData.binding == ab) return; + + _secondaryColorData.binding = ab; + computeFastPathsUsed(); + dirtyDisplayList(); +} + +void Geometry::setFogCoordBinding(AttributeBinding ab) +{ + if (_fogCoordData.binding == ab) return; + + _fogCoordData.binding = ab; + computeFastPathsUsed(); + dirtyDisplayList(); +} + void Geometry::setTexCoordData(unsigned int unit,const ArrayData& arrayData) { if (_texCoordList.size()<=unit) @@ -614,8 +650,9 @@ const IndexArray* Geometry::getVertexAttribIndices(unsigned int index) const void Geometry::setVertexAttribBinding(unsigned int index,AttributeBinding ab) { + if (getVertexAttribData(index).binding == ab) + return; getVertexAttribData(index).binding = ab; - computeFastPathsUsed(); dirtyDisplayList(); }