From 9df3b6c211abaa5f57d2a4053d302eeeae9adb35 Mon Sep 17 00:00:00 2001 From: druiz17 Date: Mon, 18 Sep 2017 13:29:05 -0700 Subject: [PATCH 1/2] change tablet spawn position --- scripts/system/libraries/WebTablet.js | 57 ++++----------------------- 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 0a2a9d05ef..d1182f197c 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -48,55 +48,14 @@ function calcSpawnInfo(hand, landscape) { var headPos = (HMD.active && Camera.mode === "first person") ? HMD.position : Camera.position; var headRot = (HMD.active && Camera.mode === "first person") ? HMD.orientation : Camera.orientation; - if (!hand) { - hand = NO_HANDS; - } - - var handController = null; - if (HMD.active && hand !== NO_HANDS) { - handController = getControllerWorldLocation(hand, true); - } - - if (handController && handController.valid) { - // Orient tablet per hand pitch and yaw. - // Angle it back similar to holding it like a book. - // Move tablet up so that hand is at bottom. - // Move tablet back so that hand is in front. - - var position = handController.position; - var rotation = handController.rotation; - - if (hand === Controller.Standard.LeftHand) { - rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, 90, 0)); - } else { - rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, -90, 0)); - } - var normal = Vec3.multiplyQbyV(rotation, Vec3.UNIT_NEG_Y); - var lookAt = Quat.lookAt(Vec3.ZERO, normal, Vec3.multiplyQbyV(MyAvatar.orientation, Vec3.UNIT_Y)); - var TABLET_RAKE_ANGLE = 30; - rotation = Quat.multiply(Quat.angleAxis(TABLET_RAKE_ANGLE, Vec3.multiplyQbyV(lookAt, Vec3.UNIT_X)), lookAt); - - var sensorScaleFactor = MyAvatar.sensorToWorldScale; - var tabletWidth = getTabletWidthFromSettings() * sensorScaleFactor; - var tabletScaleFactor = tabletWidth / TABLET_NATURAL_DIMENSIONS.x; - var height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor; - var RELATIVE_SPAWN_OFFSET = { x: 0, y: 0.6 * height, z: 0.1 * height }; - - position = Vec3.sum(position, Vec3.multiplyQbyV(rotation, RELATIVE_SPAWN_OFFSET)); - - return { - position: position, - rotation: landscape ? Quat.multiply(rotation, { x: 0.0, y: 0.0, z: 0.707, w: 0.707 }) : rotation - }; - } else { - var forward = Quat.getForward(headRot); - finalPosition = Vec3.sum(headPos, Vec3.multiply(0.6, forward)); - var orientation = Quat.lookAt({x: 0, y: 0, z: 0}, forward, {x: 0, y: 1, z: 0}); - return { - position: finalPosition, - rotation: landscape ? Quat.multiply(orientation, ROT_LANDSCAPE) : Quat.multiply(orientation, ROT_Y_180) - }; - } + var forward = Quat.getForward(headRot); + var FORWARD_OFFSET = 0.6 * MyAvatar.sensorToWorldScale; + finalPosition = Vec3.sum(headPos, Vec3.multiply(FORWARD_OFFSET, forward)); + var orientation = Quat.lookAt({x: 0, y: 0, z: 0}, forward, {x: 0, y: 1, z: 0}); + return { + position: finalPosition, + rotation: landscape ? Quat.multiply(orientation, ROT_LANDSCAPE) : Quat.multiply(orientation, ROT_Y_180) + }; } /** From f314ba38dfe93dcee16d248c291e8218183d290e Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 18 Sep 2017 14:38:03 -0700 Subject: [PATCH 2/2] Oculus: fix for lighting changes as avatar scale changes The code was incorrectly NOT using the near and far clip distances when computing the culling projection matrix. This projection matrix is used by the lighting system to for deferred lighting, if it does not match actual projection used for rendering into the g-buffer, the lighting will be incorrect. --- plugins/oculus/src/OculusBaseDisplayPlugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp index ea0af0d5f5..7e7fcc0db3 100644 --- a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp +++ b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp @@ -84,7 +84,7 @@ glm::mat4 OculusBaseDisplayPlugin::getCullingProjection(const glm::mat4& basePro float baseFarClip = baseFrustum.getFarClip(); auto combinedFov = _eyeFovs[0]; combinedFov.LeftTan = combinedFov.RightTan = std::max(combinedFov.LeftTan, combinedFov.RightTan); - return toGlm(ovrMatrix4f_Projection(combinedFov, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP, ovrProjection_ClipRangeOpenGL)); + return toGlm(ovrMatrix4f_Projection(combinedFov, baseNearClip, baseFarClip, ovrProjection_ClipRangeOpenGL)); } else { return baseProjection; }