diff --git a/drawing.cpp b/drawing.cpp index 3aab0149..8184509f 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -298,13 +298,18 @@ hyperpoint goodpoint; vector> tofix; EX bool two_sided_model() { + #if CAP_VR + bool in_vr = vrhr::state == 2; + #else + constexpr bool in_vr = false; + #endif if(GDIM == 3) return false; - if(pmodel == mdHyperboloid) return !euclid && vrhr::state != 2; + if(pmodel == mdHyperboloid) return !euclid && !in_vr; // if(pmodel == mdHemisphere) return true; if(pmodel == mdDisk) return sphere; if(pmodel == mdRetroLittrow) return sphere; if(pmodel == mdRetroHammer) return sphere; - if(pmodel == mdHemisphere) return vrhr::state != 2; + if(pmodel == mdHemisphere) return !in_vr; if(pmodel == mdRotatedHyperboles) return true; if(pmodel == mdSpiral && pconf.spiral_cone < 360) return true; return false; @@ -357,9 +362,11 @@ void fixpoint(glvertex& hscr, hyperpoint H) { } hyperpoint Hscr; applymodel(shiftless(good), Hscr); + #if CAP_VR if(vrhr::state == 2) hscr = glhr::makevertex(Hscr[0], Hscr[1]*pconf.stretch, Hscr[2]); else + #endif hscr = glhr::makevertex(Hscr[0]*current_display->radius, Hscr[1]*current_display->radius*pconf.stretch, Hscr[2]*current_display->radius); } @@ -368,7 +375,9 @@ void addpoint(const shiftpoint& H) { ld z = current_display->radius; // if(pconf.alpha + H[2] <= BEHIND_LIMIT && pmodel == mdDisk) poly_flags |= POLY_BEHIND; + #if CAP_VR if(vrhr::state == 2) z = 1; + #endif if(spherespecial) { auto H0 = H.h; @@ -410,10 +419,13 @@ void addpoint(const shiftpoint& H) { } Hlast = Hscr; } + #if CAP_VR if(vrhr::state == 2) { for(int i=0; i<3; i++) Hscr[i] *= z; } - else if(GDIM == 2) { + else + #endif + if(GDIM == 2) { for(int i=0; i<3; i++) Hscr[i] *= z; Hscr[1] *= pconf.stretch; } diff --git a/hypgraph.cpp b/hypgraph.cpp index da84baee..79d1d357 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -148,7 +148,10 @@ void ballmodel(hyperpoint& ret, double alpha, double d, double zl) { } bool use_z_coordinate() { - return vrhr::state == 2 || current_display->stereo_active(); + #if CAP_VR + if(vrhr::state == 2) return true; + #endif + return current_display->stereo_active(); } void apply_depth(hyperpoint &f, ld z) { @@ -612,12 +615,13 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { ld zl = zlevel(H); ret = H / H[2]; ret[2] = sqrt(1 - sqhypot_d(2, ret)); - if(vrhr::state == 2) { - ret = ret * (1 + (1 - zl) * ret[2] * pconf.depth_scaling); - models::apply_vr(ret[2], ret[1]); - return; - } - ret = ret * (1 + (zl - 1) * ret[2]); + // need to reverse in VR + #if CAP_VR + ld dir = vrhr::state == 2 ? -1:1; + #else + constexpr ld dir = 1; + #endif + ret = ret * (1 + (zl - 1) * ret[2] * pconf.depth_scaling * dir); break; } @@ -630,16 +634,27 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { ld y = x / hd; ret = H * x / hd / pconf.euclid_to_sphere; ret[2] = (1 - y); - ret = ret * (1 + (H[2]-1) * y / pconf.euclid_to_sphere); + ret = ret * (1 + (H[2]-1) * y * pconf.depth_scaling / pconf.euclid_to_sphere); } break; } case gcSphere: { ret = H; + if(pconf.depth_scaling != 1) { + ld v = intval(H, Hypc); + ret *= pow(v, (pconf.depth_scaling-1) / 2); + } break; } } + + #if CAP_VR + if(vrhr::state == 2) { + models::apply_vr(ret[2], ret[1]); + return; + } + #endif swap(ret[1], ret[2]); @@ -661,18 +676,25 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { break; } + #if CAP_VR if(vrhr::state == 2) { ret[0] = H[0] * pconf.hyperboloid_scaling; ret[1] = H[1] * pconf.hyperboloid_scaling; ret[2] = (pconf.alpha + H[2]); if(pconf.depth_scaling != 1) { ld v = intval(H, Hypc); - ret *= pow(v, (pconf.depth.scaling-1) / 2); + ret *= pow(v, (pconf.depth_scaling-1) / 2); } models::apply_vr(ret[2], ret[1]); break; } + #endif + if(pconf.depth_scaling != 1) { + ld v = intval(H, Hypc); + H *= pow(v, (pconf.depth_scaling-1) / 2); + } + if(pmodel == mdHyperboloid) { ld& topz = pconf.top_z; if(H[2] > topz) { @@ -2021,7 +2043,9 @@ EX color_t modelcolor = 0; #if CAP_QUEUE EX void draw_model_elements() { + #if CAP_VR if(vrhr::state && pmodel == mdHyperboloid) return; + #endif dynamicval lw(vid.linewidth, vid.linewidth * vid.multiplier_ring); switch(pmodel) { @@ -2156,7 +2180,9 @@ EX void draw_boundary(int w) { if(w == 1) return; if(nonisotropic || euclid || prod) return; + #if CAP_VR if(vrhr::state && pmodel == mdHyperboloid) return; + #endif dynamicval lw(vid.linewidth, vid.linewidth * vid.multiplier_ring); diff --git a/raycaster.cpp b/raycaster.cpp index b379decd..9967b183 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -1339,9 +1339,13 @@ EX void cast() { cd->set_viewport(global_projection); cd->set_mask(global_projection); + #if CAP_VR if(vrhr::state == 2) { glUniformMatrix4fv(o->uProjection, 1, 0, glhr::tmtogl_transpose3(vrhr::eyeproj).as_array()); } + #else + if(1) ; + #endif else { transmatrix proj = Id; proj = eupush(-global_projection * d, 0) * proj; diff --git a/shaders.cpp b/shaders.cpp index 5d1548ed..804192c6 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -292,9 +292,11 @@ shared_ptr write_shader(flagtype shader_flags) { if(dim3) shader_flags |= SF_ZFOG; } + #if CAP_VR /* no z-fog in VR */ if((shader_flags & SF_ZFOG) && vrhr::state == 2) shader_flags &= ~SF_ZFOG; + #endif if(nil && pmodel == mdPerspective) { vsh += "uniform mediump float uRotCos, uRotSin, uRotNil;\n";