1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 09:30:35 +00:00

auto-configure Clifford Torus embedding

This commit is contained in:
Zeno Rogue 2023-01-05 16:12:23 +01:00
parent 2182f442d9
commit dd01cd9af4
2 changed files with 22 additions and 1 deletions

View File

@ -1400,6 +1400,7 @@ EX void switch_always3() {
vid.wall_height *= -1;
}
}
if(spatial_embedding == seCliffordTorus) configure_clifford_torus();
}
else {
vid.always3 = false;
@ -1418,6 +1419,20 @@ EX void switch_always3() {
#endif
}
EX void configure_clifford_torus() {
rug::clifford_torus ct;
euclid_embed_scale = TAU / hypot_d(2, ct.xh);
euclid_embed_scale_y = TAU / hypot_d(2, ct.yh) / euclid_embed_scale;
euclid_embed_rotate = atan2(ct.xh[1], ct.xh[0]) / degree;
ld alpha = atan2(ct.xfactor, ct.yfactor);
vid.depth = alpha - 1;
vid.wall_height = min(1 / euclid_embed_scale_mean(), (90._deg - alpha) * 0.9);
vid.eye = vid.wall_height / 2 - vid.depth;
}
EX }
EX geometry_information *cgip;

View File

@ -395,8 +395,14 @@ clifford_torus::clifford_torus() {
auto p1 = to_loc(euc::eu.user_axes[0]);
auto p2 = to_loc(euc::eu.user_axes[1]);
bool f = embedded_plane;
if(f) geom3::light_flip(true);
xh = euc::eumove(p1)*C0-C0;
yh = euc::eumove(p2)*C0-C0;
if(f) geom3::light_flip(false);
xh[2] = xh[3] = yh[2] = yh[3] = 0;
dynamicval<eGeometry> g(geometry, gCubeTiling);
if(nonorientable) yh *= 2;
flipped = false; // sqhypot_d(2, xh) < sqhypot_d(2, yh);
@ -409,7 +415,7 @@ clifford_torus::clifford_torus() {
yfactor = sqrt(1/(1+factor2));
xfactor = factor * yfactor;
T = build_matrix(xh, yh, C0, C03);
T = build_matrix(xh, yh, C02, C03);
iT = inverse(T);
}