You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered a vertex array management issue running OSG 3.6.5.
As part of my application, in response to a user input event, a geometry has to be replaced. The old geometry is removed from the scene graph (and deleted as it has no more references) and the new geometry is created. The geometry is created with a new osg::Geometry and a new osg::Vec3Array vertex array. It is very simple, but sometimes the display gets corrupted.
What is going wrong is that sometimes during the update the new Vec3Array vertex array is created at exactly the same memory address as the vertex array which has just been deleted with the old geometry. This happens quite often on Windows, I haven't seen it on Linux. Having a new array with exactly the same address as the deleted array confuses OSG. The problem appears to be in VertexArrayState.cpp, VertexArrayState::setArray line 750:
else if (new_array!=vad->array || new_array->getModifiedCount()!=vad->modifiedCount)
{
.........
The old and new arrays have the same address, and their modifiedCounts are both zero because the arrays are not modified at all after being created. So it is assumed that they are they same object, when they are not.
I'm working round the issue in the affected area of my application by immediately applying a modifiedCount to the Vec3Arrays when created, based on an incrementing counter. So VertexArrayState then sees them as different objects. But there is an underlying problem lurking. I wondered if the vad->array should be an observer_ptr, instead of a raw pointer.
Regards
Colin McDonald
The text was updated successfully, but these errors were encountered:
As a workaround, i guess you should create newGeometry before substitute oldGeometry with newGeometry in the sceneGraph...
Could you experiment with openscenegraph/SceneGraphTestBed#1 to reproduce the bug?
Hi Robert,
I've encountered a vertex array management issue running OSG 3.6.5.
As part of my application, in response to a user input event, a geometry has to be replaced. The old geometry is removed from the scene graph (and deleted as it has no more references) and the new geometry is created. The geometry is created with a new osg::Geometry and a new osg::Vec3Array vertex array. It is very simple, but sometimes the display gets corrupted.
What is going wrong is that sometimes during the update the new Vec3Array vertex array is created at exactly the same memory address as the vertex array which has just been deleted with the old geometry. This happens quite often on Windows, I haven't seen it on Linux. Having a new array with exactly the same address as the deleted array confuses OSG. The problem appears to be in VertexArrayState.cpp, VertexArrayState::setArray line 750:
The old and new arrays have the same address, and their modifiedCounts are both zero because the arrays are not modified at all after being created. So it is assumed that they are they same object, when they are not.
I'm working round the issue in the affected area of my application by immediately applying a modifiedCount to the Vec3Arrays when created, based on an incrementing counter. So VertexArrayState then sees them as different objects. But there is an underlying problem lurking. I wondered if the vad->array should be an observer_ptr, instead of a raw pointer.
Regards
Colin McDonald
The text was updated successfully, but these errors were encountered: