From 644d20cd892468b63eb553deaf4fa1994003cabc Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 20 Aug 2020 16:12:04 +0200 Subject: [PATCH] smartrange area-based --- config.cpp | 4 ++++ debug.cpp | 4 ++++ hyper.h | 1 + hyperpoint.cpp | 2 +- hypgraph.cpp | 13 ++++++++++++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/config.cpp b/config.cpp index a3079dbc..9d45fc4f 100644 --- a/config.cpp +++ b/config.cpp @@ -554,6 +554,7 @@ EX void initConfig() { addsaver(vid.use_smart_range, "smart-range", 0); addsaver(vid.smart_range_detail, "smart-range-detail", 8); addsaver(vid.smart_range_detail_3, "smart-range-detail", 30); + addsaver(vid.smart_area_based, "smart-area-based", false); addsaver(vid.cells_drawn_limit, "limit on cells drawn", 10000); addsaver(vid.cells_generated_limit, "limit on cells generated", 250); @@ -1004,6 +1005,9 @@ EX void edit_sightrange() { dialog::addSelItem(XLAT("game range bonus"), its(gamerange_bonus), 'S'); dialog::add_action([] () { gamerange_bonus = sightrange_bonus; doOvergenerate(); }); } + if(vid.use_smart_range && WDIM == 2) { + dialog::addBoolItem_action(XLAT("area-based range"), vid.smart_area_based, 'A'); + } if(!allowChangeRange() || !allowIncreasedSight()) { dialog::addItem(XLAT("enable the cheat mode for additional options"), 'X'); dialog::add_action(enable_cheat); diff --git a/debug.cpp b/debug.cpp index b8c49729..0652ad8e 100644 --- a/debug.cpp +++ b/debug.cpp @@ -798,6 +798,10 @@ int read_cheat_args() { vid.use_smart_range = 2; shift_arg_formula(WDIM == 3 ? vid.smart_range_detail_3 : vid.smart_range_detail); } + else if(argis("-smartarea")) { + PHASEFROM(2); cheat(); + shift(); vid.smart_area_based = argi(); + } else if(argis("-smartn")) { PHASEFROM(2); vid.use_smart_range = 1; diff --git a/hyper.h b/hyper.h index 45f9de53..9a3e00cd 100644 --- a/hyper.h +++ b/hyper.h @@ -341,6 +341,7 @@ struct videopar { int use_smart_range; // 0 = distance-based, 1 = model-based, 2 = model-based and generate ld smart_range_detail;// minimum visible cell for modes 1 and 2 ld smart_range_detail_3;// minimum visible cell in 3D (for mode 2, there is no mode 1) + bool smart_area_based;// based on area or length? int cells_drawn_limit; int cells_generated_limit; // limit on cells generated per frame diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 742777ee..33bba721 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -897,7 +897,7 @@ EX ld det3(const transmatrix& T) { /** determinant */ EX ld det(const transmatrix& T) { if(GDIM == 2) - retrun det3(T); + return det3(T); else { ld det = 1; transmatrix M = T; diff --git a/hypgraph.cpp b/hypgraph.cpp index 2a7925c5..f882b396 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1168,18 +1168,29 @@ EX bool in_smart_range(const shiftmatrix& T) { ld epsilon = 0.01; + transmatrix ar; + ld dx = 0, dy = 0, dz = 0, dh[MAXMDIM]; for(int i=0; iradius * abs(h2[0] - h1[0]) / epsilon; ld y1 = current_display->radius * abs(h2[1] - h1[1]) * pconf.stretch / epsilon; + + for(int j=0; jradius * (h2[j]-h1[j]) / epsilon; + dx = max(dx, x1); dy = max(dy, y1); if(GDIM == 3) dz = max(dz, abs(h2[2] - h1[2])); dh[i] = hypot(x1, y1); } - if(GDIM == 3) { + if(GDIM == 2 && vid.smart_area_based) { + ld area = det2(ar); + ld scale = sqrt(area) * cgi.scalefactor * hcrossf7; + if(scale <= vid.smart_range_detail) return false; + } + + else if(GDIM == 3) { if(-h1[2] + 2 * dz < pconf.clip_min || -h1[2] - 2 * dz > pconf.clip_max) return false; sort(dh, dh+GDIM); ld scale = sqrt(dh[1] * dh[2]) * cgi.scalefactor * hcrossf7;