Hi Robert,

Robert Osfield schrieb:
Hi Peter,

On Tue, Oct 6, 2009 at 8:53 AM, Peter Hrenka
<[email protected]> wrote:
Hi Robert,

After the major rewrite of the BufferObject-management the original
submission is mostly obsolete. The only remaining issue is the typo and
missing early exit in Geometry::getOrCreateElementBufferObject().

I have attached a modified version of Geometry.cpp based on SVN 10604.

Many thanks for the eagled review, spotting the lack of fix to the bug
in Geometry::getOrCreateElementBufferObject() is impressive.  I've
just reviewed the original code and your fix, and while the fix is
correct and feel that it's original code is actually a bit perverse -
it's more complicated than it should be so I've re-written it to read:

osg::VertexBufferObject* Geometry::getOrCreateVertexBufferObject()
{
    ArrayList arrayList;
    getArrayList(arrayList);

    ArrayList::iterator vitr;
    for(vitr = arrayList.begin();
        vitr != arrayList.end();
        ++vitr)
    {
        osg::Array* array = *vitr;
        if (array->getVertexBufferObject()) return
array->getVertexBufferObject();
    }

    return new osg::VertexBufferObject;
}

osg::ElementBufferObject* Geometry::getOrCreateElementBufferObject()
{
    DrawElementsList drawElementsList;
    getDrawElementsList(drawElementsList);

    DrawElementsList::iterator deitr;
    for(deitr = drawElementsList.begin();
        deitr != drawElementsList.end();
        ++deitr)
    {
        osg::DrawElements* elements = *deitr;
        if (elements->getElementBufferObject()) return
elements->getElementBufferObject();
    }

    return new osg::ElementBufferObject;
}


This looks much clearer.

This is also now checked into svn/trunk.  I don't fully trust myself
to not make a mistake so would you do a code review of these changes
as QA.

Right now the version I am seeing at
http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk
is still 10604...


Thanks,
Robert.

Cheers,

Peter

--
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to