1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

ray:: special case for WDIM==2 triangles

This commit is contained in:
Zeno Rogue 2020-06-03 16:43:11 +02:00
parent 449966903e
commit 1ac116909f

View File

@ -1160,15 +1160,27 @@ EX void cast() {
ms[id+j] = hybrid::ray_iadj(c, j); ms[id+j] = hybrid::ray_iadj(c, j);
if(WDIM == 2) for(int a: {0, 1}) { if(WDIM == 2) for(int a: {0, 1}) {
int z = a ? 1 : -1; int z = a ? 1 : -1;
hyperpoint h = Hypc;
for(int a=0; a<c->type; a++) { if(c->type == 3) {
hyperpoint corner = hybrid::get_corner(c, a, 0, z); hyperpoint h =
h += corner; project_on_triangle(
hybrid::get_corner(c, a, 0, z),
hybrid::get_corner(c, a, 1, z),
hybrid::get_corner(c, a, 2, z)
);
ms[id+c->type+a] = rspintox(h) * xpush(-2*hdist0(h)) * spintox(h);
}
else {
hyperpoint h = Hypc;
for(int a=0; a<c->type; a++) {
hyperpoint corner = hybrid::get_corner(c, a, 0, z);
h += corner;
}
h = normalize(h);
ld d = hdist0(h);
if(h[2] > 0) d = -d;
ms[id+c->type+a] = zpush(2*d);
} }
h = normalize(h);
ld d = hdist0(h);
if(h[2] > 0) d = -d;
ms[id+c->type+a] = zpush(2*d);
} }
} }