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

nisot::local_perspective moved to display_data

This commit is contained in:
Zeno Rogue 2019-11-14 17:20:55 +01:00
parent 0f84ec8dc8
commit 3eee611eca
8 changed files with 23 additions and 21 deletions

View File

@ -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

View File

@ -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

View File

@ -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); }

View File

@ -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 */

View File

@ -13,7 +13,6 @@ EX namespace nisot {
typedef array<float, 3> 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;

View File

@ -32,7 +32,7 @@ pair<bool, hyperpoint> 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);
};

View File

@ -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");

View File

@ -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;