From b622a9917814044f134d2085d11d42c6acaa913b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 28 Oct 2010 14:01:47 +0000 Subject: [PATCH] Added handling of vertex buffer objects into osg::Geometry copy constructor. --- include/osg/CopyOp | 3 +++ src/osg/Geometry.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/osg/CopyOp b/include/osg/CopyOp index eff881fee..7ad159b18 100644 --- a/include/osg/CopyOp +++ b/include/osg/CopyOp @@ -64,6 +64,9 @@ class OSG_EXPORT CopyOp inline CopyOp(CopyFlags flags=SHALLOW_COPY):_flags(flags) {} virtual ~CopyOp() {} + void setCopyFlags(CopyFlags flags) { _flags = flags; } + CopyFlags getCopyFlags() const { return _flags; } + virtual Referenced* operator() (const Referenced* ref) const; virtual Object* operator() (const Object* obj) const; virtual Node* operator() (const Node* node) const; diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index 0473ee573..5a6df8a14 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -79,6 +79,18 @@ Geometry::Geometry(const Geometry& geometry,const CopyOp& copyop): { _vertexAttribList.push_back(ArrayData(*vitr, copyop)); } + + if ((copyop.getCopyFlags() & osg::CopyOp::DEEP_COPY_ARRAYS)) + { + if (_useVertexBufferObjects) + { + // copying of arrays doesn't set up buffer objects so we'll need to force + // Geometry to assign these, we'll do this by switching off VBO's then renabling them. + setUseVertexBufferObjects(false); + setUseVertexBufferObjects(true); + } + } + } Geometry::~Geometry()