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

Method load

Source/Engine/Particles/ParticleEmitter.cpp:107–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105#endif
106
107Asset::LoadResult ParticleEmitter::load()
108{
109 PROFILE_MEM(Particles);
110
111 // Load the graph
112 const auto surfaceChunk = GetChunk(SHADER_FILE_CHUNK_VISJECT_SURFACE);
113 if (!surfaceChunk)
114 {
115 // Initialize as empty graph with only root node (no modules)
116 Graph.CreateDefault();
117 return LoadResult::Ok;
118 }
119 if (LoadChunks(GET_CHUNK_FLAG(SHADER_FILE_CHUNK_VISJECT_SURFACE)))
120 {
121 LOG(Warning, "Cannot load \'{0}\' data from chunk {1}.", ToString(), SHADER_FILE_CHUNK_VISJECT_SURFACE);
122 return LoadResult::CannotLoadStorage;
123 }
124 MemoryReadStream surfaceChunkStream(surfaceChunk->Get(), surfaceChunk->Size());
125 if (Graph.Load(&surfaceChunkStream, USE_EDITOR))
126 {
127 LOG(Warning, "Cannot load Particle Emitter graph '{0}'.", GetPath());
128 return LoadResult::CannotLoadData;
129 }
130
131 // Cache data
132 {
133 auto root = Graph.Root;
134 if (root->Values.Count() != 6)
135 {
136 Graph.Clear();
137 Graph.CreateDefault();
138 LOG(Warning, "Invalid Particle Emitter graph root node '{0}'.", GetPath());
139 }
140 Capacity = root->Values[0].AsInt;
141 SimulationMode = (ParticlesSimulationMode)root->Values[1].AsInt;
142 SimulationSpace = (ParticlesSimulationSpace)root->Values[2].AsInt;
143 EnablePooling = root->Values[3].AsBool;
144 CustomBounds = (BoundingBox)root->Values[4];
145 UseAutoBounds = root->Values[5].AsBool;
146 IsUsingLights = Graph.LightModules.HasItems();
147 }
148
149 // Select simulation mode
150 //SimulationMode = ParticlesSimulationMode::CPU;
151 //SimulationMode = ParticlesSimulationMode::GPU;
152 if (SimulationMode == ParticlesSimulationMode::Default)
153 {
154 // Use GPU simulation only for bigger systems
155 SimulationMode = Capacity >= 1024 ? ParticlesSimulationMode::GPU : ParticlesSimulationMode::CPU;
156 }
157 if (SimulationMode == ParticlesSimulationMode::GPU)
158 {
159 // Downgrade to CPU simulation if no GPU support for that
160 if (IsUsingLights || Graph.RibbonRenderingModules.HasItems() || Graph.UsesVolumetricFogRendering)
161 {
162 // Downgrade to CPU simulation for ribbons (no GPU support for that)
163 SimulationMode = ParticlesSimulationMode::CPU;
164 }

Callers

nothing calls this directly

Calls 15

GetChunkFunction · 0.85
GetPathFunction · 0.85
HasChunkFunction · 0.85
DeleteFunction · 0.85
MemoryClearFunction · 0.85
GetIDFunction · 0.85
AddGraphMethod · 0.80
LockMethod · 0.80
SaveToFileMethod · 0.80
UnlockMethod · 0.80
ToStringFunction · 0.50
ClearFunction · 0.50

Tested by

no test coverage detected