Changeset 6297

Show
Ignore:
Timestamp:
03/01/07 14:41:28
Author:
robert
Message:

Changed the index value to 0 of the token vector, wheras original the 1 was used, the
later causing a crash when only one token was available. Also clean up #if #else #endif
block to help make the code more readable and maintainable. This bug and fix
was found by Anders Backman, but final implementation done by Robert Osfield.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph/trunk/src/osgPlugins/directx/mesh.cpp

    r5224 r6297  
    241241            continue; 
    242242 
    243         // dgm - check for "{ <material name> }" for a 
     243        // check for "{ <material name> }" for a 
    244244        // material which was declared globally  
    245 #if 1 
    246         Material * material = _obj->findMaterial(token[1]); 
    247         if (material)
     245        Material * material = _obj->findMaterial(token[0]); 
     246        if (material) 
     247       
    248248            _materialList->material.push_back(*material); 
    249249            continue; 
    250250        } 
    251 #else 
    252         bool found = false; 
    253         if (token.size() > 2) { 
    254             std::vector<Material>::iterator itr; 
    255             for (itr = _globalMaterials.begin(); itr != _globalMaterials.end(); ++itr) { 
    256                 if ( (*itr).name == token[1]) { 
    257                     if (!_materialList) 
    258                         _materialList = new MeshMaterialList; 
    259                     _materialList->material.push_back(*itr); 
    260                     found = true; 
    261                     break; 
    262                 } 
    263             } 
    264         } 
    265         if (found) 
    266             continue; 
    267 #endif 
    268          
     251 
    269252        if (strrchr(buf, '}') != 0) 
    270253            break;