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

Method refreshAsset

Engine/source/assets/assetManager.cpp:1203–1368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201//-----------------------------------------------------------------------------
1202
1203bool AssetManager::refreshAsset( const char* pAssetId )
1204{
1205 // Debug Profiling.
1206 PROFILE_SCOPE(AssetManager_RefreshAsset);
1207
1208 // Sanity!
1209 AssertFatal( pAssetId != NULL, "Cannot refresh NULL asset Id." );
1210
1211 // Find asset.
1212 AssetDefinition* pAssetDefinition = findAsset( pAssetId );
1213
1214 // Did we find the asset?
1215 if ( pAssetDefinition == NULL )
1216 {
1217 // No, so warn.
1218 Con::warnf( "Asset Manager: Failed to refresh asset Id '%s' as it does not exist.", pAssetId );
1219 return false;
1220 }
1221
1222 // Info.
1223 if ( mEchoInfo )
1224 {
1225 Con::printSeparator();
1226 Con::printf( "Asset Manager: Started refreshing Asset Id '%s'...", pAssetId );
1227 }
1228
1229 // Fetch asset Id.
1230 StringTableEntry assetId = StringTable->insert( pAssetId );
1231
1232 // Is the asset private?
1233 if ( pAssetDefinition->mAssetPrivate )
1234 {
1235 // Yes, so notify asset of asset refresh only.
1236 pAssetDefinition->mpAssetBase->onAssetRefresh();
1237
1238 // Asset refresh notifications.
1239 for( typeAssetPtrRefreshHash::iterator refreshNotifyItr = mAssetPtrRefreshNotifications.begin(); refreshNotifyItr != mAssetPtrRefreshNotifications.end(); ++refreshNotifyItr )
1240 {
1241 // Fetch pointed asset.
1242 StringTableEntry pointedAsset = refreshNotifyItr->key->getAssetId();
1243
1244 // Ignore if the pointed asset is not the asset or a dependency.
1245 if ( pointedAsset == StringTable->EmptyString() || ( pointedAsset != assetId && !doesAssetDependOn( pointedAsset, assetId ) ) )
1246 continue;
1247
1248 // Perform refresh notification callback.
1249 refreshNotifyItr->value->onAssetRefreshed( refreshNotifyItr->key );
1250 }
1251 }
1252 // Is the asset definition allowed to refresh?
1253 else if ( pAssetDefinition->mAssetRefreshEnable )
1254 {
1255 // Yes, so fetch the asset.
1256 AssetBase* pAssetBase = pAssetDefinition->mpAssetBase;
1257
1258 // Is the asset loaded?
1259 if ( pAssetBase != NULL )
1260 {

Callers

nothing calls this directly

Calls 15

printSeparatorFunction · 0.85
printfFunction · 0.85
EmptyStringMethod · 0.80
insertEqualMethod · 0.80
warnfFunction · 0.50
insertMethod · 0.45
onAssetRefreshMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getAssetIdMethod · 0.45
writeMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected