MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / loadAsset

Method loadAsset

Source/Engine/Content/BinaryAsset.cpp:578–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

576}
577
578Asset::LoadResult BinaryAsset::loadAsset()
579{
580 // Ensure that asset has been initialized
581 ASSERT(Storage && _header.ID.IsValid() && _header.TypeName.HasChars());
582
583 auto lock = Storage->Lock();
584 auto chunksToPreload = getChunksToPreload();
585 if (chunksToPreload != 0)
586 {
587 // Ensure that any chunks that were requested before are loaded in memory (in case streaming flushed them out after timeout)
588 for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
589 {
590 const auto chunk = _header.Chunks[i];
591 if (GET_CHUNK_FLAG(i) & chunksToPreload && chunk && chunk->IsMissing())
592 Storage->LoadAssetChunk(chunk);
593 }
594 }
595 const LoadResult result = load();
596#if !BUILD_RELEASE
597 if (result == LoadResult::MissingDataChunk)
598 {
599 // Provide more insights on potentially missing asset data chunk
600 Char chunksBitMask[ASSET_FILE_DATA_CHUNKS + 1];
601 Char chunksExistBitMask[ASSET_FILE_DATA_CHUNKS + 1];
602 Char chunksLoadBitMask[ASSET_FILE_DATA_CHUNKS + 1];
603 for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
604 {
605 if (const FlaxChunk* chunk = _header.Chunks[i])
606 {
607 chunksBitMask[i] = '1';
608 chunksExistBitMask[i] = chunk->ExistsInFile() ? '1' : '0';
609 chunksLoadBitMask[i] = chunk->IsLoaded() ? '1' : '0';
610 }
611 else
612 {
613 chunksBitMask[i] = chunksExistBitMask[i] = chunksLoadBitMask[i] = '0';
614 }
615 }
616 chunksBitMask[ASSET_FILE_DATA_CHUNKS] = chunksExistBitMask[ASSET_FILE_DATA_CHUNKS] = chunksLoadBitMask[ASSET_FILE_DATA_CHUNKS] = 0;
617 LOG(Warning, "Asset reports missing data chunk. Chunks bitmask: {}, existing chunks: {} loaded chunks: {}. '{}'", chunksBitMask, chunksExistBitMask, chunksLoadBitMask, ToString());
618 }
619#endif
620 return result;
621}
622
623void BinaryAsset::releaseStorage()
624{

Callers

nothing calls this directly

Calls 9

getChunksToPreloadFunction · 0.85
loadFunction · 0.85
LockMethod · 0.80
IsMissingMethod · 0.80
LoadAssetChunkMethod · 0.80
ToStringFunction · 0.50
IsValidMethod · 0.45
HasCharsMethod · 0.45
IsLoadedMethod · 0.45

Tested by

no test coverage detected