Changeset 7075

Show
Ignore:
Timestamp:
07/06/07 15:33:40 (7 years ago)
Author:
robert
Message:

From Brede Johansen, "Attached is a fix that returns a default color (white) if an invalid
index to the color palette is used."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/Pools.cpp

    r5375 r7075  
    2121        bool fixedIntensity = (indexIntensity & 0x1000) ? true : false; 
    2222        unsigned int index = (fixedIntensity) ? (indexIntensity & 0x0fff)+(4096>>7) : indexIntensity >> 7; 
    23         assert(index<size()); 
    24         osg::Vec4 col = at(index); 
     23 
     24        if (index>=size()) 
     25        { 
     26            // color index not available. 
     27            return osg::Vec4(1,1,1,1); 
     28        } 
     29 
     30        osg::Vec4 col =  operator[](index); 
    2531        if (!fixedIntensity) 
    2632        { 
     
    3642        // bit 0-6:  intensity 
    3743        // bit 7-15  color index 
    38         int index = indexIntensity >> 7; 
     44        unsigned int index = indexIntensity >> 7; 
    3945 
    40         if (index<0 || index>=(int)size()) 
     46        if (index>=size()) 
    4147        { 
    4248            // color index not available. 
     
    4450        } 
    4551 
    46         osg::Vec4 col = at(index); 
     52        osg::Vec4 col =  operator[](index); 
    4753        float intensity = (float)(indexIntensity & 0x7f)/127.f; 
    4854        col[0] *= intensity;