diff options
Diffstat (limited to 'src/modules/sparkler')
-rw-r--r-- | src/modules/sparkler/burst.c | 16 | ||||
-rw-r--r-- | src/modules/sparkler/helpers.h | 7 | ||||
-rw-r--r-- | src/modules/sparkler/particle.h | 11 | ||||
-rw-r--r-- | src/modules/sparkler/particles.c | 26 | ||||
-rw-r--r-- | src/modules/sparkler/particles.h | 9 | ||||
-rw-r--r-- | src/modules/sparkler/rocket.c | 9 | ||||
-rw-r--r-- | src/modules/sparkler/simple.c | 9 | ||||
-rw-r--r-- | src/modules/sparkler/spark.c | 9 | ||||
-rw-r--r-- | src/modules/sparkler/sparkler.c | 38 | ||||
-rw-r--r-- | src/modules/sparkler/xplode.c | 9 |
10 files changed, 75 insertions, 68 deletions
diff --git a/src/modules/sparkler/burst.c b/src/modules/sparkler/burst.c index b5ad365..cf35b31 100644 --- a/src/modules/sparkler/burst.c +++ b/src/modules/sparkler/burst.c @@ -43,13 +43,13 @@ static inline void thrust_part(particle_t *burst, particle_t *victim, float dist typedef struct burst_sphere_t { - particles_t *particles; - particle_t *center, *last; - fb_fragment_t *fragment; - float radius_min; - float radius_max; - unsigned trace_matches:1; - unsigned trace_affected:1; + particles_t *particles; + particle_t *center, *last; + til_fb_fragment_t *fragment; + float radius_min; + float radius_max; + unsigned trace_matches:1; + unsigned trace_affected:1; } burst_sphere_t; @@ -94,7 +94,7 @@ static void burst_cb(bsp_t *bsp, list_head_t *occupants, void *_s) } -static particle_status_t burst_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, fb_fragment_t *f) +static particle_status_t burst_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, til_fb_fragment_t *f) { burst_ctxt_t *ctxt = p->ctxt; bsp_t *bsp = particles_bsp(particles); /* XXX see note above about bsp_occupant_t */ diff --git a/src/modules/sparkler/helpers.h b/src/modules/sparkler/helpers.h index 3fd1bda..4c2497e 100644 --- a/src/modules/sparkler/helpers.h +++ b/src/modules/sparkler/helpers.h @@ -3,7 +3,8 @@ #include <stdint.h> -#include "fb.h" +#include "til_fb.h" + #include "particle.h" #include "particles.h" @@ -20,9 +21,9 @@ static inline uint32_t makergb(uint32_t r, uint32_t g, uint32_t b, float intensi /* return if the particle should be drawn, and set *longevity to 0 if out of bounds */ -static inline int should_draw_expire_if_oob(particles_t *particles, particle_t *p, int x, int y, fb_fragment_t *f, int *longevity) +static inline int should_draw_expire_if_oob(particles_t *particles, particle_t *p, int x, int y, til_fb_fragment_t *f, int *longevity) { - if (!fb_fragment_contains(f, x, y)) { + if (!til_fb_fragment_contains(f, x, y)) { if (longevity && (x < 0 || x > f->frame_width || y < 0 || y > f->frame_height)) *longevity = 0; /* offscreen */ diff --git a/src/modules/sparkler/particle.h b/src/modules/sparkler/particle.h index a5999ee..6a5bf73 100644 --- a/src/modules/sparkler/particle.h +++ b/src/modules/sparkler/particle.h @@ -1,8 +1,9 @@ #ifndef _PARTICLE_H #define _PARTICLE_H +#include "til_fb.h" + #include "bsp.h" -#include "fb.h" #include "v3f.h" typedef struct particle_props_t { @@ -28,8 +29,8 @@ 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) */ 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 *, fb_fragment_t *); /* simulate the particle for another cycle (required) */ - void (*draw)(particles_t *, const particles_conf_t *, particle_t *, int, int, fb_fragment_t *); /* draw the particle, 3d->2d projection has been done already (optional) */ + 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; struct particle_t { @@ -68,12 +69,12 @@ static inline void particle_cleanup(particles_t *particles, const particles_conf * example is true, then sim may draw into fragment, and the callers shouldn't zero the fragment between sim and draw but * instead should zero it before sim. It's kind of janky, not a fan. */ -static inline particle_status_t particle_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, fb_fragment_t *f) { +static inline particle_status_t particle_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, til_fb_fragment_t *f) { return p->ops->sim(particles, conf, p, f); } -static inline void particle_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, fb_fragment_t *f) { +static inline void particle_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, til_fb_fragment_t *f) { if (p->ops->draw) { p->ops->draw(particles, conf, p, x, y, f); } diff --git a/src/modules/sparkler/particles.c b/src/modules/sparkler/particles.c index d4677b7..a567cea 100644 --- a/src/modules/sparkler/particles.c +++ b/src/modules/sparkler/particles.c @@ -7,7 +7,7 @@ #include <stdlib.h> #include <time.h> -#include "fb.h" +#include "til_fb.h" #include "chunker.h" #include "container.h" @@ -221,7 +221,7 @@ bsp_t * particles_bsp(particles_t *particles) } -static inline void _particles_draw(particles_t *particles, list_head_t *list, fb_fragment_t *fragment) +static inline void _particles_draw(particles_t *particles, list_head_t *list, til_fb_fragment_t *fragment) { float w2 = fragment->frame_width * .5f, h2 = fragment->frame_height * .5f; _particle_t *p; @@ -247,7 +247,7 @@ static inline void _particles_draw(particles_t *particles, list_head_t *list, fb /* TODO: maybe polish up and move into fb.c? */ -static void draw_line(fb_fragment_t *fragment, int x1, int y1, int x2, int y2) +static void draw_line(til_fb_fragment_t *fragment, int x1, int y1, int x2, int y2) { int x_delta = x2 - x1; int y_delta = y2 - y1; @@ -265,7 +265,7 @@ static void draw_line(fb_fragment_t *fragment, int x1, int y1, int x2, int y2) minor -= x_delta; } - fb_fragment_put_pixel_checked(fragment, x1, y1, 0xffffffff); + til_fb_fragment_put_pixel_checked(fragment, x1, y1, 0xffffffff); } } else { /* Y-major */ @@ -275,13 +275,13 @@ static void draw_line(fb_fragment_t *fragment, int x1, int y1, int x2, int y2) minor -= y_delta; } - fb_fragment_put_pixel_checked(fragment, x1, y1, 0xffffffff); + til_fb_fragment_put_pixel_checked(fragment, x1, y1, 0xffffffff); } } } -static void draw_edge(fb_fragment_t *fragment, const v3f_t *a, const v3f_t *b) +static void draw_edge(til_fb_fragment_t *fragment, const v3f_t *a, const v3f_t *b) { float w2 = fragment->frame_width * .5f, h2 = fragment->frame_height * .5f; int x1, y1, x2, y2; @@ -296,7 +296,7 @@ static void draw_edge(fb_fragment_t *fragment, const v3f_t *a, const v3f_t *b) } -static void draw_bv(fb_fragment_t *fragment, const v3f_t *bv_min, const v3f_t *bv_max) +static void draw_bv(til_fb_fragment_t *fragment, const v3f_t *bv_min, const v3f_t *bv_max) { draw_edge(fragment, &(v3f_t){bv_min->x, bv_max->y, bv_min->z}, @@ -339,8 +339,8 @@ static void draw_bv(fb_fragment_t *fragment, const v3f_t *bv_min, const v3f_t *b /* something to encapsulate these pointers for passing through as one to draw_leaf() */ typedef struct draw_leafs_t { - particles_t *particles; - fb_fragment_t *fragment; + particles_t *particles; + til_fb_fragment_t *fragment; } draw_leafs_t; @@ -360,7 +360,7 @@ static void draw_leaf(const bsp_t *bsp, const list_head_t *occupants, unsigned d /* draw all of the particles, currently called in heirarchical order */ -void particles_draw(particles_t *particles, fb_fragment_t *fragment) +void particles_draw(particles_t *particles, til_fb_fragment_t *fragment) { draw_leafs_t draw = { .particles = particles, .fragment = fragment }; @@ -373,7 +373,7 @@ void particles_draw(particles_t *particles, fb_fragment_t *fragment) } -static inline particle_status_t _particles_sim(particles_t *particles, list_head_t *list, fb_fragment_t *fragment) +static inline particle_status_t _particles_sim(particles_t *particles, list_head_t *list, til_fb_fragment_t *fragment) { particle_status_t ret = PARTICLE_DEAD, s; _particle_t *p, *_p; @@ -400,7 +400,7 @@ static inline particle_status_t _particles_sim(particles_t *particles, list_head /* simulate the particles, call the sim method of every particle in the heirarchy, this is what makes the particles dynamic */ /* if any paticle is still living, we return PARTICLE_ALIVE, to inform the caller when everything's dead */ -particle_status_t particles_sim(particles_t *particles, fb_fragment_t *fragment) +particle_status_t particles_sim(particles_t *particles, til_fb_fragment_t *fragment) { assert(particles); @@ -480,7 +480,7 @@ void particles_age(particles_t *particles) /* draw a line expressed in world-space positions a to b into fragment, this is intended for * instrumentation/overlay debugging type purposes... */ -void particles_draw_line(particles_t *particles, const v3f_t *a, const v3f_t *b, fb_fragment_t *fragment) +void particles_draw_line(particles_t *particles, const v3f_t *a, const v3f_t *b, til_fb_fragment_t *fragment) { float w2 = fragment->frame_width * .5f, h2 = fragment->frame_height * .5f; int x1, y1, x2, y2; diff --git a/src/modules/sparkler/particles.h b/src/modules/sparkler/particles.h index 9d6e3af..1cb737f 100644 --- a/src/modules/sparkler/particles.h +++ b/src/modules/sparkler/particles.h @@ -1,8 +1,9 @@ #ifndef _PARTICLES_H #define _PARTICLES_H +#include "til_fb.h" + #include "bsp.h" -#include "fb.h" #include "list.h" #include "particle.h" @@ -17,14 +18,14 @@ typedef struct particles_t particles_t; typedef struct v3f_t v3f_t; particles_t * particles_new(const particles_conf_t *conf); -void particles_draw(particles_t *particles, fb_fragment_t *fragment); -particle_status_t particles_sim(particles_t *particles, fb_fragment_t *fragment); +void particles_draw(particles_t *particles, til_fb_fragment_t *fragment); +particle_status_t particles_sim(particles_t *particles, til_fb_fragment_t *fragment); void particles_age(particles_t *particles); void particles_free(particles_t *particles); int particles_add_particle(particles_t *particles, particle_props_t *props, particle_ops_t *ops); void particles_spawn_particle(particles_t *particles, particle_t *parent, particle_props_t *props, particle_ops_t *ops); void particles_add_particles(particles_t *particles, particle_props_t *props, particle_ops_t *ops, int num); bsp_t * particles_bsp(particles_t *particles); -void particles_draw_line(particles_t *particles, const v3f_t *a, const v3f_t *b, fb_fragment_t *fragment); +void particles_draw_line(particles_t *particles, const v3f_t *a, const v3f_t *b, til_fb_fragment_t *fragment); #endif diff --git a/src/modules/sparkler/rocket.c b/src/modules/sparkler/rocket.c index 50e1ff5..3885304 100644 --- a/src/modules/sparkler/rocket.c +++ b/src/modules/sparkler/rocket.c @@ -1,6 +1,7 @@ #include <stdlib.h> -#include "fb.h" +#include "til_fb.h" + #include "helpers.h" #include "particle.h" #include "particles.h" @@ -54,7 +55,7 @@ static int rocket_init(particles_t *particles, const particles_conf_t *conf, par } -static particle_status_t rocket_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, fb_fragment_t *f) +static particle_status_t rocket_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, til_fb_fragment_t *f) { rocket_ctxt_t *ctxt = p->ctxt; int i, n_sparks; @@ -120,7 +121,7 @@ static particle_status_t rocket_sim(particles_t *particles, const particles_conf } -static void rocket_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, fb_fragment_t *f) +static void rocket_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, til_fb_fragment_t *f) { rocket_ctxt_t *ctxt = p->ctxt; @@ -128,7 +129,7 @@ static void rocket_draw(particles_t *particles, const particles_conf_t *conf, pa /* kill off parts that wander off screen */ return; - fb_fragment_put_pixel_unchecked(f, x, y, 0xff0000); + til_fb_fragment_put_pixel_unchecked(f, x, y, 0xff0000); } diff --git a/src/modules/sparkler/simple.c b/src/modules/sparkler/simple.c index 8db15b1..14c5d49 100644 --- a/src/modules/sparkler/simple.c +++ b/src/modules/sparkler/simple.c @@ -1,6 +1,7 @@ #include <stdlib.h> -#include "fb.h" +#include "til_fb.h" + #include "helpers.h" #include "particle.h" #include "particles.h" @@ -54,7 +55,7 @@ static int simple_init(particles_t *particles, const particles_conf_t *conf, par } -static particle_status_t simple_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, fb_fragment_t *f) +static particle_status_t simple_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, til_fb_fragment_t *f) { simple_ctxt_t *ctxt = p->ctxt; @@ -95,7 +96,7 @@ static particle_status_t simple_sim(particles_t *particles, const particles_conf } -static void simple_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, fb_fragment_t *f) +static void simple_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, til_fb_fragment_t *f) { simple_ctxt_t *ctxt = p->ctxt; @@ -103,7 +104,7 @@ static void simple_draw(particles_t *particles, const particles_conf_t *conf, pa /* immediately kill off stars that wander off screen */ return; - fb_fragment_put_pixel_unchecked(f, x, y, makergb(0xff, 0xff, 0xff, ((float)ctxt->longevity / ctxt->lifetime))); + til_fb_fragment_put_pixel_unchecked(f, x, y, makergb(0xff, 0xff, 0xff, ((float)ctxt->longevity / ctxt->lifetime))); } diff --git a/src/modules/sparkler/spark.c b/src/modules/sparkler/spark.c index c432bf5..8eff728 100644 --- a/src/modules/sparkler/spark.c +++ b/src/modules/sparkler/spark.c @@ -1,6 +1,7 @@ #include <stdlib.h> -#include "fb.h" +#include "til_fb.h" + #include "helpers.h" #include "particle.h" #include "particles.h" @@ -32,7 +33,7 @@ static int spark_init(particles_t *particles, const particles_conf_t *conf, part } -static particle_status_t spark_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, fb_fragment_t *f) +static particle_status_t spark_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, til_fb_fragment_t *f) { spark_ctxt_t *ctxt = p->ctxt; @@ -45,7 +46,7 @@ static particle_status_t spark_sim(particles_t *particles, const particles_conf_ } -static void spark_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, fb_fragment_t *f) +static void spark_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, til_fb_fragment_t *f) { spark_ctxt_t *ctxt = p->ctxt; @@ -53,7 +54,7 @@ static void spark_draw(particles_t *particles, const particles_conf_t *conf, par /* offscreen */ return; - fb_fragment_put_pixel_unchecked(f, x, y, makergb(0xff, 0xa0, 0x20, ((float)ctxt->longevity / ctxt->lifetime))); + til_fb_fragment_put_pixel_unchecked(f, x, y, makergb(0xff, 0xa0, 0x20, ((float)ctxt->longevity / ctxt->lifetime))); } diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index b673d0c..8b8681f 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -4,9 +4,9 @@ #include <time.h> #include <unistd.h> -#include "fb.h" -#include "rototiller.h" -#include "util.h" +#include "til.h" +#include "til_fb.h" +#include "til_util.h" #include "particles.h" @@ -60,14 +60,14 @@ static void sparkler_destroy_context(void *context) } -static int sparkler_fragmenter(void *context, const fb_fragment_t *fragment, unsigned number, fb_fragment_t *res_fragment) +static int sparkler_fragmenter(void *context, const til_fb_fragment_t *fragment, unsigned number, til_fb_fragment_t *res_fragment) { sparkler_context_t *ctxt = context; - return fb_fragment_slice_single(fragment, ctxt->n_cpus, number, res_fragment); + return til_fb_fragment_slice_single(fragment, ctxt->n_cpus, number, res_fragment); } -static void sparkler_prepare_frame(void *context, unsigned ticks, unsigned ncpus, fb_fragment_t *fragment, rototiller_fragmenter_t *res_fragmenter) +static void sparkler_prepare_frame(void *context, unsigned ticks, unsigned ncpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter) { sparkler_context_t *ctxt = context; @@ -75,7 +75,7 @@ static void sparkler_prepare_frame(void *context, unsigned ticks, unsigned ncpus ctxt->n_cpus = ncpus; if (sparkler_conf.show_bsp_matches) - fb_fragment_zero(fragment); + til_fb_fragment_zero(fragment); particles_sim(ctxt->particles, fragment); particles_add_particles(ctxt->particles, NULL, &simple_ops, INIT_PARTS / 4); @@ -84,19 +84,19 @@ static void sparkler_prepare_frame(void *context, unsigned ticks, unsigned ncpus /* Render a 3D particle system */ -static void sparkler_render_fragment(void *context, unsigned ticks, unsigned cpu, fb_fragment_t *fragment) +static void sparkler_render_fragment(void *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) { sparkler_context_t *ctxt = context; if (!sparkler_conf.show_bsp_matches) - fb_fragment_zero(fragment); + til_fb_fragment_zero(fragment); particles_draw(ctxt->particles, fragment); } /* Settings hooks for configurable variables */ -static int sparkler_setup(const settings_t *settings, setting_desc_t **next_setting) +static int sparkler_setup(const til_settings_t *settings, til_setting_desc_t **next_setting) { const char *show_bsp_leafs; const char *show_bsp_matches; @@ -108,11 +108,11 @@ static int sparkler_setup(const settings_t *settings, setting_desc_t **next_sett /* TODO: return -EINVAL on parse errors? */ - show_bsp_leafs = settings_get_value(settings, "show_bsp_leafs"); + show_bsp_leafs = til_settings_get_value(settings, "show_bsp_leafs"); if (!show_bsp_leafs) { int r; - r = setting_desc_clone(&(setting_desc_t){ + r = til_setting_desc_clone(&(til_setting_desc_t){ .name = "Show BSP Leaf Node Bounding Boxes", .key = "show_bsp_leafs", .preferred = "off", @@ -129,7 +129,7 @@ static int sparkler_setup(const settings_t *settings, setting_desc_t **next_sett sparkler_conf.show_bsp_leafs = 1; - show_bsp_leafs_min_depth = settings_get_value(settings, "show_bsp_leafs_min_depth"); + show_bsp_leafs_min_depth = til_settings_get_value(settings, "show_bsp_leafs_min_depth"); if (!show_bsp_leafs_min_depth) { const char *depth_values[] = { "0", @@ -141,7 +141,7 @@ static int sparkler_setup(const settings_t *settings, setting_desc_t **next_sett }; int r; - r = setting_desc_clone(&(setting_desc_t){ + r = til_setting_desc_clone(&(til_setting_desc_t){ .name = "Show BSP Leaf Node Bounding Boxes Minimum Depth", .key = "show_bsp_leafs_min_depth", .preferred = "8", @@ -158,11 +158,11 @@ static int sparkler_setup(const settings_t *settings, setting_desc_t **next_sett sparkler_conf.show_bsp_leafs = 0; } - show_bsp_matches = settings_get_value(settings, "show_bsp_matches"); + show_bsp_matches = til_settings_get_value(settings, "show_bsp_matches"); if (!show_bsp_matches) { int r; - r = setting_desc_clone(&(setting_desc_t){ + r = til_setting_desc_clone(&(til_setting_desc_t){ .name = "Show BSP Search Matches", .key = "show_bsp_matches", .preferred = "off", @@ -182,11 +182,11 @@ static int sparkler_setup(const settings_t *settings, setting_desc_t **next_sett if (!strcasecmp(show_bsp_matches, "on")) { const char *show_bsp_matches_affected_only; - show_bsp_matches_affected_only = settings_get_value(settings, "show_bsp_matches_affected_only"); + show_bsp_matches_affected_only = til_settings_get_value(settings, "show_bsp_matches_affected_only"); if (!show_bsp_matches_affected_only) { int r; - r = setting_desc_clone(&(setting_desc_t){ + r = til_setting_desc_clone(&(til_setting_desc_t){ .name = "Show Only Affected BSP Search Matches", .key = "show_bsp_matches_affected_only", .preferred = "off", @@ -208,7 +208,7 @@ static int sparkler_setup(const settings_t *settings, setting_desc_t **next_sett } -rototiller_module_t sparkler_module = { +til_module_t sparkler_module = { .create_context = sparkler_create_context, .destroy_context = sparkler_destroy_context, .prepare_frame = sparkler_prepare_frame, diff --git a/src/modules/sparkler/xplode.c b/src/modules/sparkler/xplode.c index 4d6ee36..931ec83 100644 --- a/src/modules/sparkler/xplode.c +++ b/src/modules/sparkler/xplode.c @@ -1,6 +1,7 @@ #include <stdlib.h> -#include "fb.h" +#include "til_fb.h" + #include "helpers.h" #include "particle.h" #include "particles.h" @@ -36,7 +37,7 @@ static int xplode_init(particles_t *particles, const particles_conf_t *conf, par } -static particle_status_t xplode_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, fb_fragment_t *f) +static particle_status_t xplode_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, til_fb_fragment_t *f) { xplode_ctxt_t *ctxt = p->ctxt; @@ -57,7 +58,7 @@ static particle_status_t xplode_sim(particles_t *particles, const particles_conf } -static void xplode_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, fb_fragment_t *f) +static void xplode_draw(particles_t *particles, const particles_conf_t *conf, particle_t *p, int x, int y, til_fb_fragment_t *f) { xplode_ctxt_t *ctxt = p->ctxt; uint32_t color; @@ -71,7 +72,7 @@ static void xplode_draw(particles_t *particles, const particles_conf_t *conf, pa color = makergb(0xff, 0xff, 0x00, ((float)ctxt->longevity / ctxt->lifetime)); } - fb_fragment_put_pixel_unchecked(f, x, y, color); + til_fb_fragment_put_pixel_unchecked(f, x, y, color); } |