Show
Ignore:
Timestamp:
03/11/09 13:42:44 (6 years ago)
Author:
robert
Message:

From Lionel Lagarde, "the attachment contains a correction of the Optimizer::MergeGeometryVisitor?.
When 2 geometries are merged, the primitive sets of the second geometry
are copied to the first geometry.

The primitive sets were copied with a std::insert into the first geometry
primitive set vector. It doesn't work when the geometry is using VBOs (because
the element buffer object of the primitive set is not updated).

The correction replaces

lhs.getPrimitiveSetList().insert( lhs.getPrimitiveSetList().end(),

rhs.getPrimitiveSetList().begin(),
rhs.getPrimitiveSetList().end() );

by

for( primItr=rhs.getPrimitiveSetList().begin();

primItr!=rhs.getPrimitiveSetList().end();
++primItr )

{

lhs.addPrimitiveSet(primItr->get());

}
"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgUtil/Optimizer.cpp

    • Property svn:mergeinfo set to
      /OpenSceneGraph/trunk/include/osg/src/osgUtil/Optimizer.cpp:9882
      /OpenSceneGraph/trunk/src/osgUtil/Optimizer.cpp:9902
    r9702 r9903  
    24162416 
    24172417    // shift the indices of the incoming primitives to account for the pre existing geometry. 
    2418     for(osg::Geometry::PrimitiveSetList::iterator primItr=rhs.getPrimitiveSetList().begin(); 
    2419         primItr!=rhs.getPrimitiveSetList().end(); 
    2420         ++primItr) 
     2418    osg::Geometry::PrimitiveSetList::iterator primItr; 
     2419    for(primItr=rhs.getPrimitiveSetList().begin(); primItr!=rhs.getPrimitiveSetList().end(); ++primItr) 
    24212420    { 
    24222421        osg::PrimitiveSet* primitive = primItr->get(); 
     2422         
    24232423        switch(primitive->getType()) 
    24242424        { 
     
    24872487            break; 
    24882488        } 
    2489  
    2490          
    2491     } 
    2492      
    2493     lhs.getPrimitiveSetList().insert(lhs.getPrimitiveSetList().end(), 
    2494                                      rhs.getPrimitiveSetList().begin(),rhs.getPrimitiveSetList().end()); 
     2489    } 
     2490     
     2491    for(primItr=rhs.getPrimitiveSetList().begin(); primItr!=rhs.getPrimitiveSetList().end(); ++primItr) 
     2492    { 
     2493        lhs.addPrimitiveSet(primItr->get()); 
     2494    } 
    24952495 
    24962496    lhs.dirtyBound();