From 092dd93be88fbb38123e9cea72bd63d9c74b5be4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 27 Jun 2013 10:58:26 +0000 Subject: [PATCH] Removed deprecated usage of osg::Geometry::get*Binding() --- src/osgUtil/MeshOptimizers.cpp | 29 ++++++++++---------- src/osgUtil/Optimizer.cpp | 39 +++++++++++++-------------- src/osgUtil/Simplifier.cpp | 20 +++++++------- src/osgUtil/SmoothingVisitor.cpp | 16 +++++------ src/osgUtil/TangentSpaceGenerator.cpp | 6 ++--- src/osgUtil/Tessellator.cpp | 18 ++++++------- src/osgUtil/TriStripVisitor.cpp | 28 +++++++++---------- 7 files changed, 77 insertions(+), 79 deletions(-) diff --git a/src/osgUtil/MeshOptimizers.cpp b/src/osgUtil/MeshOptimizers.cpp index a5ba79205..b77fcbf75 100644 --- a/src/osgUtil/MeshOptimizers.cpp +++ b/src/osgUtil/MeshOptimizers.cpp @@ -62,28 +62,27 @@ struct GeometryArrayGatherer GeometryArrayGatherer(osg::Geometry& geometry) : _useDrawElements(true) { - add(geometry.getVertexArray(),osg::Geometry::BIND_PER_VERTEX); - add(geometry.getNormalArray(),geometry.getNormalBinding()); - add(geometry.getColorArray(),geometry.getColorBinding()); - add(geometry.getSecondaryColorArray(),geometry.getSecondaryColorBinding()); - add(geometry.getFogCoordArray(),geometry.getFogCoordBinding()); + add(geometry.getVertexArray()); + add(geometry.getNormalArray()); + add(geometry.getColorArray()); + add(geometry.getSecondaryColorArray()); + add(geometry.getFogCoordArray()); unsigned int i; for(i=0;igetBinding()==osg::Array::BIND_PER_VERTEX) { - if (array) - _arrayList.push_back(array); + _arrayList.push_back(array); } } @@ -231,13 +230,13 @@ void IndexMeshVisitor::makeMesh(Geometry& geom) { if (geom.containsDeprecatedData()) geom.fixDeprecatedData(); - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (osg::getBinding(geom.getNormalArray())==osg::Array::BIND_PER_PRIMITIVE_SET) return; - if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (osg::getBinding(geom.getColorArray())==osg::Array::BIND_PER_PRIMITIVE_SET) return; - if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (osg::getBinding(geom.getSecondaryColorArray())==osg::Array::BIND_PER_PRIMITIVE_SET) return; - if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (osg::getBinding(geom.getFogCoordArray())==osg::Array::BIND_PER_PRIMITIVE_SET) return; // no point optimizing if we don't have enough vertices. if (!geom.getVertexArray() || geom.getVertexArray()->getNumElements()<3) return; diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 576ec98d6..149ac5a04 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -1678,6 +1678,11 @@ void Optimizer::CombineLODsVisitor::combineLODs() // code to merge geometry object which share, state, and attribute bindings. //////////////////////////////////////////////////////////////////////////// +#define COMPARE_BINDING(lhs, rhs) \ + if (osg::getBinding(lhs)getStateSet()getStateSet()) return true; if (rhs->getStateSet()getStateSet()) return false; - if (lhs->getNormalBinding()getNormalBinding()) return true; - if (rhs->getNormalBinding()getNormalBinding()) return false; + COMPARE_BINDING(lhs->getNormalArray(), rhs->getNormalArray()) + COMPARE_BINDING(lhs->getColorArray(), rhs->getColorArray()) + COMPARE_BINDING(lhs->getSecondaryColorArray(), rhs->getSecondaryColorArray()) + COMPARE_BINDING(lhs->getFogCoordArray(), rhs->getFogCoordArray()) - if (lhs->getColorBinding()getColorBinding()) return true; - if (rhs->getColorBinding()getColorBinding()) return false; - - if (lhs->getSecondaryColorBinding()getSecondaryColorBinding()) return true; - if (rhs->getSecondaryColorBinding()getSecondaryColorBinding()) return false; - - if (lhs->getFogCoordBinding()getFogCoordBinding()) return true; - if (rhs->getFogCoordBinding()getFogCoordBinding()) return false; if (lhs->getNumTexCoordArrays()getNumTexCoordArrays()) return true; if (rhs->getNumTexCoordArrays()getNumTexCoordArrays()) return false; @@ -1722,7 +1721,7 @@ struct LessGeometry } - if (lhs->getNormalBinding()==osg::Geometry::BIND_OVERALL) + if (osg::getBinding(lhs->getNormalArray())==osg::Array::BIND_OVERALL) { // assumes that the bindings and arrays are set up correctly, this // should be the case after running computeCorrectBindingsAndArraySizes(); @@ -1749,7 +1748,7 @@ struct LessGeometry } } - if (lhs->getColorBinding()==osg::Geometry::BIND_OVERALL) + if (osg::getBinding(lhs->getColorArray())==osg::Array::BIND_OVERALL) { const osg::Array* lhs_colorArray = lhs->getColorArray(); const osg::Array* rhs_colorArray = rhs->getColorArray(); @@ -2166,10 +2165,10 @@ bool Optimizer::MergeGeometryVisitor::mergeGeode(osg::Geode& geode) if (geom) { if (geom->getNumPrimitiveSets()>0 && - geom->getNormalBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET && - geom->getColorBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET && - geom->getSecondaryColorBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET && - geom->getFogCoordBinding()!=osg::Geometry::BIND_PER_PRIMITIVE_SET) + osg::getBinding(geom->getNormalArray())!=osg::Array::BIND_PER_PRIMITIVE_SET && + osg::getBinding(geom->getColorArray())!=osg::Array::BIND_PER_PRIMITIVE_SET && + osg::getBinding(geom->getSecondaryColorArray())!=osg::Array::BIND_PER_PRIMITIVE_SET && + osg::getBinding(geom->getFogCoordArray())!=osg::Array::BIND_PER_PRIMITIVE_SET) { #if 1 @@ -2457,7 +2456,7 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom } - if (lhs.getNormalArray() && rhs.getNormalArray() && lhs.getNormalBinding()!=osg::Geometry::BIND_OVERALL) + if (lhs.getNormalArray() && rhs.getNormalArray() && lhs.getNormalArray()->getBinding()!=osg::Array::BIND_OVERALL) { if (!merger.merge(lhs.getNormalArray(),rhs.getNormalArray())) { @@ -2470,7 +2469,7 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom } - if (lhs.getColorArray() && rhs.getColorArray() && lhs.getColorBinding()!=osg::Geometry::BIND_OVERALL) + if (lhs.getColorArray() && rhs.getColorArray() && lhs.getColorArray()->getBinding()!=osg::Array::BIND_OVERALL) { if (!merger.merge(lhs.getColorArray(),rhs.getColorArray())) { @@ -2482,7 +2481,7 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom lhs.setColorArray(rhs.getColorArray()); } - if (lhs.getSecondaryColorArray() && rhs.getSecondaryColorArray() && lhs.getSecondaryColorBinding()!=osg::Geometry::BIND_OVERALL) + if (lhs.getSecondaryColorArray() && rhs.getSecondaryColorArray() && lhs.getSecondaryColorArray()->getBinding()!=osg::Array::BIND_OVERALL) { if (!merger.merge(lhs.getSecondaryColorArray(),rhs.getSecondaryColorArray())) { @@ -2494,7 +2493,7 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom lhs.setSecondaryColorArray(rhs.getSecondaryColorArray()); } - if (lhs.getFogCoordArray() && rhs.getFogCoordArray() && lhs.getFogCoordBinding()!=osg::Geometry::BIND_OVERALL) + if (lhs.getFogCoordArray() && rhs.getFogCoordArray() && lhs.getFogCoordArray()->getBinding()!=osg::Array::BIND_OVERALL) { if (!merger.merge(lhs.getFogCoordArray(),rhs.getFogCoordArray())) { diff --git a/src/osgUtil/Simplifier.cpp b/src/osgUtil/Simplifier.cpp index 6bf041d99..23c9c2597 100644 --- a/src/osgUtil/Simplifier.cpp +++ b/src/osgUtil/Simplifier.cpp @@ -1444,21 +1444,21 @@ void EdgeCollapse::setGeometry(osg::Geometry* geometry, const Simplifier::IndexL geometry->getTexCoordArray(ti)->accept(copyArrayToPoints); } - if (_geometry->getNormalArray() && _geometry->getNormalBinding()==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getNormalArray() && _geometry->getNormalArray()->getBinding()==osg::Array::BIND_PER_VERTEX) geometry->getNormalArray()->accept(copyArrayToPoints); - if (_geometry->getColorArray() && _geometry->getColorBinding()==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getColorArray() && _geometry->getColorArray()->getBinding()==osg::Array::BIND_PER_VERTEX) geometry->getColorArray()->accept(copyArrayToPoints); - if (_geometry->getSecondaryColorArray() && _geometry->getSecondaryColorBinding()==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getSecondaryColorArray() && _geometry->getSecondaryColorArray()->getBinding()==osg::Array::BIND_PER_VERTEX) geometry->getSecondaryColorArray()->accept(copyArrayToPoints); - if (_geometry->getFogCoordArray() && _geometry->getFogCoordBinding()==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getFogCoordArray() && _geometry->getFogCoordArray()->getBinding()==osg::Array::BIND_PER_VERTEX) geometry->getFogCoordArray()->accept(copyArrayToPoints); for(unsigned int vi=0;vi<_geometry->getNumVertexAttribArrays();++vi) { - if (_geometry->getVertexAttribArray(vi) && _geometry->getVertexAttribBinding(vi)==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getVertexAttribArray(vi) && _geometry->getVertexAttribArray(vi)->getBinding()==osg::Array::BIND_PER_VERTEX) geometry->getVertexAttribArray(vi)->accept(copyArrayToPoints); } @@ -1669,7 +1669,7 @@ void EdgeCollapse::copyBackToGeometry() _geometry->getTexCoordArray(ti)->accept(copyArrayToPoints); } - if (_geometry->getNormalArray() && _geometry->getNormalBinding()==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getNormalArray() && _geometry->getNormalArray()->getBinding()==osg::Array::BIND_PER_VERTEX) { _geometry->getNormalArray()->accept(copyArrayToPoints); @@ -1678,18 +1678,18 @@ void EdgeCollapse::copyBackToGeometry() _geometry->getNormalArray()->accept(nav); } - if (_geometry->getColorArray() && _geometry->getColorBinding()==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getColorArray() && _geometry->getColorArray()->getBinding()==osg::Array::BIND_PER_VERTEX) _geometry->getColorArray()->accept(copyArrayToPoints); - if (_geometry->getSecondaryColorArray() && _geometry->getSecondaryColorBinding()==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getSecondaryColorArray() && _geometry->getSecondaryColorArray()->getBinding()==osg::Array::BIND_PER_VERTEX) _geometry->getSecondaryColorArray()->accept(copyArrayToPoints); - if (_geometry->getFogCoordArray() && _geometry->getFogCoordBinding()==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getFogCoordArray() && _geometry->getFogCoordArray()->getBinding()==osg::Array::BIND_PER_VERTEX) _geometry->getFogCoordArray()->accept(copyArrayToPoints); for(unsigned int vi=0;vi<_geometry->getNumVertexAttribArrays();++vi) { - if (_geometry->getVertexAttribArray(vi) && _geometry->getVertexAttribBinding(vi)==osg::Geometry::BIND_PER_VERTEX) + if (_geometry->getVertexAttribArray(vi) && _geometry->getVertexAttribArray(vi)->getBinding()==osg::Array::BIND_PER_VERTEX) _geometry->getVertexAttribArray(vi)->accept(copyArrayToPoints); } diff --git a/src/osgUtil/SmoothingVisitor.cpp b/src/osgUtil/SmoothingVisitor.cpp index 6eefa307e..e65d9900d 100644 --- a/src/osgUtil/SmoothingVisitor.cpp +++ b/src/osgUtil/SmoothingVisitor.cpp @@ -297,23 +297,23 @@ struct FindSharpEdgesFunctor _problemVertexVector.resize(_vertices->size()); - addArray(geom->getVertexArray(), osg::Geometry::BIND_PER_VERTEX); - addArray(geom->getNormalArray(), geom->getNormalBinding()); - addArray(geom->getColorArray(), geom->getColorBinding()); - addArray(geom->getSecondaryColorArray(), geom->getSecondaryColorBinding()); - addArray(geom->getFogCoordArray(), geom->getFogCoordBinding()); + addArray(geom->getVertexArray()); + addArray(geom->getNormalArray()); + addArray(geom->getColorArray()); + addArray(geom->getSecondaryColorArray()); + addArray(geom->getFogCoordArray()); for(unsigned int i=0; igetNumTexCoordArrays(); ++i) { - addArray(geom->getTexCoordArray(i), osg::Geometry::BIND_PER_VERTEX); + addArray(geom->getTexCoordArray(i)); } return true; } - void addArray(osg::Array* array, osg::Geometry::AttributeBinding binding) + void addArray(osg::Array* array) { - if (array && binding==osg::Geometry::BIND_PER_VERTEX) + if (array && array->getBinding()==osg::Array::BIND_PER_VERTEX) { _arrays.push_back(array); } diff --git a/src/osgUtil/TangentSpaceGenerator.cpp b/src/osgUtil/TangentSpaceGenerator.cpp index e352db468..c82bffbfb 100644 --- a/src/osgUtil/TangentSpaceGenerator.cpp +++ b/src/osgUtil/TangentSpaceGenerator.cpp @@ -11,9 +11,9 @@ TangentSpaceGenerator::TangentSpaceGenerator() B_(new osg::Vec4Array), N_(new osg::Vec4Array) { - T_->setBinding(osg::Geometry::BIND_PER_VERTEX); T_->setNormalize(false); - B_->setBinding(osg::Geometry::BIND_PER_VERTEX); T_->setNormalize(false); - N_->setBinding(osg::Geometry::BIND_PER_VERTEX); T_->setNormalize(false); + T_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false); + B_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false); + N_->setBinding(osg::Array::BIND_PER_VERTEX); T_->setNormalize(false); } TangentSpaceGenerator::TangentSpaceGenerator(const TangentSpaceGenerator ©, const osg::CopyOp ©op) diff --git a/src/osgUtil/Tessellator.cpp b/src/osgUtil/Tessellator.cpp index a173ef55d..495057ace 100644 --- a/src/osgUtil/Tessellator.cpp +++ b/src/osgUtil/Tessellator.cpp @@ -433,7 +433,7 @@ void Tessellator::handleNewVertices(osg::Geometry& geom,VertexPtrToIndexMap &ver osg::Vec3Array* vertices = dynamic_cast(geom.getVertexArray()); osg::Vec3Array* normals = NULL; - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_VERTEX) + if (osg::getBinding(geom.getNormalArray())==osg::Array::BIND_PER_VERTEX) { normals = dynamic_cast(geom.getNormalArray()); } @@ -441,17 +441,17 @@ void Tessellator::handleNewVertices(osg::Geometry& geom,VertexPtrToIndexMap &ver typedef std::vector ArrayList; ArrayList arrays; - if (geom.getColorBinding()==osg::Geometry::BIND_PER_VERTEX) + if (osg::getBinding(geom.getColorArray())==osg::Array::BIND_PER_VERTEX) { arrays.push_back(geom.getColorArray()); } - if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_VERTEX) + if (osg::getBinding(geom.getSecondaryColorArray())==osg::Array::BIND_PER_VERTEX) { arrays.push_back(geom.getSecondaryColorArray()); } - if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_VERTEX) + if (osg::getBinding(geom.getFogCoordArray())==osg::Array::BIND_PER_VERTEX) { arrays.push_back(geom.getFogCoordArray()); } @@ -610,7 +610,7 @@ void Tessellator::reduceArray(osg::Array * cold, const unsigned int nnu) void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int originalIndex) { if (geom.containsDeprecatedData()) geom.fixDeprecatedData(); - + osg::Vec3Array* vertices = dynamic_cast(geom.getVertexArray()); VertexPtrToIndexMap vertexPtrToIndexMap; @@ -627,14 +627,14 @@ void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int original { osg::Vec3Array* normals = NULL; // GWM Sep 2002 - add normals for extra facets int iprim=0; - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) + if (osg::getBinding(geom.getNormalArray())==osg::Array::BIND_PER_PRIMITIVE_SET) { normals = dynamic_cast(geom.getNormalArray()); // GWM Sep 2002 } // GWM Dec 2003 - needed to add colours for extra facets osg::Vec4Array* cols4 = NULL; // GWM Dec 2003 colours are vec4 osg::Vec3Array* cols3 = NULL; // GWM Dec 2003 colours are vec3 - if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) + if (osg::getBinding(geom.getColorArray())==osg::Array::BIND_PER_PRIMITIVE_SET) { Array* colours = geom.getColorArray(); // GWM Dec 2003 - need to duplicate face colours switch (colours->getType()) { @@ -736,12 +736,12 @@ void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int original if (cols3) cols3->push_back(primCol3); // GWM Dec 2003 add flat shaded colour for new facet } if (prim->_mode==GL_TRIANGLES) { - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) { // need one per triangle? Not one per set. + if (osg::getBinding(geom.getNormalArray())==osg::Array::BIND_PER_PRIMITIVE_SET) { // need one per triangle? Not one per set. for (int ii=1; iipush_back(norm); // GWM Sep 2002 add flat shaded normal for new facet } } - if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) { // need one per triangle? Not one per set. + if (osg::getBinding(geom.getColorArray())==osg::Array::BIND_PER_PRIMITIVE_SET) { // need one per triangle? Not one per set. for (int ii=1; ii=cols3->size()) { if (cols3) cols3->push_back(primCol3); diff --git a/src/osgUtil/TriStripVisitor.cpp b/src/osgUtil/TriStripVisitor.cpp index 1181df76a..a3fe3e68f 100644 --- a/src/osgUtil/TriStripVisitor.cpp +++ b/src/osgUtil/TriStripVisitor.cpp @@ -58,25 +58,25 @@ struct VertexAttribComparitor { VertexAttribComparitor(osg::Geometry& geometry) { - add(geometry.getVertexArray(),osg::Geometry::BIND_PER_VERTEX); - add(geometry.getNormalArray(),geometry.getNormalBinding()); - add(geometry.getColorArray(),geometry.getColorBinding()); - add(geometry.getSecondaryColorArray(),geometry.getSecondaryColorBinding()); - add(geometry.getFogCoordArray(),geometry.getFogCoordBinding()); + add(geometry.getVertexArray()); + add(geometry.getNormalArray()); + add(geometry.getColorArray()); + add(geometry.getSecondaryColorArray()); + add(geometry.getFogCoordArray()); unsigned int i; for(i=0;igetBinding()==osg::Array::BIND_PER_VERTEX) { for(ArrayList::const_iterator itr=_arrayList.begin(); itr!=_arrayList.end(); @@ -216,13 +216,13 @@ void TriStripVisitor::stripify(Geometry& geom) { if (geom.containsDeprecatedData()) geom.fixDeprecatedData(); - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (osg::getBinding(geom.getNormalArray())==osg::Array::BIND_PER_PRIMITIVE_SET) return; - if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (osg::getBinding(geom.getColorArray())==osg::Array::BIND_PER_PRIMITIVE_SET) return; - if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (osg::getBinding(geom.getSecondaryColorArray())==osg::Array::BIND_PER_PRIMITIVE_SET) return; - if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (osg::getBinding(geom.getFogCoordArray())==osg::Array::BIND_PER_PRIMITIVE_SET) return; // no point tri stripping if we don't have enough vertices. if (!geom.getVertexArray() || geom.getVertexArray()->getNumElements()<3) return; @@ -553,7 +553,7 @@ void TriStripVisitor::stripify(Geometry& geom) 1.0f); } geom.setColorArray(colors); - geom.setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET); + geom.setColorBinding(osg::Array::BIND_PER_PRIMITIVE_SET); #endif } else