From 04e3ba9a85209eb83100c83118f0db5dece1788f Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 19 Mar 2018 23:58:03 +0200 Subject: [PATCH] - fixed bug in mirror matching - added option to disable mirror rendering --- src/app.cc | 5 +++++ src/metascene.cc | 2 +- src/opt.cc | 9 ++++++++- src/opt.h | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app.cc b/src/app.cc index ee9b5e6..21e8acc 100644 --- a/src/app.cc +++ b/src/app.cc @@ -183,6 +183,11 @@ bool app_init(int argc, char **argv) if(!rend->init()) { return false; } + if(opt.reflect) { + rend->ropt |= RENDER_MIRRORS; + } else { + rend->ropt &= ~RENDER_MIRRORS; + } rend->set_scene(mscn); glUseProgram(0); diff --git a/src/metascene.cc b/src/metascene.cc index ba5bdc2..465decf 100644 --- a/src/metascene.cc +++ b/src/metascene.cc @@ -279,7 +279,7 @@ int MetaScene::calc_mirror_planes() FlatMirror *m = new FlatMirror; m->wplane = mir->wplane; m->next = planes; - planes = node; + planes = m; mir->objects.push_back(obj); objmirror[obj] = mir; // associate with object diff --git a/src/opt.cc b/src/opt.cc index f9bcf53..b5ab7ed 100644 --- a/src/opt.cc +++ b/src/opt.cc @@ -11,7 +11,8 @@ Options def_opt = { false, // vr false, // fullscreen 0, // scene file - true // music + true, // music + true // reflections }; enum { @@ -21,6 +22,7 @@ enum { OPT_WINDOWED, OPT_SCENEFILE, OPT_MUSIC, + OPT_REFLECT, OPT_HELP }; @@ -32,6 +34,7 @@ static optcfg_option options[] = { {'w', "windowed", OPT_WINDOWED, "run in windowed mode"}, {0, "scene", OPT_SCENEFILE, "scene file to open"}, {'m', "music", OPT_MUSIC, "play background audio"}, + {'r', "reflect", OPT_REFLECT, "render reflections"}, {'h', "help", OPT_HELP, "print usage and exit"}, OPTCFG_OPTIONS_END }; @@ -102,6 +105,10 @@ static int opt_handler(optcfg *oc, int optid, void *cls) opt.music = is_enabled(oc); break; + case OPT_REFLECT: + opt.reflect = is_enabled(oc); + break; + case OPT_HELP: printf("Usage: demo [options]\nOptions:\n"); optcfg_print_options(oc); diff --git a/src/opt.h b/src/opt.h index eb81ceb..df7ef30 100644 --- a/src/opt.h +++ b/src/opt.h @@ -7,6 +7,7 @@ struct Options { bool fullscreen; const char *scenefile; bool music; + bool reflect; }; extern Options opt, def_opt; -- 1.7.10.4