I've recently started using OpenSceneGraph. I'm wondering how it deals with memory management( if at all ). For example, we have the geometry class. The geometry class accepts arrays of vertices, colours, texture coordinates as you'd expect. Except, it expects these things as a pointer to an object:
void Geometry::setVertexArray(Array* array)
{
if (array && array->getBinding()==osg::Array::BIND_UNDEFINED) array->setBinding(osg::Array::BIND_PER_VERTEX);
_vertexArray = array;
dirtyDisplayList();
dirtyBound();
if (_useVertexBufferObjects && array) addVertexBufferObjectIfRequired(array);
}
This is from the OpenSceneGraph source code. As you can see an Array* is passed to the method, which is expected to be allocated by the user. If that's the case, who deletes it? Obviously not OSG( and that makes sense ), because we can see that it blindly overwrites the last array pointer when a new one is assigned. This is fine, however now the user must make sure that the array they allocated outlives the geometry class. Also for every array the user gives this geometry object, they must keep a reference to this array.
This leaves us with an absurd amount of pointers that must be deleted only after the object is deleted. The result is I'm finding this very cumbersome to use. Am I missing something here? Why is the system designed like this?