radarrange configurable

This commit is contained in:
Zeno Rogue 2019-07-31 17:32:44 +02:00
parent a6b71facfb
commit dc54135d5f
4 changed files with 25 additions and 8 deletions

View File

@ -159,6 +159,7 @@ void initConfig() {
addsaver(vid.mobilecompasssize, "mobile compass size", 0); // ISMOBILE || ISPANDORA ? 30 : 0);
addsaver(vid.radarsize, "radarsize size", 120);
addsaver(vid.radarrange, "radarrange", 2.5);
addsaver(vid.axes, "movement help", 1);
addsaver(vid.axes3, "movement help3", false);
addsaver(vid.shifttarget, "shift-targetting", 2);
@ -1397,6 +1398,15 @@ void show3D() {
dialog::addSelItem(XLAT("radar size"), fts(vid.radarsize), 'r');
dialog::add_action([] () {
dialog::editNumber(vid.radarsize, 0, 360, 15, 90, "", XLAT("set to 0 to disable"));
dialog::extra_options = [] () { draw_radar(true); };
});
}
if(WDIM == 3 || (GDIM == 3 && euclid)) {
dialog::addSelItem(XLAT("radar range"), fts(vid.radarrange), 'R');
dialog::add_action([] () {
dialog::editNumber(vid.radarrange, 0, 10, 0.5, 2, "", XLAT(""));
dialog::extra_options = [] () { draw_radar(true); };
});
}
if(DIM == 3) add_edit_wall_quality('W');

View File

@ -761,7 +761,6 @@ bool drawing_usershape_on(cell *c, mapeditor::eShapegroup sg) {
#endif
}
ld max_eu_dist = 0;
transmatrix radar_transform;
pair<bool, hyperpoint> makeradar(hyperpoint h) {
@ -769,10 +768,18 @@ pair<bool, hyperpoint> makeradar(hyperpoint h) {
using namespace hyperpoint_vec;
ld d = hdist0(h);
if(d >= sightranges[geometry]) return {false, h};
if(solv::geodesic_movement) {
h = solv::inverse_exp(h, true);
ld r = hypot_d(3, h);
if(r < 1) h = h * (atanh(r) / r);
else return {false, h};
}
if(solv::local_perspective_used()) h = solv::local_perspective * h;
if(WDIM == 3) {
if(d) h = h * (d / sightranges[geometry] / hypot_d(3, h));
if(d >= vid.radarrange) return {false, h};
if(d) h = h * (d / vid.radarrange / hypot_d(3, h));
}
else if(hyperbolic) {
for(int a=0; a<3; a++) h[a] = h[a] / (1 + h[3]);
@ -781,8 +788,8 @@ pair<bool, hyperpoint> makeradar(hyperpoint h) {
h[2] = h[3];
}
else {
if(d > max_eu_dist) max_eu_dist = d;
if(d) h = h * (d / (max_eu_dist + cgi.scalefactor/4) / hypot_d(3, h));
if(d > vid.radarrange) return {false, h};
if(d) h = h * (d / (vid.radarrange + cgi.scalefactor/4) / hypot_d(3, h));
}
return {true, h};
}
@ -7212,7 +7219,6 @@ void drawthemap() {
if(DIM == 3) make_clipping_planes();
radarpoints.clear();
radarlines.clear();
if(!(cmode & sm::NORMAL)) max_eu_dist = 0;
callhooks(hooks_drawmap);
frameid++;

View File

@ -351,7 +351,6 @@ void drawMobileArrow(int i) {
#endif
bool nofps = false;
extern ld max_eu_dist;
void draw_radar(bool cornermode) {
@ -405,7 +404,7 @@ void draw_radar(bool cornermode) {
else if(hyp)
return point3(cx + rad * h[0], cy + rad * h[1], 1/(1+h[3]) * cgi.scalefactor * current_display->radius / (inHighQual ? 10 : 6));
else
return point3(cx + rad * h[0], cy + rad * h[1], rad * cgi.scalefactor / (max_eu_dist + cgi.scalefactor/4) * 0.8);
return point3(cx + rad * h[0], cy + rad * h[1], rad * cgi.scalefactor / (vid.radarrange + cgi.scalefactor/4) * 0.8);
};
for(auto& r: radarlines) {

View File

@ -225,6 +225,7 @@ struct videopar {
ld ballangle, ballproj, euclid_to_sphere, twopoint_param, stretch, binary_width, fixed_facing_dir;
int mobilecompasssize;
int radarsize; // radar for 3D geometries
ld radarrange;
int aurastr, aurasmoothen;
bool fixed_facing;
bool fixed_yz;
@ -5644,5 +5645,6 @@ namespace solv {
bool in_perspective();
extern int noclipped;
void draw_radar(bool cornermode);
}