diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp index c2a202342..5a12b5b4f 100644 --- a/components/sceneutil/riggeometry.cpp +++ b/components/sceneutil/riggeometry.cpp @@ -71,8 +71,7 @@ RigGeometry::RigGeometry() setCullCallback(new UpdateRigGeometry); setUpdateCallback(new UpdateRigBounds); setSupportsDisplayList(false); - //setUseVertexBufferObjects(true); - //getOrCreateVertexBufferObject()->setUsage(GL_DYNAMIC_DRAW_ARB); + setUseVertexBufferObjects(true); setComputeBoundingBoxCallback(new DummyComputeBoundCallback); } @@ -121,8 +120,23 @@ void RigGeometry::setSourceGeometry(osg::ref_ptr sourceGeometry) setVertexAttribArray(vi,array); } - setVertexArray(dynamic_cast(from.getVertexArray()->clone(osg::CopyOp::DEEP_COPY_ALL))); - setNormalArray(dynamic_cast(from.getNormalArray()->clone(osg::CopyOp::DEEP_COPY_ALL)), osg::Array::BIND_PER_VERTEX); + + osg::ref_ptr vbo (new osg::VertexBufferObject); + vbo->setUsage(GL_DYNAMIC_DRAW_ARB); + + osg::ref_ptr vertexArray = osg::clone(from.getVertexArray(), osg::CopyOp::DEEP_COPY_ALL); + if (vertexArray) + { + vertexArray->setVertexBufferObject(vbo); + setVertexArray(vertexArray); + } + + osg::ref_ptr normalArray = osg::clone(from.getNormalArray(), osg::CopyOp::DEEP_COPY_ALL); + if (normalArray) + { + normalArray->setVertexBufferObject(vbo); + setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX); + } } bool RigGeometry::initFromParentSkeleton(osg::NodeVisitor* nv)