-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparticles.h
69 lines (54 loc) · 974 Bytes
/
particles.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const u32 MAX_PARTICLE_SOURCES = 512;
const u32 MAX_PARTICLES = 8192;
enum ParticleType
{
PS_CIRCLE,
PS_GROW
};
struct Particle
{
u64 t0;
u32 ttl;
WorldSpace source_pos;
// The position of the particle relative to it's initial (source) position
vec2 offset;
r32 speed;
vec4 color;
r32 hue;
b32 fade_out;
Bitmap *bitmap;
ParticleType type;
union
{
struct
{
u32 radius;
} circle;
struct
{
u32 initial_radius;
r32 direction;
} grow;
};
};
struct ParticleSource
{
WorldSpace pos;
r32 spawn_rate;
u64 last_spawn;
u64 t0;
u32 ttl;
Particle particle_prototype;
};
struct Particles
{
// TODO: Make these arrays stay contiguous with deletes
ParticleSource sources[MAX_PARTICLE_SOURCES];
u32 next_free_particle_source;
Particle particles[MAX_PARTICLES];
u32 next_particle_to_use;
Bitmap spark_bitmap;
Bitmap cross_bitmap;
Bitmap blob_bitmap;
Bitmap smoke_bitmap;
};