mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-30 23:37:03 +00:00
added some missing CAP_VR guards, more work on 2D in VR
This commit is contained in:
parent
85ab111abb
commit
f9d65a2e37
18
drawing.cpp
18
drawing.cpp
@ -298,13 +298,18 @@ hyperpoint goodpoint;
|
||||
vector<pair<int, hyperpoint>> 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;
|
||||
}
|
||||
|
44
hypgraph.cpp
44
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<ld> 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<ld> lw(vid.linewidth, vid.linewidth * vid.multiplier_ring);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -292,9 +292,11 @@ shared_ptr<glhr::GLprogram> 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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user