summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-28 21:52:13 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-28 21:52:13 -0700
commit4c04ba8a2f75ac1ece7e0bb407f0298a5686850f (patch)
tree0dd82c5a7730b93163574ed68c22171007c21364 /src
parent3d1da3925126f8a3d1ec41c0b562949925efd0a0 (diff)
modules/spiro: filter same-tick context increments
This needs a bit more work, but at least filtering the same-tick renders avoids the many-increments-per-frame potential when used as something like a checkers::fill_module
Diffstat (limited to 'src')
-rw-r--r--src/modules/spiro/spiro.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c
index 99a654b..684cf03 100644
--- a/src/modules/spiro/spiro.c
+++ b/src/modules/spiro/spiro.c
@@ -122,18 +122,24 @@ static void spiro_render_fragment(til_module_context_t *context, til_stream_t *s
(ctxt->p*display_R), display_origin_y, makergb(0xFF, 0xFF, 0x00, 1));
#endif
- /* check bounds and increment r & p */
- float next_r=ctxt->r+(.00001f*ctxt->r_dir);
- if(next_r >= 1.f || next_r <= 0.f || next_r <= ctxt->p)
- ctxt->r_dir=ctxt->r_dir*-1;
- else
- ctxt->r=ctxt->r+(.00001f*ctxt->r_dir);
-
- float next_p=ctxt->p+(.0003f*ctxt->p_dir);
- if(next_p >= ctxt->r || next_p <= 0)
- ctxt->p_dir=ctxt->p_dir*-1;
- else
- ctxt->p=ctxt->p+(.0003f*ctxt->p_dir);
+ if (context->last_ticks != ticks) {
+ /* FIXME: these increments should be scaled by a delta-t,
+ * but at least by filtering on same-tick things don't go
+ * crazy in multi-drawn context scenarios like checkers::fill_module
+ */
+ /* check bounds and increment r & p */
+ float next_r=ctxt->r+(.00001f*ctxt->r_dir);
+ if(next_r >= 1.f || next_r <= 0.f || next_r <= ctxt->p)
+ ctxt->r_dir=ctxt->r_dir*-1;
+ else
+ ctxt->r=ctxt->r+(.00001f*ctxt->r_dir);
+
+ float next_p=ctxt->p+(.0003f*ctxt->p_dir);
+ if(next_p >= ctxt->r || next_p <= 0)
+ ctxt->p_dir=ctxt->p_dir*-1;
+ else
+ ctxt->p=ctxt->p+(.0003f*ctxt->p_dir);
+ }
}
© All Rights Reserved