summaryrefslogtreecommitdiff
path: root/src/modules/sparkler/burst.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/sparkler/burst.c')
-rw-r--r--src/modules/sparkler/burst.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/modules/sparkler/burst.c b/src/modules/sparkler/burst.c
index 72cde03..b5ad365 100644
--- a/src/modules/sparkler/burst.c
+++ b/src/modules/sparkler/burst.c
@@ -18,7 +18,7 @@ typedef struct _burst_ctxt_t {
} burst_ctxt_t;
-static int burst_init(particles_t *particles, particle_t *p)
+static int burst_init(particles_t *particles, const particles_conf_t *conf, particle_t *p)
{
burst_ctxt_t *ctxt = p->ctxt;
@@ -43,9 +43,13 @@ static inline void thrust_part(particle_t *burst, particle_t *victim, float dist
typedef struct burst_sphere_t {
- particle_t *center;
+ 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;
} burst_sphere_t;
@@ -64,7 +68,7 @@ static void burst_cb(bsp_t *bsp, list_head_t *occupants, void *_s)
list_for_each_entry(o, occupants, occupants) {
particle_t *p = container_of(o, particle_t, occupant);
float d_sq;
-
+
if (p->props->virtual) {
/* don't move virtual particles (includes ourself) */
continue;
@@ -75,13 +79,22 @@ static void burst_cb(bsp_t *bsp, list_head_t *occupants, void *_s)
if (d_sq > rmin_sq && d_sq < rmax_sq) {
/* displace the part relative to the burst origin */
thrust_part(s->center, p, d_sq);
+
+ if (s->trace_affected) {
+ particles_draw_line(s->particles, &s->last->props->position, &p->props->position, s->fragment);
+ s->last = p;
+ }
}
+ if (s->trace_matches) {
+ particles_draw_line(s->particles, &s->last->props->position, &p->props->position, s->fragment);
+ s->last = p;
+ }
}
}
-static particle_status_t burst_sim(particles_t *particles, particle_t *p)
+static particle_status_t burst_sim(particles_t *particles, const particles_conf_t *conf, particle_t *p, fb_fragment_t *f)
{
burst_ctxt_t *ctxt = p->ctxt;
bsp_t *bsp = particles_bsp(particles); /* XXX see note above about bsp_occupant_t */
@@ -94,7 +107,11 @@ static particle_status_t burst_sim(particles_t *particles, particle_t *p)
/* affect neighbors for the shock-wave */
s.radius_min = (1.0f - ((float)ctxt->longevity / ctxt->lifetime)) * 0.075f;
s.radius_max = s.radius_min + .01f;
- s.center = p;
+ s.center = s.last = p;
+ s.trace_matches = (conf->show_bsp_matches && !conf->show_bsp_matches_affected_only);
+ s.trace_affected = (conf->show_bsp_matches && conf->show_bsp_matches_affected_only);
+ s.particles = particles;
+ s.fragment = f;
bsp_search_sphere(bsp, &p->props->position, s.radius_min, s.radius_max, burst_cb, &s);
return PARTICLE_ALIVE;
© All Rights Reserved