From fb4f7a025b02d1479ade22677367fee511db6682 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 4 Sep 2016 18:31:13 +0100 Subject: [PATCH] Added local deprecated_osg::Geometry implementation from OpenSceneGraph-3.4 to keep build working now that deprecated_osg::Geometry has been removed from the core OSG. --- src/osgPlugins/Inventor/CMakeLists.txt | 2 + src/osgPlugins/Inventor/ConvertFromInventor.h | 2 + src/osgPlugins/Inventor/ConvertToInventor.h | 2 + .../Inventor/DeprecatedGeometry.cpp | 129 ++++++++++++++++++ src/osgPlugins/Inventor/DeprecatedGeometry.h | 108 +++++++++++++++ 5 files changed, 243 insertions(+) create mode 100644 src/osgPlugins/Inventor/DeprecatedGeometry.cpp create mode 100644 src/osgPlugins/Inventor/DeprecatedGeometry.h diff --git a/src/osgPlugins/Inventor/CMakeLists.txt b/src/osgPlugins/Inventor/CMakeLists.txt index 035cb36c4..963a49420 100644 --- a/src/osgPlugins/Inventor/CMakeLists.txt +++ b/src/osgPlugins/Inventor/CMakeLists.txt @@ -1,6 +1,7 @@ INCLUDE(OsgMacroUtils) SET(TARGET_SRC + DeprecatedGeometry.cpp ConvertToInventor.cpp ConvertFromInventor.cpp PendulumCallback.cpp @@ -8,6 +9,7 @@ SET(TARGET_SRC ShuttleCallback.cpp ) SET(TARGET_HDRS + DeprecatedGeometry.h ConvertToInventor.h ConvertFromInventor.h PendulumCallback.h diff --git a/src/osgPlugins/Inventor/ConvertFromInventor.h b/src/osgPlugins/Inventor/ConvertFromInventor.h index 8f6da65a2..2dcc66a13 100644 --- a/src/osgPlugins/Inventor/ConvertFromInventor.h +++ b/src/osgPlugins/Inventor/ConvertFromInventor.h @@ -12,6 +12,8 @@ #include #include +#include "DeprecatedGeometry.h" + class ConvertFromInventor { public: diff --git a/src/osgPlugins/Inventor/ConvertToInventor.h b/src/osgPlugins/Inventor/ConvertToInventor.h index a95a90e5c..40487d2f1 100644 --- a/src/osgPlugins/Inventor/ConvertToInventor.h +++ b/src/osgPlugins/Inventor/ConvertToInventor.h @@ -31,6 +31,8 @@ #include #include +#include "DeprecatedGeometry.h" + class SoSeparator; namespace osg { diff --git a/src/osgPlugins/Inventor/DeprecatedGeometry.cpp b/src/osgPlugins/Inventor/DeprecatedGeometry.cpp new file mode 100644 index 000000000..f32822661 --- /dev/null +++ b/src/osgPlugins/Inventor/DeprecatedGeometry.cpp @@ -0,0 +1,129 @@ +#include "DeprecatedGeometry.h" + +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) { 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) { 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) { 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,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!=GL_FALSE); + + dirtyDisplayList(); + } +} + +GLboolean deprecated_osg::Geometry::getVertexAttribNormalize(unsigned int index) const { return osg::getNormalize(getVertexAttribArray(index)); } + +void deprecated_osg::Geometry::setVertexIndices(osg::IndexArray* array) +{ + if (_vertexArray.valid()) { _vertexArray->setUserData(array); if (array) _containsDeprecatedData = true; } + else { OSG_WARN<<"Geometry::setVertexIndicies(..) function failed as there is no vertex array to associate inidices with."<(_vertexArray->getUserData()); + else return 0; +} + +void deprecated_osg::Geometry::setNormalIndices(osg::IndexArray* array) +{ + if (_normalArray.valid()) { _normalArray->setUserData(array); if (array) _containsDeprecatedData = true; } + else { OSG_WARN<<"Geometry::setNormalIndicies(..) function failed as there is no normal array to associate inidices with."<(_normalArray->getUserData()); + else return 0; +} + +void deprecated_osg::Geometry::setColorIndices(osg::IndexArray* array) +{ + if (_colorArray.valid()) { _colorArray->setUserData(array); if (array) _containsDeprecatedData = true; } + else { OSG_WARN<<"Geometry::setColorIndicies(..) function failed as there is no color array to associate inidices with."<(_colorArray->getUserData()); + else return 0; +} + +void deprecated_osg::Geometry::setSecondaryColorIndices(osg::IndexArray* array) +{ + if (_secondaryColorArray.valid()) { _secondaryColorArray->setUserData(array); if (array) _containsDeprecatedData = true; } + else { OSG_WARN<<"Geometry::setSecondaryColorArray(..) function failed as there is no secondary color array to associate inidices with."<(_secondaryColorArray->getUserData()); + else return 0; +} + +void deprecated_osg::Geometry::setFogCoordIndices(osg::IndexArray* array) +{ + if (_fogCoordArray.valid()) { _fogCoordArray->setUserData(array); if (array) _containsDeprecatedData = true; } + else { OSG_WARN<<"Geometry::setFogCoordIndicies(..) function failed as there is no fog coord array to associate inidices with."<(_fogCoordArray->getUserData()); + else return 0; +} + +void deprecated_osg::Geometry::setTexCoordIndices(unsigned int unit,osg::IndexArray* array) +{ + if (unit<_texCoordList.size() && _texCoordList[unit].valid()) { _texCoordList[unit]->setUserData(array); if (array) _containsDeprecatedData = true; } + else { OSG_WARN<<"Geometry::setTexCoordIndices(..) function failed as there is no texcoord array to associate inidices with."<(_texCoordList[unit]->getUserData()); + else return 0; +} + +void deprecated_osg::Geometry::setVertexAttribIndices(unsigned int index,osg::IndexArray* array) +{ + if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) { _vertexAttribList[index]->setUserData(array); if (array) _containsDeprecatedData = true; } + else { OSG_WARN<<"Geometry::setVertexAttribIndices(..) function failed as there is no vertex attrib array to associate inidices with."<(_vertexAttribList[index]->getUserData()); + else return 0; +} + + diff --git a/src/osgPlugins/Inventor/DeprecatedGeometry.h b/src/osgPlugins/Inventor/DeprecatedGeometry.h new file mode 100644 index 000000000..5d9b0843a --- /dev/null +++ b/src/osgPlugins/Inventor/DeprecatedGeometry.h @@ -0,0 +1,108 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSG_DEPRECATED_GEOMETRY +#define OSG_DEPRECATED_GEOMETRY 1 + +#include + +/** Contains deprecated features of namespace osg. */ +namespace deprecated_osg { + + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// 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) + + +/** Geometry class contaning deprecated features. + * Users should only use deprecated_osg::Geometry when absolutely necessary 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 +{ + public: + Geometry() : osg::Geometry() {} + Geometry(const Geometry& geometry,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Geometry(geometry, copyop) {} + + /** Same values as Array::Binding.*/ + enum AttributeBinding + { + BIND_OFF=0, + BIND_OVERALL=1, + BIND_PER_PRIMITIVE_SET=2, + BIND_PER_PRIMITIVE=3, + BIND_PER_VERTEX=4 + }; + + void setNormalBinding(AttributeBinding ab); + AttributeBinding getNormalBinding() const; + + void setColorBinding(AttributeBinding ab); + AttributeBinding getColorBinding() const; + + void setSecondaryColorBinding(AttributeBinding ab); + AttributeBinding getSecondaryColorBinding() const; + + void setFogCoordBinding(AttributeBinding ab); + AttributeBinding getFogCoordBinding() const; + + void setVertexAttribBinding(unsigned int index,AttributeBinding ab); + AttributeBinding getVertexAttribBinding(unsigned int index) const; + + void setVertexAttribNormalize(unsigned int index,GLboolean norm); + GLboolean getVertexAttribNormalize(unsigned int index) const; + + void setVertexIndices(osg::IndexArray* array); + const osg::IndexArray* getVertexIndices() const; + + void setNormalIndices(osg::IndexArray* array); + const osg::IndexArray* getNormalIndices() const; + + void setColorIndices(osg::IndexArray* array); + const osg::IndexArray* getColorIndices() const; + + void setSecondaryColorIndices(osg::IndexArray* array); + const osg::IndexArray* getSecondaryColorIndices() const; + + void setFogCoordIndices(osg::IndexArray* array); + const osg::IndexArray* getFogCoordIndices() const; + + void setTexCoordIndices(unsigned int unit,osg::IndexArray* array); + const osg::IndexArray* getTexCoordIndices(unsigned int unit) const; + + void setVertexAttribIndices(unsigned int index,osg::IndexArray* array); + const osg::IndexArray* getVertexAttribIndices(unsigned int index) const; + +}; + +} // namespace deprecated_osg + +#endif +