src/CSLModels.cpp
void CSLObj::DetermineWhichObjToLoad ()
{
    // 1. Determine if we need to access a copied file at all
    const bool bDoReplTextures = glob.bObjReplTextures && (!texture.empty() || !text_lit.empty());
    if (!glob.bObjReplDataRefs && !bDoReplTextures)
        return;
    
    // 2. Compute that copied file name
    pathOrig = path;                // Save the original name
    // remove the current extension
    RemoveExtension(path);
    // if we need to replace texture then a texture id should become part of the file name
    if (bDoReplTextures) {
        std::string addTxt = texture.empty() ? text_lit : texture;
        RemoveExtension(addTxt);
        path += '.';
        path += addTxt;
    }
    // always add 'xpmp2.obj' as the final extension
    path += ".xpmp2.obj";
    
    // 3. Test if that copied file already exists
    if (ExistsFile(path))
        // It does exist, so no new copy is needed
        pathOrig.clear();
}
// Determine which file to load and if we need a copied .obj file
/// @details 1. Determine if we need to access a copied file at all
///          2. Compute that copied file name
///             It will include one of the texture ids if texture replacement is involved
///             It will always end on ".xpmp2.obj"
///          3. Test if that copied file already exists
///          The actual copy operation will only be peformed upon load.
Determine which file to load and if we need a copied .obj file
Determine which file to load and if we need a copied . obj file
void CSLObj::DetermineWhichObjToLoad ()
{
    const bool bDoReplTextures = glob.bObjReplTextures && (!texture.empty() || !text_lit.empty());
    if (!glob.bObjReplDataRefs && !bDoReplTextures)
        return;
    pathOrig = path;                
    RemoveExtension(path);
    if (bDoReplTextures) {
        std::string addTxt = texture.empty() ? text_lit : texture;
        RemoveExtension(addTxt);
        path += '.';
        path += addTxt;
    }
    path += ".xpmp2.obj";
    if (ExistsFile(path))
        pathOrig.clear();
}
void CSLObj :: DetermineWhichObjToLoad ( ) { const bool bDoReplTextures = glob . bObjReplTextures && ( ! texture . empty ( ) || ! text_lit . empty ( ) ) ; if ( ! glob . bObjReplDataRefs && ! bDoReplTextures ) return ; pathOrig = path ; RemoveExtension ( path ) ; if ( bDoReplTextures ) { std :: string addTxt = texture . empty ( ) ? text_lit : texture ; RemoveExtension ( addTxt ) ; path += ' ' ; path += addTxt ; } path += " " ; if ( ExistsFile ( path ) ) pathOrig . clear ( ) ; }
Determine which file to load and if we need a copied .obj file
Determine which file to load and if we need a copied . obj file
// 1. Determine if we need to access a copied file at all // 2. Compute that copied file name // Save the original name // remove the current extension // if we need to replace texture then a texture id should become part of the file name // always add 'xpmp2.obj' as the final extension // 3. Test if that copied file already exists // It does exist, so no new copy is needed