From a79d28fafe14a355b265073244f1c641ffaabba6 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 9 Oct 2021 10:24:35 +0200 Subject: [PATCH] more portal fixes --- intra.cpp | 15 ++++++++++----- raycaster.cpp | 17 +++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/intra.cpp b/intra.cpp index 56b8c858..15275fd0 100644 --- a/intra.cpp +++ b/intra.cpp @@ -142,7 +142,12 @@ EX portal_data make_portal(cellwalker cw, int spin) { id.d = product_decompose(fac[0]).first; id.v0 = C0 * exp(id.d); if(bt::in()) { - fac.pop_back(); + for(auto h: fac) + println(hlog, PIU(deparabolic13(normalize_flat(h)))); + if(cw.spin == cw.at->type - 2) + fac.pop_back(); + else + fac.erase(fac.begin() + 1); id.scale = log(2)/2; } else { @@ -157,12 +162,12 @@ EX portal_data make_portal(cellwalker cw, int spin) { id.v0 = Hypc; id.scale = cgi.plevel; for(auto p: fac) id.v0 += p; - id.v0 /= sqrt(abs(intval(id.v0, Hypc))); - hyperpoint h = fac[0]; - h /= sqrt(abs(intval(h, Hypc))); + id.v0 = normalize_flat(id.v0); + hyperpoint h = normalize_flat(fac[0]); id.T = cspin(0, 1, -90*degree) * spintox(gpushxto0(id.v0) * h) * gpushxto0(id.v0); + if((id.T * C0)[0] > 0) id.T = cspin(0, 1, 180*degree) * id.T; for(int i=0; i<3; i++) id.T[3][i] = id.T[i][3] = i==3; - if(debugflags & DF_GEOM) + // if(debugflags & DF_GEOM) for(int a=0; a<4; a++) { hyperpoint h = fac[a]; println(hlog, kz(h), " -> ", kz(spintox(id.v0)*h), " -> ", kz(cpush(0, -hdist0(id.v0))) * kz(spintox(id.v0) * h), " -> ", kz(id.to_poco(h))); diff --git a/raycaster.cpp b/raycaster.cpp index e48cfe82..44a41132 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -1012,12 +1012,17 @@ void raygen::emit_intra_portal(int gid1, int gid2) { fmain += "if(pconnection.x != .5) {\n"; // kind != 0 if(1) { string fn = bt::in() ? "to_poco_h2xr_b" : in_h2xe() ? "to_poco_h2xr_h" : "to_poco_s2xr_s"; + string tmul = ""; + if(!bt::in()) { + fmain += + " mediump mat4 tkt = " + getM("mid+1") + ";\n"; + tmul = "tkt*"; + } fmain += - " mediump mat4 tkt = " + getM("mid+1") + ";\n" " nposition = position + tangent * xspeed * 1e-3;\n" - " position = "+fn+"(tkt*position);\n" + " position = "+fn+"("+tmul+"position);\n" " position.z = 0.;\n" // zpos - uPLevel;\n" - " nposition = "+fn+"(tkt*nposition);\n" + " nposition = "+fn+"("+tmul+"nposition);\n" " nposition.z = zspeed * 1e-3;\n" " if(pconnection.y < .5) { nposition.z = -nposition.z; nposition.x = -nposition.x; position.x = -position.x; }\n"; } @@ -1081,15 +1086,15 @@ void raygen::emit_intra_portal(int gid1, int gid2) { fmain += "if(pconnection.z != .5) {\n"; // kind != 0 if(1) { string sgn = in_h2xe() ? "-" : "+"; - string fn = bt::in() ? "from_poco_h2xr_b" : in_h2xe() ? "from_poco_h2xr_h" : "from_poco_s2xr_s"; + string fn = bt::in() ? "from_poco_h2xr_b" : in_h2xe() ? "itkt*from_poco_h2xr_h" : "itkt*from_poco_s2xr_s"; fmain += " if(pconnection.w < .5) { position.z = -position.z; nposition.z = -nposition.z; nposition.x = -nposition.x; position.x = -position.x; }\n" " zspeed = (nposition.z - position.z) * 1e3;\n" " zpos = position.z + (pconnection.w - .5) * 16.;\n" " mediump mat4 itkt = " + getM("mid+2") + ";\n" - " position = itkt*"+fn+"(position);\n" - " nposition = itkt*"+fn+"(nposition);\n" + " position = "+fn+"(position);\n" + " nposition = "+fn+"(nposition);\n" " tangent = (nposition - position) * 1e3;\n" " mediump float pnorm = tangent.z * position.z "+sgn+" tangent.x * position.x "+sgn+" tangent.y * position.y;\n" " tangent -= position * pnorm;\n"