diff --git a/include/osg/Array b/include/osg/Array index 58679609b..55fab8342 100644 --- a/include/osg/Array +++ b/include/osg/Array @@ -140,10 +140,10 @@ class OSG_EXPORT Array : public BufferData /** Specify how this array should be passed to OpenGL.*/ - void setBinding(int binding) { _binding = binding; } + void setBinding(Binding binding) { _binding = binding; } /** Get how this array should be passed to OpenGL.*/ - int getBinding() const { return _binding; } + Binding getBinding() const { return _binding; } /** Specify whether the array data should be normalized by OpenGL.*/ @@ -179,13 +179,16 @@ class OSG_EXPORT Array : public BufferData Type _arrayType; GLint _dataSize; GLenum _dataType; - int _binding; + Binding _binding; bool _normalize; bool _preserveDataType; }; /** convinience function for getting the binding of array via a ptr that may be null.*/ -inline int getBinding(const osg::Array* array) { return array ? array->getBinding() : osg::Array::BIND_OFF; } +inline osg::Array::Binding getBinding(const osg::Array* array) { return array ? array->getBinding() : osg::Array::BIND_OFF; } + +/** convinience function for getting the binding of array via a ptr that may be null.*/ +inline bool getNormalize(const osg::Array* array) { return array ? array->getNormalize() : false; } template diff --git a/include/osg/Geometry b/include/osg/Geometry index 2505b1a45..68246d92e 100644 --- a/include/osg/Geometry +++ b/include/osg/Geometry @@ -21,6 +21,9 @@ #include #include +// leave defined for OpenSceneGraph-3.2 release, post 3.2 associated methods will be only be available in deprecated_osg::Geometry +#define OSG_DEPRECATED_GEOMETRY_BINDING 1 + namespace osg { class OSG_EXPORT Geometry : public Drawable @@ -229,7 +232,8 @@ class OSG_EXPORT Geometry : public Drawable /** fallback for deprecated functionality. Removes any array indices and BIND_PER_PRIMITIVE arrays.*/ void fixDeprecatedData(); - /** Same values as Array::Binding.*/ +#if defined(OSG_DEPRECATED_GEOMETRY_BINDING) + /** deprecated, Same values as Array::Binding.*/ enum AttributeBinding { BIND_OFF=0, @@ -238,29 +242,26 @@ class OSG_EXPORT Geometry : public Drawable BIND_PER_VERTEX=4 }; - /** deprecated, use array->setBinding(..). */ + /** deprecated, use array->set*Binding(..). */ void setNormalBinding(AttributeBinding ab); - AttributeBinding getNormalBinding() const; - - /** deprecated, use array->setBinding(..). */ void setColorBinding(AttributeBinding ab); - AttributeBinding getColorBinding() const; - - /** deprecated, use array->setBinding(..). */ void setSecondaryColorBinding(AttributeBinding ab); - AttributeBinding getSecondaryColorBinding() const; - - /** deprecated, use array->setBinding(..). */ void setFogCoordBinding(AttributeBinding ab); - AttributeBinding getFogCoordBinding() const; - - /** deprecated, use array->setBinding(..). */ void setVertexAttribBinding(unsigned int index,AttributeBinding ab); + + /** deprecated, use array->get*Binding(..). */ + AttributeBinding getNormalBinding() const; + AttributeBinding getColorBinding() const; + AttributeBinding getSecondaryColorBinding() const; + AttributeBinding getFogCoordBinding() const; AttributeBinding getVertexAttribBinding(unsigned int index) const; - /** deprecated, use array->setNormalize(..). */ + /** deprecated, use array->set*Normalize(..). */ void setVertexAttribNormalize(unsigned int index,GLboolean norm); + + /** deprecated, use array->get*Normalize(..). */ GLboolean getVertexAttribNormalize(unsigned int index) const; +#endif }; /** Convenience function to be used for creating quad geometry with texture coords. @@ -284,7 +285,9 @@ inline Geometry* createTexturedQuadGeometry(const Vec3& corner,const Vec3& width namespace deprecated_osg { /** Geometry class contaning deprecated features. - * Please note this class is \b not "exported" (OSG_EXPORT) to avoid issues with MSVC, when compiling plugins. + * Users should only use deprecatged_osg::Geometry when absolutely neccessary for keeping things compiling, + * it is recommended that you should migrate your code to work just with osg::Geometry as existing + * deprecated_osg::Geometry will be removed in future release. */ class OSG_EXPORT Geometry : public osg::Geometry { diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index a0fc17084..432293a48 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -154,21 +154,6 @@ void Geometry::setFogCoordArray(Array* array, osg::Array::Binding binding) if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array); } -#define SET_BINDING(array, ab)\ - if (!array) \ - { \ - if (ab==BIND_OFF) return; \ - OSG_NOTICE<<"Warning, can't assign attribute binding as no has been array assigned to set binding for."<getBinding() == static_cast(ab)) return; \ - array->setBinding(static_cast(ab));\ - if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true; - - -#define GET_BINDING(array) (array!=0 ? static_cast(array->getBinding()) : BIND_OFF) - - void Geometry::setTexCoordArray(unsigned int index,Array* array, osg::Array::Binding binding) @@ -736,7 +721,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const } // dispatch any attributes that are bound overall - arrayDispatchers.dispatch(BIND_OVERALL,0); + arrayDispatchers.dispatch(osg::Array::BIND_OVERALL,0); state.lazyDisablingOfVertexAttributes(); @@ -779,7 +764,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const state.applyDisablingOfVertexAttributes(); - bool bindPerPrimitiveSetActive = arrayDispatchers.active(BIND_PER_PRIMITIVE_SET); + bool bindPerPrimitiveSetActive = arrayDispatchers.active(osg::Array::BIND_PER_PRIMITIVE_SET); if (checkForGLErrors) state.checkGLErrors("Geometry::drawImplementation() after vertex arrays setup."); @@ -790,7 +775,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const for(unsigned int primitiveSetNum=0; primitiveSetNum!=_primitives.size(); ++primitiveSetNum) { // dispatch any attributes that are bound per primitive - if (bindPerPrimitiveSetActive) arrayDispatchers.dispatch(BIND_PER_PRIMITIVE_SET, primitiveSetNum); + if (bindPerPrimitiveSetActive) arrayDispatchers.dispatch(osg::Array::BIND_PER_PRIMITIVE_SET, primitiveSetNum); const PrimitiveSet* primitiveset = _primitives[primitiveSetNum].get(); @@ -1102,52 +1087,42 @@ Geometry* osg::createTexturedQuadGeometry(const Vec3& corner,const Vec3& widthVe // // Deprecated methods. // +#define SET_BINDING(array, ab)\ + if (!array) \ + { \ + if (ab==BIND_OFF) return; \ + OSG_NOTICE<<"Warning, can't assign attribute binding as no has been array assigned to set binding for."<getBinding() == static_cast(ab)) return; \ + array->setBinding(static_cast(ab));\ + if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true; \ + dirtyDisplayList(); + + +#define GET_BINDING(array) (array!=0 ? static_cast(array->getBinding()) : BIND_OFF) + +#if defined(OSG_DEPRECATED_GEOMETRY_BINDING) void Geometry::setNormalBinding(AttributeBinding ab) { SET_BINDING(_normalArray.get(), ab) - - dirtyDisplayList(); -} - -Geometry::AttributeBinding Geometry::getNormalBinding() const -{ - return GET_BINDING(_normalArray.get()); } void Geometry::setColorBinding(AttributeBinding ab) { SET_BINDING(_colorArray.get(), ab) - - dirtyDisplayList(); } -Geometry::AttributeBinding Geometry::getColorBinding() const -{ - return GET_BINDING(_colorArray.get()); -} void Geometry::setSecondaryColorBinding(AttributeBinding ab) { SET_BINDING(_secondaryColorArray.get(), ab) - - dirtyDisplayList(); } -Geometry::AttributeBinding Geometry::getSecondaryColorBinding() const -{ - return GET_BINDING(_secondaryColorArray.get()); -} void Geometry::setFogCoordBinding(AttributeBinding ab) { SET_BINDING(_fogCoordArray.get(), ab) - - dirtyDisplayList(); -} - -Geometry::AttributeBinding Geometry::getFogCoordBinding() const -{ - return GET_BINDING(_fogCoordArray.get()); } void Geometry::setVertexAttribBinding(unsigned int index,AttributeBinding ab) @@ -1166,12 +1141,6 @@ void Geometry::setVertexAttribBinding(unsigned int index,AttributeBinding ab) } } -Geometry::AttributeBinding Geometry::getVertexAttribBinding(unsigned int index) const -{ - if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return static_cast(_vertexAttribList[index]->getBinding()); - else return BIND_OFF; -} - void Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm) { if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) @@ -1182,12 +1151,38 @@ void Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm) } } +Geometry::AttributeBinding Geometry::getNormalBinding() const +{ + return GET_BINDING(_normalArray.get()); +} + +Geometry::AttributeBinding Geometry::getColorBinding() const +{ + return GET_BINDING(_colorArray.get()); +} +Geometry::AttributeBinding Geometry::getSecondaryColorBinding() const +{ + return GET_BINDING(_secondaryColorArray.get()); +} + +Geometry::AttributeBinding Geometry::getFogCoordBinding() const +{ + return GET_BINDING(_fogCoordArray.get()); +} + +Geometry::AttributeBinding Geometry::getVertexAttribBinding(unsigned int index) const +{ + if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return static_cast(_vertexAttribList[index]->getBinding()); + else return BIND_OFF; +} + + GLboolean Geometry::getVertexAttribNormalize(unsigned int index) const { if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return _vertexAttribList[index]->getNormalize(); else return GL_FALSE; } - +#endif //////////////////////////////////////////////////////////////////////////////////////////////////////// // // Helper methods @@ -1363,25 +1358,24 @@ void Geometry::fixDeprecatedData() bool containsBindPerPrimitive = false; - OSG_NOTICE<<"Geometry::fixDeprecatedData()"<(ab)); } -deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getNormalBinding() const { return static_cast(osg::Geometry::getNormalBinding()); } +void deprecated_osg::Geometry::setNormalBinding(AttributeBinding ab) { SET_BINDING(_normalArray.get(), ab) } +deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getNormalBinding() const { return static_cast(osg::getBinding(getNormalArray())); } -void deprecated_osg::Geometry::setColorBinding(deprecated_osg::Geometry::AttributeBinding ab) { osg::Geometry::setColorBinding(static_cast(ab)); } -deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getColorBinding() const { return static_cast(osg::Geometry::getColorBinding()); } +void deprecated_osg::Geometry::setColorBinding(deprecated_osg::Geometry::AttributeBinding ab) { SET_BINDING(_colorArray.get(), ab) } +deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getColorBinding() const { return static_cast(osg::getBinding(getColorArray())); } -void deprecated_osg::Geometry::setSecondaryColorBinding(deprecated_osg::Geometry::AttributeBinding ab) { osg::Geometry::setSecondaryColorBinding(static_cast(ab)); } -deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getSecondaryColorBinding() const { return static_cast(osg::Geometry::getSecondaryColorBinding()); } +void deprecated_osg::Geometry::setSecondaryColorBinding(deprecated_osg::Geometry::AttributeBinding ab) { SET_BINDING(_secondaryColorArray.get(), ab) } +deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getSecondaryColorBinding() const { return static_cast(osg::getBinding(getSecondaryColorArray())); } -void deprecated_osg::Geometry::setFogCoordBinding(deprecated_osg::Geometry::AttributeBinding ab) { osg::Geometry::setFogCoordBinding(static_cast(ab)); } -deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getFogCoordBinding() const { return static_cast(osg::Geometry::getFogCoordBinding()); } +void deprecated_osg::Geometry::setFogCoordBinding(deprecated_osg::Geometry::AttributeBinding ab) { SET_BINDING(_fogCoordArray.get(), ab) } +deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getFogCoordBinding() const { return static_cast(osg::getBinding(getFogCoordArray())); } -void deprecated_osg::Geometry::setVertexAttribBinding(unsigned int index,deprecated_osg::Geometry::AttributeBinding ab) { osg::Geometry::setVertexAttribBinding(index, static_cast(ab)); } -deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getVertexAttribBinding(unsigned int index) const { return static_cast(osg::Geometry::getVertexAttribBinding(index)); } -void deprecated_osg::Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm) { osg::Geometry::setVertexAttribNormalize(index, norm); } -GLboolean deprecated_osg::Geometry::getVertexAttribNormalize(unsigned int index) const { return osg::Geometry::getVertexAttribNormalize(index); } +void deprecated_osg::Geometry::setVertexAttribBinding(unsigned int index,AttributeBinding ab) +{ + if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) + { + if (_vertexAttribList[index]->getBinding()==static_cast(ab)) return; + + _vertexAttribList[index]->setBinding(static_cast(ab)); + + dirtyDisplayList(); + } + else + { + OSG_NOTICE<<"Warning, can't assign attribute binding as no has been array assigned to set binding for."<(osg::getBinding(getVertexAttribArray(index))); } + +void deprecated_osg::Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm) +{ + if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) + { + _vertexAttribList[index]->setNormalize(norm); + + dirtyDisplayList(); + } +} + +GLboolean deprecated_osg::Geometry::getVertexAttribNormalize(unsigned int index) const { return osg::getNormalize(getVertexAttribArray(index)); } void deprecated_osg::Geometry::setVertexIndices(osg::IndexArray* array) { diff --git a/src/osgPlugins/OpenFlight/GeometryRecords.cpp b/src/osgPlugins/OpenFlight/GeometryRecords.cpp index 460fdbbbf..315e0aa98 100644 --- a/src/osgPlugins/OpenFlight/GeometryRecords.cpp +++ b/src/osgPlugins/OpenFlight/GeometryRecords.cpp @@ -90,7 +90,7 @@ void addDrawableAndReverseWindingOrder( osg::Geode* geode ) reverseWindingOrder( vertices, drawarray->getMode(), first, last ); } - if( geom->getNormalBinding( ) == osg::Geometry::BIND_PER_VERTEX ) + if( osg::getBinding(geom->getNormalArray()) == osg::Array::BIND_PER_VERTEX ) { osg::Vec3Array* normals = dynamic_cast(geom->getNormalArray()); if( normals ) @@ -104,7 +104,7 @@ void addDrawableAndReverseWindingOrder( osg::Geode* geode ) } } - if( geom->getColorBinding( ) == osg::Geometry::BIND_PER_VERTEX ) + if( osg::getBinding(geom->getColorArray()) == osg::Array::BIND_PER_VERTEX ) { osg::Vec4Array* colors = dynamic_cast(geom->getColorArray()); if( colors ) diff --git a/src/osgPlugins/OpenFlight/VertexPaletteManager.cpp b/src/osgPlugins/OpenFlight/VertexPaletteManager.cpp index 74f3ee666..7005a3e61 100644 --- a/src/osgPlugins/OpenFlight/VertexPaletteManager.cpp +++ b/src/osgPlugins/OpenFlight/VertexPaletteManager.cpp @@ -79,8 +79,8 @@ VertexPaletteManager::add( const osg::Geometry& geom ) if (t && !t2) return; - const bool cpv =( geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX ); - const bool npv =( geom.getNormalBinding() == osg::Geometry::BIND_PER_VERTEX ); + const bool cpv =( osg::getBinding(geom.getColorArray()) == osg::Array::BIND_PER_VERTEX ); + const bool npv =( osg::getBinding(geom.getNormalArray()) == osg::Array::BIND_PER_VERTEX ); add( v, v3.get(), c4.get(), n3.get(), t2.get(), cpv, npv ); } void diff --git a/src/osgPlugins/OpenFlight/expGeometryRecords.cpp b/src/osgPlugins/OpenFlight/expGeometryRecords.cpp index de6ef656e..31f0595e0 100644 --- a/src/osgPlugins/OpenFlight/expGeometryRecords.cpp +++ b/src/osgPlugins/OpenFlight/expGeometryRecords.cpp @@ -56,7 +56,7 @@ FltExportVisitor::isLit( const osg::Geometry& geom ) const if ( ss->getMode( GL_LIGHTING ) & osg::StateAttribute::ON ) return true; else - return false; //( geom.getNormalBinding() == osg::Geometry::BIND_PER_VERTEX ); + return false; //( geom.getNormalBinding() == osg::Array::BIND_PER_VERTEX ); } bool @@ -151,7 +151,7 @@ FltExportVisitor::writeFace( const osg::Geode& geode, const osg::Geometry& geom, int8 lightMode; osg::Vec4 packedColorRaw( 1., 1., 1., 1. ); uint16 transparency( 0 ); - if (geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX) + if (osg::getBinding(geom.getColorArray()) == osg::Array::BIND_PER_VERTEX) { if( isLit( geom ) ) lightMode = VERTEX_COLOR_LIGHTING; @@ -357,7 +357,7 @@ FltExportVisitor::writeMesh( const osg::Geode& geode, const osg::Geometry& geom int8 lightMode; osg::Vec4 packedColorRaw( 1., 1., 1., 1. ); uint16 transparency( 0 ); - if (geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX) + if (osg::getBinding(geom.getColorArray()) == osg::Array::BIND_PER_VERTEX) { if (isLit( geom )) lightMode = VERTEX_COLOR_LIGHTING; @@ -608,12 +608,12 @@ FltExportVisitor::writeLocalVertexPool( const osg::Geometry& geom ) uint32 attr( HAS_POSITION ); unsigned int vertSize( sizeof( float64 ) * 3 ); - if ( ( c4 != NULL ) && ( geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX) ) + if ( ( c4 != NULL ) && ( osg::getBinding(geom.getColorArray()) == osg::Array::BIND_PER_VERTEX) ) { attr |= HAS_RGBA_COLOR; vertSize += sizeof( unsigned int ); } - if ( ( n3 != NULL ) && ( geom.getNormalBinding() == osg::Geometry::BIND_PER_VERTEX) ) + if ( ( n3 != NULL ) && ( osg::getBinding(geom.getNormalArray()) == osg::Array::BIND_PER_VERTEX) ) { attr |= HAS_NORMAL; vertSize += ( sizeof( float32 ) * 3 ); diff --git a/src/osgPlugins/dae/daeRGeometry.cpp b/src/osgPlugins/dae/daeRGeometry.cpp index 2ba5ef59d..62198a8b2 100644 --- a/src/osgPlugins/dae/daeRGeometry.cpp +++ b/src/osgPlugins/dae/daeRGeometry.cpp @@ -801,7 +801,7 @@ template ArrayType* createGeometryArray(domSourceReader & sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap, int texcoordNum=-1) { const ArrayType * source = sourceReader.getArray(); if (!source) return 0; - ArrayType * pArray = new ArrayType(osg::Geometry::BIND_PER_VERTEX); + ArrayType * pArray = new ArrayType(osg::Array::BIND_PER_VERTEX); for (VertexIndicesIndexMap::const_iterator it = vertexIndicesIndexMap.begin(), end = vertexIndicesIndexMap.end(); it != end; ++it) { int index = texcoordNum>=0 ? it->first.texcoord_indices[texcoordNum] : it->first.get(); if (index>=0 && static_cast(index)size()) pArray->push_back(source->at(index)); diff --git a/src/osgPlugins/dae/daeWGeometry.cpp b/src/osgPlugins/dae/daeWGeometry.cpp index 95469b5a7..1aca7d22e 100644 --- a/src/osgPlugins/dae/daeWGeometry.cpp +++ b/src/osgPlugins/dae/daeWGeometry.cpp @@ -511,7 +511,7 @@ void daeWriter::appendGeometryIndices(osg::Geometry *geom, if ( norm != NULL ) { - if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX ) + if ( osg::getBinding(geom->getNormalArray()) == osg::Array::BIND_PER_VERTEX ) p->getValue().append( normals.inds!=NULL?normals.inds->index( vindex ):vindex ); else p->getValue().append( normals.inds!=NULL?normals.inds->index( ncount ):ncount ); @@ -519,7 +519,7 @@ void daeWriter::appendGeometryIndices(osg::Geometry *geom, if ( color != NULL ) { - if ( geom->getColorBinding() == osg::Geometry::BIND_PER_VERTEX ) + if ( osg::getBinding(geom->getColorArray()) == osg::Array::BIND_PER_VERTEX ) p->getValue().append( colors.inds!=NULL?colors.inds->index( vindex ):vindex ); else p->getValue().append( colors.inds!=NULL?colors.inds->index( ccount ):ccount ); @@ -1292,11 +1292,11 @@ bool daeWriter::processGeometry( osg::Geometry *geom, domGeometry *geo, const st break; } - if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET ) + if ( osg::getBinding(geom->getNormalArray()) == osg::Array::BIND_PER_PRIMITIVE_SET ) { ncount++; } - if ( geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET ) + if ( osg::getBinding(geom->getColorArray()) == osg::Array::BIND_PER_PRIMITIVE_SET ) { ccount++; } diff --git a/src/osgPlugins/dxf/DXFWriterNodeVisitor.cpp b/src/osgPlugins/dxf/DXFWriterNodeVisitor.cpp index 2f439c6f2..300723c70 100644 --- a/src/osgPlugins/dxf/DXFWriterNodeVisitor.cpp +++ b/src/osgPlugins/dxf/DXFWriterNodeVisitor.cpp @@ -502,9 +502,10 @@ void DXFWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) OSG_DEBUG << "adding Layer " << _layer._name << std::endl; // if single colour include in header - if ( osg::Geometry::BIND_OVERALL == geo->getColorBinding() ) { + osg::Array::Binding colorBinding = osg::getBinding(geo->getColorArray()); + if ( osg::Array::BIND_OVERALL == colorBinding ) { _layer._color = _acadColor.findColor(getNodeRGB(geo)); // per layer color - } else if ( osg::Geometry::BIND_OFF== geo->getColorBinding() ) { + } else if ( osg::Array::BIND_OFF== colorBinding ) { _layer._color = 0xff; // use white - or can we easily lookup in texture? } else { _layer._color = 0; // per point color @@ -514,7 +515,7 @@ void DXFWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) } else { _layer = _layers[_count++]; OSG_DEBUG << "writing Layer " << _layer._name << std::endl; - + processStateSet(_currentStateSet.get()); if ( geo->getNumPrimitiveSets() ) { diff --git a/src/osgPlugins/normals/Normals.cpp b/src/osgPlugins/normals/Normals.cpp index 4999b5949..749ca2a83 100644 --- a/src/osgPlugins/normals/Normals.cpp +++ b/src/osgPlugins/normals/Normals.cpp @@ -68,11 +68,11 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) if( normals == 0L ) continue; - Geometry::AttributeBinding binding = geom->getNormalBinding(); - if( binding == Geometry::BIND_OFF ) + Array::Binding binding = osg::getBinding(geom->getNormalArray()); + if( binding == Array::BIND_OFF ) continue; - if( binding == Geometry::BIND_OVERALL ) + if( binding == Array::BIND_OVERALL ) { Vec3 v(0,0,0); Vec3 n = normals->front(); @@ -99,7 +99,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) #ifdef DEBUG _printPrimitiveType( (*itr).get() ); #endif - if( binding == Geometry::BIND_PER_PRIMITIVE_SET ) + if( binding == Array::BIND_PER_PRIMITIVE_SET ) { Vec3 v(0,0,0); Vec3 n = *(normals_index++); @@ -135,7 +135,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) normals_index++; } coord_index += 2; - if( binding == Geometry::BIND_PER_VERTEX ) + if( binding == Array::BIND_PER_VERTEX ) normals_index += 2; break; } @@ -185,13 +185,13 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode ) void Normals::MakeNormalsVisitor::_processPrimitive( unsigned int nv, Vec3Array::iterator coords, Vec3Array::iterator normals, - Geometry::AttributeBinding binding ) + Array::Binding binding ) { Vec3 v(0,0,0); Vec3 n(0,0,0); if( _mode == SurfaceNormals ) { - if( binding == Geometry::BIND_PER_VERTEX ) + if( binding == Array::BIND_PER_VERTEX ) { for( unsigned int i = 0; i < nv; i++ ) n += *(normals++); diff --git a/src/osgPlugins/normals/Normals.h b/src/osgPlugins/normals/Normals.h index ae57c6e59..857c3e94c 100644 --- a/src/osgPlugins/normals/Normals.h +++ b/src/osgPlugins/normals/Normals.h @@ -50,7 +50,7 @@ class Normals: public osg::Geode void _processPrimitive( unsigned int nv, osg::Vec3Array::iterator coords, osg::Vec3Array::iterator normals, - osg::Geometry::AttributeBinding binding ); + osg::Array::Binding binding ); }; #ifdef DEBUG diff --git a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp index a5a412ebe..0bc397b6c 100644 --- a/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp +++ b/src/osgPlugins/obj/OBJWriterNodeVisitor.cpp @@ -119,7 +119,7 @@ class ObjPrimitiveIndexWriter : public osg::PrimitiveIndexFunctor { _fout << "/"; if (_hasNormalCoords) { - if (_geo->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX) + if (osg::getBinding(_geo->getNormalArray()) == osg::Array::BIND_PER_VERTEX) _fout << (i+_lastNormalIndex); else _fout << (_normalIndex + _lastNormalIndex); @@ -519,7 +519,7 @@ void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) { _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); @@ -533,7 +533,7 @@ void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) { ObjPrimitiveIndexWriter pif(_fout, geo, normalIndex, _lastVertexIndex, _lastNormalIndex, _lastTexIndex); ps->accept(pif); - if(geo->getNormalArray() && geo->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) + if(geo->getNormalArray() && geo->getNormalArray()->getBinding() == osg::Array::BIND_PER_PRIMITIVE_SET) ++normalIndex; } if (geo->getVertexArray()) diff --git a/src/osgPlugins/vrml/ConvertToVRML.cpp b/src/osgPlugins/vrml/ConvertToVRML.cpp index 27129dd4d..7440b1d65 100644 --- a/src/osgPlugins/vrml/ConvertToVRML.cpp +++ b/src/osgPlugins/vrml/ConvertToVRML.cpp @@ -269,7 +269,7 @@ 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; @@ -1106,7 +1106,8 @@ void ToVRML::writeNormal(osg::Geometry* geom, std::vector& primitiveSetFace return; } - if (geom->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX || geom->getNormalBinding() == osg::Geometry::BIND_OVERALL) { + osg::Array::Binding normalBinding = osg::getBinding(geom->getNormalArray()); + if (normalBinding == osg::Array::BIND_PER_VERTEX || normalBinding == osg::Array::BIND_OVERALL) { _fout << indentM() << "normalPerVertex TRUE \n"; } else { _fout << indentM() << "normalPerVertex FALSE \n"; @@ -1117,20 +1118,20 @@ void ToVRML::writeNormal(osg::Geometry* geom, std::vector& primitiveSetFace indentM(); osg::Vec3 n; - if (geom->getNormalBinding() == osg::Geometry::BIND_PER_VERTEX) { + if (normalBinding == osg::Array::BIND_PER_VERTEX) { 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_OVERALL) { + } else if (normalBinding == osg::Array::BIND_OVERALL) { n = (*nArray)[0]; int size = ((osg::Vec3Array*) (geom->getVertexArray()))->size(); for (int j = 0; j < size; j++) { _fout << indent() << n[0] << " " << n[1] << " " << n[2] << ",\n"; } - } else if (geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) { + } else if (normalBinding == osg::Array::BIND_PER_PRIMITIVE_SET) { for (unsigned int j = 0; j < (*nArray).size(); j++) { n = (*nArray)[j]; for (int k = 0; k < primitiveSetFaces[j]; k++) { @@ -1254,7 +1255,8 @@ void ToVRML::writeColor(osg::Geometry* geom, std::vector& primitiveSetFaces return; } - if (geom->getColorBinding() == osg::Geometry::BIND_PER_VERTEX || geom->getColorBinding() == osg::Geometry::BIND_OVERALL) { + osg::Array::Binding colorBinding = osg::getBinding(geom->getColorArray()); + if (colorBinding == osg::Array::BIND_PER_VERTEX || colorBinding == osg::Array::BIND_OVERALL) { _fout << indentM() << "colorPerVertex TRUE \n"; } else { _fout << indentM() << "colorPerVertex FALSE \n"; @@ -1265,20 +1267,20 @@ void ToVRML::writeColor(osg::Geometry* geom, std::vector& primitiveSetFaces indentM(); osg::Vec4 c; - if (geom->getColorBinding() == osg::Geometry::BIND_PER_VERTEX) { + if (colorBinding == osg::Array::BIND_PER_VERTEX) { 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_OVERALL) { + } else if (colorBinding == osg::Array::BIND_OVERALL) { c = (*cArray)[0]; int size = ((osg::Vec3Array*) (geom->getVertexArray()))->size(); for (int j = 0; j < size; j++) { _fout << indent() << c[0] << " " << c[1] << " " << c[2] << ",\n"; } - } else if (geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) { + } else if (colorBinding == osg::Array::BIND_PER_PRIMITIVE_SET) { for (unsigned int j = 0; j < (*cArray).size(); j++) { c = (*cArray)[j]; for (int k = 0; k < primitiveSetFaces[j]; k++) { diff --git a/src/osgWrappers/serializers/osg/Geometry.cpp b/src/osgWrappers/serializers/osg/Geometry.cpp index d77926fd6..f024188a2 100644 --- a/src/osgWrappers/serializers/osg/Geometry.cpp +++ b/src/osgWrappers/serializers/osg/Geometry.cpp @@ -4,11 +4,11 @@ #include BEGIN_USER_TABLE( AttributeBinding, osg::Geometry ); - ADD_USER_VALUE( BIND_OFF ); - ADD_USER_VALUE( BIND_OVERALL ); - 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 ); + lookup->add("BIND_OFF",0); // ADD_USER_VALUE("ADD_USER_VALUE( BIND_OFF ); + lookup->add("BIND_OVERALL",1); // ADD_USER_VALUE( BIND_OVERALL ); + lookup->add("BIND_PER_PRIMITIVE_SET",2); // ADD_USER_VALUE( BIND_PER_PRIMITIVE_SET ); + lookup->add("BIND_PER_PRIMITIVE",3); //ADD_USER_VALUE( BIND_PER_PRIMITIVE ); + lookup->add("BIND_PER_VERTEX",4); // ADD_USER_VALUE( BIND_PER_VERTEX ); END_USER_TABLE() USER_READ_FUNC( AttributeBinding, readAttributeBinding ) @@ -37,7 +37,7 @@ static osg::Array* readArray( osgDB::InputStream& is) int normalizeValue = 0; is >> is.PROPERTY("Normalize") >> normalizeValue; if (array.valid()) array->setNormalize(normalizeValue!=0); - + return array.release(); } @@ -52,7 +52,7 @@ static void writeArray( osgDB::OutputStream& os, const osg::Array* array) if ( indices!=0 ) os << indices; else os << std::endl; - os << os.PROPERTY("Binding"); writeAttributeBinding(os, (array!=0) ? static_cast(array->getBinding()) : osg::Geometry::BIND_OFF); os << std::endl; + os << os.PROPERTY("Binding"); writeAttributeBinding(os, osg::getBinding(array)); os << std::endl; os << os.PROPERTY("Normalize") << ((array!=0 && array->getNormalize()) ? 1:0) << std::endl; } @@ -123,7 +123,7 @@ struct GeometryFinishedObjectReadCallback : public osgDB::FinishedObjectReadCall // implement backwards compatibility with reading/writing the FastPathHint static bool checkFastPathHint( const osg::Geometry& geom ) { return false; } static bool readFastPathHint( osgDB::InputStream& is, osg::Geometry& geom ) -{ +{ // Compatibility info: // Previous Geometry wrapper (before 3.1.8) require a bool fast-path serializer. // It saves "FastPathHint true" in ascii mode and a single [bool] in binary mode.