summaryrefslogtreecommitdiff
path: root/src/modules/sparkler/particle.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@gnugeneration.com>2023-08-30 13:45:07 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-30 13:49:54 -0700
commit20d097ab1fe8ef5b62f4169f4353cc0074c27e4b (patch)
tree412f1069b7a3fa3953df02b54302bbdca3ddf6fb /src/modules/sparkler/particle.h
parenta634b2df74222be85a03b1895ee10135822031c3 (diff)
sparkler: parameterize particles
Having everything in fixed defines severely constrains the diversity of particle behaviors and appearances. This commit has been sitting around bitrotting since 2017, but now that there's all this settings infra. and randomizing via rtv, it seems worth landing, so I've rebased and am merging to prevent a bitrot->rebase recurrence. As-is, this commit ~minimally establishes a somewhat streamlined parameterizing mechanism w/X-Macro patterns, while wiring up a few of the obvious use cases surrounding xplode/burst, colorizing the default sparkler explosions while at it. It appears that when I first hacked this up I did some experimentation with parameters as well, so there are some tweaks to the behavior as opposed to a strict conversion of the fixed defines to parameters. They seem minor enough to just leave be. Plus a few minor optimizations like converting divides to multiplies were in there. Future commits can now wire up settings to choose from parameter presets for different sparklers...
Diffstat (limited to 'src/modules/sparkler/particle.h')
-rw-r--r--src/modules/sparkler/particle.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/modules/sparkler/particle.h b/src/modules/sparkler/particle.h
index a7c4138..491dc65 100644
--- a/src/modules/sparkler/particle.h
+++ b/src/modules/sparkler/particle.h
@@ -1,6 +1,8 @@
#ifndef _PARTICLE_H
#define _PARTICLE_H
+#include <stdarg.h>
+
#include "til_fb.h"
#include "bsp.h"
@@ -26,10 +28,10 @@ typedef struct particles_t particles_t;
typedef struct particles_conf_t particles_conf_t;
typedef struct particle_ops_t {
- unsigned context_size; /* size of the particle context (0 for none) */
- int (*init)(particles_t *, const particles_conf_t *, particle_t *); /* initialize the particle, called after allocating context (optional) */
+ unsigned context_size; /* size of the particle context (0 for none) */
+ int (*init)(particles_t *, const particles_conf_t *, particle_t *, unsigned, va_list); /* initialize the particle, called after allocating context (optional) */
void (*cleanup)(particles_t *, const particles_conf_t *, particle_t *); /* cleanup function, called before freeing context (optional) */
- particle_status_t (*sim)(particles_t *, const particles_conf_t *, particle_t *, til_fb_fragment_t *); /* simulate the particle for another cycle (required) */
+ particle_status_t (*sim)(particles_t *, const particles_conf_t *, particle_t *, til_fb_fragment_t *); /* simulate the particle for another cycle (required) */
void (*draw)(particles_t *, const particles_conf_t *, particle_t *, int, int, til_fb_fragment_t *); /* draw the particle, 3d->2d projection has been done already (optional) */
} particle_ops_t;
@@ -49,9 +51,9 @@ struct particle_t {
#define INHERIT_PROPS NULL
-static inline int particle_init(particles_t *particles, const particles_conf_t *conf, particle_t *p) {
+static inline int particle_init(particles_t *particles, const particles_conf_t *conf, particle_t *p, unsigned n_params, va_list params) {
if (p->ops->init) {
- return p->ops->init(particles, conf, p);
+ return p->ops->init(particles, conf, p, n_params, params);
}
return 1;
@@ -81,6 +83,6 @@ static inline void particle_draw(particles_t *particles, const particles_conf_t
}
-void particle_convert(particles_t *particles, const particles_conf_t *conf, particle_t *p, particle_props_t *props, particle_ops_t *ops);
+void particle_convert(particles_t *particles, const particles_conf_t *conf, particle_t *p, particle_props_t *props, particle_ops_t *ops, unsigned n_params, ...);
#endif
© All Rights Reserved