diff --git a/rogueviz/objmodels.cpp b/rogueviz/objmodels.cpp index 5a9299a1..2e3ef552 100644 --- a/rogueviz/objmodels.cpp +++ b/rogueviz/objmodels.cpp @@ -22,6 +22,8 @@ bool model::available() { } void model::load_obj(model_data& md) { + md.prec_used = prec; + auto& objects = md.objs; fhstream fs(path+fname, "rt"); @@ -246,6 +248,12 @@ model_data& model::get() { md = std::make_unique(); load_obj(*md); } + + if(md && md->prec_used < prec) { + println(hlog, "need prec=", prec, " used = ", md->prec_used); + md->objs.clear(); + load_obj(*md); + } return *md; } @@ -256,5 +264,28 @@ void model_data::render(const shiftmatrix& V) { } } +void model_settings() { + emptyscreen(); + dialog::init(); + add_edit(prec); + dialog::addBack(); + dialog::display(); + } + +void o_key(o_funcs& v) { + v.push_back(named_dialog("set model settings", model_settings)); + } + +void add_model_settings() { + rogueviz::rv_hook(hooks_o_key, 200, o_key); + } + +auto cf = addHook(hooks_configfile, 100, [] { + param_f(prec, "obj_prec") + ->editable(1, 100, 1, "3D model precision", "higher-precision models take more time to load and to render.", 'p') + ->set_sets([] { dialog::numberdark = dialog::DONT_SHOW; }) + ; + }); + } } diff --git a/rogueviz/rogueviz.h b/rogueviz/rogueviz.h index b99fba13..b82cd50d 100644 --- a/rogueviz/rogueviz.h +++ b/rogueviz/rogueviz.h @@ -238,7 +238,7 @@ namespace objmodels { using transformer = std::function; using subdivider = std::function&)>; - inline int prec = 1; + inline ld prec = 1; struct object { hpcshape sh; @@ -247,6 +247,7 @@ namespace objmodels { }; struct model_data : gi_extension { + ld prec_used; vector> objs; void render(const shiftmatrix& V); }; @@ -286,6 +287,8 @@ namespace objmodels { bool available(); }; + + void add_model_settings(); }