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

fixed/improved dice in non-H geometries

This commit is contained in:
Zeno Rogue 2021-05-30 22:31:31 +02:00
parent ec966403fe
commit 199d5ef598

View File

@ -1226,13 +1226,24 @@ EX namespace dice {
ld base_to_base; ld base_to_base;
bool osphere = sphere && GDIM == 2;
bool oeuclid = euclid && GDIM == 2;
eGeometry highdim =
(GDIM == 3) ? geometry :
hyperbolic ? gSpace534 : gCubeTiling;
if(1) { if(1) {
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
hyperpoint h = cspin(2, 0, M_PI-outradius) * zpush0(-dieradius); hyperpoint h = cspin(2, 0, M_PI-outradius) * zpush0(-dieradius);
base_to_base = binsearch(-5, 5, [h] (ld d) { if(osphere || oeuclid)
base_to_base = -h[2];
else {
ld lim = sphere ? 1 : 5;
base_to_base = binsearch(-lim, lim, [h, osphere] (ld d) {
return (zpush(d) * h)[2] >= sin_auto(vid.depth); return (zpush(d) * h)[2] >= sin_auto(vid.depth);
}); });
} }
}
vector<pair<ld, int> > ordering; vector<pair<ld, int> > ordering;
@ -1242,12 +1253,12 @@ EX namespace dice {
int ws = facequeue[i].second; int ws = facequeue[i].second;
for(int d=0; d<si; d++) { for(int d=0; d<si; d++) {
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
add_to_queue(T * cspin(0, 1, 2*M_PI*d/si) * cspin(2, 0, inradius) * cspin(0, 1, M_PI-2*M_PI*dw->spins[ws][d]/si), dw->sides[ws][d]); add_to_queue(T * cspin(0, 1, 2*M_PI*d/si) * cspin(2, 0, inradius) * cspin(0, 1, M_PI-2*M_PI*dw->spins[ws][d]/si), dw->sides[ws][d]);
} }
if(1) { if(1) {
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
hyperpoint h = zpush(base_to_base) * T * zpush0(dieradius); hyperpoint h = zpush(base_to_base) * T * zpush0(dieradius);
ld z = fpp ? hdist0(h) : asin_auto(h[2]); ld z = fpp ? hdist0(h) : asin_auto(h[2]);
ordering.emplace_back(-z, i); ordering.emplace_back(-z, i);
@ -1266,8 +1277,13 @@ EX namespace dice {
auto sphere_to_space = [&] (hyperpoint h) { auto sphere_to_space = [&] (hyperpoint h) {
if(fpp) return h; if(fpp) return h;
if(osphere) {
h[2] = 1 - h[2]; h[3] = 0;
return h;
}
if(oeuclid) { h[2] = 1-h[2]; return h; }
ld z = asin_auto(h[2]); ld z = asin_auto(h[2]);
h /= cos_auto(z); h = zpush(-z) * h;
h[2] = h[3]; h[3] = 0; h[2] = h[3]; h[3] = 0;
dynamicval<eGeometry> g(geometry, orig); dynamicval<eGeometry> g(geometry, orig);
return zshift(h, geom3::scale_at_lev(z)); return zshift(h, geom3::scale_at_lev(z));
@ -1276,7 +1292,7 @@ EX namespace dice {
for(int d=0; d<=si; d++) { for(int d=0; d<=si; d++) {
hyperpoint h, hs; hyperpoint h, hs;
if(1) { if(1) {
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
h = zpush(base_to_base) * T * cspin(0, 1, 2*M_PI*(d+.5)/si) * cspin(2, 0, outradius) * zpush0(dieradius); h = zpush(base_to_base) * T * cspin(0, 1, 2*M_PI*(d+.5)/si) * cspin(2, 0, outradius) * zpush0(dieradius);
if(d < si) face[d] = h; if(d < si) face[d] = h;
hs = sphere_to_space(h); hs = sphere_to_space(h);
@ -1286,21 +1302,21 @@ EX namespace dice {
hyperpoint ctr, cx, cy; hyperpoint ctr, cx, cy;
if(dw->facesides == 3) { if(dw->facesides == 3) {
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
ctr = (face[0] + face[1] + face[2]) / 3; ctr = (face[0] + face[1] + face[2]) / 3;
ctr = ctr * 1.01 - dctr * 0.01; ctr = ctr * 1.01 - dctr * 0.01;
cx = face[2] - face[0]; cx = face[2] - face[0];
cy = face[1] - (face[0] + face[2]) / 2; cy = face[1] - (face[0] + face[2]) / 2;
} }
if(dw->facesides == 4) { if(dw->facesides == 4) {
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
ctr = (face[0] + face[1] + face[2] + face[3]) / 4; ctr = (face[0] + face[1] + face[2] + face[3]) / 4;
ctr = ctr * 1.01 - dctr * 0.01; ctr = ctr * 1.01 - dctr * 0.01;
cx = face[1] - face[2]; cx = face[1] - face[2];
cy = face[0] - face[1]; cy = face[0] - face[1];
} }
if(dw->facesides == 5) { if(dw->facesides == 5) {
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
ctr = (face[0] + face[1] + face[2] + face[3] + face[4]) / 5; ctr = (face[0] + face[1] + face[2] + face[3] + face[4]) / 5;
ctr = ctr * 1.01 - dctr * 0.01; ctr = ctr * 1.01 - dctr * 0.01;
cx = (face[2] - face[0]) * .75; cx = (face[2] - face[0]) * .75;
@ -1312,7 +1328,7 @@ EX namespace dice {
#if !CAP_EXTFONT #if !CAP_EXTFONT
pointfunction pf = [&] (ld x, ld y) { pointfunction pf = [&] (ld x, ld y) {
hyperpoint hs; hyperpoint hs;
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
return sphere_to_space(normalize(ctr + cx * x + cy * y)); return sphere_to_space(normalize(ctr + cx * x + cy * y));
}; };
@ -1322,7 +1338,7 @@ EX namespace dice {
int j1 = (j+1)%3; int j1 = (j+1)%3;
int j2 = (j+2)%3; int j2 = (j+2)%3;
if(1) { if(1) {
dynamicval<eGeometry> g(geometry, gSpace534); dynamicval<eGeometry> g(geometry, highdim);
ctr = (face[0] + face[1] + face[2] + face[j1] * 3) / 6; ctr = (face[0] + face[1] + face[2] + face[j1] * 3) / 6;
ctr = ctr * 1.01 - dctr * 0.01; ctr = ctr * 1.01 - dctr * 0.01;
cx = (face[j2] - face[j]) / 2; cx = (face[j2] - face[j]) / 2;