summaryrefslogtreecommitdiff
path: root/src/modules/sparkler/particles.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2017-04-26 16:02:30 -0700
committerVito Caputo <vcaputo@pengaru.com>2017-04-26 16:02:30 -0700
commit9f499b0590b1a7d56c36ec5d093e82795c3aba19 (patch)
tree165f984ea248580a767a245a1fe5bde528375a59 /src/modules/sparkler/particles.c
parent9acecdfdd43c0eca5e7d0ec22aaf3ac51b94a7c2 (diff)
sparkler: add virtual flag to particle_props_t
The burst particle abused a zero mass to circumvent the effects of aging. Instead use an explicit virtual flag to suppress aging, change busrt_cb to ignore all virtual particles instead of only its center. Previously burst_cb would thrust other bursts like any other particle, and this was incorrect. Now burst centers are always stationary, even when they overlap other bursts.
Diffstat (limited to 'src/modules/sparkler/particles.c')
-rw-r--r--src/modules/sparkler/particles.c62
1 files changed, 36 insertions, 26 deletions
diff --git a/src/modules/sparkler/particles.c b/src/modules/sparkler/particles.c
index 0eb260e..e504adb 100644
--- a/src/modules/sparkler/particles.c
+++ b/src/modules/sparkler/particles.c
@@ -283,7 +283,40 @@ particle_status_t particles_sim(particles_t *particles)
}
-static inline void _particles_age(particles_t *particles, list_head_t *list)
+/* "age" the particle by applying its properties for one step */
+static inline void _particle_age(particles_t *particles, _particle_t *p)
+{
+#if 1
+ if (p->props.mass > 0.0f) {
+ /* gravity, TODO: mass isn't applied. */
+ static v3f_t gravity = v3f_init(0.0f, -0.05f, 0.0f);
+
+ p->props.direction = v3f_add(&p->props.direction, &gravity);
+ p->props.direction = v3f_normalize(&p->props.direction);
+ }
+#endif
+
+#if 1
+ /* some drag/resistance proportional to velocity TODO: integrate mass */
+ if (p->props.velocity > 0.0f) {
+ p->props.velocity -= ((p->props.velocity * p->props.velocity * p->props.drag));
+ if (p->props.velocity < 0.0f) {
+ p->props.velocity = 0;
+ }
+ }
+#endif
+
+ /* regular movement */
+ if (p->props.velocity > 0.0f) {
+ v3f_t movement = v3f_mult_scalar(&p->props.direction, p->props.velocity);
+
+ p->props.position = v3f_add(&p->props.position, &movement);
+ bsp_move_occupant(particles->bsp, &p->public.occupant, &p->props.position);
+ }
+}
+
+
+static void _particles_age(particles_t *particles, list_head_t *list)
{
_particle_t *p;
@@ -297,32 +330,9 @@ static inline void _particles_age(particles_t *particles, list_head_t *list)
* particularly good for cache utilization.
*/
list_for_each_entry(p, list, siblings) {
-#if 1
- if (p->props.mass > 0.0f) {
- /* gravity, TODO: mass isn't applied. */
- static v3f_t gravity = v3f_init(0.0f, -0.05f, 0.0f);
-
- p->props.direction = v3f_add(&p->props.direction, &gravity);
- p->props.direction = v3f_normalize(&p->props.direction);
- }
-#endif
-
-#if 1
- /* some drag/resistance proportional to velocity TODO: integrate mass */
- if (p->props.velocity > 0.0f) {
- p->props.velocity -= ((p->props.velocity * p->props.velocity * p->props.drag));
- if (p->props.velocity < 0.0f) {
- p->props.velocity = 0;
- }
- }
-#endif
-
- /* regular movement */
- if (p->props.velocity > 0.0f) {
- v3f_t movement = v3f_mult_scalar(&p->props.direction, p->props.velocity);
- p->props.position = v3f_add(&p->props.position, &movement);
- bsp_move_occupant(particles->bsp, &p->public.occupant, &p->props.position);
+ if (!p->props.virtual) {
+ _particle_age(particles, p);
}
if (!list_empty(&p->children)) {
© All Rights Reserved