| 323 | } |
| 324 | |
| 325 | bool 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 | |
| 364 | bool CookAssetsStep::Process(CookingData& data, CacheData& cache, Asset* asset) |
| 365 | { |
nothing calls this directly
no test coverage detected