From 1ac116909ff755bc3c110eea08db86dc3a81438d Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 3 Jun 2020 16:43:11 +0200 Subject: [PATCH] ray:: special case for WDIM==2 triangles --- raycaster.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/raycaster.cpp b/raycaster.cpp index a4772c57..de34f8b3 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -1160,15 +1160,27 @@ EX void cast() { ms[id+j] = hybrid::ray_iadj(c, j); if(WDIM == 2) for(int a: {0, 1}) { int z = a ? 1 : -1; - hyperpoint h = Hypc; - for(int a=0; atype; a++) { - hyperpoint corner = hybrid::get_corner(c, a, 0, z); - h += corner; + + if(c->type == 3) { + hyperpoint h = + 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; atype; 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); } }