diff --git a/basegraph.cpp b/basegraph.cpp index 24332e61..92fc2097 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -17,6 +17,8 @@ struct display_data { cell *precise_center; /** The current rotation, relative to precise_center. */ transmatrix view_matrix; + /** Camera rotation, used in nonisotropic geometries. */ + transmatrix local_perspective; /** The view relative to the player character. */ transmatrix player_matrix; /** On-screen coordinates for all the visible cells. */ @@ -52,6 +54,7 @@ struct display_data { #define centerover (current_display->precise_center) #define gmatrix (current_display->cellmatrices) #define gmatrix0 (current_display->old_cellmatrices) +#define NLP (current_display->local_perspective) #endif diff --git a/graph.cpp b/graph.cpp index d5f06338..923a0a26 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3541,7 +3541,7 @@ void make_clipping_planes() { hyperpoint sx = point3(y1 * z2 - y2 * z1, z1 * x2 - z2 * x1, x1 * y2 - x2 * y1); sx /= hypot_d(3, sx); sx[3] = 0; - if(nisot::local_perspective_used()) sx = inverse(nisot::local_perspective) * sx; + if(nisot::local_perspective_used()) sx = inverse(NLP) * sx; clipping_planes.push_back(sx); }; ld tx = current_display->tanfov; @@ -4248,7 +4248,7 @@ EX void make_actual_view() { ld max = WDIM == 2 ? vid.camera : vid.yshift; if(max) { transmatrix Start = inverse(actual_view_transform * View); - ld d = wall_radar(centerover, Start, nisot::local_perspective, max); + ld d = wall_radar(centerover, Start, NLP, max); actual_view_transform = get_shift_view_of(ztangent(d), actual_view_transform * View) * inverse(View); } camera_level = asin_auto(tC0(inverse(actual_view_transform * View))[2]); @@ -4256,8 +4256,8 @@ EX void make_actual_view() { if(nonisotropic) { transmatrix T = actual_view_transform * View; transmatrix T2 = eupush( tC0(inverse(T)) ); - nisot::local_perspective = T * T2; - actual_view_transform = inverse(nisot::local_perspective) * actual_view_transform; + NLP = T * T2; + actual_view_transform = inverse(NLP) * actual_view_transform; } #endif #if MAXMDIM >= 4 diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 3246cf29..780afb84 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -1171,11 +1171,11 @@ EX ld geo_dist(const hyperpoint h1, const hyperpoint h2, iePrecision p) { } EX hyperpoint lp_iapply(const hyperpoint h) { - return nisot::local_perspective_used() ? inverse(nisot::local_perspective) * h : h; + return nisot::local_perspective_used() ? inverse(NLP) * h : h; } EX hyperpoint lp_apply(const hyperpoint h) { - return nisot::local_perspective_used() ? nisot::local_perspective * h : h; + return nisot::local_perspective_used() ? NLP * h : h; } EX hyperpoint smalltangent() { return xtangent(.1); } diff --git a/hypgraph.cpp b/hypgraph.cpp index f423e8a4..89bce806 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -320,7 +320,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { H /= exp(zlev); hybrid::in_underlying_geometry([&] { applymodel(H, ret); }); ret[2] = zlev * models::product_z_scale; - ret = nisot::local_perspective * ret; + ret = NLP * ret; return; } @@ -514,7 +514,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { case mdHyperboloid: { if(nonisotropic) { - // if(nisot::local_perspective_used()) H = nisot::local_perspective * H; + // if(nisot::local_perspective_used()) H = NLP * H; ret = lp_apply(H); break; } @@ -1369,7 +1369,7 @@ EX void centerpc(ld aspd) { int sl = snakelevel(cwt.at); if(sl && WDIM == 2) T = T * zpush(cgi.SLEV[sl] - cgi.FLOOR); View = inverse(T); - if(prod) nisot::local_perspective = inverse(pc->ori); + if(prod) NLP = inverse(pc->ori); if(WDIM == 2) rotate_view( cspin(0, 1, M_PI) * cspin(2, 1, M_PI/2 + shmup::playerturny[id]) * spin(-M_PI/2) ); return; } @@ -1486,7 +1486,7 @@ EX void resetview() { View = Id; } cwtV = View; - nisot::local_perspective = Id; + NLP = Id; // SDL_LockSurface(s); // SDL_UnlockSurface(s); } @@ -2069,7 +2069,7 @@ EX int cone_side(const hyperpoint H) { /** get the current orientation of the view */ EX transmatrix& get_view_orientation() { - return prod ? nisot::local_perspective : View; + return prod ? NLP : View; } /** rotate the view using the given rotation matrix */ diff --git a/nonisotropic.cpp b/nonisotropic.cpp index d2813cee..2e358f2e 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -13,7 +13,6 @@ EX namespace nisot { typedef array ptlow; #endif - EX transmatrix local_perspective; #if HDR inline bool local_perspective_used() { return nonisotropic || prod; } #endif @@ -1674,7 +1673,7 @@ EX namespace rots { auto g = std::move(gmatrix); auto g0 = std::move(gmatrix0); - ld alpha = atan2(inverse(nisot::local_perspective) * point3(1, 0, 0)); + ld alpha = atan2(inverse(NLP) * point3(1, 0, 0)); bool inprod = prod; transmatrix pView = View; diff --git a/radar.cpp b/radar.cpp index aa72cee7..0e1cd64f 100644 --- a/radar.cpp +++ b/radar.cpp @@ -32,7 +32,7 @@ pair makeradar(hyperpoint h) { else return {false, h}; } if(prod) h = product::inverse_exp(h); - if(nisot::local_perspective_used()) h = nisot::local_perspective * h; + if(nisot::local_perspective_used()) h = NLP * h; if(WDIM == 3) { if(d >= vid.radarrange) return {false, h}; @@ -141,7 +141,7 @@ EX void draw_radar(bool cornermode) { if(scompass) { auto compassdir = [&] (char dirname, hyperpoint h) { - h = nisot::local_perspective * h * .8; + h = NLP * h * .8; queueline(atscreenpos(cx+rad * h[0], cy - rad * h[2] * si + rad * h[1] * co, 0)*C0, atscreenpos(cx+rad*h[0], cy - rad*h[2] * si, 0)*C0, 0xA0401040, -1); displaychr(int(cx+rad * h[0]), int(cy - rad * h[2] * si + rad * h[1] * co), 0, 8, dirname, 0xA04010); }; diff --git a/raycaster.cpp b/raycaster.cpp index 1bbec120..e7988b80 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -817,7 +817,7 @@ EX void cast() { cell *cs = centerover; transmatrix T = cview(); - if(nonisotropic) T = nisot::local_perspective * T; + if(nonisotropic) T = NLP * T; T = inverse(T); virtualRebase(cs, T, true); @@ -849,7 +849,7 @@ EX void cast() { GLERR("uniform length"); glUniformMatrix4fv(o->uStart, 1, 0, glhr::tmtogl_transpose3(T).as_array()); - if(o->uLP != -1) glUniformMatrix4fv(o->uLP, 1, 0, glhr::tmtogl_transpose3(inverse(nisot::local_perspective)).as_array()); + if(o->uLP != -1) glUniformMatrix4fv(o->uLP, 1, 0, glhr::tmtogl_transpose3(inverse(NLP)).as_array()); GLERR("uniform start"); uniform2(o->uStartid, enc(ids[cs], 0)); GLERR("uniform startid"); diff --git a/shaders.cpp b/shaders.cpp index d57abbd3..b0379fa4 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -358,7 +358,7 @@ void display_data::set_projection(int ed) { else M[2][2] /= 1000; glhr::projection_multiply(M); if(nisot::local_perspective_used() && (shader_flags & SF_BOX)) - glhr::projection_multiply(glhr::tmtogl_transpose(nisot::local_perspective)); + glhr::projection_multiply(glhr::tmtogl_transpose(NLP)); if(ed) { glhr::glmatrix m = glhr::id; m[2][0] -= ed; @@ -374,10 +374,10 @@ void display_data::set_projection(int ed) { glhr::projection_multiply(glhr::scale(1, -1, -1)); if(nisot::local_perspective_used()) { if(prod) { - for(int i=0; i<3; i++) nisot::local_perspective[3][i] = nisot::local_perspective[i][3] = 0; - nisot::local_perspective[3][3] = 1; + for(int i=0; i<3; i++) NLP[3][i] = NLP[i][3] = 0; + NLP[3][3] = 1; } - glhr::projection_multiply(glhr::tmtogl_transpose(nisot::local_perspective)); + glhr::projection_multiply(glhr::tmtogl_transpose(NLP)); } if(ed) { glhr::using_eyeshift = true;