2022-12-28 16:50:54 -06:00
|
|
|
#ifndef PARTICLE_H
|
|
|
|
#define PARTICLE_H
|
|
|
|
|
2023-11-28 17:17:40 -06:00
|
|
|
#include "HandmadeMath.h"
|
2023-12-04 13:38:37 -06:00
|
|
|
#include "transform.h"
|
2022-12-28 16:50:54 -06:00
|
|
|
|
|
|
|
struct particle {
|
2023-11-28 17:17:40 -06:00
|
|
|
HMM_Vec3 pos;
|
|
|
|
HMM_Vec3 v; /* velocity */
|
|
|
|
HMM_Quat angle;
|
|
|
|
HMM_Quat av; /* angular velocity */
|
2022-12-28 16:50:54 -06:00
|
|
|
|
2023-11-28 17:17:40 -06:00
|
|
|
union {
|
|
|
|
double life;
|
|
|
|
unsigned int next;
|
|
|
|
};
|
2022-12-28 16:50:54 -06:00
|
|
|
};
|
|
|
|
|
2023-12-04 13:38:37 -06:00
|
|
|
typedef struct emitter {
|
2023-11-28 17:17:40 -06:00
|
|
|
struct particle *particles;
|
2023-12-04 13:38:37 -06:00
|
|
|
transform3d t;
|
2023-11-28 17:17:40 -06:00
|
|
|
int max;
|
|
|
|
double life;
|
|
|
|
void (*seeder)(struct particle *p); /* Called to initialize each particle */
|
2023-12-04 13:38:37 -06:00
|
|
|
} emitter;
|
2022-12-28 16:50:54 -06:00
|
|
|
|
|
|
|
struct emitter make_emitter();
|
|
|
|
void free_emitter(struct emitter e);
|
|
|
|
|
|
|
|
void start_emitter(struct emitter e);
|
|
|
|
void pause_emitter(struct emitter e);
|
|
|
|
void stop_emitter(struct emitter e);
|
|
|
|
|
|
|
|
void emitter_step(struct emitter e, double dt);
|
|
|
|
|
2023-11-28 17:17:40 -06:00
|
|
|
#endif
|