1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-07-05 11:12:49 +00:00

made radar work in new embedded_planes, with some glitches

This commit is contained in:
Zeno Rogue 2022-12-17 23:59:39 +01:00
parent c252e8f51e
commit c2dc16f8ca
4 changed files with 63 additions and 23 deletions

View File

@ -687,7 +687,7 @@ EX void initConfig() {
param_i(vid.mobilecompasssize, "mobile compass size", 0); // ISMOBILE || ISPANDORA ? 30 : 0); param_i(vid.mobilecompasssize, "mobile compass size", 0); // ISMOBILE || ISPANDORA ? 30 : 0);
param_i(vid.radarsize, "radarsize size", 120); param_i(vid.radarsize, "radarsize size", 120);
addsaver(vid.radarrange, "radarrange", 2.5); param_f(vid.radarrange, "radarrange", 2.5);
param_i(vid.axes, "movement help", 1); param_i(vid.axes, "movement help", 1);
param_b(vid.axes3, "movement help3", true); param_b(vid.axes3, "movement help3", true);
param_i(vid.shifttarget, "shift-targetting", 2); param_i(vid.shifttarget, "shift-targetting", 2);
@ -2405,7 +2405,7 @@ EX void show3D() {
edit_levellines('L'); edit_levellines('L');
if(WDIM == 3 || (GDIM == 3 && euclid)) { if(WDIM == 3 || (GDIM == 3 && meuclid)) {
dialog::addSelItem(XLAT("radar range"), fts(vid.radarrange), 'R'); dialog::addSelItem(XLAT("radar range"), fts(vid.radarrange), 'R');
dialog::add_action([] () { dialog::add_action([] () {
dialog::editNumber(vid.radarrange, 0, 10, 0.5, 2, "", XLAT("")); dialog::editNumber(vid.radarrange, 0, 10, 0.5, 2, "", XLAT(""));

View File

@ -5092,6 +5092,20 @@ EX void make_actual_view() {
#endif #endif
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(embedded_plane) { if(embedded_plane) {
if(nonisotropic) {
transmatrix T = actual_view_transform * View;
ld z = -tC0(view_inverse(T)) [2];
transmatrix R = actual_view_transform;
R = (logical_to_actual()) * R;
if(R[0][2] || R[2][2])
R = cspin(0, 2, -atan2(R[0][2], R[2][2])) * R;
if(R[1][2] || R[2][2])
R = cspin(1, 2, -atan2(R[1][2], R[2][2])) * R;
if(geom3::hyp_in_solnih()) R = Id;
R = inverse(logical_to_actual()) * R;
current_display->radar_transform = inverse(R) * zpush(-z);
}
else {
transmatrix T = actual_view_transform * View; transmatrix T = actual_view_transform * View;
transmatrix U = view_inverse(T); transmatrix U = view_inverse(T);
@ -5105,6 +5119,7 @@ EX void make_actual_view() {
current_display->radar_transform = T * U; current_display->radar_transform = T * U;
} }
}
#endif #endif
Viewbase = View; Viewbase = View;
} }

View File

@ -956,7 +956,7 @@ EX void swapmatrix(hyperpoint& h) {
EX transmatrix parabolic1(ld u) { EX transmatrix parabolic1(ld u) {
if(euclid) if(euclid)
return ypush(u); return ypush(u);
else if(geom3::hyp_in_solnih()) { else if(geom3::hyp_in_solnih() && !geom3::flipped) {
return ypush(u); return ypush(u);
} }
else { else {

View File

@ -3,13 +3,13 @@ namespace hr {
#if MAXMDIM >= 4 #if MAXMDIM >= 4
pair<bool, hyperpoint> makeradar(shiftpoint h) { pair<bool, hyperpoint> makeradar(shiftpoint h) {
if(GDIM == 3 && WDIM == 2) h.h = current_display->radar_transform * h.h; if(embedded_plane) h.h = current_display->radar_transform * h.h;
ld d = hdist0(h); ld d = hdist0(h);
hyperpoint h1; hyperpoint h1;
if(sol && nisot::geodesic_movement) { if(sol && nisot::geodesic_movement && !embedded_plane) {
hyperpoint h1 = inverse_exp(h, pQUICK); hyperpoint h1 = inverse_exp(h, pQUICK);
ld r = hypot_d(3, h1); ld r = hypot_d(3, h1);
if(r < 1) h1 = h1 * (atanh(r) / r); if(r < 1) h1 = h1 * (atanh(r) / r);
@ -19,28 +19,53 @@ pair<bool, hyperpoint> makeradar(shiftpoint h) {
else if(sl2) h1 = slr::get_inverse_exp(h); else if(sl2) h1 = slr::get_inverse_exp(h);
else h1 = unshift(h); else h1 = unshift(h);
if(nisot::local_perspective_used()) h1 = NLP * h1; if(nisot::local_perspective_used() && !embedded_plane) {
h1 = NLP * h1;
}
if(WDIM == 3) { if(WDIM == 3) {
if(d >= vid.radarrange) return {false, h1}; if(d >= vid.radarrange) return {false, h1};
if(d) h1 = h1 * (d / vid.radarrange / hypot_d(3, h1)); if(d) h1 = h1 * (d / vid.radarrange / hypot_d(3, h1));
} }
else if(hyperbolic) { else if(mhyperbolic) {
for(int a=0; a<3; a++) h1[a] = h1[a] / (1 + h[3]); if(geom3::hyp_in_solnih()) {
geom3::light_flip(true);
h1 = parabolic1(h1[1]) * xpush0(h1[0]);
geom3::light_flip(false);
h1[3] = h1[2]; h1[2] = 0;
// h1 = current_display->radar_transform * h1;
} }
else if(sphere) { for(int a=0; a<3; a++) h1[a] = h1[a] / (1 + h1[3]);
h1[2] = h1[3]; }
else if(msphere) {
if(geom3::same_in_same()) h1[2] = h1[3];
if(geom3::sph_in_hyp()) h1 /= sinh(1);
} }
else { else {
if(geom3::euc_in_hyp()) {
for(int a=0; a<3; a++) h1[a] = h1[a] / (1 + h1[3]);
h1[2] -= 1;
h1 *= 2 / sqhypot_d(3, h1);
d = hypot_d(2, h1);
if(d > vid.radarrange) return {false, h1};
if(d) h1 = h1 / (vid.radarrange + cgi.scalefactor/4);
}
else if(geom3::same_in_same()) {
if(d > vid.radarrange) return {false, h1}; if(d > vid.radarrange) return {false, h1};
if(d) h1 = h1 * (d / (vid.radarrange + cgi.scalefactor/4) / hypot_d(3, h1)); if(d) h1 = h1 * (d / (vid.radarrange + cgi.scalefactor/4) / hypot_d(3, h1));
} }
else {
d = hypot_d(2, h1);
if(d > vid.radarrange) return {false, h1};
if(d) h1 = h1 / (vid.radarrange + cgi.scalefactor/4);
}
}
if(invalid_point(h1)) return {false, h1}; if(invalid_point(h1)) return {false, h1};
return {true, h1}; return {true, h1};
} }
EX void addradar(const shiftmatrix& V, char ch, color_t col, color_t outline) { EX void addradar(const shiftmatrix& V, char ch, color_t col, color_t outline) {
shiftpoint h = tC0(V); shiftpoint h = V * tile_center();
auto hp = makeradar(h); auto hp = makeradar(h);
if(hp.first) if(hp.first)
current_display->radarpoints.emplace_back(radarpoint{hp.second, ch, col, outline}); current_display->radarpoints.emplace_back(radarpoint{hp.second, ch, col, outline});