diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-12-13 19:20:47 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-12-13 19:20:47 -0800 |
commit | 942131dc41905ee14b6bfbc3182282c73694be4d (patch) | |
tree | 16a9505f7cc63e286013112cc144bb9725d9e6e6 /src/modules | |
parent | edddfe75c95b35c819c59a755b2ac190b072de97 (diff) |
modules/flow: trivial optimization
Small micro optimization avoiding bounds check for respawned
elements, plus comment fixup.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/flow/flow.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/modules/flow/flow.c b/src/modules/flow/flow.c index 34159e3..c9b94e4 100644 --- a/src/modules/flow/flow.c +++ b/src/modules/flow/flow.c @@ -236,10 +236,8 @@ static void flow_render_fragment(til_module_context_t *context, til_stream_t *st ff_data_t d; e->lifetime -= .1f; - if (e->lifetime <= 0.0f) - *e = rand_element(&ctxt->til_module_context.seed); - - if (e->position_b.x < -1.f || e->position_b.x > 1.f || + if (e->lifetime <= 0.0f || + e->position_b.x < -1.f || e->position_b.x > 1.f || e->position_b.y < -1.f || e->position_b.y > 1.f || e->position_b.z < 0.f || e->position_b.z > 1.f) *e = rand_element(&ctxt->til_module_context.seed); @@ -259,7 +257,7 @@ static void flow_render_fragment(til_module_context_t *context, til_stream_t *st /* Compute the final position now for the next go-round. * The second pass can't just write it back willy-nilly while racing with others, * despite doing the same thing iteratively as it draws n_iters pixels. Hence - * this position_b becomes position_a situation above. + * the position_b becomes position_a situation above. */ d.direction = v3f_mult_scalar(&d.direction, (float)ctxt->n_iters); e->position_b = v3f_add(&pos, &d.direction); |