| 41 | } |
| 42 | |
| 43 | Asset::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 | |
| 96 | void ParticleEmitterFunction::unload(bool isReloading) |
| 97 | { |
nothing calls this directly
no test coverage detected