From f3cd8248ef2142650adff145f8dcf595d4e7186f Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 2 Mar 2025 21:44:27 +0100 Subject: [PATCH] atscreenpos now returns shiftmatrix; changed the atscreenpos references in hyperrogue to use new atscreenpos and eupoint when applicable --- config.cpp | 5 ++- dialogs.cpp | 91 ++++++++++++++++++++++++--------------------------- hud.cpp | 14 ++++---- hypgraph.cpp | 12 +++---- inventory.cpp | 4 +-- racing.cpp | 12 +++---- radar.cpp | 30 ++++++++--------- 7 files changed, 79 insertions(+), 89 deletions(-) diff --git a/config.cpp b/config.cpp index e090b229..88689ce8 100644 --- a/config.cpp +++ b/config.cpp @@ -3591,11 +3591,10 @@ EX void showCustomizeChar() { flat_model_enabler fme; initquickqueue(); - transmatrix V = atscreenpos(vid.xres/2, firsty, scale); - + shiftmatrix V = atscreenpos(vid.xres/2, firsty, scale); double alpha = atan2(mousex - vid.xres/2, mousey - firsty) - 90._deg; V = V * spin(alpha); - drawMonsterType(moPlayer, NULL, shiftless(V), 0, cc_footphase / scale, NOCOLOR); + drawMonsterType(moPlayer, NULL, V, 0, cc_footphase / scale, NOCOLOR); quickqueue(); keyhandler = [] (int sym, int uni) { diff --git a/dialogs.cpp b/dialogs.cpp index f0051dba..608613d5 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -536,8 +536,7 @@ EX namespace dialog { flat_model_enabler fme; initquickqueue(); - ld pix = 1 / (2 * cgi.hcrossf / cgi.crossf); - shiftmatrix V = shiftless(atscreenpos(0, 0, pix)); + shiftmatrix ASP = atscreenpos(0, 0); color_t col = 0xFFFFFFFF; @@ -546,22 +545,22 @@ EX namespace dialog { int yb = yt + list_actual_size; - curvepoint(hyperpoint(x-si, yt, 1, 1)); + curvepoint(eupoint(x-si, yt)); for(int i=0; i<=a/2; i++) - curvepoint(hyperpoint(x - si * cos(i*TAU/a), yb + si * sin(i*TAU/a), 1, 1)); + curvepoint(eupoint(x - si * cos(i*TAU/a), yb + si * sin(i*TAU/a))); for(int i=(a+1)/2; i<=a; i++) - curvepoint(hyperpoint(x - si * cos(i*TAU/a), yt + si * sin(i*TAU/a), 1, 1)); - queuecurve(V, col, 0x80, PPR::LINE); + curvepoint(eupoint(x - si * cos(i*TAU/a), yt + si * sin(i*TAU/a))); + queuecurve(ASP, col, 0x80, PPR::LINE); int yt1 = yt + (list_actual_size * list_skip) / list_full_size; int yb1 = yt + (list_actual_size * (list_skip + list_actual_size)) / list_full_size; - curvepoint(hyperpoint(x-siz, yt1, 1, 1)); + curvepoint(eupoint(x-siz, yt1)); for(int i=0; i<=a/2; i++) - curvepoint(hyperpoint(x - siz * cos(i*TAU/a), yb1 + siz * sin(i*TAU/a), 1, 1)); + curvepoint(eupoint(x - siz * cos(i*TAU/a), yb1 + siz * sin(i*TAU/a))); for(int i=(a+1)/2; i<=a; i++) - curvepoint(hyperpoint(x - siz * cos(i*TAU/a), yt1 + siz * sin(i*TAU/a), 1, 1)); - queuecurve(V, col, 0x80, PPR::LINE); + curvepoint(eupoint(x - siz * cos(i*TAU/a), yt1 + siz * sin(i*TAU/a))); + queuecurve(ASP, col, 0x80, PPR::LINE); quickqueue(); } @@ -575,8 +574,7 @@ EX namespace dialog { flat_model_enabler fme; initquickqueue(); - ld pix = 1 / (2 * cgi.hcrossf / cgi.crossf); - shiftmatrix V = shiftless(atscreenpos(0, 0, pix)); + shiftmatrix ASP = atscreenpos(0, 0); color_t col = addalpha(I.color); @@ -585,35 +583,35 @@ EX namespace dialog { if(I.type == diIntSlider && I.p2 < sw/4) { for(int a=0; a<=I.p2; a++) { ld x = sl + sw * a * 1. / I.p2; - curvepoint(hyperpoint(x, y-si, 1, 1)); - curvepoint(hyperpoint(x, y+si, 1, 1)); - queuecurve(V, col, 0, PPR::LINE); + curvepoint(eupoint(x, y-si)); + curvepoint(eupoint(x, y+si)); + queuecurve(ASP, col, 0, PPR::LINE); } } - curvepoint(hyperpoint(sl, y-si, 1, 1)); + curvepoint(eupoint(sl, y-si)); for(int i=0; i<=a/2; i++) - curvepoint(hyperpoint(sr + si * sin(i*TAU/a), y - si * cos(i*TAU/a), 1, 1)); + curvepoint(eupoint(sr + si * sin(i*TAU/a), y - si * cos(i*TAU/a))); for(int i=(a+1)/2; i<=a; i++) - curvepoint(hyperpoint(sl + si * sin(i*TAU/a), y - si * cos(i*TAU/a), 1, 1)); - queuecurve(V, col, 0x80, PPR::LINE); + curvepoint(eupoint(sl + si * sin(i*TAU/a), y - si * cos(i*TAU/a))); + queuecurve(ASP, col, 0x80, PPR::LINE); quickqueue(); ld x = sl + sw * (I.type == diIntSlider ? I.p1 * 1. / I.p2 : I.param); if(x < sl-si) { - curvepoint(hyperpoint(sl-si, y, 1, 1)); - curvepoint(hyperpoint(x, y, 1, 1)); - queuecurve(V, col, 0x80, PPR::LINE); + curvepoint(eupoint(sl-si, y)); + curvepoint(eupoint(x, y)); + queuecurve(ASP, col, 0x80, PPR::LINE); quickqueue(); } if(x > sr+si) { - curvepoint(hyperpoint(sr+si, y, 1, 1)); - curvepoint(hyperpoint(x, y, 1, 1)); - queuecurve(V, col, 0x80, PPR::LINE); + curvepoint(eupoint(sr+si, y)); + curvepoint(eupoint(x, y)); + queuecurve(ASP, col, 0x80, PPR::LINE); quickqueue(); } - for(int i=0; i<=a; i++) curvepoint(hyperpoint(x + siz * sin(i*TAU/a), y - siz * cos(i*TAU/a), 1, 1)); - queuecurve(V, col, col, PPR::LINE); + for(int i=0; i<=a; i++) curvepoint(eupoint(x + siz * sin(i*TAU/a), y - siz * cos(i*TAU/a))); + queuecurve(ASP, col, col, PPR::LINE); quickqueue(); } else if(I.type == diSlider) { @@ -639,28 +637,27 @@ EX namespace dialog { flat_model_enabler fme; initquickqueue(); - ld pix = 1 / (2 * cgi.hcrossf / cgi.crossf); - shiftmatrix V = shiftless(atscreenpos(x, y, pix)); + shiftmatrix ASP = atscreenpos(x, y); for(int i=0; i<=360; i++) - curvepoint(hyperpoint(r * sin(i*degree), r*cos(i*degree), 1, 1)); - queuecurve(V, 0xFFFFFFFF, 0x202020FF, PPR::LINE); + curvepoint(eupoint(r * sin(i*degree), r*cos(i*degree))); + queuecurve(ASP, 0xFFFFFFFF, 0x202020FF, PPR::LINE); color_t cols[3] = {0xFF8080FF, 0x80FF80FF, 0x8080FFFF}; for(int a=0; a> 2; - drawMonsterType(m, NULL, shiftless(V), mcol, glyphphase[id]/500.0, NOCOLOR); + drawMonsterType(m, NULL, V, mcol, glyphphase[id]/500.0, NOCOLOR); } else { eItem it = eItem(id); @@ -241,14 +241,14 @@ bool displayglyph(int cx, int cy, int buttonsize, char glyph, color_t color, int icol -= (color & 0xFCFCFC) >> 2; int ic = itemclass(it); bsize = bsize * zoom; - transmatrix V = atscreenpos(cx+buttonsize/2, cy, bsize); + shiftmatrix V = atscreenpos(cx+buttonsize/2, cy, bsize); double t = (ic == IC_ORB || ic == IC_NAI) ? ticks*2 : ((glyph == 't' && qty%5) || it == itOrbYendor) ? ticks/2 : it == itTerra ? glyphphase[id] * 3 * M_PI + 900 * M_PI: glyphphase[id] * 2; - drawItemType(it, NULL, shiftless(V), icol, t, false); + drawItemType(it, NULL, V, icol, t, false); int c1 = max(color_diff(color, backcolor), color_diff(color, bordcolor)); if(c1 < 0x80) { @@ -426,7 +426,7 @@ void drawMobileArrow(int i) { double dx = xmove + rad*(1+SKIPFAC-.2)/2 * cos(alpha); double dy = yb + rad*(1+SKIPFAC-.2)/2 * sin(alpha); - queuepolyat(shiftless(atscreenpos(dx, dy, scale) * spin(-alpha)), cgi.shArrow, col, PPR::MOBILE_ARROW); + queuepolyat(atscreenpos(dx, dy, scale) * spin(-alpha), cgi.shArrow, col, PPR::MOBILE_ARROW); } #endif @@ -455,8 +455,8 @@ EX void draw_crosshair() { if(crosshair_color && crosshair_size > 0) { initquickqueue(); vid.linewidth = 1; - queueline(shiftless(tC0(atscreenpos(xc - crosshair_size, yc, 1))), shiftless(tC0(atscreenpos(xc + crosshair_size, yc, 1))), crosshair_color).prio = PPR::SUPERLINE; - queueline(shiftless(tC0(atscreenpos(xc, yc - crosshair_size, 1))), shiftless(tC0(atscreenpos(xc, yc + crosshair_size, 1))), crosshair_color).prio = PPR::SUPERLINE; + queueline(tC0(atscreenpos(xc - crosshair_size, yc)), tC0(atscreenpos(xc + crosshair_size, yc)), crosshair_color).prio = PPR::SUPERLINE; + queueline(tC0(atscreenpos(xc, yc - crosshair_size)), tC0(atscreenpos(xc, yc + crosshair_size)), crosshair_color).prio = PPR::SUPERLINE; quickqueue(); } return; diff --git a/hypgraph.cpp b/hypgraph.cpp index 8a2b0d27..338f99c5 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -2563,7 +2563,7 @@ struct flat_model_enabler { }; #endif -EX transmatrix atscreenpos(ld x, ld y) { +EX shiftmatrix atscreenpos(ld x, ld y) { transmatrix V = Id; if(pmodel == mdPixel) { @@ -2588,14 +2588,14 @@ EX transmatrix atscreenpos(ld x, ld y) { if(S3 >= OINF) V[0][0] /= 5, V[1][1] /= 5; } - return V; + return shiftless(V); } -EX transmatrix atscreenpos(ld x, ld y, ld size) { - transmatrix V = atscreenpos(x, y); +EX shiftmatrix atscreenpos(ld x, ld y, ld size) { + shiftmatrix V = atscreenpos(x, y); ld s = size * 2 * cgi.hcrossf / cgi.crossf; - V[0][0] *= s; - V[1][1] *= s; + V.T[0][0] *= s; + V.T[1][1] *= s; return V; } diff --git a/inventory.cpp b/inventory.cpp index d48715e3..da3ab938 100644 --- a/inventory.cpp +++ b/inventory.cpp @@ -545,8 +545,8 @@ EX namespace inv { if(gg) { initquickqueue(); poly_outline = OUTLINE_DEFAULT; - transmatrix V = atscreenpos(px, py, rad*2); - drawItemType(o, NULL, shiftless(V), icol, ticks/3 + i * 137, false); + shiftmatrix V = atscreenpos(px, py, rad*2); + drawItemType(o, NULL, V, icol, ticks/3 + i * 137, false); quickqueue(); } diff --git a/racing.cpp b/racing.cpp index c4c75e7b..56be1f1d 100644 --- a/racing.cpp +++ b/racing.cpp @@ -1356,7 +1356,7 @@ void draw_ghost(ghost& ghost) { shiftmatrix racerel(ld rel) { int bsize = vid.fsize * 2; - return shiftless(atscreenpos(bsize, vid.yres - bsize - rel * (vid.yres - bsize*2) / 100, bsize) * spin90()); + return atscreenpos(bsize, vid.yres - bsize - rel * (vid.yres - bsize*2) / 100, bsize) * spin90(); } EX int get_percentage(cell *c) { @@ -1383,12 +1383,12 @@ EX void drawStats() { int bsize = vid.fsize * 2; for(int y: {bsize, vid.yres - bsize}) { - curvepoint(atscreenpos(bsize, y, bsize) * C0); - curvepoint(atscreenpos(bsize/2, y, bsize) * C0); - curvepoint(atscreenpos(bsize*3/2, y, bsize) * C0); - curvepoint(atscreenpos(bsize, y, bsize) * C0); + curvepoint(eupoint(bsize, y)); + curvepoint(eupoint(bsize/2, y)); + curvepoint(eupoint(bsize*3/2, y)); + curvepoint(eupoint(bsize, y)); } - queuecurve(shiftless(Id), 0xFFFFFFFF, 0, PPR::ZERO); + queuecurve(atscreenpos(0,0), 0xFFFFFFFF, 0, PPR::ZERO); for(auto& ghost: ghostset) draw_ghost_state(ghost); diff --git a/radar.cpp b/radar.cpp index 5122ed23..58327cf6 100644 --- a/radar.cpp +++ b/radar.cpp @@ -116,11 +116,11 @@ EX void draw_radar(bool cornermode) { ld cy = subscreens::in ? cd->ytop + cd->ysize - rad - 2 - vid.fsize : vid.yres-rad-2 - vid.fsize; - auto sId = shiftless(Id); + auto ASP = atscreenpos(0, 0); for(int i=0; i<=360; i++) - curvepoint(atscreenpos(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad, 1) * C0); - queuecurve(sId, 0xFFFFFFFF, 0x000000FF, PPR::ZERO); + curvepoint(eupoint(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad)); + queuecurve(ASP, 0xFFFFFFFF, 0x000000FF, PPR::ZERO); ld alpha = 15._deg; ld co = cos(alpha); @@ -128,29 +128,29 @@ EX void draw_radar(bool cornermode) { if(sph && !d3) { for(int i=0; i<=360; i++) - curvepoint(atscreenpos(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad*si, 1) * C0); - queuecurve(sId, 0, 0x200000FF, PPR::ZERO); + curvepoint(eupoint(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad*si)); + queuecurve(ASP, 0, 0x200000FF, PPR::ZERO); } if(d3) { for(int i=0; i<=360; i++) - curvepoint(atscreenpos(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad*si, 1) * C0); - queuecurve(sId, 0xFF0000FF, 0x200000FF, PPR::ZERO); + curvepoint(eupoint(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad*si)); + queuecurve(ASP, 0xFF0000FF, 0x200000FF, PPR::ZERO); - curvepoint(atscreenpos(cx-sin(vid.fov*degree/2)*rad, cy-sin(vid.fov*degree/2)*rad*si, 1) * C0); - curvepoint(atscreenpos(cx, cy, 1) * C0); - curvepoint(atscreenpos(cx+sin(vid.fov*degree/2)*rad, cy-sin(vid.fov*degree/2)*rad*si, 1) * C0); - queuecurve(sId, 0xFF8000FF, 0, PPR::ZERO); + curvepoint(eupoint(cx-sin(vid.fov*degree/2)*rad, cy-sin(vid.fov*degree/2)*rad*si)); + curvepoint(eupoint(cx, cy)); + curvepoint(eupoint(cx+sin(vid.fov*degree/2)*rad, cy-sin(vid.fov*degree/2)*rad*si)); + queuecurve(ASP, 0xFF8000FF, 0, PPR::ZERO); } 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); + queueline(ASP*eupoint(cx+rad * r.h[0], cy - rad * r.h[2] * si + rad * r.h[1] * co), ASP*eupoint(cx+rad*r.h[0], cy - rad*r.h[2] * si), r.line, -1); } if(scompass) { auto compassdir = [&] (char dirname, hyperpoint h) { h = NLP * h * .8; - queueline(sId*atscreenpos(cx+rad * h[0], cy - rad * h[2] * si + rad * h[1] * co, 0)*C0, sId*atscreenpos(cx+rad*h[0], cy - rad*h[2] * si, 0)*C0, 0xA0401040, -1); + queueline(ASP*eupoint(cx+rad * h[0], cy - rad * h[2] * si + rad * h[1] * co), ASP*eupoint(cx+rad*h[0], cy - rad*h[2] * si), 0xA0401040, -1); displaychr(int(cx+rad * h[0]), int(cy - rad * h[2] * si + rad * h[1] * co), 0, 8 * mapfontscale / 100, dirname, 0xA04010); }; compassdir('E', point3(+1, 0, 0)); @@ -176,9 +176,7 @@ EX void draw_radar(bool cornermode) { for(auto& r: cd->radarlines) { hyperpoint h1 = locate(r.h1); hyperpoint h2 = locate(r.h2); - h1 = tC0(atscreenpos(h1[0], h1[1], 1)); - h2 = tC0(atscreenpos(h2[0], h2[1], 1)); - queueline(sId*h1, sId*h2, r.line, -1); + queueline(ASP*eupoint(h1[0], h1[1]), ASP*eupoint(h2[0], h2[1]), r.line, -1); } quickqueue();