Clean up up osg::Geometry, removing long deprecated support for array indices and BIND_PER_PRIMITIVE binding that forced OpenGL slow paths. osg::Geometry is now smaller and only supports OpenGL fasts paths.

New methods osg::Geometry::containsDeprecatedData() and osg::Geometry::fixDeprecatedData() provide a means for converting geometries that still use the array indices and BIND_PER_PRIMITIVE across to complient
versions.

Cleaned up the rest of the OSG where use of array indices and BIND_PER_PRIMITIVE were accessed or used.
This commit is contained in:
Robert Osfield
2013-06-18 11:18:28 +00:00
parent 05b72e9b4c
commit 7d40c7258f
35 changed files with 1379 additions and 2880 deletions

View File

@@ -40,8 +40,6 @@ MorphGeometry::MorphGeometry(const osg::Geometry& b) :
setUpdateCallback(new UpdateVertex);
setDataVariance(osg::Object::DYNAMIC);
setUseVertexBufferObjects(true);
if (b.getInternalOptimizedGeometry())
computeInternalOptimizedGeometry();
}
MorphGeometry::MorphGeometry(const MorphGeometry& b, const osg::CopyOp& copyop) :
@@ -55,8 +53,6 @@ MorphGeometry::MorphGeometry(const MorphGeometry& b, const osg::CopyOp& copyop)
{
setUseDisplayList(false);
setUseVertexBufferObjects(true);
if (b.getInternalOptimizedGeometry())
computeInternalOptimizedGeometry();
}
void MorphGeometry::transformSoftwareMethod()
@@ -65,8 +61,6 @@ void MorphGeometry::transformSoftwareMethod()
{
// See if we have an internal optimized geometry
osg::Geometry* morphGeometry = this;
if (_internalOptimizedGeometry.valid())
morphGeometry = _internalOptimizedGeometry.get();
osg::Vec3Array* pos = dynamic_cast<osg::Vec3Array*>(morphGeometry->getVertexArray());
if (pos && _positionSource.size() != pos->size())
@@ -134,9 +128,7 @@ void MorphGeometry::transformSoftwareMethod()
if (_morphTargets[i].getWeight() > 0)
{
// See if any the targets use the internal optimized geometry
osg::Geometry* targetGeometry = _morphTargets[i].getGeometry()->getInternalOptimizedGeometry();
if (!targetGeometry)
targetGeometry = _morphTargets[i].getGeometry();
osg::Geometry* targetGeometry = _morphTargets[i].getGeometry();
osg::Vec3Array* targetPos = dynamic_cast<osg::Vec3Array*>(targetGeometry->getVertexArray());
osg::Vec3Array* targetNormals = dynamic_cast<osg::Vec3Array*>(targetGeometry->getNormalArray());

View File

@@ -153,28 +153,28 @@ void RigGeometry::copyFrom(osg::Geometry& from)
if (!copyToSelf) target.setVertexArray(from.getVertexArray());
}
target.setNormalBinding(from.getNormalBinding());
if (from.getNormalArray())
{
if (!copyToSelf) target.setNormalArray(from.getNormalArray());
target.setNormalBinding(from.getNormalBinding());
}
target.setColorBinding(from.getColorBinding());
if (from.getColorArray())
{
if (!copyToSelf) target.setColorArray(from.getColorArray());
target.setColorBinding(from.getColorBinding());
}
target.setSecondaryColorBinding(from.getSecondaryColorBinding());
if (from.getSecondaryColorArray())
{
if (!copyToSelf) target.setSecondaryColorArray(from.getSecondaryColorArray());
target.setSecondaryColorBinding(from.getSecondaryColorBinding());
}
target.setFogCoordBinding(from.getFogCoordBinding());
if (from.getFogCoordArray())
{
if (!copyToSelf) target.setFogCoordArray(from.getFogCoordArray());
target.setFogCoordBinding(from.getFogCoordBinding());
}
for(unsigned int ti=0;ti<from.getNumTexCoordArrays();++ti)
@@ -185,13 +185,13 @@ void RigGeometry::copyFrom(osg::Geometry& from)
}
}
ArrayDataList& arrayList = from.getVertexAttribArrayList();
osg::Geometry::ArrayList& arrayList = from.getVertexAttribArrayList();
for(unsigned int vi=0;vi< arrayList.size();++vi)
{
ArrayData& arrayData = arrayList[vi];
if (arrayData.array.valid())
osg::Array* array = arrayList[vi].get();
if (array)
{
if (!copyToSelf) target.setVertexAttribData(vi,arrayData);
if (!copyToSelf) target.setVertexAttribArray(vi,array);
}
}
}

View File

@@ -250,7 +250,7 @@ bool RigTransformHardware::init(RigGeometry& geom)
std::stringstream ss;
ss << "boneWeight" << i;
program->addBindAttribLocation(ss.str(), attribIndex + i);
geom.setVertexAttribData(attribIndex + i, osg::Geometry::ArrayData(getVertexAttrib(i),osg::Geometry::BIND_PER_VERTEX));
geom.setVertexAttribArray(attribIndex + i, getVertexAttrib(i));
OSG_INFO << "set vertex attrib " << ss.str() << std::endl;
}
program->addShader(_shader.get());