Hi all -- I've attached a test file that demonstrates a mismatch in the behavior
of the native OSG plugins and the osgUtil Optimizer. In a nutshell, when
FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS copies a subgraph, it
fails to set the DEEP_COPY_PRIMITIVES flag bit, resulting in PrimitiveSet
instances being shared by the copied Geometry objects (Optimizer.cpp 4666).
However, none of the native serializers (.osg, .ive, .osgt, or .osgb) support
shared PrimitiveSets.
You can reproduce the resulting inconsistency with the following steps:
set OSG_NOTIFY_LEVEL=INFO
set
OSG_OPTIMIZER=FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS:MERGE_GEOMETRY
osgconv test.osg result.osg
This incorrectly fails to merge the Geometry objects because the shared
PrimitiveSets created in the first pass prevent the merging of Geometry objects.
(Output shows 4 Geometry objects, indicating a failure to merge.)
In contrast:
set OSG_OPTIMIZER=FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS
osgconv test.osg intermed.osg
set OSG_OPTIMIZER=MERGE_GEOMETRY
osgconv intermed.osg result.osg
This process correctly merges the Geometry objects, because going out to file
eliminates the shared PrimitiveSets, allowing the MERGE_GEOMETRY to correctly
perform its task. (Output shows 2 Geometry objects, indicating a successful merge.)
Intuitively, both cases should behave the same, either they should both merge,
or both fail to merge. My preference would be to deep copy the PrimitiveSets in
the Optimizer so that both cases merge. Are there any reasons why I shouldn't
proceed with such a fix?
Thanks,
--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/
Group {
DataVariance STATIC
name "paul.osg"
nodeMask 0xffffffff
cullingActive TRUE
num_children 2
MatrixTransform {
DataVariance STATIC
nodeMask 0xffffffff
cullingActive TRUE
referenceFrame RELATIVE
Matrix {
1 0 0 0
0 1 0 0
0 0 1 0
-5 0 0 1
}
num_children 1
Geode {
UniqueID Geode_0
DataVariance STATIC
nodeMask 0xffffffff
cullingActive TRUE
num_drawables 2
Geometry {
DataVariance STATIC
useDisplayList TRUE
useVertexBufferObjects FALSE
PrimitiveSets 2
{
DrawElementsUInt TRIANGLES 12
{
0 1 2 2 1 3 2 3 4 4
3 5
}
DrawElementsUInt TRIANGLES 6
{
1 6 3 3 6 5
}
}
VertexArray Vec3Array 7
{
-1 0 -1
0 0 -1
-1 0 0
0 0 0
-1 0 1
0 0 1
1 0 0
}
NormalBinding PER_VERTEX
NormalArray Vec3Array 7
{
0 -1 0
0 -1 0
0 -1 0
0 -1 0
0 -1 0
0 -1 0
0 -1 0
}
ColorBinding OVERALL
ColorArray Vec4Array 1
{
1 .2 1 1
}
}
Geometry {
DataVariance STATIC
useDisplayList TRUE
useVertexBufferObjects FALSE
PrimitiveSets 1
{
DrawElementsUInt TRIANGLES 9
{
0 1 2 2 1 3 3 1 4
}
}
VertexArray Vec3Array 5
{
-1 0 4
0 0 4
-1 0 5
1 0 5
1 0 4
}
NormalBinding PER_VERTEX
NormalArray Vec3Array 5
{
0 -1 0
0 -1 0
0 -1 0
0 -1 0
0 -1 0
}
ColorBinding OVERALL
ColorArray Vec4Array 1
{
1 .2 1 1
}
}
}
}
MatrixTransform {
DataVariance STATIC
nodeMask 0xffffffff
cullingActive TRUE
referenceFrame RELATIVE
Matrix {
1 0 0 0
0 1 0 0
0 0 1 0
5 0 0 1
}
num_children 1
Use Geode_0
}
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org