move
scrawl 9 years ago
parent 9f03982e0b
commit 1abb77f8a1

@ -94,33 +94,16 @@ void RigGeometry::setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeometry)
if (from.getStateSet()) if (from.getStateSet())
setStateSet(from.getStateSet()); setStateSet(from.getStateSet());
// copy over primitive sets. // shallow copy primitive sets & vertex attributes that we will not modify
getPrimitiveSetList() = from.getPrimitiveSetList(); getPrimitiveSetList() = from.getPrimitiveSetList();
if (from.getColorArray())
setColorArray(from.getColorArray()); setColorArray(from.getColorArray());
if (from.getSecondaryColorArray())
setSecondaryColorArray(from.getSecondaryColorArray()); setSecondaryColorArray(from.getSecondaryColorArray());
if (from.getFogCoordArray())
setFogCoordArray(from.getFogCoordArray()); setFogCoordArray(from.getFogCoordArray());
setTexCoordArrayList(from.getTexCoordArrayList());
setVertexAttribArrayList(from.getVertexAttribArrayList());
for(unsigned int ti=0;ti<from.getNumTexCoordArrays();++ti) // vertices and normals are modified every frame, so we need to deep copy them.
{ // assign a dedicated VBO to make sure that modifications don't interfere with source geometry's VBO.
if (from.getTexCoordArray(ti))
setTexCoordArray(ti,from.getTexCoordArray(ti));
}
osg::Geometry::ArrayList& arrayList = from.getVertexAttribArrayList();
for(unsigned int vi=0;vi< arrayList.size();++vi)
{
osg::Array* array = arrayList[vi].get();
if (array)
setVertexAttribArray(vi,array);
}
osg::ref_ptr<osg::VertexBufferObject> vbo (new osg::VertexBufferObject); osg::ref_ptr<osg::VertexBufferObject> vbo (new osg::VertexBufferObject);
vbo->setUsage(GL_DYNAMIC_DRAW_ARB); vbo->setUsage(GL_DYNAMIC_DRAW_ARB);

@ -36,6 +36,8 @@ namespace SceneUtil
void setInfluenceMap(osg::ref_ptr<InfluenceMap> influenceMap); void setInfluenceMap(osg::ref_ptr<InfluenceMap> influenceMap);
/// Initialize this geometry from the source geometry.
/// @note The source geometry will not be modified.
void setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeom); void setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeom);
// Called automatically by our CullCallback // Called automatically by our CullCallback

Loading…
Cancel
Save