product:: works with Euclidean

This commit is contained in:
Zeno Rogue 2019-11-28 23:30:29 +01:00
parent 5add972bdd
commit f3c97f9342
4 changed files with 24 additions and 5 deletions

View File

@ -279,8 +279,12 @@ void set_or_configure_geometry(eGeometry g) {
#endif
else {
if(among(g, gProduct, gRotSpace)) {
if(WDIM == 3 || euclid) {
addMessage(XLAT("Only works with 2D non-Euclidean geometries"));
if(WDIM == 3 || (g == gRotSpace && euclid)) {
addMessage(XLAT(
g == gRotSpace ?
"Only works with 2D non-Euclidean geometries"
: "Only works with 2D geometries"
));
return;
}
if(g == gRotSpace) {

View File

@ -373,6 +373,7 @@ EX ld zlevel(const hyperpoint &h) {
if(sl2) return sqrt(-intval(h, Hypc));
else if(translatable) return h[LDIM];
else if(sphere) return sqrt(intval(h, Hypc));
else if(in_e2xe()) return log(h[2]);
else if(prod) return log(sqrt(abs(intval(h, Hypc)))); /* abs works with both underlying spherical and hyperbolic */
else return (h[LDIM] < 0 ? -1 : 1) * sqrt(-intval(h, Hypc));
}

View File

@ -1226,15 +1226,17 @@ EX namespace product {
cell *c = cw.at;
if(sphere) gmatrix[c] = V; /* some computations need gmatrix0 for underlying geometry */
bool s = sphere || pmodel != mdPerspective;
bool euc = euclid;
hybrid::in_actual([&] {
cell *c0 = hybrid::get_at(c, z0);
cwall_offset = hybrid::wall_offset(c0);
if(s) cwall_mask = (1<<c->type) - 1;
else {
cwall_mask = 0;
ld d = V[2][2];
ld d = euc ? sqhypot_d(2, tC0(V)) : V[2][2];
for(int i=0; i<c->type; i++) {
ld d1 = (V * cgi.walltester[cwall_offset + i])[2];
hyperpoint h = (V * cgi.walltester[cwall_offset + i]);
ld d1 = euc ? sqhypot_d(2, h) : h[2];
if(d1 < d - 1e-6) cwall_mask |= (1<<i);
}
}
@ -1256,7 +1258,11 @@ EX namespace product {
res[2] = zlevel(h);
h = zshift(h, -res[2]);
ld r = hypot_d(2, h);
if(r < 1e-6) {
if(hybrid::under_class() == gcEuclid) {
res[0] = h[0];
res[1] = h[1];
}
else if(r < 1e-6) {
res[0] = h[0];
res[1] = h[1];
}

View File

@ -209,6 +209,14 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
distfun = "sqrt(z*z+d*d)";
treset = true;
}
else if(in_e2xe() && pmodel == mdPerspective) {
shader_flags |= SF_PERS3 | SF_DIRECT;
coordinator +=
"t.xy /= t.z;\n"
"t.z = log(t.z);\n";
distfun = "length(t.xyz)";
treset = true;
}
else if(in_s2xe() && pmodel == mdPerspective) {
shader_flags |= SF_PERS3 | SF_DIRECT;
distfun = "length(t.xyz)", treset = true;