Hi Robert,

I have been chasing a bug in our osg-based application where a color change resulted in a broken geometry (which uses VertexBufferObjects).

The update of the VBO does not seem to work when "copyAll" is false
(i.e. total size did not change) and not all Arrays are modified:

VertexBufferObject::compileBuffer(State& state) const
{
    [...]
    unsigned int offset = 0;
for(BufferEntryArrayPairs::const_iterator itr = _bufferEntryArrayPairs.begin();
        itr != _bufferEntryArrayPairs.end();
        ++itr)
    {
        const BufferEntryArrayPair& bep = *itr;
        const Array* de = bep.second;
        if (de)
        {
           if (copyAll ||
bep.first.modifiedCount[contextID] != bep.second->getModifiedCount() ||
                bep.first.dataSize != bep.second->getTotalDataSize())
            {
                // copy data across
                bep.first.dataSize = bep.second->getTotalDataSize();
bep.first.modifiedCount[contextID] = de->getModifiedCount();
                if (copyAll)
                {
                    bep.first.offset = offset;
                    de->setVertexBufferObjectOffset((GLvoid*)offset);
                    offset += bep.first.dataSize;
                }
     [...]

The "offset" variable is only updated when the particular Array
has changed. If only the second of two arrays changes it writes at offset 0 (where the first array starts) so both arrays will have an
offset of 0.

I think a proper fix which also properly handles array additions/removals would have to use free-lists (or some
other memory management scheme).

I can not think of a simple fix which still minimizes updates.

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

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to