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

Method removeDeclaredAsset

Engine/source/assets/assetManager.cpp:420–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418//-----------------------------------------------------------------------------
419
420bool AssetManager::removeDeclaredAsset( const char* pAssetId )
421{
422 // Debug Profiling.
423 PROFILE_SCOPE(AssetManager_RemoveSingleDeclaredAsset);
424
425 // Sanity!
426 AssertFatal( pAssetId != NULL, "Cannot remove single declared asset using NULL asset Id." );
427
428 // Fetch asset Id.
429 StringTableEntry assetId = StringTable->insert( pAssetId );
430
431 // Find declared asset.
432 typeDeclaredAssetsHash::iterator declaredAssetItr = mDeclaredAssets.find( assetId );
433
434 // Did we find the declared asset?
435 if ( declaredAssetItr == mDeclaredAssets.end() )
436 {
437 // No, so warn.
438 Con::warnf( "Asset Manager: Cannot remove single asset Id '%s' it could not be found.", assetId );
439 return false;
440 }
441
442 // Fetch asset definition.
443 AssetDefinition* pAssetDefinition = declaredAssetItr->value;
444
445 // Is the asset private?
446 if ( !pAssetDefinition->mAssetPrivate )
447 {
448 // No, so fetch module assets.
449 ModuleDefinition::typeModuleAssetsVector& moduleAssets = pAssetDefinition->mpModuleDefinition->getModuleAssets();
450
451 // Remove module asset.
452 for ( ModuleDefinition::typeModuleAssetsVector::iterator moduleAssetItr = moduleAssets.begin(); moduleAssetItr != moduleAssets.end(); ++moduleAssetItr )
453 {
454 if ( *moduleAssetItr == pAssetDefinition )
455 {
456 moduleAssets.erase( moduleAssetItr );
457 break;
458 }
459 }
460
461 // Remove asset dependencies.
462 removeAssetDependencies( pAssetId );
463 }
464
465 // Do we have an asset loaded?
466 if ( pAssetDefinition->mpAssetBase != NULL )
467 {
468 // Yes, so delete it.
469 // NOTE: If anything is using this then this'll cause a crash. Objects should always use safe reference methods however.
470 pAssetDefinition->mpAssetBase->deleteObject();
471 }
472
473 // Remove from declared assets.
474 mDeclaredAssets.erase( declaredAssetItr );
475
476 // Info.
477 if ( mEchoInfo )

Callers 1

Calls 8

printfFunction · 0.85
warnfFunction · 0.50
insertMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected