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

Method ProcessDefaultAsset

Source/Editor/Cooker/Steps/CookAssetsStep.cpp:325–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325bool CookAssetsStep::ProcessDefaultAsset(AssetCookData& options)
326{
327 const auto asBinaryAsset = dynamic_cast<BinaryAsset*>(options.Asset);
328 if (asBinaryAsset)
329 {
330 // Use default cooking rule (copy data)
331 if (asBinaryAsset->LoadChunks(ALL_ASSET_CHUNKS))
332 return true;
333 for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++)
334 {
335 const auto chunk = asBinaryAsset->GetChunk(i);
336 if (chunk)
337 options.InitData.Header.Chunks[i] = chunk->Clone();
338 }
339
340 return false;
341 }
342
343 const auto asJsonAsset = dynamic_cast<JsonAssetBase*>(options.Asset);
344 if (asJsonAsset)
345 {
346 // Use compact json
347 rapidjson_flax::StringBuffer buffer;
348 CompactJsonWriter writerObj(buffer);
349 asJsonAsset->Save(writerObj);
350
351 // Store json data in the first chunk
352 auto chunk = New<FlaxChunk>();
353 chunk->Flags = FlaxChunkFlags::CompressedLZ4; // Compress json data (internal storage layer will handle it)
354 chunk->Data.Copy((byte*)buffer.GetString(), (int32)buffer.GetSize());
355 options.InitData.Header.Chunks[0] = chunk;
356
357 return false;
358 }
359
360 LOG(Error, "Unknown asset type \'{0}\'", options.Asset->GetTypeName());
361 return false;
362}
363
364bool CookAssetsStep::Process(CookingData& data, CacheData& cache, Asset* asset)
365{

Callers

nothing calls this directly

Calls 7

LoadChunksMethod · 0.80
CloneMethod · 0.45
SaveMethod · 0.45
CopyMethod · 0.45
GetStringMethod · 0.45
GetSizeMethod · 0.45
GetTypeNameMethod · 0.45

Tested by

no test coverage detected