-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticleManager.h
More file actions
40 lines (33 loc) · 847 Bytes
/
ParticleManager.h
File metadata and controls
40 lines (33 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include <mutex>
class ParticleEffect;
class ParticleBuffer
{
public:
ParticleEffect* effects;
int lastParticleId = 0;
int nextDeadParticleId = 0;
int activeParticlesCount = 0;
};
class ParticleManager
{
public:
ParticleManager();
~ParticleManager();
void Init(int n, int particlesPerEffectCount, int particleLifetime, float gravity, float particleMaxInitialVelocity, float emitOnDestroyProbability);
void Update(int first, int end, float dt, float time);
void Render();
void Emit(int x, int y, float time);
void SwapRenderBuffer();
void SwapUpdateBuffer();
ParticleBuffer* buffers[3];
std::mutex swapMutex;
std::mutex emitMutex;
int currentUpdatingBufferId = 2;
private:
int effectsCount = 0;
int renderBufferId = 0;
int lastUpdatedBufferId = 1;
int nextToUpdateBufferId = 1;
int particleLifetime = 0;
};