Changeset 559

Show
Ignore:
Timestamp:
02/21/07 15:48:53 (2 years ago)
Author:
dirk
Message:

Added patch to more gracefully handle varying index types (Thanks to Toni Bleile for the patch!)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/System/FileIO/OBJ/OSGOBJSceneFileType.cpp

    r467 r559  
    319319                    else if (meshIndexMask != indexMask) 
    320320                    { 
    321                         FFATAL (( "IndexMask unmatch, can not create geo\n")); 
    322                         meshIndexMask = 0; 
    323                         break; 
     321                        // consider this real-world example: 
     322                       // [...] 
     323                       // f 1603//1747 1679//1744 1678//1743 
     324                       // s 1 
     325                       // f 9/1/10 5/2/9 1680/3/1748 1681/4/174 
     326                       // [...] 
     327                       // Some faces contain texture coords and others do not. 
     328                       // The old version did just skip this geometry. 
     329                       // This version should continue if there's at least 
     330                       // the vertex index 
     331                       // I've seen the change in the maskIndex only after a smooth group, 
     332                       // so it's perhaps smarter to not ignore the smooth group further up in this code 
     333                       if( !(indexMask & 1) )   
     334                       { 
     335                         // if there are vertex indices there's no reason to get in here 
     336                          FFATAL (( "IndexMask unmatch, can not create geo\n")); 
     337                          meshIndexMask = 0; 
     338                          break; 
     339                       } 
     340                       else 
     341                       { 
     342                         // consider the minimum similarities of mesh masks 
     343                         meshIndexMask &= indexMask; 
     344                       } 
    324345                    } 
    325346                } 
     
    340361                geoPtr->setTypes     ( typePtr ); 
    341362 
    342                 if ( texCoordPtr->size() > 0 ) 
     363                if ( (meshIndexMask & 2) && texCoordPtr->size() > 0 ) 
    343364                { 
    344365                    geoPtr->setTexCoords ( texCoordPtr ); 
     
    352373                } 
    353374 
    354                 if ( normalPtr->size() > 0 ) 
     375                if ( (meshIndexMask & 4) && normalPtr->size() > 0 ) 
    355376                { 
    356377                    geoPtr->setNormals   ( normalPtr );