diff --git a/Source/Engine/Content/BinaryAsset.cpp b/Source/Engine/Content/BinaryAsset.cpp index 688a3f7b5..85ffd66ec 100644 --- a/Source/Engine/Content/BinaryAsset.cpp +++ b/Source/Engine/Content/BinaryAsset.cpp @@ -584,7 +584,32 @@ Asset::LoadResult BinaryAsset::loadAsset() ASSERT(Storage && _header.ID.IsValid() && _header.TypeName.HasChars()); auto lock = Storage->Lock(); - return load(); + const LoadResult result = load(); +#if !BUILD_RELEASE + if (result == LoadResult::MissingDataChunk) + { + // Provide more insights on potentially missing asset data chunk + Char chunksBitMask[ASSET_FILE_DATA_CHUNKS + 1]; + Char chunksExistBitMask[ASSET_FILE_DATA_CHUNKS + 1]; + Char chunksLoadBitMask[ASSET_FILE_DATA_CHUNKS + 1]; + for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++) + { + if (const FlaxChunk* chunk = _header.Chunks[i]) + { + chunksBitMask[i] = '1'; + chunksExistBitMask[i] = chunk->ExistsInFile() ? '1' : '0'; + chunksLoadBitMask[i] = chunk->IsLoaded() ? '1' : '0'; + } + else + { + chunksBitMask[i] = chunksExistBitMask[i] = chunksLoadBitMask[i] = '0'; + } + } + chunksBitMask[ASSET_FILE_DATA_CHUNKS] = chunksExistBitMask[ASSET_FILE_DATA_CHUNKS] = chunksLoadBitMask[ASSET_FILE_DATA_CHUNKS] = 0; + LOG(Warning, "Asset reports missing data chunk. Chunks bitmask: {}, existing chunks: {} loaded chunks: {}. '{}'", chunksBitMask, chunksExistBitMask, chunksLoadBitMask, ToString()); + } +#endif + return result; } void BinaryAsset::releaseStorage() diff --git a/Source/Engine/Content/Storage/AssetHeader.h b/Source/Engine/Content/Storage/AssetHeader.h index 0730be025..883a16f16 100644 --- a/Source/Engine/Content/Storage/AssetHeader.h +++ b/Source/Engine/Content/Storage/AssetHeader.h @@ -81,36 +81,17 @@ public: /// /// Gets the amount of created asset chunks. /// - /// Created asset chunks - int32 GetChunksCount() const - { - int32 result = 0; - for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++) - { - if (Chunks[i] != nullptr) - result++; - } - return result; - } + int32 GetChunksCount() const; /// /// Deletes all chunks. Warning! Chunks are managed internally, use with caution! /// - void DeleteChunks() - { - for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++) - { - SAFE_DELETE(Chunks[i]); - } - } + void DeleteChunks(); /// /// Unlinks all chunks. /// - void UnlinkChunks() - { - Platform::MemoryClear(Chunks, sizeof(Chunks)); - } + void UnlinkChunks(); /// /// Gets string with a human-readable info about that header diff --git a/Source/Engine/Content/Storage/FlaxStorage.cpp b/Source/Engine/Content/Storage/FlaxStorage.cpp index 0ba268e21..acc5be881 100644 --- a/Source/Engine/Content/Storage/FlaxStorage.cpp +++ b/Source/Engine/Content/Storage/FlaxStorage.cpp @@ -20,6 +20,30 @@ #endif #include +int32 AssetHeader::GetChunksCount() const +{ + int32 result = 0; + for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++) + { + if (Chunks[i] != nullptr) + result++; + } + return result; +} + +void AssetHeader::DeleteChunks() +{ + for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++) + { + SAFE_DELETE(Chunks[i]); + } +} + +void AssetHeader::UnlinkChunks() +{ + Platform::MemoryClear(Chunks, sizeof(Chunks)); +} + String AssetHeader::ToString() const { return String::Format(TEXT("ID: {0}, TypeName: {1}, Chunks Count: {2}"), ID, TypeName, GetChunksCount());