summaryrefslogtreecommitdiff
path: root/src/modules/flui2d
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-16 22:18:02 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-16 22:18:02 -0700
commit0b471f3579e49c28032536de3c276a9d6eddd15d (patch)
treec7f653609aca80ccd0871c946900affd3589c99d /src/modules/flui2d
parent32829e6222554d9c46bfe1e6bbd9784de6860f6a (diff)
modules/*: update all taps in context_create()
Mechanical change of ensuring what little taps are implemented always get updated @ til_module_t.context_create() time as well as on every frame. This ensures the pipes are registered on stream immediately upon context creation, rather than appearing only once the context gets rendered the first time.
Diffstat (limited to 'src/modules/flui2d')
-rw-r--r--src/modules/flui2d/flui2d.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c
index bfa36fb..40307a2 100644
--- a/src/modules/flui2d/flui2d.c
+++ b/src/modules/flui2d/flui2d.c
@@ -249,6 +249,19 @@ static void gamma_init(float gamma)
}
+static void flui2d_update_taps(flui2d_context_t *ctxt, til_stream_t *stream, unsigned ticks)
+{
+ if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.viscosity))
+ *ctxt->viscosity = ctxt->setup->viscosity;
+
+ if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.diffusion))
+ *ctxt->diffusion = ctxt->setup->diffusion;
+
+ if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.decay))
+ *ctxt->decay = ctxt->setup->decay;
+}
+
+
static til_module_context_t * flui2d_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
{
static int initialized;
@@ -269,6 +282,8 @@ static til_module_context_t * flui2d_create_context(const til_module_t *module,
ctxt->taps.diffusion = til_tap_init_float(ctxt, &ctxt->diffusion, 1, &ctxt->vars.diffusion, "diffusion");
ctxt->taps.decay = til_tap_init_float(ctxt, &ctxt->decay, 1, &ctxt->vars.decay, "decay");
+ flui2d_update_taps(ctxt, stream, ticks);
+
return &ctxt->til_module_context;
}
@@ -283,14 +298,7 @@ static void flui2d_prepare_frame(til_module_context_t *context, til_stream_t *st
*res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_tile64 };
- if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.viscosity))
- *ctxt->viscosity = ctxt->setup->viscosity;
-
- if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.diffusion))
- *ctxt->diffusion = ctxt->setup->diffusion;
-
- if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.decay))
- *ctxt->decay = ctxt->setup->decay;
+ flui2d_update_taps(ctxt, stream, ticks);
/* this duplication of visc/diff/decay is silly, it's just a product of this
* module being written as a flui2d_t class in-situ but distinct from the module.
© All Rights Reserved