summaryrefslogtreecommitdiff
path: root/src/modules/stars
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/stars
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/stars')
-rw-r--r--src/modules/stars/stars.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index fff6792..bff3d8f 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -66,6 +66,36 @@ float get_random_unit_coord(unsigned *seed) {
}
+static void stars_update_taps(stars_context_t *ctxt, til_stream_t *stream, float dt)
+{
+ if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.rot_angle))
+ *ctxt->rot_angle += (*ctxt->rot_rate * dt);
+
+ if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.rot_rate)) {
+ // handle rotation parameters
+ if(*ctxt->rot_angle>M_PI_4)
+ *ctxt->rot_rate = *ctxt->rot_rate - (ctxt->rot_adj * dt);
+ else
+ *ctxt->rot_rate = *ctxt->rot_rate + (ctxt->rot_adj * dt);
+ }
+
+ /* there's no automation of offset_angle */
+ (void) til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.offset_angle);
+
+ // handle offset parameters
+ if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.offset_x)) {
+ float tmp_x = (*ctxt->offset_x*cosf(*ctxt->offset_angle * dt))-
+ (*ctxt->offset_y*sinf(*ctxt->offset_angle * dt));
+ *ctxt->offset_x = tmp_x;
+ }
+
+ if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.offset_y)) {
+ float tmp_y = (*ctxt->offset_x*sinf(*ctxt->offset_angle * dt))+
+ (*ctxt->offset_y*cosf(*ctxt->offset_angle * dt));
+ *ctxt->offset_y = tmp_y;
+ }
+}
+
static til_module_context_t * stars_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
{
stars_context_t *ctxt;
@@ -101,6 +131,9 @@ static til_module_context_t * stars_create_context(const til_module_t *module, t
ctxt->points = p_ptr;
}
}
+
+ stars_update_taps(ctxt, stream, 0.f);
+
return &ctxt->til_module_context;
}
@@ -218,33 +251,7 @@ static void stars_render_fragment(til_module_context_t *context, til_stream_t *s
ctxt->points = tmp_ptr;
}
- if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.rot_angle))
- *ctxt->rot_angle += (*ctxt->rot_rate * dt);
-
- if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.rot_rate)) {
- // handle rotation parameters
- if(*ctxt->rot_angle>M_PI_4)
- *ctxt->rot_rate = *ctxt->rot_rate - (ctxt->rot_adj * dt);
- else
- *ctxt->rot_rate = *ctxt->rot_rate + (ctxt->rot_adj * dt);
- }
-
- /* there's no automation of offset_angle */
- (void) til_stream_tap_context(stream, context, NULL, &ctxt->taps.offset_angle);
-
- // handle offset parameters
- if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.offset_x)) {
- float tmp_x = (*ctxt->offset_x*cosf(*ctxt->offset_angle * dt))-
- (*ctxt->offset_y*sinf(*ctxt->offset_angle * dt));
- *ctxt->offset_x = tmp_x;
- }
-
- if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.offset_y)) {
- float tmp_y = (*ctxt->offset_x*sinf(*ctxt->offset_angle * dt))+
- (*ctxt->offset_y*cosf(*ctxt->offset_angle * dt));
- *ctxt->offset_y = tmp_y;
- }
-
+ stars_update_taps(ctxt, stream, dt);
}
}
© All Rights Reserved