mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
rogueviz::objmodel:: precision is now configurable via o-key
This commit is contained in:
parent
084fa5ea5e
commit
599d446038
@ -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");
|
||||
|
||||
@ -247,6 +249,12 @@ model_data& model::get() {
|
||||
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; })
|
||||
;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ namespace objmodels {
|
||||
using transformer = std::function<tf_result(hyperpoint)>;
|
||||
using subdivider = std::function<int(vector<hyperpoint>&)>;
|
||||
|
||||
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<shared_ptr<object>> objs;
|
||||
void render(const shiftmatrix& V);
|
||||
};
|
||||
@ -287,6 +288,8 @@ namespace objmodels {
|
||||
bool available();
|
||||
};
|
||||
|
||||
void add_model_settings();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user