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

Method load

Source/Engine/Particles/ParticleEmitterFunction.cpp:43–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43Asset::LoadResult ParticleEmitterFunction::load()
44{
45 PROFILE_MEM(Particles);
46
47 // Load graph
48 const auto surfaceChunk = GetChunk(0);
49 if (!surfaceChunk || !surfaceChunk->IsLoaded())
50 return LoadResult::MissingDataChunk;
51 MemoryReadStream stream(surfaceChunk->Get(), surfaceChunk->Size());
52 if (Graph.Load(&stream, USE_EDITOR))
53 return LoadResult::Failed;
54 for (int32 i = 0; i < Graph.Nodes.Count(); i++)
55 {
56 // Initialize all used nodes (starting from function output as roots)
57 if (Graph.Nodes[i].Type == GRAPH_NODE_MAKE_TYPE(16, 2))
58 {
59 Graph.InitializeNode(&Graph.Nodes[i]);
60 }
61 }
62#if COMPILE_WITH_PARTICLE_GPU_GRAPH
63 stream.SetPosition(0);
64 if (GraphGPU.Load(&stream, false))
65 return LoadResult::Failed;
66#endif
67
68 // Cache input and output nodes
69 bool tooManyInputsOutputs = false;
70 for (int32 i = 0; i < Graph.Nodes.Count(); i++)
71 {
72 auto& node = Graph.Nodes[i];
73 if (node.Type == GRAPH_NODE_MAKE_TYPE(16, 1))
74 {
75 if (Inputs.Count() < 16)
76 Inputs.Add(i);
77 else
78 tooManyInputsOutputs = true;
79 }
80 else if (node.Type == GRAPH_NODE_MAKE_TYPE(16, 2))
81 {
82 if (Outputs.Count() < 16)
83 Outputs.Add(i);
84 else
85 tooManyInputsOutputs = true;
86 }
87 }
88 if (tooManyInputsOutputs)
89 {
90 LOG(Error, "Too many function inputs/outputs in '{0}'. The limit is max 16 inputs and max 16 outputs.", ToString());
91 }
92
93 return LoadResult::Ok;
94}
95
96void ParticleEmitterFunction::unload(bool isReloading)
97{

Callers

nothing calls this directly

Calls 10

GetChunkFunction · 0.85
ToStringFunction · 0.50
IsLoadedMethod · 0.45
GetMethod · 0.45
SizeMethod · 0.45
LoadMethod · 0.45
CountMethod · 0.45
InitializeNodeMethod · 0.45
SetPositionMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected