From df075ef9bb04a975cb9ad8ca69fbc9f803f20cc8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 19 Jun 2013 16:24:59 +0000 Subject: [PATCH] Cleaned up usage of BIND_PER_PRIMITIVE where possible. --- examples/osgdelaunay/osgdelaunay.cpp | 5 +++ .../osgocclusionquery/osgocclusionquery.cpp | 4 +++ include/osg/Geometry | 2 ++ src/osg/Geometry.cpp | 12 +++---- .../Inventor/ConvertFromInventor.cpp | 5 +++ src/osgPlugins/ive/DataInputStream.cpp | 4 +-- src/osgPlugins/ive/DataOutputStream.cpp | 10 +++--- src/osgPlugins/normals/Normals.cpp | 28 +++++---------- src/osgPlugins/obj/OBJWriterNodeVisitor.cpp | 8 ++--- src/osgPlugins/stl/ReaderWriterSTL.cpp | 36 +++++++++++++++---- src/osgPlugins/vrml/ConvertToVRML.cpp | 14 ++------ src/osgSim/ScalarBar.cpp | 5 +++ src/osgUtil/MeshOptimizers.cpp | 16 ++++----- src/osgUtil/Tessellator.cpp | 27 +++++--------- src/osgUtil/TriStripVisitor.cpp | 13 +++---- src/osgWrappers/serializers/osg/Geometry.cpp | 4 +-- 16 files changed, 97 insertions(+), 96 deletions(-) diff --git a/examples/osgdelaunay/osgdelaunay.cpp b/examples/osgdelaunay/osgdelaunay.cpp index ec02c4fa4..3034c4f9a 100644 --- a/examples/osgdelaunay/osgdelaunay.cpp +++ b/examples/osgdelaunay/osgdelaunay.cpp @@ -22,6 +22,11 @@ * exist in the triangulation. */ +#include +#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS +#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1 +#endif + #include #include #include diff --git a/examples/osgocclusionquery/osgocclusionquery.cpp b/examples/osgocclusionquery/osgocclusionquery.cpp index 09403f9fc..8f77c3f56 100644 --- a/examples/osgocclusionquery/osgocclusionquery.cpp +++ b/examples/osgocclusionquery/osgocclusionquery.cpp @@ -33,6 +33,10 @@ // example uses a NodeVisitor to try to find worthwhile locations // for OcclusionQueryNodes in your the scene graph. +#include +#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS +#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1 +#endif #include diff --git a/include/osg/Geometry b/include/osg/Geometry index 3ee7d82e1..09e4e3185 100644 --- a/include/osg/Geometry +++ b/include/osg/Geometry @@ -235,7 +235,9 @@ class OSG_EXPORT Geometry : public Drawable BIND_OFF=0, BIND_OVERALL=1, BIND_PER_PRIMITIVE_SET=2, +#if defined(OSG_USE_DEPRECATED_GEOMETRY_METHODS) BIND_PER_PRIMITIVE=3, /// no longer supported +#endif BIND_PER_VERTEX=4 }; diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index f3f30fb30..c45a46a0f 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -153,7 +153,7 @@ void Geometry::setFogCoordArray(Array* array) } \ if (array->getBinding() == static_cast(ab)) return; \ array->setBinding(static_cast(ab));\ - if (ab==BIND_PER_PRIMITIVE) _containsDeprecatedData = true; + if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true; #define GET_BINDING(array) (array!=0 ? static_cast(array->getBinding()) : BIND_OFF) @@ -1352,19 +1352,19 @@ void Geometry::fixDeprecatedData() osg::IndexArray* indices = getIndexArray(_vertexArray.get()); if (indices) setVertexArray(expandIndexArray(_vertexArray.get(), indices)); - if (getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true; + if (getNormalBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true; indices = getIndexArray(_normalArray.get()); if (indices) setNormalArray(expandIndexArray(getNormalArray(), indices)); - if (getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true; + if (getColorBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true; indices = getIndexArray(_colorArray.get()); if (indices) setColorArray(expandIndexArray(getColorArray(), indices)); - if (getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true; + if (getSecondaryColorBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true; indices = getIndexArray(_secondaryColorArray.get()); if (indices) setSecondaryColorArray(expandIndexArray(getSecondaryColorArray(), indices)); - if (getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true; + if (getFogCoordBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true; indices = getIndexArray(_fogCoordArray.get()); if (indices) setFogCoordArray(expandIndexArray(getFogCoordArray(), indices)); @@ -1376,7 +1376,7 @@ void Geometry::fixDeprecatedData() for(unsigned int vi=0;vi<_vertexAttribList.size();++vi) { - if (getVertexAttribBinding(vi)==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true; + if (getVertexAttribBinding(vi)==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true; indices = getIndexArray(_vertexAttribList[vi].get()); if (indices) setVertexAttribArray(vi, expandIndexArray(getVertexAttribArray(vi), indices)); } diff --git a/src/osgPlugins/Inventor/ConvertFromInventor.cpp b/src/osgPlugins/Inventor/ConvertFromInventor.cpp index ec7ca7e53..e1dcbc49e 100644 --- a/src/osgPlugins/Inventor/ConvertFromInventor.cpp +++ b/src/osgPlugins/Inventor/ConvertFromInventor.cpp @@ -1,3 +1,8 @@ +#include +#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS +#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1 +#endif + #include "ConvertFromInventor.h" #include "PendulumCallback.h" diff --git a/src/osgPlugins/ive/DataInputStream.cpp b/src/osgPlugins/ive/DataInputStream.cpp index 3c038d792..4f30c3472 100644 --- a/src/osgPlugins/ive/DataInputStream.cpp +++ b/src/osgPlugins/ive/DataInputStream.cpp @@ -587,12 +587,12 @@ osg::Quat DataInputStream::readQuat(){ osg::Geometry::AttributeBinding DataInputStream::readBinding(){ char c = readChar(); - if (_verboseOutput) std::cout<<"read/writeBinding() ["<<(int)c<<"]"<(3): writeChar((char) 2); break; /*osg::Geometry::BIND_PER_PRIMITIVE*/ + case osg::Geometry::BIND_PER_PRIMITIVE_SET: writeChar((char) 3); break; + case osg::Geometry::BIND_PER_VERTEX: writeChar((char) 4); break; default: throwException("Unknown binding in DataOutputStream::writeBinding()"); } diff --git a/src/osgPlugins/normals/Normals.cpp b/src/osgPlugins/normals/Normals.cpp index ba4925f9b..252fec7e9 100644 --- a/src/osgPlugins/normals/Normals.cpp +++ b/src/osgPlugins/normals/Normals.cpp @@ -59,6 +59,8 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) Geometry *geom = dynamic_cast(geode.getDrawable(i)); if( geom ) { + if (geom->containsDeprecatedData()) geom->fixDeprecatedData(); + Vec3Array *coords = dynamic_cast(geom->getVertexArray()); if( coords == 0L ) continue; @@ -85,7 +87,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) _local_coords->push_back( v ); _local_coords->push_back( (v + n)); } - else // BIND_PER_PRIMITIVE_SET, BIND_PER_PRIMITIVE, BIND_PER_VERTEX + else // BIND_PER_PRIMITIVE_SET, BIND_PER_VERTEX { Geometry::PrimitiveSetList& primitiveSets = geom->getPrimitiveSetList(); Geometry::PrimitiveSetList::iterator itr; @@ -121,10 +123,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) { _processPrimitive( 3, coord_index, normals_index, binding ); coord_index += 3; - if( binding == Geometry::BIND_PER_PRIMITIVE ) - normals_index++; - else - normals_index+=3; + normals_index+=3; } break; } @@ -150,10 +149,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) { _processPrimitive( 4, coord_index, normals_index, binding ); coord_index += 4; - if( binding == Geometry::BIND_PER_PRIMITIVE ) - normals_index++; - else - normals_index+=4; + normals_index +=4; } break; } @@ -169,11 +165,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) //OSG_WARN << "j=" << j << " num_prim=" << num_prim << std::endl; _processPrimitive(num_prim, coord_index, normals_index, binding); coord_index += num_prim; - if (binding == Geometry::BIND_PER_PRIMITIVE) { - ++normals_index; - } else { - normals_index += num_prim; - } + normals_index += num_prim; } } break; @@ -198,13 +190,9 @@ void Normals::MakeNormalsVisitor::_processPrimitive( unsigned int nv, { Vec3 v(0,0,0); Vec3 n(0,0,0); - if( _mode == SurfaceNormals || binding == Geometry::BIND_PER_PRIMITIVE ) + if( _mode == SurfaceNormals ) { - if( binding == Geometry::BIND_PER_PRIMITIVE ) - { - n = *(normals++); - } - else if( binding == Geometry::BIND_PER_VERTEX ) + if( binding == Geometry::BIND_PER_VERTEX ) { for( unsigned int i = 0; i < nv; i++ ) n += *(normals++); diff --git a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp index c253dee27..a5a412ebe 100644 --- a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp +++ b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp @@ -136,8 +136,6 @@ class ObjPrimitiveIndexWriter : public osg::PrimitiveIndexFunctor { write(i2); write(i3); _fout << std::endl; - // not sure if this is correct? - if(_geo->getNormalBinding() && _geo->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE) ++_normalIndex; } // operator for lines @@ -147,8 +145,6 @@ class ObjPrimitiveIndexWriter : public osg::PrimitiveIndexFunctor { write(i1); write(i2); _fout << std::endl; - // not sure if this is correct? - if(_geo->getNormalBinding() && _geo->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE) ++_normalIndex; } // operator for points @@ -157,8 +153,6 @@ class ObjPrimitiveIndexWriter : public osg::PrimitiveIndexFunctor { _fout << "p "; write(i1); _fout << std::endl; - // not sure if this is correct? - if(_geo->getNormalBinding() && _geo->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE) ++_normalIndex; } virtual void begin(GLenum mode) @@ -524,6 +518,8 @@ void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) { _fout << std::endl; _fout << "o " << getUniqueName( geo->getName().empty() ? geo->className() : geo->getName() ) << std::endl; + if (geo->containsDeprecatedData()) geo->fixDeprecatedData(); + processStateSet(_currentStateSet.get()); processArray("v", geo->getVertexArray(), m, false); diff --git a/src/osgPlugins/stl/ReaderWriterSTL.cpp b/src/osgPlugins/stl/ReaderWriterSTL.cpp index 82d413915..a968f65a6 100644 --- a/src/osgPlugins/stl/ReaderWriterSTL.cpp +++ b/src/osgPlugins/stl/ReaderWriterSTL.cpp @@ -97,17 +97,41 @@ private: osg::ref_ptr geom = new osg::Geometry; geom->setVertexArray(_vertex.get()); - geom->setNormalArray(_normal.get()); - geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE); - geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, _numFacets * 3)); - + + if (_normal.valid()) + { + // need to convert per triangle normals to per vertex + osg::ref_ptr perVertexNormals = new osg::Vec3Array; + perVertexNormals->reserveArray(_normal->size() * 3); + for(osg::Vec3Array::iterator itr = _normal->begin(); + itr != _normal->end(); + ++itr) + { + perVertexNormals->push_back(*itr); + } + + geom->setNormalArray(perVertexNormals.get()); + geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); + } + if (_color.valid()) { + // need to convert per triangle colours to per vertex OSG_INFO << "STL file with color" << std::endl; - geom->setColorArray(_color.get()); - geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE); + osg::ref_ptr perVertexColours = new osg::Vec4Array; + perVertexColours->reserveArray(_color->size() * 3); + for(osg::Vec4Array::iterator itr = _color->begin(); + itr != _color->end(); + ++itr) + { + perVertexColours->push_back(*itr); + } + geom->setColorArray(perVertexColours.get()); + geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX); } + geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, _numFacets * 3)); + osgUtil::TriStripVisitor tristripper; tristripper.stripify(*geom); diff --git a/src/osgPlugins/vrml/ConvertToVRML.cpp b/src/osgPlugins/vrml/ConvertToVRML.cpp index ef309aacd..27129dd4d 100644 --- a/src/osgPlugins/vrml/ConvertToVRML.cpp +++ b/src/osgPlugins/vrml/ConvertToVRML.cpp @@ -268,6 +268,8 @@ void ToVRML::apply(osg::Drawable* drawable) { ///////////////////////////////////////////////////////////////////////// void ToVRML::apply(osg::Geometry* geom) { + if (geom->containsDeprecatedData()) geom->fixDeprecatedData(); + // are all primitives faces or line ? GLenum mode; osg::PrimitiveSet::Type type; @@ -1128,12 +1130,6 @@ void ToVRML::writeNormal(osg::Geometry* geom, std::vector& primitiveSetFace _fout << indent() << n[0] << " " << n[1] << " " << n[2] << ",\n"; } - } else if (geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE) { - for (unsigned int j = 0; j < (*nArray).size(); j++) { - n = (*nArray)[j]; - _fout << indent() << n[0] << " " << n[1] << " " << n[2] << ",\n"; - } - } else if (geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) { for (unsigned int j = 0; j < (*nArray).size(); j++) { n = (*nArray)[j]; @@ -1282,12 +1278,6 @@ void ToVRML::writeColor(osg::Geometry* geom, std::vector& primitiveSetFaces _fout << indent() << c[0] << " " << c[1] << " " << c[2] << ",\n"; } - } else if (geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE) { - for (unsigned int j = 0; j < (*cArray).size(); j++) { - c = (*cArray)[j]; - _fout << indent() << c[0] << " " << c[1] << " " << c[2] << ",\n"; - } - } else if (geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) { for (unsigned int j = 0; j < (*cArray).size(); j++) { c = (*cArray)[j]; diff --git a/src/osgSim/ScalarBar.cpp b/src/osgSim/ScalarBar.cpp index 0f0fba889..a3c121e75 100644 --- a/src/osgSim/ScalarBar.cpp +++ b/src/osgSim/ScalarBar.cpp @@ -1,3 +1,8 @@ +#include +#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS +#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1 +#endif + #include #include #include diff --git a/src/osgUtil/MeshOptimizers.cpp b/src/osgUtil/MeshOptimizers.cpp index 4d978515f..3a246e5f1 100644 --- a/src/osgUtil/MeshOptimizers.cpp +++ b/src/osgUtil/MeshOptimizers.cpp @@ -85,8 +85,6 @@ struct GeometryArrayGatherer if (array) _arrayList.push_back(array); } - else if (binding == osg::Geometry::BIND_PER_PRIMITIVE) - _useDrawElements = false; } void accept(osg::ArrayVisitor& av) @@ -231,17 +229,15 @@ typedef osg::TriangleIndexFunctor MyTriangleIndexFunctor; void IndexMeshVisitor::makeMesh(Geometry& geom) { - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE || - geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (geom.containsDeprecatedData()) geom.fixDeprecatedData(); - if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE || - geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; - if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE || - geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; - if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE || - geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + + if (geom.getFogCoordBinding()==osg::Geometry::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/Tessellator.cpp b/src/osgUtil/Tessellator.cpp index d8cbaccb9..a173ef55d 100644 --- a/src/osgUtil/Tessellator.cpp +++ b/src/osgUtil/Tessellator.cpp @@ -609,6 +609,8 @@ 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; @@ -625,16 +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 || - geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) + if (geom.getNormalBinding()==osg::Geometry::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 || - geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) + if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) { Array* colours = geom.getColorArray(); // GWM Dec 2003 - need to duplicate face colours switch (colours->getType()) { @@ -708,10 +708,7 @@ void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int original if (primItr==_primList.begin()) { // first primitive so collect primitive normal & colour. if (normals) { - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE) - norm=(*normals)[originalIndex + _extraPrimitives]; - else - norm=(*normals)[iprim]; // GWM Sep 2002 the flat shaded normal + norm=(*normals)[iprim]; // GWM Sep 2002 the flat shaded normal } if (cols4) { primCol4=(*cols4)[iprim]; // GWM Dec 2003 the flat shaded rgba colour @@ -730,13 +727,7 @@ void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int original { // later primitives use same colour if (normals) { - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE) - { - _extraPrimitives++; - normals->insert(normals->begin() + originalIndex + _extraPrimitives, norm); - } - else - normals->push_back(norm); // GWM Sep 2002 add flat shaded normal for new facet + normals->push_back(norm); // GWM Sep 2002 add flat shaded normal for new facet } if (cols4 && _index>=cols4->size()) { cols4->push_back(primCol4); // GWM Dec 2003 add flat shaded colour for new facet @@ -745,14 +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 || - geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE) { // need one per triangle? Not one per set. + if (geom.getNormalBinding()==osg::Geometry::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 || - geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE) { // need one per triangle? Not one per set. + if (geom.getColorBinding()==osg::Geometry::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 555ebb5e1..1181df76a 100644 --- a/src/osgUtil/TriStripVisitor.cpp +++ b/src/osgUtil/TriStripVisitor.cpp @@ -214,18 +214,15 @@ typedef osg::TriangleIndexFunctor MyTriangleIndexFunctor; void TriStripVisitor::stripify(Geometry& geom) { + if (geom.containsDeprecatedData()) geom.fixDeprecatedData(); - if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE || - geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; - if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE || - geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; - if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE || - geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; - if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE || - geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; + if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return; // no point tri stripping if we don't have enough vertices. if (!geom.getVertexArray() || geom.getVertexArray()->getNumElements()<3) return; diff --git a/src/osgWrappers/serializers/osg/Geometry.cpp b/src/osgWrappers/serializers/osg/Geometry.cpp index 6d3f45c24..093b3c8dd 100644 --- a/src/osgWrappers/serializers/osg/Geometry.cpp +++ b/src/osgWrappers/serializers/osg/Geometry.cpp @@ -6,8 +6,8 @@ BEGIN_USER_TABLE( AttributeBinding, osg::Geometry ); ADD_USER_VALUE( BIND_OFF ); ADD_USER_VALUE( BIND_OVERALL ); - ADD_USER_VALUE( BIND_PER_PRIMITIVE_SET ); - ADD_USER_VALUE( BIND_PER_PRIMITIVE ); + ADD_USER_VALUE( BIND_PER_PRIMITIVE_SET ); + lookup->add("BIND_PER_PRIMITIVE",3); //ADD_USER_VALUE( BIND_PER_PRIMITIVE ); ADD_USER_VALUE( BIND_PER_VERTEX ); END_USER_TABLE()