Added new osg::Array::Binding parameter to osg::Geometry::set*Array(osg::Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED) methods to make it easier for the user
to set the binding without the need to call the deprecated osg::Geometry::set*Binding(osg::Geometry::AttributeBinding)
This commit is contained in:
parent
d82c62a03b
commit
15fea448d8
@ -121,15 +121,13 @@ osg::Node* createScene()
|
|||||||
|
|
||||||
// pass the color array to points geometry, note the binding to tell the geometry
|
// pass the color array to points geometry, note the binding to tell the geometry
|
||||||
// that only use one color for the whole object.
|
// that only use one color for the whole object.
|
||||||
pointsGeom->setColorArray(colors);
|
pointsGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||||
pointsGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// set the normal in the same way color.
|
// set the normal in the same way color.
|
||||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||||
pointsGeom->setNormalArray(normals);
|
pointsGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||||
pointsGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// create and add a DrawArray Primitive (see include/osg/Primitive). The first
|
// create and add a DrawArray Primitive (see include/osg/Primitive). The first
|
||||||
@ -169,15 +167,13 @@ osg::Node* createScene()
|
|||||||
// set the colors as before, plus using the above
|
// set the colors as before, plus using the above
|
||||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||||
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
||||||
linesGeom->setColorArray(colors);
|
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// set the normal in the same way color.
|
// set the normal in the same way color.
|
||||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||||
linesGeom->setNormalArray(normals);
|
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// This time we simply use primitive, and hardwire the number of coords to use
|
// This time we simply use primitive, and hardwire the number of coords to use
|
||||||
@ -211,15 +207,13 @@ osg::Node* createScene()
|
|||||||
// set the colors as before, plus using the above
|
// set the colors as before, plus using the above
|
||||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||||
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
||||||
linesGeom->setColorArray(colors);
|
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// set the normal in the same way color.
|
// set the normal in the same way color.
|
||||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||||
linesGeom->setNormalArray(normals);
|
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// This time we simply use primitive, and hardwire the number of coords to use
|
// This time we simply use primitive, and hardwire the number of coords to use
|
||||||
@ -258,15 +252,13 @@ osg::Node* createScene()
|
|||||||
// set the colors as before, plus using the above
|
// set the colors as before, plus using the above
|
||||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||||
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
|
||||||
linesGeom->setColorArray(colors);
|
linesGeom->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// set the normal in the same way color.
|
// set the normal in the same way color.
|
||||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||||
linesGeom->setNormalArray(normals);
|
linesGeom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// This time we simply use primitive, and hardwire the number of coords to use
|
// This time we simply use primitive, and hardwire the number of coords to use
|
||||||
@ -332,13 +324,11 @@ osg::Node* createScene()
|
|||||||
polyGeom->setVertexArray(vertices);
|
polyGeom->setVertexArray(vertices);
|
||||||
|
|
||||||
// use the shared color array.
|
// use the shared color array.
|
||||||
polyGeom->setColorArray(shared_colors.get());
|
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
|
||||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// use the shared normal array.
|
// use the shared normal array.
|
||||||
polyGeom->setNormalArray(shared_normals.get());
|
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
|
||||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// This time we simply use primitive, and hardwire the number of coords to use
|
// This time we simply use primitive, and hardwire the number of coords to use
|
||||||
@ -379,13 +369,11 @@ osg::Node* createScene()
|
|||||||
polyGeom->setVertexArray(vertices);
|
polyGeom->setVertexArray(vertices);
|
||||||
|
|
||||||
// use the shared color array.
|
// use the shared color array.
|
||||||
polyGeom->setColorArray(shared_colors.get());
|
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
|
||||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// use the shared normal array.
|
// use the shared normal array.
|
||||||
polyGeom->setNormalArray(shared_normals.get());
|
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
|
||||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// This time we simply use primitive, and hardwire the number of coords to use
|
// This time we simply use primitive, and hardwire the number of coords to use
|
||||||
@ -428,13 +416,11 @@ osg::Node* createScene()
|
|||||||
polyGeom->setVertexArray(vertices);
|
polyGeom->setVertexArray(vertices);
|
||||||
|
|
||||||
// use the shared color array.
|
// use the shared color array.
|
||||||
polyGeom->setColorArray(shared_colors.get());
|
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
|
||||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// use the shared normal array.
|
// use the shared normal array.
|
||||||
polyGeom->setNormalArray(shared_normals.get());
|
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
|
||||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// This time we simply use primitive, and hardwire the number of coords to use
|
// This time we simply use primitive, and hardwire the number of coords to use
|
||||||
@ -496,13 +482,11 @@ osg::Node* createScene()
|
|||||||
polyGeom->setVertexArray(vertices);
|
polyGeom->setVertexArray(vertices);
|
||||||
|
|
||||||
// use the shared color array.
|
// use the shared color array.
|
||||||
polyGeom->setColorArray(shared_colors.get());
|
polyGeom->setColorArray(shared_colors.get(), osg::Array::BIND_OVERALL);
|
||||||
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// use the shared normal array.
|
// use the shared normal array.
|
||||||
polyGeom->setNormalArray(shared_normals.get());
|
polyGeom->setNormalArray(shared_normals.get(), osg::Array::BIND_OVERALL);
|
||||||
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
|
||||||
|
|
||||||
|
|
||||||
// This time we simply use primitive, and hardwire the number of coords to use
|
// This time we simply use primitive, and hardwire the number of coords to use
|
||||||
|
@ -50,29 +50,29 @@ class OSG_EXPORT Geometry : public Drawable
|
|||||||
const Array* getVertexArray() const { return _vertexArray.get(); }
|
const Array* getVertexArray() const { return _vertexArray.get(); }
|
||||||
|
|
||||||
|
|
||||||
void setNormalArray(Array* array);
|
void setNormalArray(Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED);
|
||||||
Array* getNormalArray() { return _normalArray.get(); }
|
Array* getNormalArray() { return _normalArray.get(); }
|
||||||
const Array* getNormalArray() const { return _normalArray.get(); }
|
const Array* getNormalArray() const { return _normalArray.get(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setColorArray(Array* array);
|
|
||||||
|
void setColorArray(Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED);
|
||||||
Array* getColorArray() { return _colorArray.get(); }
|
Array* getColorArray() { return _colorArray.get(); }
|
||||||
const Array* getColorArray() const { return _colorArray.get(); }
|
const Array* getColorArray() const { return _colorArray.get(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setSecondaryColorArray(Array* array);
|
void setSecondaryColorArray(Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED);
|
||||||
Array* getSecondaryColorArray() { return _secondaryColorArray.get(); }
|
Array* getSecondaryColorArray() { return _secondaryColorArray.get(); }
|
||||||
const Array* getSecondaryColorArray() const { return _secondaryColorArray.get(); }
|
const Array* getSecondaryColorArray() const { return _secondaryColorArray.get(); }
|
||||||
|
|
||||||
|
|
||||||
void setFogCoordArray(Array* array);
|
void setFogCoordArray(Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED);
|
||||||
Array* getFogCoordArray() { return _fogCoordArray.get(); }
|
Array* getFogCoordArray() { return _fogCoordArray.get(); }
|
||||||
const Array* getFogCoordArray() const { return _fogCoordArray.get(); }
|
const Array* getFogCoordArray() const { return _fogCoordArray.get(); }
|
||||||
|
|
||||||
|
|
||||||
void setTexCoordArray(unsigned int unit,Array*);
|
void setTexCoordArray(unsigned int unit,Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED);
|
||||||
Array* getTexCoordArray(unsigned int unit);
|
Array* getTexCoordArray(unsigned int unit);
|
||||||
const Array* getTexCoordArray(unsigned int unit) const;
|
const Array* getTexCoordArray(unsigned int unit) const;
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class OSG_EXPORT Geometry : public Drawable
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setVertexAttribArray(unsigned int index,Array* array);
|
void setVertexAttribArray(unsigned int index, Array* array, osg::Array::Binding binding=osg::Array::BIND_UNDEFINED);
|
||||||
Array *getVertexAttribArray(unsigned int index);
|
Array *getVertexAttribArray(unsigned int index);
|
||||||
const Array *getVertexAttribArray(unsigned int index) const;
|
const Array *getVertexAttribArray(unsigned int index) const;
|
||||||
|
|
||||||
@ -214,12 +214,12 @@ class OSG_EXPORT Geometry : public Drawable
|
|||||||
osg::ref_ptr<Array> _fogCoordArray;
|
osg::ref_ptr<Array> _fogCoordArray;
|
||||||
ArrayList _texCoordList;
|
ArrayList _texCoordList;
|
||||||
ArrayList _vertexAttribList;
|
ArrayList _vertexAttribList;
|
||||||
|
|
||||||
bool _containsDeprecatedData;
|
bool _containsDeprecatedData;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
/** Return true if the deprecated use array indicies or BIND_PER_PRIMITIVE binding has been assigned to arrays.*/
|
/** Return true if the deprecated use array indicies or BIND_PER_PRIMITIVE binding has been assigned to arrays.*/
|
||||||
bool containsDeprecatedData() const { return _containsDeprecatedData; }
|
bool containsDeprecatedData() const { return _containsDeprecatedData; }
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ class OSG_EXPORT Geometry : public Drawable
|
|||||||
/** no longer supported.*/
|
/** no longer supported.*/
|
||||||
inline void setVertexAttribIndices(unsigned int index,IndexArray* array);
|
inline void setVertexAttribIndices(unsigned int index,IndexArray* array);
|
||||||
inline const IndexArray* getVertexAttribIndices(unsigned int index) const;
|
inline const IndexArray* getVertexAttribIndices(unsigned int index) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Convenience function to be used for creating quad geometry with texture coords.
|
/** Convenience function to be used for creating quad geometry with texture coords.
|
||||||
@ -392,7 +392,7 @@ inline const IndexArray* Geometry::getVertexAttribIndices(unsigned int index) co
|
|||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -83,7 +83,7 @@ Geometry::~Geometry()
|
|||||||
// no need to delete, all automatically handled by ref_ptr :-)
|
// no need to delete, all automatically handled by ref_ptr :-)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARRAY_NOT_EMPTY(array) (array!=0 && array->getNumElements()!=0)
|
#define ARRAY_NOT_EMPTY(array) (array!=0 && array->getNumElements()!=0)
|
||||||
|
|
||||||
bool Geometry::empty() const
|
bool Geometry::empty() const
|
||||||
{
|
{
|
||||||
@ -100,6 +100,8 @@ bool Geometry::empty() const
|
|||||||
|
|
||||||
void Geometry::setVertexArray(Array* array)
|
void Geometry::setVertexArray(Array* array)
|
||||||
{
|
{
|
||||||
|
if (array && array->getBinding()==osg::Array::BIND_UNDEFINED) array->setBinding(osg::Array::BIND_PER_VERTEX);
|
||||||
|
|
||||||
_vertexArray = array;
|
_vertexArray = array;
|
||||||
|
|
||||||
dirtyDisplayList();
|
dirtyDisplayList();
|
||||||
@ -108,8 +110,10 @@ void Geometry::setVertexArray(Array* array)
|
|||||||
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
|
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Geometry::setNormalArray(Array* array)
|
void Geometry::setNormalArray(Array* array, osg::Array::Binding binding)
|
||||||
{
|
{
|
||||||
|
if (array && binding!=osg::Array::BIND_UNDEFINED) array->setBinding(binding);
|
||||||
|
|
||||||
_normalArray = array;
|
_normalArray = array;
|
||||||
|
|
||||||
dirtyDisplayList();
|
dirtyDisplayList();
|
||||||
@ -117,8 +121,10 @@ void Geometry::setNormalArray(Array* array)
|
|||||||
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
|
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Geometry::setColorArray(Array* array)
|
void Geometry::setColorArray(Array* array, osg::Array::Binding binding)
|
||||||
{
|
{
|
||||||
|
if (array && binding!=osg::Array::BIND_UNDEFINED) array->setBinding(binding);
|
||||||
|
|
||||||
_colorArray = array;
|
_colorArray = array;
|
||||||
|
|
||||||
dirtyDisplayList();
|
dirtyDisplayList();
|
||||||
@ -126,8 +132,10 @@ void Geometry::setColorArray(Array* array)
|
|||||||
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
|
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Geometry::setSecondaryColorArray(Array* array)
|
void Geometry::setSecondaryColorArray(Array* array, osg::Array::Binding binding)
|
||||||
{
|
{
|
||||||
|
if (array && binding!=osg::Array::BIND_UNDEFINED) array->setBinding(binding);
|
||||||
|
|
||||||
_secondaryColorArray = array;
|
_secondaryColorArray = array;
|
||||||
|
|
||||||
dirtyDisplayList();
|
dirtyDisplayList();
|
||||||
@ -135,8 +143,10 @@ void Geometry::setSecondaryColorArray(Array* array)
|
|||||||
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
|
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Geometry::setFogCoordArray(Array* array)
|
void Geometry::setFogCoordArray(Array* array, osg::Array::Binding binding)
|
||||||
{
|
{
|
||||||
|
if (array && binding!=osg::Array::BIND_UNDEFINED) array->setBinding(binding);
|
||||||
|
|
||||||
_fogCoordArray = array;
|
_fogCoordArray = array;
|
||||||
|
|
||||||
dirtyDisplayList();
|
dirtyDisplayList();
|
||||||
@ -154,18 +164,20 @@ void Geometry::setFogCoordArray(Array* array)
|
|||||||
if (array->getBinding() == static_cast<osg::Array::Binding>(ab)) return; \
|
if (array->getBinding() == static_cast<osg::Array::Binding>(ab)) return; \
|
||||||
array->setBinding(static_cast<osg::Array::Binding>(ab));\
|
array->setBinding(static_cast<osg::Array::Binding>(ab));\
|
||||||
if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true;
|
if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true;
|
||||||
|
|
||||||
|
|
||||||
#define GET_BINDING(array) (array!=0 ? static_cast<AttributeBinding>(array->getBinding()) : BIND_OFF)
|
|
||||||
|
#define GET_BINDING(array) (array!=0 ? static_cast<AttributeBinding>(array->getBinding()) : BIND_OFF)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Geometry::setTexCoordArray(unsigned int index,Array* array)
|
void Geometry::setTexCoordArray(unsigned int index,Array* array, osg::Array::Binding binding)
|
||||||
{
|
{
|
||||||
if (_texCoordList.size()<=index)
|
if (_texCoordList.size()<=index)
|
||||||
_texCoordList.resize(index+1);
|
_texCoordList.resize(index+1);
|
||||||
|
|
||||||
|
if (array && binding!=osg::Array::BIND_UNDEFINED) array->setBinding(binding);
|
||||||
|
|
||||||
_texCoordList[index] = array;
|
_texCoordList[index] = array;
|
||||||
|
|
||||||
// do we set to array BIND_PER_VERTEX?
|
// do we set to array BIND_PER_VERTEX?
|
||||||
@ -191,7 +203,7 @@ const Array* Geometry::getTexCoordArray(unsigned int index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Geometry::setVertexAttribArray(unsigned int index, Array* array)
|
void Geometry::setVertexAttribArray(unsigned int index, Array* array, osg::Array::Binding binding)
|
||||||
{
|
{
|
||||||
if (_vertexAttribList.size()<=index)
|
if (_vertexAttribList.size()<=index)
|
||||||
_vertexAttribList.resize(index+1);
|
_vertexAttribList.resize(index+1);
|
||||||
@ -696,7 +708,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
OSG_WARN<<"Geometry::drawImplementation() unable to render due to deprecated data, call geometry->fixDeprecatedData();"<<std::endl;
|
OSG_WARN<<"Geometry::drawImplementation() unable to render due to deprecated data, call geometry->fixDeprecatedData();"<<std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
State& state = *renderInfo.getState();
|
State& state = *renderInfo.getState();
|
||||||
|
|
||||||
bool checkForGLErrors = state.getCheckForGLErrors()==osg::State::ONCE_PER_ATTRIBUTE;
|
bool checkForGLErrors = state.getCheckForGLErrors()==osg::State::ONCE_PER_ATTRIBUTE;
|
||||||
@ -747,7 +759,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
for(unsigned int unit=0;unit<_texCoordList.size();++unit)
|
for(unsigned int unit=0;unit<_texCoordList.size();++unit)
|
||||||
{
|
{
|
||||||
const Array* array = _texCoordList[unit].get();
|
const Array* array = _texCoordList[unit].get();
|
||||||
if (array)
|
if (array)
|
||||||
{
|
{
|
||||||
state.setTexCoordPointer(unit,array);
|
state.setTexCoordPointer(unit,array);
|
||||||
}
|
}
|
||||||
@ -1075,7 +1087,7 @@ Geometry* osg::createTexturedQuadGeometry(const Vec3& corner,const Vec3& widthVe
|
|||||||
elems->push_back(0);
|
elems->push_back(0);
|
||||||
elems->push_back(1);
|
elems->push_back(1);
|
||||||
elems->push_back(2);
|
elems->push_back(2);
|
||||||
|
|
||||||
elems->push_back(2);
|
elems->push_back(2);
|
||||||
elems->push_back(3);
|
elems->push_back(3);
|
||||||
elems->push_back(0);
|
elems->push_back(0);
|
||||||
@ -1102,7 +1114,7 @@ Geometry::AttributeBinding Geometry::getNormalBinding() const
|
|||||||
{
|
{
|
||||||
return GET_BINDING(_normalArray.get());
|
return GET_BINDING(_normalArray.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Geometry::setColorBinding(AttributeBinding ab)
|
void Geometry::setColorBinding(AttributeBinding ab)
|
||||||
{
|
{
|
||||||
SET_BINDING(_colorArray.get(), ab)
|
SET_BINDING(_colorArray.get(), ab)
|
||||||
@ -1114,7 +1126,7 @@ Geometry::AttributeBinding Geometry::getColorBinding() const
|
|||||||
{
|
{
|
||||||
return GET_BINDING(_colorArray.get());
|
return GET_BINDING(_colorArray.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Geometry::setSecondaryColorBinding(AttributeBinding ab)
|
void Geometry::setSecondaryColorBinding(AttributeBinding ab)
|
||||||
{
|
{
|
||||||
SET_BINDING(_secondaryColorArray.get(), ab)
|
SET_BINDING(_secondaryColorArray.get(), ab)
|
||||||
@ -1126,7 +1138,7 @@ Geometry::AttributeBinding Geometry::getSecondaryColorBinding() const
|
|||||||
{
|
{
|
||||||
return GET_BINDING(_secondaryColorArray.get());
|
return GET_BINDING(_secondaryColorArray.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Geometry::setFogCoordBinding(AttributeBinding ab)
|
void Geometry::setFogCoordBinding(AttributeBinding ab)
|
||||||
{
|
{
|
||||||
SET_BINDING(_fogCoordArray.get(), ab)
|
SET_BINDING(_fogCoordArray.get(), ab)
|
||||||
@ -1146,7 +1158,7 @@ void Geometry::setVertexAttribBinding(unsigned int index,AttributeBinding ab)
|
|||||||
if (_vertexAttribList[index]->getBinding()==static_cast<osg::Array::Binding>(ab)) return;
|
if (_vertexAttribList[index]->getBinding()==static_cast<osg::Array::Binding>(ab)) return;
|
||||||
|
|
||||||
_vertexAttribList[index]->setBinding(static_cast<osg::Array::Binding>(ab));
|
_vertexAttribList[index]->setBinding(static_cast<osg::Array::Binding>(ab));
|
||||||
|
|
||||||
dirtyDisplayList();
|
dirtyDisplayList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1166,7 +1178,7 @@ void Geometry::setVertexAttribNormalize(unsigned int index,GLboolean norm)
|
|||||||
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid())
|
if (index<_vertexAttribList.size() && _vertexAttribList[index].valid())
|
||||||
{
|
{
|
||||||
_vertexAttribList[index]->setNormalize(norm);
|
_vertexAttribList[index]->setNormalize(norm);
|
||||||
|
|
||||||
dirtyDisplayList();
|
dirtyDisplayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1236,7 +1248,7 @@ void Geometry::duplicateSharedArrays()
|
|||||||
|
|
||||||
namespace GeometryUtilFunctions
|
namespace GeometryUtilFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
inline osg::IndexArray* getIndexArray(osg::Array* array)
|
inline osg::IndexArray* getIndexArray(osg::Array* array)
|
||||||
{
|
{
|
||||||
return array ? dynamic_cast<osg::IndexArray*>(array->getUserData()) : 0;
|
return array ? dynamic_cast<osg::IndexArray*>(array->getUserData()) : 0;
|
||||||
@ -1259,7 +1271,7 @@ namespace GeometryUtilFunctions
|
|||||||
targetArray->setNormalize(sourceArray->getNormalize());
|
targetArray->setNormalize(sourceArray->getNormalize());
|
||||||
targetArray->setPreserveDataType(sourceArray->getPreserveDataType());
|
targetArray->setPreserveDataType(sourceArray->getPreserveDataType());
|
||||||
targetArray->resizeArray(indices->getNumElements());
|
targetArray->resizeArray(indices->getNumElements());
|
||||||
|
|
||||||
unsigned int elementSize = sourceArray->getElementSize();
|
unsigned int elementSize = sourceArray->getElementSize();
|
||||||
const char* sourcePtr = static_cast<const char*>(sourceArray->getDataPointer());
|
const char* sourcePtr = static_cast<const char*>(sourceArray->getDataPointer());
|
||||||
char* targetPtr = const_cast<char*>(static_cast<const char*>(targetArray->getDataPointer()));
|
char* targetPtr = const_cast<char*>(static_cast<const char*>(targetArray->getDataPointer()));
|
||||||
@ -1296,17 +1308,17 @@ namespace GeometryUtilFunctions
|
|||||||
unsigned int elementSize;
|
unsigned int elementSize;
|
||||||
|
|
||||||
PtrData():source(0),target(0),elementSize(0) {}
|
PtrData():source(0),target(0),elementSize(0) {}
|
||||||
|
|
||||||
PtrData(osg::Array* s, osg::Array* t):
|
PtrData(osg::Array* s, osg::Array* t):
|
||||||
source(const_cast<char*>(static_cast<const char*>(s->getDataPointer()))),
|
source(const_cast<char*>(static_cast<const char*>(s->getDataPointer()))),
|
||||||
target(const_cast<char*>(static_cast<const char*>(t->getDataPointer()))),
|
target(const_cast<char*>(static_cast<const char*>(t->getDataPointer()))),
|
||||||
elementSize(s->getElementSize()) {}
|
elementSize(s->getElementSize()) {}
|
||||||
|
|
||||||
PtrData(const PtrData& rhs):
|
PtrData(const PtrData& rhs):
|
||||||
source(rhs.source),
|
source(rhs.source),
|
||||||
target(rhs.target),
|
target(rhs.target),
|
||||||
elementSize(rhs.elementSize) {}
|
elementSize(rhs.elementSize) {}
|
||||||
|
|
||||||
PtrData& operator = (const PtrData& rhs)
|
PtrData& operator = (const PtrData& rhs)
|
||||||
{
|
{
|
||||||
source = rhs.source;
|
source = rhs.source;
|
||||||
@ -1315,13 +1327,13 @@ namespace GeometryUtilFunctions
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Geometry::checkForDeprecatedData()
|
bool Geometry::checkForDeprecatedData()
|
||||||
{
|
{
|
||||||
_containsDeprecatedData = false;
|
_containsDeprecatedData = false;
|
||||||
|
|
||||||
if (GeometryUtilFunctions::containsDeprecatedUsage(_vertexArray.get())) _containsDeprecatedData = true;
|
if (GeometryUtilFunctions::containsDeprecatedUsage(_vertexArray.get())) _containsDeprecatedData = true;
|
||||||
|
|
||||||
if (GeometryUtilFunctions::containsDeprecatedUsage(_normalArray.get())) _containsDeprecatedData = true;
|
if (GeometryUtilFunctions::containsDeprecatedUsage(_normalArray.get())) _containsDeprecatedData = true;
|
||||||
@ -1349,9 +1361,9 @@ bool Geometry::checkForDeprecatedData()
|
|||||||
void Geometry::fixDeprecatedData()
|
void Geometry::fixDeprecatedData()
|
||||||
{
|
{
|
||||||
if (!_containsDeprecatedData) return;
|
if (!_containsDeprecatedData) return;
|
||||||
|
|
||||||
bool containsBindPerPrimitive = false;
|
bool containsBindPerPrimitive = false;
|
||||||
|
|
||||||
OSG_NOTICE<<"Geometry::fixDeprecatedData()"<<std::endl;
|
OSG_NOTICE<<"Geometry::fixDeprecatedData()"<<std::endl;
|
||||||
|
|
||||||
// copy over attribute arrays.
|
// copy over attribute arrays.
|
||||||
@ -1392,10 +1404,10 @@ void Geometry::fixDeprecatedData()
|
|||||||
{
|
{
|
||||||
_containsDeprecatedData = false;
|
_containsDeprecatedData = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to expand bind per primitive entries.
|
// need to expand bind per primitive entries.
|
||||||
|
|
||||||
// count how many vertices are required
|
// count how many vertices are required
|
||||||
unsigned int numVertices = 0;
|
unsigned int numVertices = 0;
|
||||||
for(PrimitiveSetList::iterator itr = _primitives.begin();
|
for(PrimitiveSetList::iterator itr = _primitives.begin();
|
||||||
@ -1448,36 +1460,36 @@ void Geometry::fixDeprecatedData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate the arrays.
|
// allocate the arrays.
|
||||||
GeometryUtilFunctions::ArrayPairs perVertexArrays;
|
GeometryUtilFunctions::ArrayPairs perVertexArrays;
|
||||||
GeometryUtilFunctions::ArrayPairs perPrimitiveArrays;
|
GeometryUtilFunctions::ArrayPairs perPrimitiveArrays;
|
||||||
if (_vertexArray.valid()) GeometryUtilFunctions::duplicateArray(perVertexArrays, _vertexArray, numVertices);
|
if (_vertexArray.valid()) GeometryUtilFunctions::duplicateArray(perVertexArrays, _vertexArray, numVertices);
|
||||||
|
|
||||||
if (_normalArray.valid())
|
if (_normalArray.valid())
|
||||||
{
|
{
|
||||||
if (_normalArray->getBinding()==osg::Array::BIND_PER_VERTEX) GeometryUtilFunctions::duplicateArray(perVertexArrays, _normalArray, numVertices);
|
if (_normalArray->getBinding()==osg::Array::BIND_PER_VERTEX) GeometryUtilFunctions::duplicateArray(perVertexArrays, _normalArray, numVertices);
|
||||||
else if (_normalArray->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, _normalArray, numVertices);
|
else if (_normalArray->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, _normalArray, numVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_colorArray.valid())
|
if (_colorArray.valid())
|
||||||
{
|
{
|
||||||
if (_colorArray->getBinding()==osg::Array::BIND_PER_VERTEX) GeometryUtilFunctions::duplicateArray(perVertexArrays, _colorArray, numVertices);
|
if (_colorArray->getBinding()==osg::Array::BIND_PER_VERTEX) GeometryUtilFunctions::duplicateArray(perVertexArrays, _colorArray, numVertices);
|
||||||
else if (_colorArray->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, _colorArray, numVertices);
|
else if (_colorArray->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, _colorArray, numVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_secondaryColorArray.valid())
|
if (_secondaryColorArray.valid())
|
||||||
{
|
{
|
||||||
if (_secondaryColorArray->getBinding()==osg::Array::BIND_PER_VERTEX) GeometryUtilFunctions::duplicateArray(perVertexArrays, _secondaryColorArray, numVertices);
|
if (_secondaryColorArray->getBinding()==osg::Array::BIND_PER_VERTEX) GeometryUtilFunctions::duplicateArray(perVertexArrays, _secondaryColorArray, numVertices);
|
||||||
else if (_secondaryColorArray->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, _secondaryColorArray, numVertices);
|
else if (_secondaryColorArray->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, _secondaryColorArray, numVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_fogCoordArray.valid())
|
if (_fogCoordArray.valid())
|
||||||
{
|
{
|
||||||
if (_fogCoordArray->getBinding()==osg::Array::BIND_PER_VERTEX) GeometryUtilFunctions::duplicateArray(perVertexArrays, _fogCoordArray, numVertices);
|
if (_fogCoordArray->getBinding()==osg::Array::BIND_PER_VERTEX) GeometryUtilFunctions::duplicateArray(perVertexArrays, _fogCoordArray, numVertices);
|
||||||
else if (_fogCoordArray->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, _fogCoordArray, numVertices);
|
else if (_fogCoordArray->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, _fogCoordArray, numVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ArrayList::iterator itr = _texCoordList.begin();
|
for(ArrayList::iterator itr = _texCoordList.begin();
|
||||||
itr != _texCoordList.end();
|
itr != _texCoordList.end();
|
||||||
++itr)
|
++itr)
|
||||||
@ -1488,7 +1500,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
else if ((*itr)->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, *itr, numVertices);
|
else if ((*itr)->getBinding()==3 /*osg::Array::BIND_PER_PRIMITIVE*/) GeometryUtilFunctions::duplicateArray(perPrimitiveArrays, *itr, numVertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ArrayList::iterator itr = _vertexAttribList.begin();
|
for(ArrayList::iterator itr = _vertexAttribList.begin();
|
||||||
itr != _vertexAttribList.end();
|
itr != _vertexAttribList.end();
|
||||||
++itr)
|
++itr)
|
||||||
@ -1503,23 +1515,23 @@ void Geometry::fixDeprecatedData()
|
|||||||
typedef std::vector<GeometryUtilFunctions::PtrData> PtrList;
|
typedef std::vector<GeometryUtilFunctions::PtrData> PtrList;
|
||||||
PtrList perVertexPtrs;
|
PtrList perVertexPtrs;
|
||||||
PtrList perPrimitivePtrs;
|
PtrList perPrimitivePtrs;
|
||||||
|
|
||||||
for(GeometryUtilFunctions::ArrayPairs::iterator itr = perVertexArrays.begin();
|
for(GeometryUtilFunctions::ArrayPairs::iterator itr = perVertexArrays.begin();
|
||||||
itr != perVertexArrays.end();
|
itr != perVertexArrays.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
perVertexPtrs.push_back(GeometryUtilFunctions::PtrData(itr->first.get(), itr->second.get()));
|
perVertexPtrs.push_back(GeometryUtilFunctions::PtrData(itr->first.get(), itr->second.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(GeometryUtilFunctions::ArrayPairs::iterator itr = perPrimitiveArrays.begin();
|
for(GeometryUtilFunctions::ArrayPairs::iterator itr = perPrimitiveArrays.begin();
|
||||||
itr != perPrimitiveArrays.end();
|
itr != perPrimitiveArrays.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
perPrimitivePtrs.push_back(GeometryUtilFunctions::PtrData(itr->first.get(), itr->second.get()));
|
perPrimitivePtrs.push_back(GeometryUtilFunctions::PtrData(itr->first.get(), itr->second.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// start the primitiveNum at -1 as we increment it the first time through when
|
// start the primitiveNum at -1 as we increment it the first time through when
|
||||||
// we start processing the primitive sets.
|
// we start processing the primitive sets.
|
||||||
int primitiveNum = -1;
|
int primitiveNum = -1;
|
||||||
for(PrimitiveSetList::iterator itr = _primitives.begin();
|
for(PrimitiveSetList::iterator itr = _primitives.begin();
|
||||||
@ -1551,7 +1563,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
const DrawArrays* drawArray = static_cast<const DrawArrays*>(primitiveset);
|
const DrawArrays* drawArray = static_cast<const DrawArrays*>(primitiveset);
|
||||||
|
|
||||||
if (primLength==0) primLength = drawArray->getCount();
|
if (primLength==0) primLength = drawArray->getCount();
|
||||||
|
|
||||||
unsigned int primCount=0;
|
unsigned int primCount=0;
|
||||||
unsigned int indexEnd = drawArray->getFirst()+drawArray->getCount();
|
unsigned int indexEnd = drawArray->getFirst()+drawArray->getCount();
|
||||||
for(unsigned int vindex=drawArray->getFirst();
|
for(unsigned int vindex=drawArray->getFirst();
|
||||||
@ -1559,7 +1571,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
++vindex, ++target_vindex, ++primCount)
|
++vindex, ++target_vindex, ++primCount)
|
||||||
{
|
{
|
||||||
if ((primCount%primLength)==0) ++source_pindex;
|
if ((primCount%primLength)==0) ++source_pindex;
|
||||||
|
|
||||||
// copy bind per primitive from primitiveNum
|
// copy bind per primitive from primitiveNum
|
||||||
for(PtrList::iterator itr = perVertexPtrs.begin();
|
for(PtrList::iterator itr = perVertexPtrs.begin();
|
||||||
itr != perVertexPtrs.end();
|
itr != perVertexPtrs.end();
|
||||||
@ -1573,7 +1585,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
*target++ = *source++;
|
*target++ = *source++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy bind per vertex from vindex
|
// copy bind per vertex from vindex
|
||||||
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
||||||
itr != perPrimitivePtrs.end();
|
itr != perPrimitivePtrs.end();
|
||||||
@ -1607,7 +1619,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
++vindex, ++target_vindex, ++primCount)
|
++vindex, ++target_vindex, ++primCount)
|
||||||
{
|
{
|
||||||
if ((primCount%localPrimLength)==0) ++source_pindex;
|
if ((primCount%localPrimLength)==0) ++source_pindex;
|
||||||
|
|
||||||
// copy bind per primitive from primitiveNum
|
// copy bind per primitive from primitiveNum
|
||||||
for(PtrList::iterator itr = perVertexPtrs.begin();
|
for(PtrList::iterator itr = perVertexPtrs.begin();
|
||||||
itr != perVertexPtrs.end();
|
itr != perVertexPtrs.end();
|
||||||
@ -1621,7 +1633,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
*target++ = *source++;
|
*target++ = *source++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy bind per vertex from vindex
|
// copy bind per vertex from vindex
|
||||||
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
||||||
itr != perPrimitivePtrs.end();
|
itr != perPrimitivePtrs.end();
|
||||||
@ -1651,7 +1663,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
{
|
{
|
||||||
if ((primCount%primLength)==0) ++source_pindex;
|
if ((primCount%primLength)==0) ++source_pindex;
|
||||||
unsigned int vindex=*primItr;
|
unsigned int vindex=*primItr;
|
||||||
|
|
||||||
// copy bind per primitive from primitiveNum
|
// copy bind per primitive from primitiveNum
|
||||||
for(PtrList::iterator itr = perVertexPtrs.begin();
|
for(PtrList::iterator itr = perVertexPtrs.begin();
|
||||||
itr != perVertexPtrs.end();
|
itr != perVertexPtrs.end();
|
||||||
@ -1665,7 +1677,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
*target++ = *source++;
|
*target++ = *source++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy bind per vertex from vindex
|
// copy bind per vertex from vindex
|
||||||
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
||||||
itr != perPrimitivePtrs.end();
|
itr != perPrimitivePtrs.end();
|
||||||
@ -1708,7 +1720,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
*target++ = *source++;
|
*target++ = *source++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy bind per vertex from vindex
|
// copy bind per vertex from vindex
|
||||||
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
||||||
itr != perPrimitivePtrs.end();
|
itr != perPrimitivePtrs.end();
|
||||||
@ -1751,7 +1763,7 @@ void Geometry::fixDeprecatedData()
|
|||||||
*target++ = *source++;
|
*target++ = *source++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy bind per vertex from vindex
|
// copy bind per vertex from vindex
|
||||||
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
for(PtrList::iterator itr = perPrimitivePtrs.begin();
|
||||||
itr != perPrimitivePtrs.end();
|
itr != perPrimitivePtrs.end();
|
||||||
@ -1774,6 +1786,6 @@ void Geometry::fixDeprecatedData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_containsDeprecatedData = false;
|
_containsDeprecatedData = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user