From Marc Helbling, "please find a fix for the vertex pretransform visitor (VertexAccessOrderVisitor).

The issue with current code is that arrays are collected *before* duplicating shared arrays which leads to arrays that are correctly duplicated but that are not reordered.

Also the submitted patch contains a small cleaning in GeometryArrayGathrer as the _useDrawElements variable is not used; it is only set in the GeometryArrayGathrer constructor and VertexAccessOrderVisitor already checks that primitives have indexed type."


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14403 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-08-08 16:09:39 +00:00
parent 973ac76197
commit 89786dd42a

View File

@@ -60,7 +60,6 @@ struct GeometryArrayGatherer
typedef std::vector<osg::Array*> ArrayList;
GeometryArrayGatherer(osg::Geometry& geometry)
: _useDrawElements(true)
{
add(geometry.getVertexArray());
add(geometry.getNormalArray());
@@ -97,9 +96,6 @@ struct GeometryArrayGatherer
}
ArrayList _arrayList;
// True if geometry contains bindings that are compatible with
// DrawElements.
bool _useDrawElements;
};
// Compare vertices in a mesh using all their attributes. The vertices
@@ -1124,9 +1120,6 @@ void VertexAccessOrderVisitor::optimizeOrder(Geometry& geom)
if (!vertArray)
return;
Geometry::PrimitiveSetList& primSets = geom.getPrimitiveSetList();
GeometryArrayGatherer gatherer(geom);
if (!gatherer._useDrawElements)
return;
VertexReorder vr(vertArray->getNumElements());
for (Geometry::PrimitiveSetList::iterator itr = primSets.begin(),
end = primSets.end();
@@ -1144,6 +1137,7 @@ void VertexAccessOrderVisitor::optimizeOrder(Geometry& geom)
// duplicate shared arrays as it isn't safe to rearrange vertices when arrays are shared.
if (geom.containsSharedArrays()) geom.duplicateSharedArrays();
GeometryArrayGatherer gatherer(geom);
Remapper remapper(vr.remap);
gatherer.accept(remapper);