From 0d9aa593e68f33da8ea71a04b930bb6093dbaccb Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 11 May 2023 12:51:00 -0700 Subject: modules/*: stop storing setup by value in contexts With setup refcounting and a reference bound to the context, we should just dereference the single instance. The way setups are used it just as a read-only thing to affect context behavior... Note I've left the module-type-specific setup pointer despite it duplicating the setup pointer in the module_context. This is just a convenience thing so the accessors don't have to cast the general til_setup_t* to my_module_setup_t* everywhere. --- src/modules/swarm/swarm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules/swarm') diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c index d7f1614..78acc38 100644 --- a/src/modules/swarm/swarm.c +++ b/src/modules/swarm/swarm.c @@ -57,7 +57,7 @@ typedef struct swarm_context_t { til_module_context_t til_module_context; v3f_t color; float ztweak; - swarm_setup_t setup; + swarm_setup_t *setup; boid_t boids[]; } swarm_context_t; @@ -185,7 +185,7 @@ static til_module_context_t * swarm_create_context(const til_module_t *module, t if (!ctxt) return NULL; - ctxt->setup = *(swarm_setup_t *)setup; + ctxt->setup = (swarm_setup_t *)setup; for (unsigned i = 0; i < SWARM_SIZE; i++) boid_randomize(&ctxt->boids[i], &seed); @@ -403,7 +403,7 @@ static void swarm_render_fragment(til_module_context_t *context, til_stream_t *s til_fb_fragment_clear(fragment); - switch (ctxt->setup.draw_style) { + switch (ctxt->setup->draw_style) { case SWARM_DRAW_STYLE_POINTS: return swarm_draw_as_points(ctxt, fragment); case SWARM_DRAW_STYLE_LINES: -- cgit v1.2.3