From a459033eff2d2c1d320bb4e29fcb929c27756dd4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 26 Jun 2013 16:16:23 +0000 Subject: [PATCH] From Sebastian Messerschmidt, "I've taken some time and refactored some places where the old set*Binding were used." --- src/osg/Geometry.cpp | 7 +++---- src/osg/Image.cpp | 3 +-- src/osg/OcclusionQueryNode.cpp | 3 +-- src/osgAnimation/RigTransformSoftware.cpp | 3 +-- src/osgAnimation/StatsHandler.cpp | 6 ++---- src/osgManipulator/RotateCylinderDragger.cpp | 3 +-- src/osgManipulator/TabPlaneDragger.cpp | 6 ++---- src/osgManipulator/TrackballDragger.cpp | 3 +-- src/osgManipulator/TranslatePlaneDragger.cpp | 3 +-- src/osgPlugins/OpenFlight/GeometryRecords.cpp | 15 ++++++--------- src/osgShadow/ConvexPolyhedron.cpp | 3 +-- src/osgSim/OverlayNode.cpp | 3 +-- src/osgUtil/SceneGraphBuilder.cpp | 11 ++++------- 13 files changed, 25 insertions(+), 44 deletions(-) diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index d5772280e..a0fc17084 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -1073,14 +1073,13 @@ Geometry* osg::createTexturedQuadGeometry(const Vec3& corner,const Vec3& widthVe osg::Vec4Array* colours = new osg::Vec4Array(1); (*colours)[0].set(1.0f,1.0f,1.0,1.0f); - geom->setColorArray(colours); - geom->setColorBinding(Geometry::BIND_OVERALL); + geom->setColorArray(colours, osg::Array::BIND_OVERALL); osg::Vec3Array* normals = new osg::Vec3Array(1); (*normals)[0] = widthVec^heightVec; (*normals)[0].normalize(); - geom->setNormalArray(normals); - geom->setNormalBinding(Geometry::BIND_OVERALL); + geom->setNormalArray(normals, osg::Array::BIND_OVERALL); + #if defined(OSG_GLES1_AVAILABLE) || !defined(OSG_GLES2_AVAILABLE) DrawElementsUByte* elems = new DrawElementsUByte(PrimitiveSet::TRIANGLES); diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 6363ea442..63e8b7645 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -1805,8 +1805,7 @@ Geode* osg::createGeodeForImage(osg::Image* image,float s,float t) osg::Vec4Array* colours = new osg::Vec4Array(1); (*colours)[0].set(1.0f,1.0f,1.0,1.0f); - geom->setColorArray(colours); - geom->setColorBinding(Geometry::BIND_OVERALL); + geom->setColorArray(colours, osg::Array::BIND_OVERALL); geom->addPrimitiveSet(new DrawArrays(PrimitiveSet::QUADS,0,4)); diff --git a/src/osg/OcclusionQueryNode.cpp b/src/osg/OcclusionQueryNode.cpp index d44f38c87..410f047f7 100644 --- a/src/osg/OcclusionQueryNode.cpp +++ b/src/osg/OcclusionQueryNode.cpp @@ -715,8 +715,7 @@ void OcclusionQueryNode::createSupportNodes() ref_ptr ca = new Vec4Array; ca->push_back( Vec4( 1.f, 1.f, 1.f, 1.f ) ); - geom->setColorArray( ca.get() ); - geom->setColorBinding( Geometry::BIND_OVERALL ); + geom->setColorArray( ca.get(), Array::BIND_OVERALL ); geom->addPrimitiveSet( new DrawElementsUShort( PrimitiveSet::QUADS, 24, indices ) ); diff --git a/src/osgAnimation/RigTransformSoftware.cpp b/src/osgAnimation/RigTransformSoftware.cpp index 0889a6d52..ec64fb662 100644 --- a/src/osgAnimation/RigTransformSoftware.cpp +++ b/src/osgAnimation/RigTransformSoftware.cpp @@ -78,8 +78,7 @@ void RigTransformSoftware::operator()(RigGeometry& geom) { normalDst = new osg::Vec3Array; normalDst->setDataVariance(osg::Object::DYNAMIC); - destination.setNormalArray(normalDst); - destination.setNormalBinding(osg::Geometry::BIND_PER_VERTEX); + destination.setNormalArray(normalDst, osg::Array::BIND_PER_VERTEX); } *normalDst = *normalSrc; } diff --git a/src/osgAnimation/StatsHandler.cpp b/src/osgAnimation/StatsHandler.cpp index 288151816..74fc8c0af 100644 --- a/src/osgAnimation/StatsHandler.cpp +++ b/src/osgAnimation/StatsHandler.cpp @@ -62,8 +62,7 @@ osg::Geometry* createBackgroundRectangle(const osg::Vec3& pos, const float width osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back(color); - geometry->setColorArray(colors); - geometry->setColorBinding(osg::Geometry::BIND_OVERALL); + geometry->setColorArray(colors, osg::Array::BIND_OVERALL); osg::DrawElementsUInt *base = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS,0); base->push_back(0); @@ -133,8 +132,7 @@ struct StatsGraph : public osg::MatrixTransform void setColor(const osg::Vec4& color) { osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back(color); - setColorArray(colors); - setColorBinding(osg::Geometry::BIND_OVERALL); + setColorArray(colors, osg::Array::BIND_OVERALL); } }; diff --git a/src/osgManipulator/RotateCylinderDragger.cpp b/src/osgManipulator/RotateCylinderDragger.cpp index f01076c9a..b4b06c0b8 100644 --- a/src/osgManipulator/RotateCylinderDragger.cpp +++ b/src/osgManipulator/RotateCylinderDragger.cpp @@ -57,8 +57,7 @@ osg::Geometry* createDiskGeometry(float radius, float offset, float z, unsigned osg::Geometry* geometry = new osg::Geometry; geometry->setVertexArray(vertexArray); - geometry->setNormalArray(normalArray); - geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); + geometry->setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX); geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP, 0, vertexArray->size())); return geometry; } diff --git a/src/osgManipulator/TabPlaneDragger.cpp b/src/osgManipulator/TabPlaneDragger.cpp index 829c53ed9..c5bbe531a 100644 --- a/src/osgManipulator/TabPlaneDragger.cpp +++ b/src/osgManipulator/TabPlaneDragger.cpp @@ -42,8 +42,7 @@ osg::Node* createHandleNode(Scale2DDragger* cornerScaleDragger, float handleScal osg::Vec3Array* normals = new osg::Vec3Array; normals->push_back(osg::Vec3(0.0,1.0,0.0)); - geometry->setNormalArray(normals); - geometry->setNormalBinding(osg::Geometry::BIND_OVERALL); + geometry->setNormalArray(normals, osg::Array::BIND_OVERALL); osg::Geode* geode = new osg::Geode; geode->setName("Dragger Handle"); @@ -173,8 +172,7 @@ void createTranslateDraggerGeometry(Scale2DDragger* cornerScaleDragger, Translat osg::Vec3Array* normals = new osg::Vec3Array; normals->push_back(osg::Vec3(0.0,1.0,0.0)); - geometry->setNormalArray(normals); - geometry->setNormalBinding(osg::Geometry::BIND_OVERALL); + geometry->setNormalArray(normals, osg::Array::BIND_OVERALL); geode->addDrawable(geometry); diff --git a/src/osgManipulator/TrackballDragger.cpp b/src/osgManipulator/TrackballDragger.cpp index b9a801bc9..069ce4e99 100644 --- a/src/osgManipulator/TrackballDragger.cpp +++ b/src/osgManipulator/TrackballDragger.cpp @@ -44,8 +44,7 @@ osg::Geometry* createCircleGeometry(float radius, unsigned int numSegments) } osg::Geometry* geometry = new osg::Geometry(); geometry->setVertexArray(vertexArray); - geometry->setNormalArray(normalArray); - geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); + geometry->setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX); geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,vertexArray->size())); return geometry; } diff --git a/src/osgManipulator/TranslatePlaneDragger.cpp b/src/osgManipulator/TranslatePlaneDragger.cpp index 8b5148b58..662b73080 100644 --- a/src/osgManipulator/TranslatePlaneDragger.cpp +++ b/src/osgManipulator/TranslatePlaneDragger.cpp @@ -88,8 +88,7 @@ void TranslatePlaneDragger::setupDefaultGeometry() osg::Vec3Array* normals = new osg::Vec3Array; normals->push_back(osg::Vec3(0.0,1.0,0.0)); - geometry->setNormalArray(normals); - geometry->setNormalBinding(osg::Geometry::BIND_OVERALL); + geometry->setNormalArray(normals, osg::Array::BIND_OVERALL); geode->addDrawable(geometry); diff --git a/src/osgPlugins/OpenFlight/GeometryRecords.cpp b/src/osgPlugins/OpenFlight/GeometryRecords.cpp index d8fb6fabe..ec11b7390 100644 --- a/src/osgPlugins/OpenFlight/GeometryRecords.cpp +++ b/src/osgPlugins/OpenFlight/GeometryRecords.cpp @@ -12,7 +12,7 @@ */ // -// OpenFlight� loader for OpenSceneGraph +// OpenFlight loader for OpenSceneGraph // // Copyright (C) 2005-2007 Brede Johansen // @@ -589,10 +589,9 @@ protected: osg::Vec4 col = getPrimaryColor(); col[3] = 1.0f - getTransparency(); - geometry->setColorBinding(osg::Geometry::BIND_OVERALL); osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0] = col; - geometry->setColorArray(colors); + geometry->setColorArray(colors, osg::Array::BIND_OVERALL); } // Normal binding @@ -602,8 +601,7 @@ protected: } else { - geometry->setNormalBinding(osg::Geometry::BIND_OFF); - geometry->setNormalArray(NULL); + geometry->setNormalArray(0); } } } @@ -1421,10 +1419,10 @@ protected: osg::Vec4 col = mesh->getPrimaryColor(); col[3] = 1.0f - mesh->getTransparency(); - geometry->setColorBinding(osg::Geometry::BIND_OVERALL); + osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0] = col; - geometry->setColorArray(colors); + geometry->setColorArray(colors, osg::Array::BIND_OVERALL); } // Normal binding @@ -1434,8 +1432,7 @@ protected: } else { - geometry->setNormalBinding(osg::Geometry::BIND_OFF); - geometry->setNormalArray(NULL); + geometry->setNormalArray(0); } mesh->addGeometry(*geometry); diff --git a/src/osgShadow/ConvexPolyhedron.cpp b/src/osgShadow/ConvexPolyhedron.cpp index 72e342533..f00dbd6ba 100644 --- a/src/osgShadow/ConvexPolyhedron.cpp +++ b/src/osgShadow/ConvexPolyhedron.cpp @@ -1755,8 +1755,7 @@ osg::Geometry* ConvexPolyhedron::buildGeometry( const osg::Vec4d& colorOutline, geometry->setVertexArray(vertices); osg::Vec4Array* colors = new osg::Vec4Array; - geometry->setColorArray(colors); - geometry->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET); + geometry->setColorArray(colors, osg::Array::BIND_PER_PRIMITIVE_SET); for(Faces::const_iterator itr = _faces.begin(); itr != _faces.end(); diff --git a/src/osgSim/OverlayNode.cpp b/src/osgSim/OverlayNode.cpp index 2bc57b3b0..e2ac34bc4 100644 --- a/src/osgSim/OverlayNode.cpp +++ b/src/osgSim/OverlayNode.cpp @@ -799,8 +799,7 @@ public: osg::Vec4Array* colours = new osg::Vec4Array; colours->push_back(colour); - geometry->setColorArray(colours); - geometry->setColorBinding(osg::Geometry::BIND_OVERALL); + geometry->setColorArray(colours, osg::Array::BIND_OVERALL); osg::StateSet* stateset = geometry->getOrCreateStateSet(); stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF); diff --git a/src/osgUtil/SceneGraphBuilder.cpp b/src/osgUtil/SceneGraphBuilder.cpp index 5f9cc29a1..d872ffa02 100644 --- a/src/osgUtil/SceneGraphBuilder.cpp +++ b/src/osgUtil/SceneGraphBuilder.cpp @@ -248,26 +248,23 @@ void SceneGraphBuilder::End() if (_colorSet) { - _geometry->setColorArray(_colors.get()); - _geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX); + _geometry->setColorArray(_colors.get(), osg::Array::BIND_PER_VERTEX); } else { osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back(_color); - _geometry->setColorArray(colors); - _geometry->setColorBinding(osg::Geometry::BIND_OVERALL); + _geometry->setColorArray(colors, osg::Array::BIND_OVERALL); } if (_normalSet) { - _geometry->setNormalArray(_normals.get()); - _geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); + _geometry->setNormalArray(_normals.get(), osg::Array::BIND_PER_VERTEX); } else { - _geometry->setNormalBinding(osg::Geometry::BIND_OFF); + _geometry->setNormalArray(NULL, osg::Array::BIND_OFF); } if (_maxNumTexCoordComponents==1)