# HG changeset patch # User John Tsiombikas # Date 1412366847 -10800 # Node ID 1067274dc7809bf35ba87b87c1cd9174208a5ebb # Parent 3de7339841d0d1d940b31039a571bbec2f970e00 fixed the fallback vr_view_translation and vr_view_matrix to include stereo separation diff -r 3de7339841d0 -r 1067274dc780 src/vr.c --- a/src/vr.c Thu Sep 25 17:14:04 2014 +0300 +++ b/src/vr.c Fri Oct 03 23:07:27 2014 +0300 @@ -158,7 +158,7 @@ static float def_option_float(const char *optname) { - int res = 0; + float res = 0.0f; if(strcmp(optname, VR_RENDER_XRES) == 0 || strcmp(optname, VR_RENDER_YRES) == 0) { return (float)def_option_int(optname); @@ -214,12 +214,17 @@ int vr_view_translation(int eye, float *vec) { + float eye_offset; + if(vrm && vrm->translation) { vrm->translation(eye, vec); return 1; } - vec[0] = vec[1] = vec[2] = 0.0f; - return 0; + + eye_offset = vr_getf(VR_IPD) / 2.0; + vec[0] = eye == VR_EYE_LEFT ? -eye_offset : eye_offset; + vec[1] = vec[2] = 0.0f; + return 1; } int vr_view_rotation(int eye, float *quat) @@ -235,7 +240,6 @@ int vr_view_matrix(int eye, float *mat) { - int have_trans, have_rot; float offs[3], quat[4]; float rmat[16], tmat[16]; @@ -244,12 +248,14 @@ return 1; } - have_trans = vr_view_translation(eye, offs); - have_rot = vr_view_rotation(eye, quat); - - if(!have_trans && !have_rot) { - memcpy(mat, idmat, sizeof idmat); - return 0; + if(!vr_view_translation(eye, offs)) { + float eye_offset = vr_getf(VR_IPD) / 2.0; + offs[0] = eye == VR_EYE_LEFT ? -eye_offset : eye_offset; + offs[1] = offs[2]; + } + if(!vr_view_rotation(eye, quat)) { + quat[0] = quat[1] = quat[2] = 0.0f; + quat[3] = 1.0f; } offs[0] = -offs[0]; diff -r 3de7339841d0 -r 1067274dc780 src/vr.h --- a/src/vr.h Thu Sep 25 17:14:04 2014 +0300 +++ b/src/vr.h Fri Oct 03 23:07:27 2014 +0300 @@ -17,7 +17,7 @@ #define VR_EYE_HEIGHT "eye-height" #define VR_IPD "ipd" /* misc options */ -#define VR_NULL_STEREO "null-show-stereo" /* bool, default 0 */ +#define VR_NULL_STEREO "null-stereo" /* bool, default 0 */ enum { VR_EYE_LEFT,