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

Method LoadSurface

Source/Engine/Particles/ParticleEmitter.cpp:402–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400#endif
401
402BytesContainer 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

Callers 1

ProcessGroupParticlesMethod · 0.45

Calls 8

LastLoadFailedFunction · 0.85
HasChunkFunction · 0.85
GetChunkFunction · 0.85
GetPathFunction · 0.85
ToSpanFunction · 0.50
CopyMethod · 0.45
CreateDefaultMethod · 0.45
SaveMethod · 0.45

Tested by

no test coverage detected