1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

multi:: radar works correctly in split_screen

This commit is contained in:
Zeno Rogue 2022-03-27 20:35:09 +02:00
parent 53d5813267
commit 8489550aed
7 changed files with 41 additions and 40 deletions

View File

@ -9,6 +9,18 @@
namespace hr {
#if HDR
struct radarpoint {
hyperpoint h;
char glyph;
color_t color;
color_t line;
};
struct radarline {
hyperpoint h1, h2;
color_t line;
};
/** configuration of the current view */
struct display_data {
/** The cell which is currently in the center. */
@ -36,6 +48,10 @@ struct display_data {
ld tanfov;
flagtype next_shader_flags;
vector<radarpoint> radarpoints;
vector<radarline> radarlines;
transmatrix radar_transform;
ld eyewidth();
bool stereo_active();
bool in_anaglyph();

View File

@ -2343,7 +2343,7 @@ EX int config3 = addHook(hooks_configfile, 100, [] {
"distances.)"
);
if(GDIM == 3 && pmodel == mdPerspective && !euclid) {
ld current_camera_level = hdist0(tC0(radar_transform));
ld current_camera_level = hdist0(tC0(current_display->radar_transform));
help += "\n\n";
if(abs(current_camera_level) < 1e-6)
help += XLAT(

View File

@ -82,7 +82,7 @@ EX bool mouseout2() {
EX movedir vectodir(hyperpoint P) {
transmatrix U = unshift(ggmatrix(cwt.at));
if(GDIM == 3 && WDIM == 2) U = radar_transform * U;
if(GDIM == 3 && WDIM == 2) U = current_display->radar_transform * U;
P = direct_exp(lp_iapply(P));

View File

@ -4864,7 +4864,7 @@ EX void make_actual_view() {
ld z = -asin_auto(tC0(view_inverse(T)) [2]);
T = zpush(-z) * T;
radar_transform = T * U;
current_display->radar_transform = T * U;
}
#endif
Viewbase = View;
@ -4943,8 +4943,8 @@ EX void drawthemap() {
firelimit = 0;
make_clipping_planes();
radarpoints.clear();
radarlines.clear();
current_display->radarpoints.clear();
current_display->radarlines.clear();
callhooks(hooks_drawmap);
frameid++;
@ -5627,7 +5627,7 @@ auto graphcm = addHook(hooks_clearmemory, 0, [] () {
gd->store(animations);
gd->store(flashes);
gd->store(fallanims);
gd->store(radar_transform);
gd->store(current_display->radar_transform);
gd->store(actual_view_transform);
});

View File

@ -74,10 +74,6 @@ void gamedata_all(gamedata& gd) {
gd.store(gamerange_bonus);
gd.store(targets);
gd.store(patterns::rwalls);
if(GDIM == 3) {
gd.store(radarlines);
gd.store(radarpoints);
}
if(GOLDBERG) gd.store(gp::param);
callhooks(hooks_gamedata, &gd);
}

View File

@ -1,28 +1,9 @@
#include "hyper.h"
namespace hr {
#if HDR
struct radarpoint {
hyperpoint h;
char glyph;
color_t color;
color_t line;
};
struct radarline {
hyperpoint h1, h2;
color_t line;
};
#endif
EX vector<radarpoint> radarpoints;
EX vector<radarline> radarlines;
EX transmatrix radar_transform;
#if MAXMDIM >= 4
pair<bool, hyperpoint> makeradar(shiftpoint h) {
if(GDIM == 3 && WDIM == 2) h.h = radar_transform * h.h;
if(GDIM == 3 && WDIM == 2) h.h = current_display->radar_transform * h.h;
ld d = hdist0(h);
@ -62,14 +43,14 @@ EX void addradar(const shiftmatrix& V, char ch, color_t col, color_t outline) {
shiftpoint h = tC0(V);
auto hp = makeradar(h);
if(hp.first)
radarpoints.emplace_back(radarpoint{hp.second, ch, col, outline});
current_display->radarpoints.emplace_back(radarpoint{hp.second, ch, col, outline});
}
EX void addradar(const shiftpoint h1, const shiftpoint h2, color_t col) {
auto hp1 = makeradar(h1);
auto hp2 = makeradar(h2);
if(hp1.first && hp2.first)
radarlines.emplace_back(radarline{hp1.second, hp2.second, col});
current_display->radarlines.emplace_back(radarline{hp1.second, hp2.second, col});
}
void celldrawer::drawcell_in_radar() {
@ -98,6 +79,7 @@ void celldrawer::radar_grid() {
EX void draw_radar(bool cornermode) {
#if MAXMDIM >= 4
if(subscreens::split([=] () { calcparam(); draw_radar(false); })) return;
if(dual::split([] { dual::in_subscreen([] { calcparam(); draw_radar(false); }); })) return;
bool d3 = WDIM == 3;
bool hyp = hyperbolic;
@ -110,10 +92,17 @@ EX void draw_radar(bool cornermode) {
dynamicval<geometryinfo1> gi(ginf[gEuclid].g, giEuclid2);
initquickqueue();
int rad = vid.radarsize;
if(dual::state) rad /= 2;
int divby = 1;
if(dual::state) divby *= 2;
if(subscreens::in) divby *= 2;
rad /= divby;
auto& cd = current_display;
ld cx = dual::state ? (dual::currently_loaded ? vid.xres/2+rad+2 : vid.xres/2-rad-2) : cornermode ? rad+2 : vid.xres-rad-2;
ld cy = vid.yres-rad-2 - vid.fsize;
ld cx = dual::state ? (dual::currently_loaded ? vid.xres/2+rad+2 : vid.xres/2-rad-2) :
subscreens::in ? cd->xtop + cd->xsize - rad - 2 :
cornermode ? rad+2 : vid.xres-rad-2;
ld cy = subscreens::in ? cd->ytop + cd->ysize - rad - 2 - vid.fsize :
vid.yres-rad-2 - vid.fsize;
auto sId = shiftless(Id);
@ -142,7 +131,7 @@ EX void draw_radar(bool cornermode) {
queuecurve(sId, 0xFF8000FF, 0, PPR::ZERO);
}
if(d3) for(auto& r: radarpoints) {
if(d3) for(auto& r: cd->radarpoints) {
queueline(sId*atscreenpos(cx+rad * r.h[0], cy - rad * r.h[2] * si + rad * r.h[1] * co, 0)*C0, sId*atscreenpos(cx+rad*r.h[0], cy - rad*r.h[2] * si, 0)*C0, r.line, -1);
}
@ -169,7 +158,7 @@ EX void draw_radar(bool cornermode) {
return point3(cx + rad * h[0], cy + rad * h[1], rad * cgi.scalefactor / (vid.radarrange + cgi.scalefactor/4) * 0.8);
};
for(auto& r: radarlines) {
for(auto& r: cd->radarlines) {
hyperpoint h1 = locate(r.h1);
hyperpoint h2 = locate(r.h2);
h1 = tC0(atscreenpos(h1[0], h1[1], 1));
@ -180,11 +169,11 @@ EX void draw_radar(bool cornermode) {
quickqueue();
glflush();
for(auto& r: radarpoints) {
for(auto& r: cd->radarpoints) {
if(d3) displaychr(int(cx + rad * r.h[0]), int(cy - rad * r.h[2] * si + rad * r.h[1] * co), 0, 8, r.glyph, r.color);
else {
hyperpoint h = locate(r.h);
displaychr(int(h[0]), int(h[1]), 0, int(h[2]), r.glyph, r.color);
displaychr(int(h[0]), int(h[1]), 0, int(h[2]) / divby, r.glyph, r.color);
}
}
#endif

View File

@ -560,7 +560,7 @@ EX void make_air() {
if(1) {
geometry = gSpace534;
S = g.T.T;
S = radar_transform * S;
S = current_display->radar_transform * S;
geometry = orig;
swapmatrix(S);
}