| 400 | #endif |
| 401 | |
| 402 | BytesContainer ParticleEmitter::LoadSurface(bool createDefaultIfMissing) |
| 403 | { |
| 404 | BytesContainer result; |
| 405 | if (WaitForLoaded() && !LastLoadFailed()) |
| 406 | return result; |
| 407 | ScopeLock lock(Locker); |
| 408 | |
| 409 | // Check if has that chunk |
| 410 | if (HasChunk(SHADER_FILE_CHUNK_VISJECT_SURFACE)) |
| 411 | { |
| 412 | // Load graph |
| 413 | if (!LoadChunks(GET_CHUNK_FLAG(SHADER_FILE_CHUNK_VISJECT_SURFACE))) |
| 414 | { |
| 415 | // Get stream with graph data |
| 416 | const auto data = GetChunk(SHADER_FILE_CHUNK_VISJECT_SURFACE); |
| 417 | result.Copy(data->Data); |
| 418 | return result; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | LOG(Warning, "Particle Emitter \'{0}\' surface data is missing.", GetPath()); |
| 423 | |
| 424 | // Check if create default surface |
| 425 | if (createDefaultIfMissing) |
| 426 | { |
| 427 | // Create default layer |
| 428 | ParticleEmitterGraphCPU graph; |
| 429 | graph.CreateDefault(); |
| 430 | |
| 431 | // Serialize layer to stream |
| 432 | MemoryWriteStream stream(512); |
| 433 | graph.Save(&stream, false); |
| 434 | |
| 435 | // Set output data |
| 436 | result.Copy(ToSpan(stream)); |
| 437 | } |
| 438 | |
| 439 | return result; |
| 440 | } |
| 441 | |
| 442 | #if USE_EDITOR |
| 443 |
no test coverage detected