Skip to content

Vertex Array Management Problem #915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cj-mcdonald opened this issue Feb 21, 2020 · 1 comment
Open

Vertex Array Management Problem #915

cj-mcdonald opened this issue Feb 21, 2020 · 1 comment

Comments

@cj-mcdonald
Copy link
Contributor

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:

    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

@mp3butcher
Copy link
Contributor

mp3butcher commented Mar 24, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants