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.

This commit is contained in:
Robert Osfield
2016-09-04 18:31:13 +01:00
parent 19270d0833
commit fb4f7a025b
5 changed files with 243 additions and 0 deletions

View File

@@ -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

View File

@@ -12,6 +12,8 @@
#include <stack>
#include <assert.h>
#include "DeprecatedGeometry.h"
class ConvertFromInventor
{
public:

View File

@@ -31,6 +31,8 @@
#include <osg/CullFace>
#include <osg/FrontFace>
#include "DeprecatedGeometry.h"
class SoSeparator;
namespace osg {

View File

@@ -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<AttributeBinding>(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<AttributeBinding>(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<AttributeBinding>(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<AttributeBinding>(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<osg::Array::Binding>(ab)) return;
_vertexAttribList[index]->setBinding(static_cast<osg::Array::Binding>(ab));
dirtyDisplayList();
}
else
{
OSG_NOTICE<<"Warning, can't assign attribute binding as no has been array assigned to set binding for."<<std::endl;
}
}
deprecated_osg::Geometry::AttributeBinding deprecated_osg::Geometry::getVertexAttribBinding(unsigned int index) const { return static_cast<AttributeBinding>(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."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getVertexIndices() const
{
if (_vertexArray.valid()) return dynamic_cast<osg::IndexArray*>(_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."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getNormalIndices() const
{
if (_normalArray.valid()) return dynamic_cast<osg::IndexArray*>(_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."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getColorIndices() const
{
if (_colorArray.valid()) return dynamic_cast<osg::IndexArray*>(_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."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getSecondaryColorIndices() const
{
if (_secondaryColorArray.valid()) return dynamic_cast<osg::IndexArray*>(_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."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getFogCoordIndices() const
{
if (_fogCoordArray.valid()) return dynamic_cast<osg::IndexArray*>(_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."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getTexCoordIndices(unsigned int unit) const
{
if (unit<_texCoordList.size() && _texCoordList[unit].valid()) return dynamic_cast<osg::IndexArray*>(_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."<<std::endl; }
}
const osg::IndexArray* deprecated_osg::Geometry::getVertexAttribIndices(unsigned int index) const
{
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid()) return dynamic_cast<osg::IndexArray*>(_vertexAttribList[index]->getUserData());
else return 0;
}

View File

@@ -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 <osg/Geometry>
/** 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."<<std::endl; \
return; \
} \
if (array->getBinding() == static_cast<osg::Array::Binding>(ab)) return; \
array->setBinding(static_cast<osg::Array::Binding>(ab));\
if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true; \
dirtyDisplayList();
#define GET_BINDING(array) (array!=0 ? static_cast<AttributeBinding>(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