From 428a4bb896c04e0089339a5e2d2e734a2403c09f Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 9 Jan 2023 18:47:11 -0800 Subject: modules/plato: add taps for {spin,orbit}_rate vars Wiring up some minimal taps to see how this will work... This only initializes the taps and changes the render to access the rates indirectly via the tapped pointers. --- src/modules/plato/plato.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/modules/plato') diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c index e43990f..c3302f6 100644 --- a/src/modules/plato/plato.c +++ b/src/modules/plato/plato.c @@ -47,6 +47,7 @@ #include "til.h" #include "til_fb.h" #include "til_module_context.h" +#include "til_tap.h" #define PLATO_DEFAULT_ORBIT_RATE .25 #define PLATO_DEFAULT_SPIN_RATE .75 @@ -60,6 +61,15 @@ typedef struct plato_setup_t { typedef struct plato_context_t { til_module_context_t til_module_context; plato_setup_t setup; + + struct { + til_tap_t orbit_rate; + til_tap_t spin_rate; + } taps; + + float *orbit_rate; + float *spin_rate; + float r, rr; } plato_context_t; @@ -629,6 +639,9 @@ static til_module_context_t * plato_create_context(unsigned seed, unsigned ticks ctxt->setup = *((plato_setup_t *)setup); + ctxt->taps.spin_rate = til_tap_init_float(&ctxt->spin_rate, 1, &ctxt->setup.spin_rate, "spin_rate"); + ctxt->taps.orbit_rate = til_tap_init_float(&ctxt->orbit_rate, 1, &ctxt->setup.orbit_rate, "orbit_rate"); + return &ctxt->til_module_context; } @@ -638,8 +651,8 @@ static void plato_render_fragment(til_module_context_t *context, unsigned ticks, plato_context_t *ctxt = (plato_context_t *)context; til_fb_fragment_t *fragment = *fragment_ptr; - ctxt->r += (float)(ticks - context->ticks) * (ctxt->setup.orbit_rate * .001f); - ctxt->rr += (float)(ticks - context->ticks) * (ctxt->setup.spin_rate * .001f); + ctxt->r += (float)(ticks - context->ticks) * (*ctxt->orbit_rate * .001f); + ctxt->rr += (float)(ticks - context->ticks) * (*ctxt->spin_rate * .001f); context->ticks = ticks; til_fb_fragment_clear(fragment); -- cgit v1.2.3