MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / findAssetLooseFile

Method findAssetLooseFile

Engine/source/assets/assetManager.cpp:2293–2380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2291//-----------------------------------------------------------------------------
2292
2293S32 AssetManager::findAssetLooseFile( AssetQuery* pAssetQuery, const char* pLooseFile, const bool assetQueryAsSource )
2294{
2295 // Debug Profiling.
2296 PROFILE_SCOPE(AssetManager_FindAssetLooseFile);
2297
2298 // Sanity!
2299 AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." );
2300 AssertFatal( pLooseFile != NULL, "Cannot use NULL loose file." );
2301
2302 // Make game relative path for loose file.
2303 StringTableEntry looseFile = Platform::makeRelativePathName(pLooseFile, NULL);;
2304
2305 // Reset result count.
2306 S32 resultCount = 0;
2307
2308 // Use asset-query as the source?
2309 if ( assetQueryAsSource )
2310 {
2311 AssetQuery filteredAssets;
2312
2313 // Yes, so iterate asset query.
2314 for (Vector<StringTableEntry>::iterator assetItr = pAssetQuery->mAssetList.begin(); assetItr != pAssetQuery->mAssetList.end(); ++assetItr)
2315 {
2316 // Fetch asset definition.
2317 AssetDefinition* pAssetDefinition = findAsset( *assetItr );
2318
2319 // Fetch loose files.
2320 Vector<StringTableEntry>& assetLooseFiles = pAssetDefinition->mAssetLooseFiles;
2321
2322 // Skip if this asset has no loose files.
2323 if ( assetLooseFiles.size() == 0 )
2324 continue;
2325
2326 // Search the assets loose files.
2327 for( Vector<StringTableEntry>::iterator looseFileItr = assetLooseFiles.begin(); looseFileItr != assetLooseFiles.end(); ++looseFileItr )
2328 {
2329 // Is this the loose file we are searching for?
2330 if ( *looseFileItr != looseFile )
2331 continue;
2332
2333 // Store as result.
2334 filteredAssets.mAssetList.push_back(pAssetDefinition->mAssetId);
2335
2336 // Increase result count.
2337 resultCount++;
2338
2339 break;
2340 }
2341 }
2342
2343 // Set asset query.
2344 pAssetQuery->set( filteredAssets );
2345 }
2346 else
2347 {
2348 // No, so iterate declared assets.
2349 for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr )
2350 {

Callers 8

getLevelAssetMethod · 0.80
getAssetByFilenameMethod · 0.80
getAssetIdByFilenameMethod · 0.80
getAssetByFilenameMethod · 0.80
getAssetIdByFilenameMethod · 0.80
getAssetByFilenameMethod · 0.80
getAssetIdByFilenameMethod · 0.80

Calls 5

beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected