summaryrefslogtreecommitdiff
path: root/src/modules/swarm
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-05-11 12:51:00 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-05-11 15:19:25 -0700
commit0d9aa593e68f33da8ea71a04b930bb6093dbaccb (patch)
tree679fd3c55385e597176b51a7d4b4c297680ad341 /src/modules/swarm
parentdede4eca3e2fca76f297b5f5b901434cb99eafb0 (diff)
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.
Diffstat (limited to 'src/modules/swarm')
-rw-r--r--src/modules/swarm/swarm.c6
1 files changed, 3 insertions, 3 deletions
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:
© All Rights Reserved