From 917fbac4a27abead286cad19ca7d5c371f2f2397 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 30 Jul 2019 12:58:42 +0200 Subject: [PATCH] configurable Sol sight range, and glitch removal --- config.cpp | 97 ++++++++++++++++++++++++++++++++++++++---------------- langen.cpp | 2 ++ sol.cpp | 29 +++++++++++++--- 3 files changed, 95 insertions(+), 33 deletions(-) diff --git a/config.cpp b/config.cpp index 6782077b..cf65e9e2 100644 --- a/config.cpp +++ b/config.cpp @@ -689,6 +689,17 @@ void add_cells_drawn(char c = 'C') { } } +string solhelp() { + return XLAT( + "Solv (aka Sol) is a 3D space where directions work in different ways. It is described by the following metric:\n" + "ds² = (eᶻdx)² + (e⁻ᶻdy)² + dz²\n\n" + "You are currently displaying Solv in the perspective projection based on native geodesics. You can control how " + "the fog effects depends on the geodesic distance, and how far object in X/Y/Z coordinates are rendered.\n\n" + "Cells with relative x,y coordinates both over %1 and z coordinate below %2 are not rendered for technical reasons" + " (geodesics to that points are too weird).", fts(solv::glitch_xy), fts(solv::glitch_z) + ); + } + void edit_sightrange() { if(vid.use_smart_range) { ld& det = WDIM == 2 ? vid.smart_range_detail : vid.smart_range_detail_3; @@ -696,7 +707,7 @@ void edit_sightrange() { } else if(WDIM == 3) { dialog::editNumber(sightranges[geometry], 0, 2 * M_PI, 0.5, M_PI, XLAT("3D sight range"), - XLAT( + pmodel == mdSolPerspective ? solhelp() : XLAT( "Sight range for 3D geometries is specified in the absolute units. This value also affects the fog effect.\n\n" "In spherical geometries, the sight range of 2? will let you see things behind you as if they were in front of you, " "and the sight range of ? (or more) will let you see things on the antipodal point just as if they were close to you.\n\n" @@ -716,42 +727,68 @@ void edit_sightrange() { dialog::bound_up(allowIncreasedSight() ? euclid ? 99 : gp::dist_2() * 5 : 0); } dialog::extra_options = [] () { - dialog::addBoolItem(XLAT("draw range based on distance"), vid.use_smart_range == 0, 'D'); - dialog::add_action([] () { vid.use_smart_range = 0; popScreen(); edit_sightrange(); }); - if(WDIM == 2 && allowIncreasedSight()) { - dialog::addBoolItem(XLAT("draw based on size in the projection (no generation)"), vid.use_smart_range == 1, 'N'); - dialog::add_action([] () { vid.use_smart_range = 1; popScreen(); edit_sightrange(); }); - } - if(allowChangeRange() && allowIncreasedSight()) { - dialog::addBoolItem(XLAT("draw based on size in the projection (generation)"), vid.use_smart_range == 2, 'G'); - dialog::add_action([] () { vid.use_smart_range = 2; popScreen(); edit_sightrange(); }); - } - if(vid.use_smart_range == 0 && allowChangeRange() && WDIM == 2) { - dialog::addSelItem(XLAT("generation range bonus"), its(genrange_bonus), 'O'); - dialog::add_action([] () { genrange_bonus = sightrange_bonus; doOvergenerate(); }); - dialog::addSelItem(XLAT("game range bonus"), its(gamerange_bonus), 'S'); - dialog::add_action([] () { gamerange_bonus = sightrange_bonus; doOvergenerate(); }); - } - if(!allowChangeRange() || !allowIncreasedSight()) { - dialog::addItem(XLAT("enable the cheat mode for additional options"), 'X'); - dialog::add_action(enable_cheat); - } - if(WDIM == 3 && !vid.use_smart_range) { - dialog::addBoolItem_action(XLAT("sloppy range checking"), vid.sloppy_3d, 'S'); - } - if(DIM == 3 && !vid.use_smart_range) { - dialog::addSelItem(XLAT("limit generation"), fts(extra_generation_distance), 'E'); + if(pmodel == mdSolPerspective) { + dialog::addSelItem(XLAT("fog effect"), fts(sightranges[geometry]), 'R'); dialog::add_action([] { - dialog::editNumber(extra_generation_distance, 0, 999, 0.5, 999, XLAT("limit generation"), - "Cells over this distance will not be generated, but they will be drawn if they are already generated and in the sight range." - ); + auto xo = dialog::extra_options; + dialog::editNumber(sightranges[geometry], 0, 10, 0.5, M_PI, solhelp(), ""); + dialog::extra_options = xo; popScreen(); }); + dialog::addSelItem(XLAT("max difference in X/Y coordinates"), fts(solv::solrange_xy), 'X'); + dialog::add_action([] { + auto xo = dialog::extra_options; + dialog::editNumber(solv::solrange_xy, 0.01, 200, 0.1, 50, XLAT("max difference in X/Y coordinates"), solhelp()), dialog::scaleLog(); + dialog::extra_options = xo; popScreen(); + }); + dialog::addSelItem(XLAT("max difference in Z coordinate"), fts(solv::solrange_z), 'Z'); + dialog::add_action([] { + auto xo = dialog::extra_options; + dialog::editNumber(solv::solrange_z, 0, 20, 0.1, 6, XLAT("max difference in Z coordinates"), solhelp()); + dialog::extra_options = xo; popScreen(); + }); + } + else { + dialog::addBoolItem(XLAT("draw range based on distance"), vid.use_smart_range == 0, 'D'); + dialog::add_action([] () { vid.use_smart_range = 0; popScreen(); edit_sightrange(); }); + if(WDIM == 2 && allowIncreasedSight()) { + dialog::addBoolItem(XLAT("draw based on size in the projection (no generation)"), vid.use_smart_range == 1, 'N'); + dialog::add_action([] () { vid.use_smart_range = 1; popScreen(); edit_sightrange(); }); + } + if(allowChangeRange() && allowIncreasedSight()) { + dialog::addBoolItem(XLAT("draw based on size in the projection (generation)"), vid.use_smart_range == 2, 'G'); + dialog::add_action([] () { vid.use_smart_range = 2; popScreen(); edit_sightrange(); }); + } + if(vid.use_smart_range == 0 && allowChangeRange() && WDIM == 2) { + dialog::addSelItem(XLAT("generation range bonus"), its(genrange_bonus), 'O'); + dialog::add_action([] () { genrange_bonus = sightrange_bonus; doOvergenerate(); }); + dialog::addSelItem(XLAT("game range bonus"), its(gamerange_bonus), 'S'); + dialog::add_action([] () { gamerange_bonus = sightrange_bonus; doOvergenerate(); }); + } + if(!allowChangeRange() || !allowIncreasedSight()) { + dialog::addItem(XLAT("enable the cheat mode for additional options"), 'X'); + dialog::add_action(enable_cheat); + } + if(WDIM == 3 && !vid.use_smart_range) { + dialog::addBoolItem_action(XLAT("sloppy range checking"), vid.sloppy_3d, 'S'); + } + if(DIM == 3 && !vid.use_smart_range) { + dialog::addSelItem(XLAT("limit generation"), fts(extra_generation_distance), 'E'); + dialog::add_action([] { + auto xo = dialog::extra_options; + dialog::editNumber(extra_generation_distance, 0, 999, 0.5, 999, XLAT("limit generation"), + "Cells over this distance will not be generated, but they will be drawn if they are already generated and in the sight range." + ); + dialog::extra_options = xo; popScreen(); + }); + } } add_cells_drawn('C'); if(GDIM == 3 && WDIM == 2 && pmodel == mdPerspective) { dialog::addSelItem(XLAT("fog effect"), fts(sightranges[geometry]), 'R'); dialog::add_action([] { + auto xo = dialog::extra_options; dialog::editNumber(sightranges[geometry], 0, 2 * M_PI, 0.5, M_PI, XLAT("fog effect"), ""); + dialog::extra_options = xo; popScreen(); }); }; }; @@ -760,6 +797,8 @@ void edit_sightrange() { void menuitem_sightrange(char c) { if(vid.use_smart_range) dialog::addSelItem(XLAT("minimum visible cell in pixels"), fts(WDIM == 3 ? vid.smart_range_detail_3 : vid.smart_range_detail), c); + else if(pmodel == mdSolPerspective) + dialog::addSelItem(XLAT("3D sight range"), fts(solv::solrange_xy) + "x" + fts(solv::solrange_z), c); else if(WDIM == 3) dialog::addSelItem(XLAT("3D sight range"), fts(sightranges[geometry]), c); else diff --git a/langen.cpp b/langen.cpp index b453c8b9..7259f562 100644 --- a/langen.cpp +++ b/langen.cpp @@ -299,6 +299,8 @@ int main() { allchars.insert("⏎"); allchars.insert("←"); allchars.insert("→"); + allchars.insert("⁻"); + allchars.insert("ᶻ"); langPL(); langCZ(); langRU(); langTR(); langDE(); langPT(); diff --git a/sol.cpp b/sol.cpp index 54d769bd..5ea7dc83 100644 --- a/sol.cpp +++ b/sol.cpp @@ -298,12 +298,15 @@ namespace solv { }; hrmap *new_map() { return new hrmap_sol; } + + ld solrange_xy = 50; + ld solrange_z = 6; + + ld glitch_xy = 2, glitch_z = 0.6; bool in_table_range(hyperpoint h) { - ld ix = asinh(h[0]) * SXY; - ld iy = asinh(h[1]) * SXY; - ld iz = h[2] * SZ / log(2); - return abs(ix) <= PRECX && abs(iy) <= PRECX && abs(iz) <= PRECZ + 1e-2; + if(abs(h[0]) > glitch_xy && abs(h[1]) > glitch_xy && abs(h[2]) < glitch_z) return false; + return abs(h[0]) < solrange_xy && abs(h[1]) < solrange_xy && abs(h[2]) < solrange_z; } transmatrix get_solmul(const transmatrix T, const transmatrix V) { @@ -399,6 +402,24 @@ namespace solv { "return res;" "}"; + +auto sol_config = addHook(hooks_args, 0, [] () { + using namespace arg; + if(argis("-solrange")) { + shift_arg_formula(solrange_xy); + shift_arg_formula(solrange_z); + return 0; + } + else if(argis("-fsol")) { + shift(); solfname = args(); + return 0; + } + else if(argis("-solglitch")) { + shift_arg_formula(glitch_xy); + shift_arg_formula(glitch_z); + } + return 1; + }); }