Hi Gerrit,

Are you still around? I have a program crash in the setup of the GeoPump data 
and I would like to hear your opinion. I have the following scenario: I have a 
Geometry core that is filled with usual data (length, types, props, ...) and 
this renders fine. Now, during a dynamic operation on the geometry, the mesh 
degrades and the length and types becomes empty. That leads to a program crash 
in the following code place:

In file OSGGeoSplitVertexArrayPumpGroup.cpp line 133

namespace
{
    // collect info for property in 'slot'
    bool pumpGLSetup(PumpData &info, UInt16 slot)
    {
        ...
        if(info.attribPtr[slot]              != NULL  &&
           info.attribPtr[slot]->getIgnore() == false   )
        {
            info.attribData  [slot] = info.attribPtr[slot]->getData();
            ...
        ...
    }
}

The crash happens in the getData access function, which assumes that the 
property has at least one element, i.e. it accesses vector index 0.

I have added the following additional code into this function and the related 
functions of the other PumpGroups:

    // collect info for property in 'slot'
    bool pumpGLSetup(PumpData &info, UInt16 slot)
    {
        bool retVal = false;

        if(slot < info.prop->size())
           info.attribPtr[slot] = (*info.prop)[slot];

        if(slot < info.propIdx->size())
            info.attribIndex[slot] = (*info.propIdx)[slot];

        if (info.attribPtr[slot]         != NULL &&                          // 
NEW
            info.attribPtr[slot]->size() == 0      )                            
// NEW
            info.attribPtr[slot] = NULL;                                        
    // NEW

        if(info.attribPtr[slot]              != NULL  &&
           info.attribPtr[slot]->getIgnore() == false   )
        {
            info.attribData  [slot] = info.attribPtr[slot]->getData();
            info.attribStride[slot] = info.attribPtr[slot]->getStride();

            if(info.attribStride[slot] == 0)
            {
                info.attribStride[slot] =
                    info.attribPtr[slot]->getFormatSize() *
                    info.attribPtr[slot]->getDimension();
            }

            retVal = true;
        }

        return retVal;
    }

This way the info.attribPtr[slot] stays zero and the calling code of the 
function filters the empty props case:

bool GeoSplitVertexArrayPumpGroup::masterClassicGeoSetupPump(...)
{
    ...
    // Setup: get all the data
    PumpData       pumpData;

    pumpData.lengths = lengths;
    pumpData.types   = types;
    pumpData.prop    = prop;
    pumpData.propIdx = propIdx;

    UInt16 nattrib = prop->size32();

    for(UInt16 i = 0; i < nattrib; ++i)
    {
        if(pumpGLSetup(pumpData, i) == false)
            continue;
    }

    // we need positions
    if(pumpData.attribPtr[0]              == NULL ||    // catches the situation
       pumpData.attribPtr[0]->getUseVBO() == false)
    {
        ...
    }
    ...
}

Now my question is whether this is a good solution to circumvent the program 
crash?
Do I have overseen some crucial point?
Do you have a better solution in mind?

In my opinion the situation, that the geometry carries empty properties should 
be valid.
What is your opinion?

I hope you still read the mailing list and have some time to give me an answer 
to my problem.

Best,
Johannes


_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to