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

Method Sync

Source/Engine/Particles/ParticlesSimulation.cpp:40–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void ParticleEmitterInstance::Sync(ParticleSystemInstance& systemInstance, ParticleSystem* system, int32 emitterIndex)
41{
42 auto emitter = system->Emitters[emitterIndex].Get();
43
44 // Sync instance version
45 if (Version != emitter->Graph.Version)
46 {
47 ClearState();
48 Version = emitter->Graph.Version;
49 systemInstance.ParametersVersion++;
50
51 // Synchronize parameters
52 ParticleSystem::EmitterParameterOverrideKey key;
53 key.First = emitterIndex;
54 Parameters.Resize(emitter->Graph.Parameters.Count(), false);
55 for (int32 i = 0; i < emitter->Graph.Parameters.Count(); i++)
56 {
57 auto& e = emitter->Graph.Parameters.At(i);
58 key.Second = e.Identifier;
59 if (!system->EmittersParametersOverrides.TryGet(key, Parameters[i]))
60 Parameters[i] = e.Value;
61 }
62
63 if (SpawnModulesData.Count() != emitter->Graph.SpawnModules.Count())
64 {
65 SpawnModulesData.Resize(emitter->Graph.SpawnModules.Count(), false);
66 SpawnerData data;
67 data.SpawnCounter = 0;
68 data.NextSpawnTime = 0;
69 SpawnModulesData.SetAll(data);
70 }
71 if (CustomData.Count() != emitter->Graph.CustomDataSize)
72 {
73 CustomData.Resize(emitter->Graph.CustomDataSize, false);
74 Platform::MemoryClear(CustomData.Get(), CustomData.Count());
75 }
76 }
77
78 // Sync buffer version
79 if (Buffer && Buffer->Version != Version)
80 {
81 Particles::RecycleParticleBuffer(Buffer);
82 Buffer = nullptr;
83 }
84}
85
86ParticleSystemInstance::~ParticleSystemInstance()
87{

Callers

nothing calls this directly

Calls 8

ClearStateFunction · 0.85
MemoryClearFunction · 0.85
GetMethod · 0.45
ResizeMethod · 0.45
CountMethod · 0.45
TryGetMethod · 0.45
SetAllMethod · 0.45
ReleaseGPUMethod · 0.45

Tested by

no test coverage detected