summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-03-29 23:34:18 -0700
committerVito Caputo <vcaputo@pengaru.com>2020-09-11 01:05:40 -0700
commita9f489265c1ebbc67a3f675d1a79a2254345b489 (patch)
tree5df81ac1e96f5468d3ad4610c23e98815252fd51 /src/modules
parente34d928d56debcb6dbdc4f16335ece59209b5e27 (diff)
modules/sparkler: wire up particles_conf_t settings
These don't actually do anything yet
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/sparkler/sparkler.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c
index bdee130..20a56c7 100644
--- a/src/modules/sparkler/sparkler.c
+++ b/src/modules/sparkler/sparkler.c
@@ -23,6 +23,7 @@ typedef struct sparkler_context_t {
extern particle_ops_t simple_ops;
+static particles_conf_t sparkler_conf;
static void * sparkler_create_context(unsigned ticks, unsigned num_cpus)
{
@@ -38,7 +39,7 @@ static void * sparkler_create_context(unsigned ticks, unsigned num_cpus)
if (!ctxt)
return NULL;
- ctxt->particles = particles_new(NULL);
+ ctxt->particles = particles_new(&sparkler_conf);
if (!ctxt->particles) {
free(ctxt);
return NULL;
@@ -89,11 +90,70 @@ static void sparkler_render_fragment(void *context, unsigned ticks, unsigned cpu
}
+/* Settings hooks for configurable variables */
+static int sparkler_setup(const settings_t *settings, setting_desc_t **next_setting)
+{
+ const char *show_bsp_leafs;
+ const char *show_bsp_matches;
+ const char *values[] = {
+ "on",
+ "off",
+ NULL
+ };
+
+ show_bsp_leafs = settings_get_value(settings, "show_bsp_leafs");
+ if (!show_bsp_leafs) {
+ int r;
+
+ r = setting_desc_clone(&(setting_desc_t){
+ .name = "Show BSP Leaf Node Bounding Boxes",
+ .key = "show_bsp_leafs",
+ .preferred = "off",
+ .values = values,
+ }, next_setting);
+ if (r < 0)
+ return r;
+
+ return 1;
+ }
+
+ show_bsp_matches = settings_get_value(settings, "show_bsp_matches");
+ if (!show_bsp_matches) {
+ int r;
+
+ r = setting_desc_clone(&(setting_desc_t){
+ .name = "Show BSP Search Matches",
+ .key = "show_bsp_matches",
+ .preferred = "off",
+ .values = values,
+ }, next_setting);
+ if (r < 0)
+ return r;
+
+ return 1;
+ }
+
+ /* TODO: return -EINVAL on parse errors? */
+ if (!strcasecmp(show_bsp_leafs, "on"))
+ sparkler_conf.show_bsp_leafs = 1;
+ else
+ sparkler_conf.show_bsp_leafs = 0;
+
+ if (!strcasecmp(show_bsp_matches, "on"))
+ sparkler_conf.show_bsp_matches = 1;
+ else
+ sparkler_conf.show_bsp_matches = 0;
+
+ return 0;
+}
+
+
rototiller_module_t sparkler_module = {
.create_context = sparkler_create_context,
.destroy_context = sparkler_destroy_context,
.prepare_frame = sparkler_prepare_frame,
.render_fragment = sparkler_render_fragment,
+ .setup = sparkler_setup,
.name = "sparkler",
.description = "Particle system with spatial interactions (threaded (poorly))",
.author = "Vito Caputo <vcaputo@pengaru.com>",
© All Rights Reserved