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

Method GetOrCreateChunk

Source/Engine/Content/BinaryAsset.cpp:198–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196#endif
197
198FlaxChunk* BinaryAsset::GetOrCreateChunk(int32 index) const
199{
200 if (IsVirtual()) // Virtual assets don't own storage container
201 return nullptr;
202 ASSERT(Math::IsInRange(index, 0, ASSET_FILE_DATA_CHUNKS - 1));
203
204 // Try get
205 auto chunk = _header.Chunks[index];
206 if (chunk)
207 {
208 chunk->RegisterUsage();
209 return chunk;
210 }
211
212 // Allocate
213 ASSERT(Storage);
214 const_cast<BinaryAsset*>(this)->_header.Chunks[index] = chunk = Storage->AllocateChunk();
215 if (chunk)
216 chunk->RegisterUsage();
217
218 return chunk;
219}
220
221void BinaryAsset::SetChunk(int32 index, const Span<byte>& data)
222{

Callers 2

LoadShaderCacheMethod · 0.80
RunMethod · 0.80

Calls 4

IsVirtualFunction · 0.85
IsInRangeFunction · 0.85
RegisterUsageMethod · 0.80
AllocateChunkMethod · 0.45

Tested by

no test coverage detected