From 4c04ba8a2f75ac1ece7e0bb407f0298a5686850f Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 28 Aug 2023 21:52:13 -0700 Subject: 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 --- src/modules/spiro/spiro.c | 30 ++++++++++++++++++------------ 1 file 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); + } } -- cgit v1.2.3