prosperon/source/engine/particle.c

37 lines
744 B
C
Raw Normal View History

2022-12-28 16:50:54 -06:00
#include "particle.h"
#include "stb_ds.h"
2023-11-28 17:17:40 -06:00
#include "freelist.h"
2022-12-28 16:50:54 -06:00
2023-05-12 13:22:05 -05:00
struct emitter make_emitter() {
struct emitter e = {0};
2023-11-28 17:17:40 -06:00
arrsetcap(e.particles, 200);
2023-05-12 13:22:05 -05:00
return e;
2022-12-28 16:50:54 -06:00
}
2023-05-12 13:22:05 -05:00
void free_emitter(struct emitter e) {
arrfree(e.particles);
2022-12-28 16:50:54 -06:00
}
2023-05-12 13:22:05 -05:00
void start_emitter(struct emitter e) {
2023-11-28 17:17:40 -06:00
2022-12-28 16:50:54 -06:00
}
2023-05-12 13:22:05 -05:00
void pause_emitter(struct emitter e) {
2023-11-28 17:17:40 -06:00
2022-12-28 16:50:54 -06:00
}
2023-05-12 13:22:05 -05:00
void stop_emitter(struct emitter e) {
2023-11-28 17:17:40 -06:00
2022-12-28 16:50:54 -06:00
}
2023-05-12 13:22:05 -05:00
void emitter_step(struct emitter e, double dt) {
for (int i = 0; i < arrlen(e.particles); i++) {
2023-11-28 17:17:40 -06:00
e.particles[i].pos = HMM_AddV3(e.particles[i].pos, HMM_MulV3F(e.particles[i].v, dt));
e.particles[i].angle = HMM_MulQ(e.particles[i].angle, HMM_MulQF(e.particles[i].angle, dt));
e.particles[i].life -= dt;
2022-12-28 16:50:54 -06:00
2023-11-28 17:17:40 -06:00
if (e.particles[i].life <= 0)
arrdelswap(e.particles, i);
2023-05-12 13:22:05 -05:00
}
}