diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-01-09 18:47:11 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-01-10 10:11:01 -0800 |
commit | 428a4bb896c04e0089339a5e2d2e734a2403c09f (patch) | |
tree | 4a7892897bc2274efe121d77323155e127a0d634 /src/modules/plato | |
parent | 88c977a9f5f2eeb95586ab087629a3e9f6cbe0b1 (diff) |
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.
Diffstat (limited to 'src/modules/plato')
-rw-r--r-- | src/modules/plato/plato.c | 17 |
1 files changed, 15 insertions, 2 deletions
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); |