Skip to content

Vertex Array Management Problem #915

@cj-mcdonald

Description

@cj-mcdonald

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions