1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-26 18:10:35 +00:00

fixed lta

This commit is contained in:
Zeno Rogue 2023-01-06 00:24:45 +01:00
parent 4b3bfb9932
commit 1fc48be781
4 changed files with 23 additions and 20 deletions

View File

@ -206,6 +206,12 @@ struct geometry_information {
/* convert the tangent space in actual coordinates to logical coordinates */ /* convert the tangent space in actual coordinates to logical coordinates */
transmatrix actual_to_logical; transmatrix actual_to_logical;
/* convert the tangent space in logical coordinates to actual coordinates */
transmatrix logical_to_actual_units;
/* convert the tangent space in actual coordinates to logical coordinates */
transmatrix actual_to_logical_units;
/** size of the Sword (from Orb of the Sword), used in the shmup mode */ /** size of the Sword (from Orb of the Sword), used in the shmup mode */
ld sword_size; ld sword_size;
/** scale factor for the graphics of most things*/ /** scale factor for the graphics of most things*/
@ -591,15 +597,18 @@ void geometry_information::prepare_lta() {
if(b) geom3::light_flip(false); if(b) geom3::light_flip(false);
lta = Id; lta = Id;
if(embedded_plane) { if(embedded_plane) {
if(geom3::euc_in_noniso()) {
lta[0][0] *= geom3::euclid_embed_scale;
lta[1][1] *= geom3::euclid_embed_scale * geom3::euclid_embed_scale_y;
lta = cspin(0, 1, geom3::euclid_embed_rotate * degree) * lta;
}
if(geom3::euc_vertical()) lta = cspin90(2, 1) * lta; if(geom3::euc_vertical()) lta = cspin90(2, 1) * lta;
if(geom3::hyp_in_solnih()) lta = cspin90(0, 1) * cspin90(1, 2) * cspin90(0, 1) * lta; if(geom3::hyp_in_solnih()) lta = cspin90(0, 1) * cspin90(1, 2) * cspin90(0, 1) * lta;
} }
logical_to_actual_units = lta;
if(geom3::euc_in_noniso()) {
lta = Id;
lta[0][0] *= geom3::euclid_embed_scale;
lta[1][1] *= geom3::euclid_embed_scale * geom3::euclid_embed_scale_y;
lta = cspin(0, 1, geom3::euclid_embed_rotate * degree) * lta * logical_to_actual_units;
}
actual_to_logical = inverse(lta); actual_to_logical = inverse(lta);
actual_to_logical_units = inverse(logical_to_actual_units);
if(b) geom3::light_flip(true); if(b) geom3::light_flip(true);
} }
@ -1142,8 +1151,8 @@ EX namespace geom3 {
EX ld euclid_embed_scale_mean() { return euclid_embed_scale * sqrt(euclid_embed_scale_y); } EX ld euclid_embed_scale_mean() { return euclid_embed_scale * sqrt(euclid_embed_scale_y); }
EX void set_euclid_embed_scale(ld x) { euclid_embed_scale = x; euclid_embed_scale_y = 1; euclid_embed_rotate = 0; } EX void set_euclid_embed_scale(ld x) { euclid_embed_scale = x; euclid_embed_scale_y = 1; euclid_embed_rotate = 0; }
EX bool supports_flat() { return spatial_embedding == seDefault; } EX bool supports_flat() { return among(spatial_embedding, seDefault, seProductH, seProductS); }
EX bool supports_invert() { return among(spatial_embedding, seDefault, seLowerCurvature, seMuchLowerCurvature, seNil, seSol, seNIH, seSolN); } EX bool supports_invert() { return among(spatial_embedding, seDefault, seLowerCurvature, seMuchLowerCurvature, seNil, seSol, seNIH, seSolN, seProductH, seProductS); }
EX vector<geometryinfo> ginf_backup; EX vector<geometryinfo> ginf_backup;
@ -1382,7 +1391,7 @@ EX void switch_always3() {
vid.depth = 0.5; vid.depth = 0.5;
} }
} }
if(spatial_embedding == seDefault && flat_embedding) { if(supports_flat() && flat_embedding) {
vid.eye += vid.depth / 2; vid.eye += vid.depth / 2;
vid.depth = 0; vid.depth = 0;
} }

View File

@ -5101,13 +5101,13 @@ EX void make_actual_view() {
transmatrix T = actual_view_transform * View; transmatrix T = actual_view_transform * View;
ld z = -tC0(view_inverse(T)) [2]; ld z = -tC0(view_inverse(T)) [2];
transmatrix R = actual_view_transform; transmatrix R = actual_view_transform;
R = cgi.logical_to_actual * R; R = cgi.logical_to_actual_units * R;
if(R[1][2] || R[2][2]) if(R[1][2] || R[2][2])
R = cspin(1, 2, -atan2(R[1][2], R[2][2])) * R; R = cspin(1, 2, -atan2(R[1][2], R[2][2])) * R;
if(R[0][2] || R[2][2]) if(R[0][2] || R[2][2])
R = cspin(0, 2, -atan2(R[0][2], R[2][2])) * R; R = cspin(0, 2, -atan2(R[0][2], R[2][2])) * R;
if(geom3::hyp_in_solnih()) R = Id; if(geom3::hyp_in_solnih()) R = Id;
R = cgi.actual_to_logical * R; R = cgi.actual_to_logical_units * R;
current_display->radar_transform = inverse(R) * zpush(-z); current_display->radar_transform = inverse(R) * zpush(-z);
} }
else if(gproduct) { else if(gproduct) {

View File

@ -675,7 +675,7 @@ EX transmatrix spin(ld alpha) {
} }
EX transmatrix unswap_spin(transmatrix T) { EX transmatrix unswap_spin(transmatrix T) {
return cgi.actual_to_logical * T * cgi.logical_to_actual; return cgi.actual_to_logical_units * T * cgi.logical_to_actual_units;
} }
/** rotate by 90 degrees in the XY plane */ /** rotate by 90 degrees in the XY plane */

View File

@ -2036,7 +2036,7 @@ EX void adjust_eye(transmatrix& T, cell *c, ld sign) {
/** achieve top-down perspective */ /** achieve top-down perspective */
EX transmatrix default_spin() { EX transmatrix default_spin() {
return cspin90(0, 1) * cgi.actual_to_logical; return cspin90(0, 1) * cgi.actual_to_logical_units;
} }
EX void centerpc(ld aspd) { EX void centerpc(ld aspd) {
@ -2207,12 +2207,6 @@ void ballgeometry() {
queuereset(pmodel, PPR::CIRCLE); queuereset(pmodel, PPR::CIRCLE);
} }
EX transmatrix logical_to_actual_units() {
transmatrix T = cgi.logical_to_actual;
for(int i=0; i<3; i++) set_column(T, i, get_column(T, i) / hypot_d(3, get_column(T, i)));
return T;
}
EX void resetview() { EX void resetview() {
DEBBI(DF_GRAPH, ("reset view")); DEBBI(DF_GRAPH, ("reset view"));
// EUCLIDEAN // EUCLIDEAN
@ -2245,7 +2239,7 @@ EX void resetview() {
if(WDIM == 2) vo = spin(M_PI + vid.fixed_facing_dir * degree) * vo; if(WDIM == 2) vo = spin(M_PI + vid.fixed_facing_dir * degree) * vo;
if(WDIM == 3) vo = cspin90(0, 2) * vo; if(WDIM == 3) vo = cspin90(0, 2) * vo;
vo = inverse(logical_to_actual_units()) * vo; vo = cgi.actual_to_logical_units * vo;
if(embedded_plane) vo = cspin90(1, 2) * vo; if(embedded_plane) vo = cspin90(1, 2) * vo;
if(embedded_plane && vid.wall_height < 0) vo = cspin180(0, 1) * vo; if(embedded_plane && vid.wall_height < 0) vo = cspin180(0, 1) * vo;