From eb4dee0495d292eb97e4193c592c2cf044e21e3f Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Fri, 10 Mar 2017 23:37:29 +0000 Subject: [PATCH 01/42] create audioMuteOverlay.js client scipt that creates an overlay to provide mute feedback --- scripts/system/audioMuteOverlay.js | 122 +++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 scripts/system/audioMuteOverlay.js diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js new file mode 100644 index 0000000000..bb1eb70aa9 --- /dev/null +++ b/scripts/system/audioMuteOverlay.js @@ -0,0 +1,122 @@ +"use strict"; +/* jslint vars: true, plusplus: true, forin: true*/ +/* globals Tablet, Script, AvatarList, Users, Entities, MyAvatar, Camera, Overlays, Vec3, Quat, Controller, print, getControllerWorldLocation */ +/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */ +// +// audioMuteOverlay.js +// +// client scipt that creates an overlay to provide mute feedback +// +// Created by Triplelexx on 17/03/09 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +(function() { // BEGIN LOCAL_SCOPE + var TWEEN_SPEED = 0.025; + var LERP_AMOUNT = 0.25; + + var overlayPosition = Vec3.ZERO; + var tweenPosition = 0; + var startColor = { + red: 150, + green: 150, + blue: 150 + }; + var endColor = { + red: 255, + green: 0, + blue: 0 + }; + var overlayID; + + AudioDevice.muteToggled.connect(onMuteToggled); + Script.update.connect(update); + Script.scriptEnding.connect(cleanup); + + function update(dt) { + if (!AudioDevice.getMuted()) { + return; + } + updateTween(); + } + + function lerp(a, b, val) { + return (1 - val) * a + val * b; + } + + function getOffsetPosition() { + return Vec3.sum(MyAvatar.getHeadPosition(), Quat.getFront(MyAvatar.headOrientation)); + } + + function updateTween() { + // increase the tween value based on speed till it's complete + if (tweenPosition < 1) { + tweenPosition += TWEEN_SPEED; + } else { + // after tween completion reset to zero and flip values to ping pong + tweenPosition = 0; + var buf = startColor.red; + startColor.red = endColor.red; + endColor.red = buf; + buf = startColor.green; + startColor.green = endColor.green; + endColor.green = buf; + buf = startColor.blue; + startColor.blue = endColor.blue; + endColor.blue = buf; + } + + // update position based on LERP_AMOUNT + var offsetPosition = getOffsetPosition(); + overlayPosition.x = lerp(overlayPosition.x, offsetPosition.x, LERP_AMOUNT); + overlayPosition.y = lerp(overlayPosition.y, offsetPosition.y, LERP_AMOUNT); + overlayPosition.z = lerp(overlayPosition.z, offsetPosition.z, LERP_AMOUNT); + + Overlays.editOverlay(overlayID, { + color: { + red: lerp(startColor.red, endColor.red, tweenPosition), + green: lerp(startColor.green, endColor.green, tweenPosition), + blue: lerp(startColor.blue, endColor.blue, tweenPosition) + }, + position: overlayPosition, + rotation: MyAvatar.orientation, + }); + } + + function onMuteToggled() { + if (AudioDevice.getMuted()) { + createOverlay(); + } else { + deleteOverlay(); + } + } + + function createOverlay() { + overlayPosition = getOffsetPosition(); + overlayID = Overlays.addOverlay("sphere", { + name: "muteSphere", + position: overlayPosition, + rotation: MyAvatar.orientation, + alpha: 0.9, + dimensions: 0.1, + solid: true, + ignoreRayIntersection: true, + visible: true + }); + } + + function deleteOverlay() { + Overlays.deleteOverlay(overlayID); + } + + function cleanup() { + if (overlayID) { + deleteOverlay(); + } + AudioDevice.muteToggled.disconnect(onMuteToggled); + Script.update.disconnect(update); + } +}()); // END LOCAL_SCOPE From 8a0dd55275879480db31736b33b7efd1f5dd727f Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Sat, 11 Mar 2017 00:19:02 +0000 Subject: [PATCH 02/42] change naming and comment --- scripts/system/audioMuteOverlay.js | 53 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index bb1eb70aa9..8ffa1655b7 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -40,7 +40,7 @@ if (!AudioDevice.getMuted()) { return; } - updateTween(); + updateOverlay(); } function lerp(a, b, val) { @@ -49,10 +49,31 @@ function getOffsetPosition() { return Vec3.sum(MyAvatar.getHeadPosition(), Quat.getFront(MyAvatar.headOrientation)); - } - - function updateTween() { - // increase the tween value based on speed till it's complete + } + + function onMuteToggled() { + if (AudioDevice.getMuted()) { + createOverlay(); + } else { + deleteOverlay(); + } + } + + function createOverlay() { + overlayPosition = getOffsetPosition(); + overlayID = Overlays.addOverlay("sphere", { + position: overlayPosition, + rotation: MyAvatar.orientation, + alpha: 0.9, + dimensions: 0.1, + solid: true, + ignoreRayIntersection: true, + visible: true + }); + } + + function updateOverlay() { + // increase by TWEEN_SPEED until completion if (tweenPosition < 1) { tweenPosition += TWEEN_SPEED; } else { @@ -86,28 +107,6 @@ }); } - function onMuteToggled() { - if (AudioDevice.getMuted()) { - createOverlay(); - } else { - deleteOverlay(); - } - } - - function createOverlay() { - overlayPosition = getOffsetPosition(); - overlayID = Overlays.addOverlay("sphere", { - name: "muteSphere", - position: overlayPosition, - rotation: MyAvatar.orientation, - alpha: 0.9, - dimensions: 0.1, - solid: true, - ignoreRayIntersection: true, - visible: true - }); - } - function deleteOverlay() { Overlays.deleteOverlay(overlayID); } From 873a9aa39ec0f5b8ceb85a3641b84adc2acfa9de Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Sat, 11 Mar 2017 07:40:32 +0000 Subject: [PATCH 03/42] change color swapping to be more concise --- scripts/system/audioMuteOverlay.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index 8ffa1655b7..973faa57a8 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -79,15 +79,11 @@ } else { // after tween completion reset to zero and flip values to ping pong tweenPosition = 0; - var buf = startColor.red; - startColor.red = endColor.red; - endColor.red = buf; - buf = startColor.green; - startColor.green = endColor.green; - endColor.green = buf; - buf = startColor.blue; - startColor.blue = endColor.blue; - endColor.blue = buf; + for (var color in startColor) { + var storedColor = startColor[color]; + startColor[color] = endColor[color]; + endColor[color] = storedColor; + } } // update position based on LERP_AMOUNT From 95fcb1df7a57b3350520eb08b5ca9513bf2692cd Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Mon, 13 Mar 2017 18:32:53 +0000 Subject: [PATCH 04/42] fix spelling mistake --- scripts/system/audioMuteOverlay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index 973faa57a8..f112381040 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -5,7 +5,7 @@ // // audioMuteOverlay.js // -// client scipt that creates an overlay to provide mute feedback +// client script that creates an overlay to provide mute feedback // // Created by Triplelexx on 17/03/09 // Copyright 2017 High Fidelity, Inc. From 8bd155cb86191a7c48b0adee4fec4625c79cfa3b Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 14 Mar 2017 01:23:04 +0000 Subject: [PATCH 05/42] change offsetPosition to use Camera.orientation --- scripts/system/audioMuteOverlay.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index f112381040..db2b706b32 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -48,7 +48,7 @@ } function getOffsetPosition() { - return Vec3.sum(MyAvatar.getHeadPosition(), Quat.getFront(MyAvatar.headOrientation)); + return Vec3.sum(MyAvatar.getHeadPosition(), Quat.getFront(Camera.orientation)); } function onMuteToggled() { @@ -63,12 +63,11 @@ overlayPosition = getOffsetPosition(); overlayID = Overlays.addOverlay("sphere", { position: overlayPosition, - rotation: MyAvatar.orientation, + rotation: Camera.orientation, alpha: 0.9, dimensions: 0.1, solid: true, - ignoreRayIntersection: true, - visible: true + ignoreRayIntersection: true }); } @@ -99,7 +98,7 @@ blue: lerp(startColor.blue, endColor.blue, tweenPosition) }, position: overlayPosition, - rotation: MyAvatar.orientation, + rotation: Camera.orientation }); } From 2e0cac4676f902db8732481db90ee8e01d0d84e6 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 14 Mar 2017 01:25:39 +0000 Subject: [PATCH 06/42] add extra safeguards --- scripts/system/audioMuteOverlay.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index db2b706b32..a037e9ac72 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -38,9 +38,16 @@ function update(dt) { if (!AudioDevice.getMuted()) { + if (overlayID) { + deleteOverlay(); + } return; } - updateOverlay(); + if (!overlayID) { + createOverlay(); + } else { + updateOverlay(); + } } function lerp(a, b, val) { From c729ceccb5a4491bda3d0caa63a2a038bd651e7e Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 14 Mar 2017 03:59:24 +0000 Subject: [PATCH 07/42] change color lerp to use HSV color --- scripts/system/audioMuteOverlay.js | 61 +++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index a037e9ac72..f83a3871ff 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -20,15 +20,16 @@ var overlayPosition = Vec3.ZERO; var tweenPosition = 0; + // colors are in HSV, h needs to be a value from 0-1 var startColor = { - red: 150, - green: 150, - blue: 150 + h: 0, + s: 0, + v: 0.67 }; var endColor = { - red: 255, - green: 0, - blue: 0 + h: 0, + s: 1, + v: 1 }; var overlayID; @@ -43,17 +44,39 @@ } return; } - if (!overlayID) { - createOverlay(); - } else { - updateOverlay(); - } + updateOverlay(); } function lerp(a, b, val) { return (1 - val) * a + val * b; } + // hsv conversion expects 0-1 values + function hsvToRgb(h, s, v) { + var r, g, b; + + var i = Math.floor(h * 6); + var f = h * 6 - i; + var p = v * (1 - s); + var q = v * (1 - f * s); + var t = v * (1 - (1 - f) * s); + + switch (i % 6) { + case 0: r = v, g = t, b = p; break; + case 1: r = q, g = v, b = p; break; + case 2: r = p, g = v, b = t; break; + case 3: r = p, g = q, b = v; break; + case 4: r = t, g = p, b = v; break; + case 5: r = v, g = p, b = q; break; + } + + return { + red: r * 255, + green: g * 255, + blue: b * 255 + } + } + function getOffsetPosition() { return Vec3.sum(MyAvatar.getHeadPosition(), Quat.getFront(Camera.orientation)); } @@ -98,11 +121,17 @@ overlayPosition.y = lerp(overlayPosition.y, offsetPosition.y, LERP_AMOUNT); overlayPosition.z = lerp(overlayPosition.z, offsetPosition.z, LERP_AMOUNT); + var rgbColor = hsvToRgb( + lerp(startColor.h, endColor.h, tweenPosition), + lerp(startColor.s, endColor.s, tweenPosition), + lerp(startColor.v, endColor.v, tweenPosition) + ); + Overlays.editOverlay(overlayID, { color: { - red: lerp(startColor.red, endColor.red, tweenPosition), - green: lerp(startColor.green, endColor.green, tweenPosition), - blue: lerp(startColor.blue, endColor.blue, tweenPosition) + red: rgbColor.red, + green: rgbColor.green, + blue: rgbColor.blue }, position: overlayPosition, rotation: Camera.orientation @@ -114,9 +143,7 @@ } function cleanup() { - if (overlayID) { - deleteOverlay(); - } + deleteOverlay(); AudioDevice.muteToggled.disconnect(onMuteToggled); Script.update.disconnect(update); } From 30c16984c06c5c16dae7e646560bfcad42ea4c47 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 14 Mar 2017 06:07:22 +0000 Subject: [PATCH 08/42] change offsetPosition to use Camera.position --- scripts/system/audioMuteOverlay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index f83a3871ff..49f2b5c618 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -78,7 +78,7 @@ } function getOffsetPosition() { - return Vec3.sum(MyAvatar.getHeadPosition(), Quat.getFront(Camera.orientation)); + return Vec3.sum(Camera.position, Quat.getFront(Camera.orientation)); } function onMuteToggled() { From 4dd9a7c37fdd93c4b97f9f27c547fa8c87999faa Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 14 Mar 2017 16:51:43 +0000 Subject: [PATCH 09/42] add simple easing function --- scripts/system/audioMuteOverlay.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index 49f2b5c618..8cf86c4395 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -122,9 +122,6 @@ overlayPosition.z = lerp(overlayPosition.z, offsetPosition.z, LERP_AMOUNT); var rgbColor = hsvToRgb( - lerp(startColor.h, endColor.h, tweenPosition), - lerp(startColor.s, endColor.s, tweenPosition), - lerp(startColor.v, endColor.v, tweenPosition) ); Overlays.editOverlay(overlayID, { From 8a39ce16bdc7a0d296f8c89f0fa2bbee5c2949d2 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 14 Mar 2017 16:57:45 +0000 Subject: [PATCH 10/42] add simple easing function dodgy add push --- scripts/system/audioMuteOverlay.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index 8cf86c4395..826498d909 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -51,6 +51,10 @@ return (1 - val) * a + val * b; } + function easeIn(t) { + return Math.pow(t / 1, 5); + } + // hsv conversion expects 0-1 values function hsvToRgb(h, s, v) { var r, g, b; @@ -122,6 +126,9 @@ overlayPosition.z = lerp(overlayPosition.z, offsetPosition.z, LERP_AMOUNT); var rgbColor = hsvToRgb( + lerp(startColor.h, endColor.h, easeIn(tweenPosition)), + lerp(startColor.s, endColor.s, easeIn(tweenPosition)), + lerp(startColor.v, endColor.v, easeIn(tweenPosition)) ); Overlays.editOverlay(overlayID, { From 6971aeb081f8d81869959dfb797a461f16001245 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 14 Mar 2017 17:18:11 +0000 Subject: [PATCH 11/42] additional reference information --- scripts/system/audioMuteOverlay.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index 826498d909..c72b62f1f7 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -55,7 +55,10 @@ return Math.pow(t / 1, 5); } - // hsv conversion expects 0-1 values + // Adapted from a blog post on http://mjijackson.com + // Michael J. I. Jackson + // Converts an HSV color value to RGB. Conversion formula adapted from http: //en.wikipedia.org/wiki/HSV_color_space. + // Assumes h, s, and v are contained in the set[0, 1] function hsvToRgb(h, s, v) { var r, g, b; From 84d157ab18503c188457d3febdab35e7058c2b18 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 15 Mar 2017 10:31:09 +0000 Subject: [PATCH 12/42] handle overlay lifetime during update, remove color conv --- scripts/system/audioMuteOverlay.js | 77 ++++++++---------------------- 1 file changed, 19 insertions(+), 58 deletions(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index c72b62f1f7..458efad6d0 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -20,31 +20,31 @@ var overlayPosition = Vec3.ZERO; var tweenPosition = 0; - // colors are in HSV, h needs to be a value from 0-1 var startColor = { - h: 0, - s: 0, - v: 0.67 + red: 170, + green: 170, + blue: 170 }; var endColor = { - h: 0, - s: 1, - v: 1 + red: 255, + green: 0, + blue: 0 }; var overlayID; - AudioDevice.muteToggled.connect(onMuteToggled); Script.update.connect(update); Script.scriptEnding.connect(cleanup); function update(dt) { if (!AudioDevice.getMuted()) { - if (overlayID) { + if (hasOverlay()) { deleteOverlay(); } - return; - } - updateOverlay(); + } else if (!hasOverlay()) { + createOverlay(); + } else { + updateOverlay(); + } } function lerp(a, b, val) { @@ -55,47 +55,10 @@ return Math.pow(t / 1, 5); } - // Adapted from a blog post on http://mjijackson.com - // Michael J. I. Jackson - // Converts an HSV color value to RGB. Conversion formula adapted from http: //en.wikipedia.org/wiki/HSV_color_space. - // Assumes h, s, and v are contained in the set[0, 1] - function hsvToRgb(h, s, v) { - var r, g, b; - - var i = Math.floor(h * 6); - var f = h * 6 - i; - var p = v * (1 - s); - var q = v * (1 - f * s); - var t = v * (1 - (1 - f) * s); - - switch (i % 6) { - case 0: r = v, g = t, b = p; break; - case 1: r = q, g = v, b = p; break; - case 2: r = p, g = v, b = t; break; - case 3: r = p, g = q, b = v; break; - case 4: r = t, g = p, b = v; break; - case 5: r = v, g = p, b = q; break; - } - - return { - red: r * 255, - green: g * 255, - blue: b * 255 - } - } - function getOffsetPosition() { return Vec3.sum(Camera.position, Quat.getFront(Camera.orientation)); } - function onMuteToggled() { - if (AudioDevice.getMuted()) { - createOverlay(); - } else { - deleteOverlay(); - } - } - function createOverlay() { overlayPosition = getOffsetPosition(); overlayID = Overlays.addOverlay("sphere", { @@ -108,6 +71,10 @@ }); } + function hasOverlay() { + return Overlays.getProperty(overlayID, "position") !== undefined; + } + function updateOverlay() { // increase by TWEEN_SPEED until completion if (tweenPosition < 1) { @@ -128,17 +95,11 @@ overlayPosition.y = lerp(overlayPosition.y, offsetPosition.y, LERP_AMOUNT); overlayPosition.z = lerp(overlayPosition.z, offsetPosition.z, LERP_AMOUNT); - var rgbColor = hsvToRgb( - lerp(startColor.h, endColor.h, easeIn(tweenPosition)), - lerp(startColor.s, endColor.s, easeIn(tweenPosition)), - lerp(startColor.v, endColor.v, easeIn(tweenPosition)) - ); - Overlays.editOverlay(overlayID, { color: { - red: rgbColor.red, - green: rgbColor.green, - blue: rgbColor.blue + red: lerp(startColor.red, endColor.red, easeIn(tweenPosition)), + green: lerp(startColor.green, endColor.green, easeIn(tweenPosition)), + blue: lerp(startColor.blue, endColor.blue, easeIn(tweenPosition)) }, position: overlayPosition, rotation: Camera.orientation From 9e0091ebe07c77683cce149e24e6b6ef91fff9fc Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 15 Mar 2017 11:08:54 +0000 Subject: [PATCH 13/42] use utils.js, move easing function, use mixes some cleanup --- scripts/developer/libraries/utils.js | 3 +++ scripts/system/audioMuteOverlay.js | 27 ++++++--------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/scripts/developer/libraries/utils.js b/scripts/developer/libraries/utils.js index f39f4d7913..0da9703c87 100644 --- a/scripts/developer/libraries/utils.js +++ b/scripts/developer/libraries/utils.js @@ -311,3 +311,6 @@ clamp = function(val, min, max){ return Math.max(min, Math.min(max, val)) } +easeIn = function(t) { + return Math.pow(t / 1, 5); +} diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index 458efad6d0..d08fafc88d 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -15,8 +15,10 @@ // (function() { // BEGIN LOCAL_SCOPE + Script.include(utilsPath); + var TWEEN_SPEED = 0.025; - var LERP_AMOUNT = 0.25; + var MIX_AMOUNT = 0.25; var overlayPosition = Vec3.ZERO; var tweenPosition = 0; @@ -47,14 +49,6 @@ } } - function lerp(a, b, val) { - return (1 - val) * a + val * b; - } - - function easeIn(t) { - return Math.pow(t / 1, 5); - } - function getOffsetPosition() { return Vec3.sum(Camera.position, Quat.getFront(Camera.orientation)); } @@ -88,19 +82,10 @@ endColor[color] = storedColor; } } - - // update position based on LERP_AMOUNT - var offsetPosition = getOffsetPosition(); - overlayPosition.x = lerp(overlayPosition.x, offsetPosition.x, LERP_AMOUNT); - overlayPosition.y = lerp(overlayPosition.y, offsetPosition.y, LERP_AMOUNT); - overlayPosition.z = lerp(overlayPosition.z, offsetPosition.z, LERP_AMOUNT); - + // mix previous position with new and mix colors + overlayPosition = Vec3.mix(overlayPosition, getOffsetPosition(), MIX_AMOUNT); Overlays.editOverlay(overlayID, { - color: { - red: lerp(startColor.red, endColor.red, easeIn(tweenPosition)), - green: lerp(startColor.green, endColor.green, easeIn(tweenPosition)), - blue: lerp(startColor.blue, endColor.blue, easeIn(tweenPosition)) - }, + color: colorMix(startColor, endColor, easeIn(tweenPosition)), position: overlayPosition, rotation: Camera.orientation }); From 41041c711f8752f96b7fb0c18a65ed9d1c9364ab Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 15 Mar 2017 11:09:13 +0000 Subject: [PATCH 14/42] use utils.js --- scripts/system/audioMuteOverlay.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index d08fafc88d..d7bb843561 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -15,6 +15,7 @@ // (function() { // BEGIN LOCAL_SCOPE + var utilsPath = Script.resolvePath('../developer/libraries/utils.js?v='+ Date.now()); Script.include(utilsPath); var TWEEN_SPEED = 0.025; From 5883bd39dc255fcdb28e282c52fdbb664d6f6ff0 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 15 Mar 2017 11:17:27 +0000 Subject: [PATCH 15/42] rename color to component --- scripts/system/audioMuteOverlay.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index d7bb843561..473e06b556 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -77,10 +77,10 @@ } else { // after tween completion reset to zero and flip values to ping pong tweenPosition = 0; - for (var color in startColor) { - var storedColor = startColor[color]; - startColor[color] = endColor[color]; - endColor[color] = storedColor; + for (var component in startColor) { + var storedColor = startColor[component]; + startColor[component] = endColor[component]; + endColor[component] = storedColor; } } // mix previous position with new and mix colors From c9d1916eea0cf4c63689df333a2affa51046a84d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 20 Mar 2017 18:24:19 -0700 Subject: [PATCH 16/42] fix for build with win path with spaces --- .../PackageLibrariesForDeployment.cmake | 28 +++++++++---------- .../SymlinkOrCopyDirectoryBesideTarget.cmake | 6 ++-- interface/CMakeLists.txt | 8 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cmake/macros/PackageLibrariesForDeployment.cmake b/cmake/macros/PackageLibrariesForDeployment.cmake index 795e3642a5..d324776572 100644 --- a/cmake/macros/PackageLibrariesForDeployment.cmake +++ b/cmake/macros/PackageLibrariesForDeployment.cmake @@ -24,9 +24,9 @@ macro(PACKAGE_LIBRARIES_FOR_DEPLOYMENT) TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} - -DBUNDLE_EXECUTABLE=$ - -DBUNDLE_PLUGIN_DIR=$/${PLUGIN_PATH} - -P ${CMAKE_CURRENT_BINARY_DIR}/FixupBundlePostBuild.cmake + -DBUNDLE_EXECUTABLE="$" + -DBUNDLE_PLUGIN_DIR="$/${PLUGIN_PATH}" + -P "${CMAKE_CURRENT_BINARY_DIR}/FixupBundlePostBuild.cmake" ) find_program(WINDEPLOYQT_COMMAND windeployqt PATHS ${QT_DIR}/bin NO_DEFAULT_PATH) @@ -39,27 +39,27 @@ macro(PACKAGE_LIBRARIES_FOR_DEPLOYMENT) add_custom_command( TARGET ${TARGET_NAME} POST_BUILD - COMMAND CMD /C "SET PATH=%PATH%;${QT_DIR}/bin && ${WINDEPLOYQT_COMMAND} ${EXTRA_DEPLOY_OPTIONS} $<$,$,$>:--release> $" + COMMAND CMD /C "SET PATH=%PATH%;${QT_DIR}/bin && ${WINDEPLOYQT_COMMAND} ${EXTRA_DEPLOY_OPTIONS} $<$,$,$>:--release> \"$\"" ) - set(QTAUDIO_PATH $/audio) - set(QTAUDIO_WIN7_PATH $/audioWin7/audio) - set(QTAUDIO_WIN8_PATH $/audioWin8/audio) + set(QTAUDIO_PATH "$/audio") + set(QTAUDIO_WIN7_PATH "$/audioWin7/audio") + set(QTAUDIO_WIN8_PATH "$/audioWin8/audio") # copy qtaudio_wasapi.dll and qtaudio_windows.dll in the correct directories for runtime selection add_custom_command( TARGET ${TARGET_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${QTAUDIO_WIN7_PATH} - COMMAND ${CMAKE_COMMAND} -E make_directory ${QTAUDIO_WIN8_PATH} + COMMAND ${CMAKE_COMMAND} -E make_directory "${QTAUDIO_WIN7_PATH}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${QTAUDIO_WIN8_PATH}" # copy release DLLs - COMMAND if exist ${QTAUDIO_PATH}/qtaudio_windows.dll ( ${CMAKE_COMMAND} -E copy ${QTAUDIO_PATH}/qtaudio_windows.dll ${QTAUDIO_WIN7_PATH} ) - COMMAND if exist ${QTAUDIO_PATH}/qtaudio_windows.dll ( ${CMAKE_COMMAND} -E copy ${WASAPI_DLL_PATH}/qtaudio_wasapi.dll ${QTAUDIO_WIN8_PATH} ) + COMMAND if exist "${QTAUDIO_PATH}/qtaudio_windows.dll" ( ${CMAKE_COMMAND} -E copy "${QTAUDIO_PATH}/qtaudio_windows.dll" "${QTAUDIO_WIN7_PATH}" ) + COMMAND if exist "${QTAUDIO_PATH}/qtaudio_windows.dll" ( ${CMAKE_COMMAND} -E copy "${WASAPI_DLL_PATH}/qtaudio_wasapi.dll" "${QTAUDIO_WIN8_PATH}" ) # copy debug DLLs - COMMAND if exist ${QTAUDIO_PATH}/qtaudio_windowsd.dll ( ${CMAKE_COMMAND} -E copy ${QTAUDIO_PATH}/qtaudio_windowsd.dll ${QTAUDIO_WIN7_PATH} ) - COMMAND if exist ${QTAUDIO_PATH}/qtaudio_windowsd.dll ( ${CMAKE_COMMAND} -E copy ${WASAPI_DLL_PATH}/qtaudio_wasapid.dll ${QTAUDIO_WIN8_PATH} ) + COMMAND if exist "${QTAUDIO_PATH}/qtaudio_windowsd.dll" ( ${CMAKE_COMMAND} -E copy "${QTAUDIO_PATH}/qtaudio_windowsd.dll" "${QTAUDIO_WIN7_PATH}" ) + COMMAND if exist "${QTAUDIO_PATH}/qtaudio_windowsd.dll" ( ${CMAKE_COMMAND} -E copy "${WASAPI_DLL_PATH}/qtaudio_wasapid.dll" "${QTAUDIO_WIN8_PATH}" ) # remove directory - COMMAND ${CMAKE_COMMAND} -E remove_directory ${QTAUDIO_PATH} + COMMAND ${CMAKE_COMMAND} -E remove_directory "${QTAUDIO_PATH}" ) endif () diff --git a/cmake/macros/SymlinkOrCopyDirectoryBesideTarget.cmake b/cmake/macros/SymlinkOrCopyDirectoryBesideTarget.cmake index 37a7a9caa0..9ae47aad82 100644 --- a/cmake/macros/SymlinkOrCopyDirectoryBesideTarget.cmake +++ b/cmake/macros/SymlinkOrCopyDirectoryBesideTarget.cmake @@ -14,7 +14,7 @@ macro(SYMLINK_OR_COPY_DIRECTORY_BESIDE_TARGET _SHOULD_SYMLINK _DIRECTORY _DESTIN # remove the current directory add_custom_command( TARGET ${TARGET_NAME} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E remove_directory $/${_DESTINATION} + COMMAND "${CMAKE_COMMAND}" -E remove_directory "$/${_DESTINATION}" ) if (${_SHOULD_SYMLINK}) @@ -48,8 +48,8 @@ macro(SYMLINK_OR_COPY_DIRECTORY_BESIDE_TARGET _SHOULD_SYMLINK _DIRECTORY _DESTIN # copy the directory add_custom_command( TARGET ${TARGET_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${_DIRECTORY} - $/${_DESTINATION} + COMMAND ${CMAKE_COMMAND} -E copy_directory "${_DIRECTORY}" + "$/${_DESTINATION}" ) endif () # glob everything in this directory - add a custom command to copy any files diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index dbc484d0b9..f64b84cdf0 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -288,7 +288,7 @@ if (APPLE) add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_SOURCE_DIR}/scripts" - $/../Resources/scripts + "$/../Resources/scripts" ) # call the fixup_interface macro to add required bundling commands for installation @@ -299,10 +299,10 @@ else (APPLE) add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory "${PROJECT_SOURCE_DIR}/resources" - $/resources + "$/resources" COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_SOURCE_DIR}/scripts" - $/scripts + "$/scripts" ) # link target to external libraries @@ -337,7 +337,7 @@ endif() add_bugsplat() if (WIN32) - set(EXTRA_DEPLOY_OPTIONS "--qmldir ${PROJECT_SOURCE_DIR}/resources/qml") + set(EXTRA_DEPLOY_OPTIONS "--qmldir \"${PROJECT_SOURCE_DIR}/resources/qml\"") set(TARGET_INSTALL_DIR ${INTERFACE_INSTALL_DIR}) set(TARGET_INSTALL_COMPONENT ${CLIENT_COMPONENT}) From 6d664fd668b519751c03b635fac2763dfdf4858e Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 21 Mar 2017 19:54:32 +0000 Subject: [PATCH 17/42] add getForward, getFront returns getForward getForward better describes the returned vector as a direction --- libraries/script-engine/src/Quat.cpp | 5 +++++ libraries/script-engine/src/Quat.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/script-engine/src/Quat.cpp b/libraries/script-engine/src/Quat.cpp index 6c2e7a349e..64d1c294c6 100644 --- a/libraries/script-engine/src/Quat.cpp +++ b/libraries/script-engine/src/Quat.cpp @@ -68,7 +68,12 @@ glm::quat Quat::inverse(const glm::quat& q) { return glm::inverse(q); } +// redundant, calls getForward which better describes the returned vector as a direction glm::vec3 Quat::getFront(const glm::quat& orientation) { + return getForward(orientation); +} + +glm::vec3 Quat::getForward(const glm::quat& orientation) { return orientation * Vectors::FRONT; } diff --git a/libraries/script-engine/src/Quat.h b/libraries/script-engine/src/Quat.h index b51f1cb47e..6a15bbac83 100644 --- a/libraries/script-engine/src/Quat.h +++ b/libraries/script-engine/src/Quat.h @@ -45,7 +45,8 @@ public slots: glm::quat fromPitchYawRollDegrees(float pitch, float yaw, float roll); // degrees glm::quat fromPitchYawRollRadians(float pitch, float yaw, float roll); // radians glm::quat inverse(const glm::quat& q); - glm::vec3 getFront(const glm::quat& orientation); + glm::vec3 getFront(const glm::quat& orientation); // redundant, calls getForward which better describes the returned vector as a direction + glm::vec3 getForward(const glm::quat& orientation); glm::vec3 getRight(const glm::quat& orientation); glm::vec3 getUp(const glm::quat& orientation); glm::vec3 safeEulerAngles(const glm::quat& orientation); // degrees From 248c932d50dcd479badd97c70d339eb8afee31c5 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 21 Mar 2017 22:11:18 +0000 Subject: [PATCH 18/42] inline getFront --- libraries/script-engine/src/Quat.cpp | 5 ----- libraries/script-engine/src/Quat.h | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/libraries/script-engine/src/Quat.cpp b/libraries/script-engine/src/Quat.cpp index 64d1c294c6..6d49ed27c1 100644 --- a/libraries/script-engine/src/Quat.cpp +++ b/libraries/script-engine/src/Quat.cpp @@ -68,11 +68,6 @@ glm::quat Quat::inverse(const glm::quat& q) { return glm::inverse(q); } -// redundant, calls getForward which better describes the returned vector as a direction -glm::vec3 Quat::getFront(const glm::quat& orientation) { - return getForward(orientation); -} - glm::vec3 Quat::getForward(const glm::quat& orientation) { return orientation * Vectors::FRONT; } diff --git a/libraries/script-engine/src/Quat.h b/libraries/script-engine/src/Quat.h index 6a15bbac83..8a88767a41 100644 --- a/libraries/script-engine/src/Quat.h +++ b/libraries/script-engine/src/Quat.h @@ -45,7 +45,8 @@ public slots: glm::quat fromPitchYawRollDegrees(float pitch, float yaw, float roll); // degrees glm::quat fromPitchYawRollRadians(float pitch, float yaw, float roll); // radians glm::quat inverse(const glm::quat& q); - glm::vec3 getFront(const glm::quat& orientation); // redundant, calls getForward which better describes the returned vector as a direction + // redundant, calls getForward which better describes the returned vector as a direction + glm::vec3 getFront(const glm::quat& orientation) { return getForward(orientation); } glm::vec3 getForward(const glm::quat& orientation); glm::vec3 getRight(const glm::quat& orientation); glm::vec3 getUp(const glm::quat& orientation); From b7980569cce5571e7c428ef340eee4af2a48ede2 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 21 Mar 2017 22:13:33 +0000 Subject: [PATCH 19/42] change all references of IDENTITY_FRONT to IDENTITY_FORWARD --- interface/src/Application.cpp | 4 ++-- interface/src/avatar/Avatar.h | 2 +- interface/src/avatar/Head.cpp | 4 ++-- interface/src/avatar/Head.h | 2 +- interface/src/avatar/MyAvatar.cpp | 6 +++--- libraries/animation/src/Rig.cpp | 4 ++-- libraries/avatars/src/HeadData.cpp | 2 +- libraries/octree/src/OctreeQuery.cpp | 2 +- libraries/render-utils/src/LightStage.cpp | 4 ++-- libraries/shared/src/GLMHelpers.h | 2 +- libraries/shared/src/ViewFrustum.cpp | 2 +- libraries/shared/src/ViewFrustum.h | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4b274906e7..dbe269d1a1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2131,7 +2131,7 @@ void Application::paintGL() { PerformanceTimer perfTimer("CameraUpdates"); auto myAvatar = getMyAvatar(); - boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FRONT; + boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD; if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); @@ -3954,7 +3954,7 @@ void Application::updateMyAvatarLookAtPosition() { auto lookingAtHead = static_pointer_cast(lookingAt)->getHead(); const float MAXIMUM_FACE_ANGLE = 65.0f * RADIANS_PER_DEGREE; - glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT; + glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FORWARD; glm::vec3 fromLookingAtToMe = glm::normalize(myAvatar->getHead()->getEyePosition() - lookingAtHead->getEyePosition()); float faceAngle = glm::angle(lookingAtFaceOrientation, fromLookingAtToMe); diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index ca4dbd2af8..d8c78d972b 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -236,7 +236,7 @@ protected: glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getBodyUpDirection() const { return getOrientation() * IDENTITY_UP; } - glm::vec3 getBodyFrontDirection() const { return getOrientation() * IDENTITY_FRONT; } + glm::vec3 getBodyFrontDirection() const { return getOrientation() * IDENTITY_FORWARD; } glm::quat computeRotationFromBodyToWorldUp(float proportion = 1.0f) const; void measureMotionDerivatives(float deltaTime); diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index d7bf2b79bf..f4fb844d9b 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -268,7 +268,7 @@ void Head::applyEyelidOffset(glm::quat headOrientation) { return; } - glm::quat eyeRotation = rotationBetween(headOrientation * IDENTITY_FRONT, getLookAtPosition() - _eyePosition); + glm::quat eyeRotation = rotationBetween(headOrientation * IDENTITY_FORWARD, getLookAtPosition() - _eyePosition); eyeRotation = eyeRotation * glm::angleAxis(safeEulerAngles(headOrientation).y, IDENTITY_UP); // Rotation w.r.t. head float eyePitch = safeEulerAngles(eyeRotation).x; @@ -375,7 +375,7 @@ glm::quat Head::getCameraOrientation() const { glm::quat Head::getEyeRotation(const glm::vec3& eyePosition) const { glm::quat orientation = getOrientation(); glm::vec3 lookAtDelta = _lookAtPosition - eyePosition; - return rotationBetween(orientation * IDENTITY_FRONT, lookAtDelta + glm::length(lookAtDelta) * _saccade) * orientation; + return rotationBetween(orientation * IDENTITY_FORWARD, lookAtDelta + glm::length(lookAtDelta) * _saccade) * orientation; } void Head::setFinalPitch(float finalPitch) { diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 3d25c79087..d556d1efc4 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -58,7 +58,7 @@ public: const glm::vec3& getSaccade() const { return _saccade; } glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getUpDirection() const { return getOrientation() * IDENTITY_UP; } - glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; } + glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FORWARD; } glm::quat getEyeRotation(const glm::vec3& eyePosition) const; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b40ef601ea..bf43a457b7 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1068,7 +1068,7 @@ void MyAvatar::updateLookAtTargetAvatar() { _lookAtTargetAvatar.reset(); _targetAvatarPosition = glm::vec3(0.0f); - glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FRONT; + glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FORWARD; glm::vec3 cameraPosition = qApp->getCamera()->getPosition(); float smallestAngleTo = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES) / 2.0f; @@ -1770,7 +1770,7 @@ void MyAvatar::updateActionMotor(float deltaTime) { } // compute action input - glm::vec3 front = (getDriveKey(TRANSLATE_Z)) * IDENTITY_FRONT; + glm::vec3 front = (getDriveKey(TRANSLATE_Z)) * IDENTITY_FORWARD; glm::vec3 right = (getDriveKey(TRANSLATE_X)) * IDENTITY_RIGHT; glm::vec3 direction = front + right; @@ -2053,7 +2053,7 @@ void MyAvatar::goToLocation(const glm::vec3& newPosition, // move the user a couple units away const float DISTANCE_TO_USER = 2.0f; - _goToPosition = newPosition - quatOrientation * IDENTITY_FRONT * DISTANCE_TO_USER; + _goToPosition = newPosition - quatOrientation * IDENTITY_FORWARD * DISTANCE_TO_USER; } _goToOrientation = quatOrientation; diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 9ecd0f6352..88cfacbd66 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -558,13 +558,13 @@ static const std::vector LATERAL_SPEEDS = { 0.2f, 0.65f }; // m/s void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation, CharacterControllerState ccState) { - glm::vec3 front = worldRotation * IDENTITY_FRONT; + glm::vec3 front = worldRotation * IDENTITY_FORWARD; glm::vec3 workingVelocity = worldVelocity; { glm::vec3 localVel = glm::inverse(worldRotation) * workingVelocity; - float forwardSpeed = glm::dot(localVel, IDENTITY_FRONT); + float forwardSpeed = glm::dot(localVel, IDENTITY_FORWARD); float lateralSpeed = glm::dot(localVel, IDENTITY_RIGHT); float turningSpeed = glm::orientedAngle(front, _lastFront, IDENTITY_UP) / deltaTime; diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index 72516d9740..d2b9e8cee4 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -65,7 +65,7 @@ glm::quat HeadData::getOrientation() const { void HeadData::setOrientation(const glm::quat& orientation) { // rotate body about vertical axis glm::quat bodyOrientation = _owningAvatar->getOrientation(); - glm::vec3 newFront = glm::inverse(bodyOrientation) * (orientation * IDENTITY_FRONT); + glm::vec3 newFront = glm::inverse(bodyOrientation) * (orientation * IDENTITY_FORWARD); bodyOrientation = bodyOrientation * glm::angleAxis(atan2f(-newFront.x, -newFront.z), glm::vec3(0.0f, 1.0f, 0.0f)); _owningAvatar->setOrientation(bodyOrientation); diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index a639eccaba..7d9fc7d08c 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -142,6 +142,6 @@ int OctreeQuery::parseData(ReceivedMessage& message) { } glm::vec3 OctreeQuery::calculateCameraDirection() const { - glm::vec3 direction = glm::vec3(_cameraOrientation * glm::vec4(IDENTITY_FRONT, 0.0f)); + glm::vec3 direction = glm::vec3(_cameraOrientation * glm::vec4(IDENTITY_FORWARD, 0.0f)); return direction; } diff --git a/libraries/render-utils/src/LightStage.cpp b/libraries/render-utils/src/LightStage.cpp index 66a9797d3c..dd6a046dea 100644 --- a/libraries/render-utils/src/LightStage.cpp +++ b/libraries/render-utils/src/LightStage.cpp @@ -27,9 +27,9 @@ void LightStage::Shadow::setKeylightFrustum(const ViewFrustum& viewFrustum, floa const auto& direction = glm::normalize(_light->getDirection()); glm::quat orientation; if (direction == IDENTITY_UP) { - orientation = glm::quat(glm::mat3(-IDENTITY_RIGHT, IDENTITY_FRONT, -IDENTITY_UP)); + orientation = glm::quat(glm::mat3(-IDENTITY_RIGHT, IDENTITY_FORWARD, -IDENTITY_UP)); } else if (direction == -IDENTITY_UP) { - orientation = glm::quat(glm::mat3(IDENTITY_RIGHT, IDENTITY_FRONT, IDENTITY_UP)); + orientation = glm::quat(glm::mat3(IDENTITY_RIGHT, IDENTITY_FORWARD, IDENTITY_UP)); } else { auto side = glm::normalize(glm::cross(direction, IDENTITY_UP)); auto up = glm::normalize(glm::cross(side, direction)); diff --git a/libraries/shared/src/GLMHelpers.h b/libraries/shared/src/GLMHelpers.h index 609c3ab08b..deb87930fc 100644 --- a/libraries/shared/src/GLMHelpers.h +++ b/libraries/shared/src/GLMHelpers.h @@ -50,7 +50,7 @@ using glm::quat; // this is where the coordinate system is represented const glm::vec3 IDENTITY_RIGHT = glm::vec3( 1.0f, 0.0f, 0.0f); const glm::vec3 IDENTITY_UP = glm::vec3( 0.0f, 1.0f, 0.0f); -const glm::vec3 IDENTITY_FRONT = glm::vec3( 0.0f, 0.0f,-1.0f); +const glm::vec3 IDENTITY_FORWARD = glm::vec3( 0.0f, 0.0f,-1.0f); glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float alpha); diff --git a/libraries/shared/src/ViewFrustum.cpp b/libraries/shared/src/ViewFrustum.cpp index a0b7d17e46..7e4f64686b 100644 --- a/libraries/shared/src/ViewFrustum.cpp +++ b/libraries/shared/src/ViewFrustum.cpp @@ -31,7 +31,7 @@ void ViewFrustum::setOrientation(const glm::quat& orientationAsQuaternion) { _orientation = orientationAsQuaternion; _right = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_RIGHT, 0.0f)); _up = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_UP, 0.0f)); - _direction = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_FRONT, 0.0f)); + _direction = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_FORWARD, 0.0f)); _view = glm::translate(mat4(), _position) * glm::mat4_cast(_orientation); } diff --git a/libraries/shared/src/ViewFrustum.h b/libraries/shared/src/ViewFrustum.h index 9a6cb9ab68..221b0b5a07 100644 --- a/libraries/shared/src/ViewFrustum.h +++ b/libraries/shared/src/ViewFrustum.h @@ -153,7 +153,7 @@ private: glm::quat _orientation; // orientation in world-frame // calculated from orientation - glm::vec3 _direction = IDENTITY_FRONT; + glm::vec3 _direction = IDENTITY_FORWARD; glm::vec3 _up = IDENTITY_UP; glm::vec3 _right = IDENTITY_RIGHT; From a964edee917893353fc76d6d1b8c797766fd2fc7 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 21 Mar 2017 22:25:30 +0000 Subject: [PATCH 20/42] change all references of Quat.getFront to Quat.getForward in scripts directory --- scripts/developer/tests/ambientSoundTest.js | 2 +- .../developer/tests/basicEntityTest/entitySpawner.js | 2 +- .../batonSoundTestEntitySpawner.js | 2 +- scripts/developer/tests/entityServerStampedeTest.js | 2 +- scripts/developer/tests/entityStampedeTest.js | 2 +- scripts/developer/tests/lodTest.js | 2 +- scripts/developer/tests/mat4test.js | 4 ++-- scripts/developer/tests/performance/tribbles.js | 2 +- .../rapidProceduralChange/rapidProceduralChangeTest.js | 4 ++-- scripts/developer/tests/sphereLODTest.js | 2 +- scripts/developer/tests/testInterval.js | 2 +- scripts/developer/tests/unit_tests/entityUnitTests.js | 2 +- scripts/developer/tests/viveTouchpadTest.js | 4 ++-- .../utilities/render/photobooth/photobooth.js | 2 +- scripts/system/away.js | 2 +- scripts/system/controllers/grab.js | 4 ++-- scripts/system/controllers/handControllerGrab.js | 2 +- scripts/system/controllers/handControllerPointer.js | 2 +- scripts/system/edit.js | 10 +++++----- scripts/system/libraries/WebTablet.js | 2 +- scripts/system/libraries/entityCameraTool.js | 4 ++-- scripts/system/libraries/entitySelectionTool.js | 2 +- scripts/system/libraries/soundArray.js | 2 +- scripts/system/nameTag.js | 4 ++-- scripts/system/pal.js | 2 +- scripts/system/voxels.js | 2 +- scripts/tutorials/NBody/makePlanets.js | 2 +- scripts/tutorials/butterflies.js | 6 +++--- scripts/tutorials/createCow.js | 2 +- scripts/tutorials/createDice.js | 4 ++-- scripts/tutorials/createFlashlight.js | 2 +- scripts/tutorials/createGolfClub.js | 2 +- scripts/tutorials/createPictureFrame.js | 2 +- scripts/tutorials/createPingPongGun.js | 2 +- scripts/tutorials/createPistol.js | 2 +- scripts/tutorials/createSoundMaker.js | 2 +- scripts/tutorials/entity_scripts/golfClub.js | 4 ++-- scripts/tutorials/entity_scripts/pingPongGun.js | 4 ++-- scripts/tutorials/entity_scripts/pistol.js | 2 +- scripts/tutorials/makeBlocks.js | 2 +- 40 files changed, 55 insertions(+), 55 deletions(-) diff --git a/scripts/developer/tests/ambientSoundTest.js b/scripts/developer/tests/ambientSoundTest.js index 5b373715c0..d048d5f73d 100644 --- a/scripts/developer/tests/ambientSoundTest.js +++ b/scripts/developer/tests/ambientSoundTest.js @@ -4,7 +4,7 @@ var uuid = Entities.addEntity({ shape: "Icosahedron", dimensions: Vec3.HALF, script: Script.resolvePath('../../tutorials/entity_scripts/ambientSound.js'), - position: Vec3.sum(Vec3.multiply(5, Quat.getFront(MyAvatar.orientation)), MyAvatar.position), + position: Vec3.sum(Vec3.multiply(5, Quat.getForward(MyAvatar.orientation)), MyAvatar.position), userData: JSON.stringify({ soundURL: WAVE, maxVolume: 0.1, diff --git a/scripts/developer/tests/basicEntityTest/entitySpawner.js b/scripts/developer/tests/basicEntityTest/entitySpawner.js index a2f38f59eb..538e9145f5 100644 --- a/scripts/developer/tests/basicEntityTest/entitySpawner.js +++ b/scripts/developer/tests/basicEntityTest/entitySpawner.js @@ -2,7 +2,7 @@ orientation = Quat.safeEulerAngles(orientation); orientation.x = 0; orientation = Quat.fromVec3Degrees(orientation); - var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); + var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(orientation))); // Math.random ensures no caching of script var SCRIPT_URL = Script.resolvePath("myEntityScript.js") diff --git a/scripts/developer/tests/batonSoundEntityTest/batonSoundTestEntitySpawner.js b/scripts/developer/tests/batonSoundEntityTest/batonSoundTestEntitySpawner.js index fdcef8d32c..f5fc35a1de 100644 --- a/scripts/developer/tests/batonSoundEntityTest/batonSoundTestEntitySpawner.js +++ b/scripts/developer/tests/batonSoundEntityTest/batonSoundTestEntitySpawner.js @@ -2,7 +2,7 @@ orientation = Quat.safeEulerAngles(orientation); orientation.x = 0; orientation = Quat.fromVec3Degrees(orientation); - var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); + var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(orientation))); // Math.random ensures no caching of script var SCRIPT_URL = Script.resolvePath("batonSoundTestEntityScript.js") diff --git a/scripts/developer/tests/entityServerStampedeTest.js b/scripts/developer/tests/entityServerStampedeTest.js index 3fcf01bb34..33aa53f9b1 100644 --- a/scripts/developer/tests/entityServerStampedeTest.js +++ b/scripts/developer/tests/entityServerStampedeTest.js @@ -4,7 +4,7 @@ var DIV = NUM_ENTITIES / Math.PI / 2; var PASS_SCRIPT_URL = Script.resolvePath('entityServerStampedeTest-entity.js'); var FAIL_SCRIPT_URL = Script.resolvePath('entityStampedeTest-entity-fail.js'); -var origin = Vec3.sum(MyAvatar.position, Vec3.multiply(5, Quat.getFront(MyAvatar.orientation))); +var origin = Vec3.sum(MyAvatar.position, Vec3.multiply(5, Quat.getForward(MyAvatar.orientation))); origin.y += HMD.eyeHeight; var uuids = []; diff --git a/scripts/developer/tests/entityStampedeTest.js b/scripts/developer/tests/entityStampedeTest.js index c5040a9796..644bf0a216 100644 --- a/scripts/developer/tests/entityStampedeTest.js +++ b/scripts/developer/tests/entityStampedeTest.js @@ -4,7 +4,7 @@ var DIV = NUM_ENTITIES / Math.PI / 2; var PASS_SCRIPT_URL = Script.resolvePath('').replace('.js', '-entity.js'); var FAIL_SCRIPT_URL = Script.resolvePath('').replace('.js', '-entity-fail.js'); -var origin = Vec3.sum(MyAvatar.position, Vec3.multiply(5, Quat.getFront(MyAvatar.orientation))); +var origin = Vec3.sum(MyAvatar.position, Vec3.multiply(5, Quat.getForward(MyAvatar.orientation))); origin.y += HMD.eyeHeight; var uuids = []; diff --git a/scripts/developer/tests/lodTest.js b/scripts/developer/tests/lodTest.js index 4b6706cd70..ce91b54d0f 100644 --- a/scripts/developer/tests/lodTest.js +++ b/scripts/developer/tests/lodTest.js @@ -19,7 +19,7 @@ var WIDTH = MAX_DIM * NUM_SPHERES; var entities = []; var right = Quat.getRight(Camera.orientation); // Starting position will be 30 meters in front of the camera -var position = Vec3.sum(Camera.position, Vec3.multiply(30, Quat.getFront(Camera.orientation))); +var position = Vec3.sum(Camera.position, Vec3.multiply(30, Quat.getForward(Camera.orientation))); position = Vec3.sum(position, Vec3.multiply(-WIDTH/2, right)); for (var i = 0; i < NUM_SPHERES; ++i) { diff --git a/scripts/developer/tests/mat4test.js b/scripts/developer/tests/mat4test.js index ebce420dcb..2d7c994631 100644 --- a/scripts/developer/tests/mat4test.js +++ b/scripts/developer/tests/mat4test.js @@ -143,10 +143,10 @@ function testInverse() { function testFront() { var test0 = IDENTITY; - assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getFront(test0))); + assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getForward(test0))); var test1 = Mat4.createFromScaleRotAndTrans(ONE_HALF, ROT_Y_180, ONE_TWO_THREE); - assert(mat4FuzzyEqual({x: 0, y: 0, z: 1}, Mat4.getFront(test1))); + assert(mat4FuzzyEqual({x: 0, y: 0, z: 1}, Mat4.getForward(test1))); } function testMat4() { diff --git a/scripts/developer/tests/performance/tribbles.js b/scripts/developer/tests/performance/tribbles.js index 4c04f8b5b7..c5735b7359 100644 --- a/scripts/developer/tests/performance/tribbles.js +++ b/scripts/developer/tests/performance/tribbles.js @@ -43,7 +43,7 @@ var HOW_FAR_UP = RANGE / 1.5; // higher (for uneven ground) above range/2 (for var totalCreated = 0; var offset = Vec3.sum(Vec3.multiply(HOW_FAR_UP, Vec3.UNIT_Y), - Vec3.multiply(HOW_FAR_IN_FRONT_OF_ME, Quat.getFront(Camera.orientation))); + Vec3.multiply(HOW_FAR_IN_FRONT_OF_ME, Quat.getForward(Camera.orientation))); var center = Vec3.sum(MyAvatar.position, offset); function randomVector(range) { diff --git a/scripts/developer/tests/rapidProceduralChange/rapidProceduralChangeTest.js b/scripts/developer/tests/rapidProceduralChange/rapidProceduralChangeTest.js index 6897a1b70f..e28a7b01e2 100644 --- a/scripts/developer/tests/rapidProceduralChange/rapidProceduralChangeTest.js +++ b/scripts/developer/tests/rapidProceduralChange/rapidProceduralChangeTest.js @@ -20,9 +20,9 @@ orientation = Quat.safeEulerAngles(orientation); orientation.x = 0; orientation = Quat.fromVec3Degrees(orientation); -var centerUp = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); +var centerUp = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(orientation))); centerUp.y += 0.5; -var centerDown = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); +var centerDown = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(orientation))); centerDown.y -= 0.5; var ENTITY_SHADER_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/shaders/uniformTest.fs"; diff --git a/scripts/developer/tests/sphereLODTest.js b/scripts/developer/tests/sphereLODTest.js index dc19094664..d0cb35eaa1 100644 --- a/scripts/developer/tests/sphereLODTest.js +++ b/scripts/developer/tests/sphereLODTest.js @@ -15,7 +15,7 @@ MyAvatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0); orientation = Quat.safeEulerAngles(MyAvatar.orientation); orientation.x = 0; orientation = Quat.fromVec3Degrees(orientation); -var tablePosition = Vec3.sum(MyAvatar.position, Quat.getFront(orientation)); +var tablePosition = Vec3.sum(MyAvatar.position, Quat.getForward(orientation)); tablePosition.y += 0.5; diff --git a/scripts/developer/tests/testInterval.js b/scripts/developer/tests/testInterval.js index 94a5fe1fa5..7898610c6d 100644 --- a/scripts/developer/tests/testInterval.js +++ b/scripts/developer/tests/testInterval.js @@ -12,7 +12,7 @@ var UPDATE_HZ = 60; // standard script update rate var UPDATE_INTERVAL = 1000/UPDATE_HZ; // standard script update interval var UPDATE_WORK_EFFORT = 0; // 1000 is light work, 1000000 ~= 30ms -var basePosition = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())); +var basePosition = Vec3.sum(Camera.getPosition(), Quat.getForward(Camera.getOrientation())); var timerBox = Entities.addEntity( { type: "Box", diff --git a/scripts/developer/tests/unit_tests/entityUnitTests.js b/scripts/developer/tests/unit_tests/entityUnitTests.js index 033a484663..1372676901 100644 --- a/scripts/developer/tests/unit_tests/entityUnitTests.js +++ b/scripts/developer/tests/unit_tests/entityUnitTests.js @@ -1,7 +1,7 @@ describe('Entity', function() { var center = Vec3.sum( MyAvatar.position, - Vec3.multiply(3, Quat.getFront(Camera.getOrientation())) + Vec3.multiply(3, Quat.getForward(Camera.getOrientation())) ); var boxEntity; var boxProps = { diff --git a/scripts/developer/tests/viveTouchpadTest.js b/scripts/developer/tests/viveTouchpadTest.js index 913da5888d..802186708c 100644 --- a/scripts/developer/tests/viveTouchpadTest.js +++ b/scripts/developer/tests/viveTouchpadTest.js @@ -24,8 +24,8 @@ var boxZAxis, boxYAxis; var prevThumbDown = false; function init() { - boxPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation()))); - var front = Quat.getFront(Camera.getOrientation()); + boxPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(Camera.getOrientation()))); + var front = Quat.getForward(Camera.getOrientation()); boxZAxis = Vec3.normalize(Vec3.cross(front, Y_AXIS)); boxYAxis = Vec3.normalize(Vec3.cross(boxZAxis, front)); diff --git a/scripts/developer/utilities/render/photobooth/photobooth.js b/scripts/developer/utilities/render/photobooth/photobooth.js index 3e86d83a98..2a17fd8da0 100644 --- a/scripts/developer/utilities/render/photobooth/photobooth.js +++ b/scripts/developer/utilities/render/photobooth/photobooth.js @@ -9,7 +9,7 @@ PhotoBooth.init = function () { var success = Clipboard.importEntities(PHOTOBOOTH_SETUP_JSON_URL); var frontFactor = 10; - var frontUnitVec = Vec3.normalize(Quat.getFront(MyAvatar.orientation)); + var frontUnitVec = Vec3.normalize(Quat.getForward(MyAvatar.orientation)); var frontOffset = Vec3.multiply(frontUnitVec,frontFactor); var rightFactor = 3; var rightUnitVec = Vec3.normalize(Quat.getRight(MyAvatar.orientation)); diff --git a/scripts/system/away.js b/scripts/system/away.js index 541fe6f679..1b11612ef0 100644 --- a/scripts/system/away.js +++ b/scripts/system/away.js @@ -87,7 +87,7 @@ function moveCloserToCamera(positionAtHUD) { // we don't actually want to render at the slerped look at... instead, we want to render // slightly closer to the camera than that. var MOVE_CLOSER_TO_CAMERA_BY = -0.25; - var cameraFront = Quat.getFront(Camera.orientation); + var cameraFront = Quat.getForward(Camera.orientation); var closerToCamera = Vec3.multiply(cameraFront, MOVE_CLOSER_TO_CAMERA_BY); // slightly closer to camera var slightlyCloserPosition = Vec3.sum(positionAtHUD, closerToCamera); diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index f0b6663bec..05b2eefeb5 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -463,7 +463,7 @@ Grabber.prototype.moveEvent = function(event) { var orientation = Camera.getOrientation(); var dragOffset = Vec3.multiply(drag.x, Quat.getRight(orientation)); dragOffset = Vec3.sum(dragOffset, Vec3.multiply(-drag.y, Quat.getUp(orientation))); - var axis = Vec3.cross(dragOffset, Quat.getFront(orientation)); + var axis = Vec3.cross(dragOffset, Quat.getForward(orientation)); axis = Vec3.normalize(axis); var ROTATE_STRENGTH = 0.4; // magic number tuned by hand var angle = ROTATE_STRENGTH * Math.sqrt((drag.x * drag.x) + (drag.y * drag.y)); @@ -487,7 +487,7 @@ Grabber.prototype.moveEvent = function(event) { if (this.mode === "verticalCylinder") { // for this mode we recompute the plane based on current Camera - var planeNormal = Quat.getFront(Camera.getOrientation()); + var planeNormal = Quat.getForward(Camera.getOrientation()); planeNormal.y = 0; planeNormal = Vec3.normalize(planeNormal); var pointOnCylinder = Vec3.multiply(planeNormal, this.xzDistanceToGrab); diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 51b01e60a2..e83e31aaa5 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1481,7 +1481,7 @@ function MyController(hand) { var pickRay = { origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position, direction: PICK_WITH_HAND_RAY ? Quat.getUp(worldHandRotation) : Vec3.mix(Quat.getUp(worldHandRotation), - Quat.getFront(Camera.orientation), + Quat.getForward(Camera.orientation), HAND_HEAD_MIX_RATIO), length: PICK_MAX_DISTANCE }; diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index f8a336a017..eb94428100 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -174,7 +174,7 @@ function calculateRayUICollisionPoint(position, direction) { // interect HUD plane, 1m in front of camera, using formula: // scale = hudNormal dot (hudPoint - position) / hudNormal dot direction // intersection = postion + scale*direction - var hudNormal = Quat.getFront(Camera.getOrientation()); + var hudNormal = Quat.getForward(Camera.getOrientation()); var hudPoint = Vec3.sum(Camera.getPosition(), hudNormal); // must also scale if PLANAR_PERPENDICULAR_HUD_DISTANCE!=1 var denominator = Vec3.dot(hudNormal, direction); if (denominator === 0) { diff --git a/scripts/system/edit.js b/scripts/system/edit.js index fb5a3c2f73..8b02eb1550 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -816,7 +816,7 @@ function mouseClickEvent(event) { if (0 < x && sizeOK) { selectedEntityID = foundEntity; orientation = MyAvatar.orientation; - intersection = rayPlaneIntersection(pickRay, P, Quat.getFront(orientation)); + intersection = rayPlaneIntersection(pickRay, P, Quat.getForward(orientation)); if (!event.isShifted) { @@ -1338,12 +1338,12 @@ function handeMenuEvent(menuItem) { } function getPositionToCreateEntity() { var HALF_TREE_SCALE = 16384; - var direction = Quat.getFront(MyAvatar.orientation); + var direction = Quat.getForward(MyAvatar.orientation); var distance = 1; var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); if (Camera.mode === "entity" || Camera.mode === "independent") { - position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), distance)) + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getForward(Camera.orientation), distance)) } position.y += 0.5; if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { @@ -1355,13 +1355,13 @@ function getPositionToCreateEntity() { function getPositionToImportEntity() { var dimensions = Clipboard.getContentsDimensions(); var HALF_TREE_SCALE = 16384; - var direction = Quat.getFront(MyAvatar.orientation); + var direction = Quat.getForward(MyAvatar.orientation); var longest = 1; longest = Math.sqrt(Math.pow(dimensions.x, 2) + Math.pow(dimensions.z, 2)); var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, longest)); if (Camera.mode === "entity" || Camera.mode === "independent") { - position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), longest)) + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getForward(Camera.orientation), longest)) } if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index dd2aaf346b..8e2aaec2d5 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -78,7 +78,7 @@ function calcSpawnInfo(hand, height) { rotation: lookAtRot }; } else { - var front = Quat.getFront(headRot); + var front = Quat.getForward(headRot); finalPosition = Vec3.sum(headPos, Vec3.multiply(0.6, front)); var orientation = Quat.lookAt({x: 0, y: 0, z: 0}, front, {x: 0, y: 1, z: 0}); return { diff --git a/scripts/system/libraries/entityCameraTool.js b/scripts/system/libraries/entityCameraTool.js index 301b60f550..6becc81d9b 100644 --- a/scripts/system/libraries/entityCameraTool.js +++ b/scripts/system/libraries/entityCameraTool.js @@ -158,7 +158,7 @@ CameraManager = function() { that.zoomDistance = INITIAL_ZOOM_DISTANCE; that.targetZoomDistance = that.zoomDistance + 3.0; var focalPoint = Vec3.sum(Camera.getPosition(), - Vec3.multiply(that.zoomDistance, Quat.getFront(Camera.getOrientation()))); + Vec3.multiply(that.zoomDistance, Quat.getForward(Camera.getOrientation()))); // Determine the correct yaw and pitch to keep the camera in the same location var dPos = Vec3.subtract(focalPoint, Camera.getPosition()); @@ -435,7 +435,7 @@ CameraManager = function() { }); var q = Quat.multiply(yRot, xRot); - var pos = Vec3.multiply(Quat.getFront(q), that.zoomDistance); + var pos = Vec3.multiply(Quat.getForward(q), that.zoomDistance); Camera.setPosition(Vec3.sum(that.focalPoint, pos)); yRot = Quat.angleAxis(that.yaw - 180, { diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index a8c4300fbe..9d4bf7d9a8 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2517,7 +2517,7 @@ SelectionDisplay = (function() { onBegin: function(event) { pickRay = generalComputePickRay(event.x, event.y); - upDownPickNormal = Quat.getFront(lastCameraOrientation); + upDownPickNormal = Quat.getForward(lastCameraOrientation); // Remove y component so the y-axis lies along the plane we picking on - this will // give movements that follow the mouse. upDownPickNormal.y = 0; diff --git a/scripts/system/libraries/soundArray.js b/scripts/system/libraries/soundArray.js index f59c88a723..7e5da11948 100644 --- a/scripts/system/libraries/soundArray.js +++ b/scripts/system/libraries/soundArray.js @@ -36,7 +36,7 @@ SoundArray = function(audioOptions, autoUpdateAudioPosition) { }; this.updateAudioPosition = function() { var position = MyAvatar.position; - var forwardVector = Quat.getFront(MyAvatar.orientation); + var forwardVector = Quat.getForward(MyAvatar.orientation); this.audioOptions.position = Vec3.sum(position, forwardVector); }; }; diff --git a/scripts/system/nameTag.js b/scripts/system/nameTag.js index e25db69064..17944bcf85 100644 --- a/scripts/system/nameTag.js +++ b/scripts/system/nameTag.js @@ -33,7 +33,7 @@ Script.setTimeout(function() { }, STARTUP_DELAY); function addNameTag() { - var nameTagPosition = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(HEAD_OFFSET, Quat.getFront(MyAvatar.orientation))); + var nameTagPosition = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(HEAD_OFFSET, Quat.getForward(MyAvatar.orientation))); nameTagPosition.y += HEIGHT_ABOVE_HEAD; var nameTagProperties = { name: MyAvatar.displayName + ' Name Tag', @@ -49,7 +49,7 @@ function addNameTag() { function updateNameTag() { var nameTagProps = Entities.getEntityProperties(nameTagEntityID); - var nameTagPosition = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(HEAD_OFFSET, Quat.getFront(MyAvatar.orientation))); + var nameTagPosition = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(HEAD_OFFSET, Quat.getForward(MyAvatar.orientation))); nameTagPosition.y += HEIGHT_ABOVE_HEAD; Entities.editEntity(nameTagEntityID, { diff --git a/scripts/system/pal.js b/scripts/system/pal.js index fdb6cbcaf5..b47ad754f7 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -298,7 +298,7 @@ function populateUserList(selectData, oldAudioData) { verticalHalfAngle = filter && (frustum.fieldOfView / 2), horizontalHalfAngle = filter && (verticalHalfAngle * frustum.aspectRatio), orientation = filter && Camera.orientation, - front = filter && Quat.getFront(orientation), + front = filter && Quat.getForward(orientation), verticalAngleNormal = filter && Quat.getRight(orientation), horizontalAngleNormal = filter && Quat.getUp(orientation); avatars.forEach(function (id) { // sorting the identifiers is just an aid for debugging diff --git a/scripts/system/voxels.js b/scripts/system/voxels.js index 3c219ebc7a..2f1d0eced9 100644 --- a/scripts/system/voxels.js +++ b/scripts/system/voxels.js @@ -253,7 +253,7 @@ function addTerrainBlock() { if (alreadyThere) { // there is already a terrain block under MyAvatar. // try in front of the avatar. - facingPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(8.0, Quat.getFront(Camera.getOrientation()))); + facingPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(8.0, Quat.getForward(Camera.getOrientation()))); facingPosition = Vec3.sum(facingPosition, { x: 8, y: 8, diff --git a/scripts/tutorials/NBody/makePlanets.js b/scripts/tutorials/NBody/makePlanets.js index 58a3c7cc2d..21415ccdc2 100644 --- a/scripts/tutorials/NBody/makePlanets.js +++ b/scripts/tutorials/NBody/makePlanets.js @@ -53,7 +53,7 @@ var deleteButton = toolBar.addOverlay("image", { }); function inFrontOfMe(distance) { - return Vec3.sum(Camera.getPosition(), Vec3.multiply(distance, Quat.getFront(Camera.getOrientation()))); + return Vec3.sum(Camera.getPosition(), Vec3.multiply(distance, Quat.getForward(Camera.getOrientation()))); } function onButtonClick() { diff --git a/scripts/tutorials/butterflies.js b/scripts/tutorials/butterflies.js index 55bafc0a27..9d8d1de52c 100644 --- a/scripts/tutorials/butterflies.js +++ b/scripts/tutorials/butterflies.js @@ -44,8 +44,8 @@ var FIXED_LOCATION = false; if (!FIXED_LOCATION) { var flockPosition = Vec3.sum(MyAvatar.position,Vec3.sum( - Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_ABOVE_ME), - Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_IN_FRONT_OF_ME))); + Vec3.multiply(Quat.getForward(MyAvatar.orientation), DISTANCE_ABOVE_ME), + Vec3.multiply(Quat.getForward(MyAvatar.orientation), DISTANCE_IN_FRONT_OF_ME))); } else { var flockPosition = { x: 4999.6, y: 4986.5, z: 5003.5 }; } @@ -119,7 +119,7 @@ function updateButterflies(deltaTime) { var HORIZ_SCALE = 0.50; var VERT_SCALE = 0.50; var newHeading = Math.random() * 360.0; - var newVelocity = Vec3.multiply(HORIZ_SCALE, Quat.getFront(Quat.fromPitchYawRollDegrees(0.0, newHeading, 0.0))); + var newVelocity = Vec3.multiply(HORIZ_SCALE, Quat.getForward(Quat.fromPitchYawRollDegrees(0.0, newHeading, 0.0))); newVelocity.y = (Math.random() + 0.5) * VERT_SCALE; Entities.editEntity(butterflies[i], { rotation: Quat.fromPitchYawRollDegrees(-80 + Math.random() * 20, newHeading, (Math.random() - 0.5) * 10), velocity: newVelocity } ); diff --git a/scripts/tutorials/createCow.js b/scripts/tutorials/createCow.js index 7446aa0fd0..16498e0e8c 100644 --- a/scripts/tutorials/createCow.js +++ b/scripts/tutorials/createCow.js @@ -18,7 +18,7 @@ var orientation = MyAvatar.orientation; orientation = Quat.safeEulerAngles(orientation); orientation.x = 0; orientation = Quat.fromVec3Degrees(orientation); -var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getFront(orientation))); +var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getForward(orientation))); // An entity is described and created by specifying a map of properties var cow = Entities.addEntity({ diff --git a/scripts/tutorials/createDice.js b/scripts/tutorials/createDice.js index 0d39d11d48..46ad0172aa 100644 --- a/scripts/tutorials/createDice.js +++ b/scripts/tutorials/createDice.js @@ -127,8 +127,8 @@ function mousePressEvent(event) { deleteDice(); } else if (clickedOverlay == diceButton) { var HOW_HARD = 2.0; - var position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())); - var velocity = Vec3.multiply(HOW_HARD, Quat.getFront(Camera.getOrientation())); + var position = Vec3.sum(Camera.getPosition(), Quat.getForward(Camera.getOrientation())); + var velocity = Vec3.multiply(HOW_HARD, Quat.getForward(Camera.getOrientation())); shootDice(position, velocity); madeSound = false; } diff --git a/scripts/tutorials/createFlashlight.js b/scripts/tutorials/createFlashlight.js index 0e3581a435..f3e1e72182 100644 --- a/scripts/tutorials/createFlashlight.js +++ b/scripts/tutorials/createFlashlight.js @@ -16,7 +16,7 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, { x: 0, y: 0.5, z: 0 -}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation()))); +}), Vec3.multiply(0.5, Quat.getForward(Camera.getOrientation()))); var flashlight = Entities.addEntity({ type: "Model", diff --git a/scripts/tutorials/createGolfClub.js b/scripts/tutorials/createGolfClub.js index aa9834276a..21e60f26ef 100644 --- a/scripts/tutorials/createGolfClub.js +++ b/scripts/tutorials/createGolfClub.js @@ -15,7 +15,7 @@ var orientation = MyAvatar.orientation; orientation = Quat.safeEulerAngles(orientation); orientation.x = 0; orientation = Quat.fromVec3Degrees(orientation); -var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getFront(orientation))); +var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getForward(orientation))); var CLUB_MODEL = "http://hifi-production.s3.amazonaws.com/tutorials/golfClub/putter_VR.fbx"; var CLUB_COLLISION_HULL = "http://hifi-production.s3.amazonaws.com/tutorials/golfClub/club_collision_hull.obj"; diff --git a/scripts/tutorials/createPictureFrame.js b/scripts/tutorials/createPictureFrame.js index 4a1e5b16a7..873b604bfa 100644 --- a/scripts/tutorials/createPictureFrame.js +++ b/scripts/tutorials/createPictureFrame.js @@ -14,7 +14,7 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, { x: 0, y: 0.5, z: 0 -}), Vec3.multiply(1, Quat.getFront(Camera.getOrientation()))); +}), Vec3.multiply(1, Quat.getForward(Camera.getOrientation()))); // this is just a model exported from blender with a texture named 'Picture' on one face. also made it emissive so it doesn't require lighting. var MODEL_URL = "http://hifi-production.s3.amazonaws.com/tutorials/pictureFrame/finalFrame.fbx"; diff --git a/scripts/tutorials/createPingPongGun.js b/scripts/tutorials/createPingPongGun.js index a077e5308d..c86a78e96d 100644 --- a/scripts/tutorials/createPingPongGun.js +++ b/scripts/tutorials/createPingPongGun.js @@ -14,7 +14,7 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, { x: 0, y: 0.5, z: 0 -}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation()))); +}), Vec3.multiply(0.5, Quat.getForward(Camera.getOrientation()))); var pingPongGunProperties = { diff --git a/scripts/tutorials/createPistol.js b/scripts/tutorials/createPistol.js index ae2f398840..8851f53d09 100644 --- a/scripts/tutorials/createPistol.js +++ b/scripts/tutorials/createPistol.js @@ -6,7 +6,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(Camera.getOrientation()))); +var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getForward(Camera.getOrientation()))); var SCRIPT_URL = "http://hifi-production.s3.amazonaws.com/tutorials/entity_scripts/pistol.js"; var MODEL_URL = "http://hifi-production.s3.amazonaws.com/tutorials/pistol/gun.fbx"; var COLLISION_SOUND_URL = 'http://hifi-production.s3.amazonaws.com/tutorials/pistol/drop.wav' diff --git a/scripts/tutorials/createSoundMaker.js b/scripts/tutorials/createSoundMaker.js index b79c650e27..2d86864982 100644 --- a/scripts/tutorials/createSoundMaker.js +++ b/scripts/tutorials/createSoundMaker.js @@ -13,7 +13,7 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, { x: 0, y: 0.5, z: 0 -}), Vec3.multiply(1, Quat.getFront(Camera.getOrientation()))); +}), Vec3.multiply(1, Quat.getForward(Camera.getOrientation()))); function makeBell() { var soundMakerProperties = { diff --git a/scripts/tutorials/entity_scripts/golfClub.js b/scripts/tutorials/entity_scripts/golfClub.js index 2df3be8b60..6342838aa4 100644 --- a/scripts/tutorials/entity_scripts/golfClub.js +++ b/scripts/tutorials/entity_scripts/golfClub.js @@ -57,7 +57,7 @@ // Position yourself facing in the direction you were originally facing, but with a // point on the ground *away* meters from *position* and in front of you. - var offset = Quat.getFront(MyAvatar.orientation); + var offset = Quat.getForward(MyAvatar.orientation); offset.y = 0.0; offset = Vec3.multiply(-away, Vec3.normalize(offset)); var newAvatarPosition = Vec3.sum(position, offset); @@ -72,7 +72,7 @@ } function inFrontOfMe() { - return Vec3.sum(MyAvatar.position, Vec3.multiply(BALL_DROP_DISTANCE, Quat.getFront(MyAvatar.orientation))); + return Vec3.sum(MyAvatar.position, Vec3.multiply(BALL_DROP_DISTANCE, Quat.getForward(MyAvatar.orientation))); } function avatarHalfHeight() { diff --git a/scripts/tutorials/entity_scripts/pingPongGun.js b/scripts/tutorials/entity_scripts/pingPongGun.js index 4ec0254747..aaaf1bd1e1 100644 --- a/scripts/tutorials/entity_scripts/pingPongGun.js +++ b/scripts/tutorials/entity_scripts/pingPongGun.js @@ -94,7 +94,7 @@ }, shootBall: function(gunProperties) { - var forwardVec = Quat.getFront(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0))); + var forwardVec = Quat.getForward(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0))); forwardVec = Vec3.normalize(forwardVec); forwardVec = Vec3.multiply(forwardVec, GUN_FORCE); @@ -131,7 +131,7 @@ getGunTipPosition: function(properties) { //the tip of the gun is going to be in a different place than the center, so we move in space relative to the model to find that position - var frontVector = Quat.getFront(properties.rotation); + var frontVector = Quat.getForward(properties.rotation); var frontOffset = Vec3.multiply(frontVector, GUN_TIP_FWD_OFFSET); var upVector = Quat.getUp(properties.rotation); var upOffset = Vec3.multiply(upVector, GUN_TIP_UP_OFFSET); diff --git a/scripts/tutorials/entity_scripts/pistol.js b/scripts/tutorials/entity_scripts/pistol.js index 73a6daab93..38eb929177 100644 --- a/scripts/tutorials/entity_scripts/pistol.js +++ b/scripts/tutorials/entity_scripts/pistol.js @@ -69,7 +69,7 @@ var gunProps = Entities.getEntityProperties(this.entityID, ['position', 'rotation']); this.position = gunProps.position; this.rotation = gunProps.rotation; - this.firingDirection = Quat.getFront(this.rotation); + this.firingDirection = Quat.getForward(this.rotation); var upVec = Quat.getUp(this.rotation); this.barrelPoint = Vec3.sum(this.position, Vec3.multiply(upVec, this.laserOffsets.y)); this.laserTip = Vec3.sum(this.barrelPoint, Vec3.multiply(this.firingDirection, this.laserLength)); diff --git a/scripts/tutorials/makeBlocks.js b/scripts/tutorials/makeBlocks.js index 54bdead792..9a3e649e7a 100644 --- a/scripts/tutorials/makeBlocks.js +++ b/scripts/tutorials/makeBlocks.js @@ -34,7 +34,7 @@ var SCRIPT_URL = Script.resolvePath("./entity_scripts/magneticBlock.js"); - var frontVector = Quat.getFront(MyAvatar.orientation); + var frontVector = Quat.getForward(MyAvatar.orientation); frontVector.y += VERTICAL_OFFSET; for (var x = 0; x < COLUMNS; x++) { for (var y = 0; y < ROWS; y++) { From 8df0395754e436d06beba2ac4ebe5168496bd85e Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 21 Mar 2017 22:28:12 +0000 Subject: [PATCH 21/42] change getFrontDirection to getForwardDirection --- interface/src/avatar/Head.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index d556d1efc4..aa801e5eb5 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -58,14 +58,14 @@ public: const glm::vec3& getSaccade() const { return _saccade; } glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getUpDirection() const { return getOrientation() * IDENTITY_UP; } - glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FORWARD; } + glm::vec3 getForwardDirection() const { return getOrientation() * IDENTITY_FORWARD; } glm::quat getEyeRotation(const glm::vec3& eyePosition) const; const glm::vec3& getRightEyePosition() const { return _rightEyePosition; } const glm::vec3& getLeftEyePosition() const { return _leftEyePosition; } - glm::vec3 getRightEarPosition() const { return _rightEyePosition + (getRightDirection() * EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); } - glm::vec3 getLeftEarPosition() const { return _leftEyePosition + (getRightDirection() * -EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); } + glm::vec3 getRightEarPosition() const { return _rightEyePosition + (getRightDirection() * EYE_EAR_GAP) + (getForwardDirection() * -EYE_EAR_GAP); } + glm::vec3 getLeftEarPosition() const { return _leftEyePosition + (getRightDirection() * -EYE_EAR_GAP) + (getForwardDirection() * -EYE_EAR_GAP); } glm::vec3 getMouthPosition() const { return _eyePosition - getUpDirection() * glm::length(_rightEyePosition - _leftEyePosition); } bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected) From 66d697873ffb521a6efb808345d655f0b7fc50c6 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 21 Mar 2017 22:31:06 +0000 Subject: [PATCH 22/42] change mat4test back to getFront premature, including in seperate commit --- scripts/developer/tests/mat4test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/developer/tests/mat4test.js b/scripts/developer/tests/mat4test.js index 2d7c994631..ebce420dcb 100644 --- a/scripts/developer/tests/mat4test.js +++ b/scripts/developer/tests/mat4test.js @@ -143,10 +143,10 @@ function testInverse() { function testFront() { var test0 = IDENTITY; - assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getForward(test0))); + assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getFront(test0))); var test1 = Mat4.createFromScaleRotAndTrans(ONE_HALF, ROT_Y_180, ONE_TWO_THREE); - assert(mat4FuzzyEqual({x: 0, y: 0, z: 1}, Mat4.getForward(test1))); + assert(mat4FuzzyEqual({x: 0, y: 0, z: 1}, Mat4.getFront(test1))); } function testMat4() { From 6e740a5fbb161c0e9798dbf8ed7be8aeeec1c148 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 21 Mar 2017 22:33:37 +0000 Subject: [PATCH 23/42] change Mat4 getFront to getForward --- libraries/script-engine/src/Mat4.cpp | 2 +- libraries/script-engine/src/Mat4.h | 4 +++- scripts/developer/tests/mat4test.js | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/script-engine/src/Mat4.cpp b/libraries/script-engine/src/Mat4.cpp index 52b9690321..6676d0cde1 100644 --- a/libraries/script-engine/src/Mat4.cpp +++ b/libraries/script-engine/src/Mat4.cpp @@ -54,7 +54,7 @@ glm::mat4 Mat4::inverse(const glm::mat4& m) const { return glm::inverse(m); } -glm::vec3 Mat4::getFront(const glm::mat4& m) const { +glm::vec3 Mat4::getForward(const glm::mat4& m) const { return glm::vec3(-m[0][2], -m[1][2], -m[2][2]); } diff --git a/libraries/script-engine/src/Mat4.h b/libraries/script-engine/src/Mat4.h index 8b2a8aa8c1..19bbbe178a 100644 --- a/libraries/script-engine/src/Mat4.h +++ b/libraries/script-engine/src/Mat4.h @@ -37,7 +37,9 @@ public slots: glm::mat4 inverse(const glm::mat4& m) const; - glm::vec3 getFront(const glm::mat4& m) const; + // redundant, calls getForward which better describes the returned vector as a direction + glm::vec3 getFront(const glm::mat4& m) const { return getForward(m); } + glm::vec3 getForward(const glm::mat4& m) const; glm::vec3 getRight(const glm::mat4& m) const; glm::vec3 getUp(const glm::mat4& m) const; diff --git a/scripts/developer/tests/mat4test.js b/scripts/developer/tests/mat4test.js index ebce420dcb..2d7c994631 100644 --- a/scripts/developer/tests/mat4test.js +++ b/scripts/developer/tests/mat4test.js @@ -143,10 +143,10 @@ function testInverse() { function testFront() { var test0 = IDENTITY; - assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getFront(test0))); + assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getForward(test0))); var test1 = Mat4.createFromScaleRotAndTrans(ONE_HALF, ROT_Y_180, ONE_TWO_THREE); - assert(mat4FuzzyEqual({x: 0, y: 0, z: 1}, Mat4.getFront(test1))); + assert(mat4FuzzyEqual({x: 0, y: 0, z: 1}, Mat4.getForward(test1))); } function testMat4() { From 2515563a0bcf821fab60419e59880b59c241b87a Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 21 Mar 2017 22:35:07 +0000 Subject: [PATCH 24/42] change getFront to getForward --- interface/resources/qml/AssetServer.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index cf61a2ae4a..6f3076b408 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -206,7 +206,7 @@ ScrollingWindow { print("Error: model cannot be both static mesh and dynamic. This should never happen."); } else if (url) { var name = assetProxyModel.data(treeView.selection.currentIndex); - var addPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(MyAvatar.orientation))); + var addPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation))); var gravity; if (dynamic) { // Create a vector <0, -10, 0>. { x: 0, y: -10, z: 0 } won't work because Qt is dumb and this is a From 2d1ca99e2e07e41295210ba199a1ae0acc15de57 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 17:00:12 +0000 Subject: [PATCH 25/42] change variable names that use Quat.getForward --- scripts/developer/tests/viveTouchpadTest.js | 6 +++--- .../utilities/render/photobooth/photobooth.js | 9 ++++----- scripts/system/away.js | 4 ++-- scripts/system/libraries/WebTablet.js | 6 +++--- scripts/system/pal.js | 6 +++--- scripts/tutorials/entity_scripts/pingPongGun.js | 14 +++++++------- scripts/tutorials/makeBlocks.js | 6 +++--- 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/scripts/developer/tests/viveTouchpadTest.js b/scripts/developer/tests/viveTouchpadTest.js index 802186708c..b5d9575adf 100644 --- a/scripts/developer/tests/viveTouchpadTest.js +++ b/scripts/developer/tests/viveTouchpadTest.js @@ -25,9 +25,9 @@ var prevThumbDown = false; function init() { boxPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(Camera.getOrientation()))); - var front = Quat.getForward(Camera.getOrientation()); - boxZAxis = Vec3.normalize(Vec3.cross(front, Y_AXIS)); - boxYAxis = Vec3.normalize(Vec3.cross(boxZAxis, front)); + var forward = Quat.getForward(Camera.getOrientation()); + boxZAxis = Vec3.normalize(Vec3.cross(forward, Y_AXIS)); + boxYAxis = Vec3.normalize(Vec3.cross(boxZAxis, forward)); boxEntity = Entities.addEntity({ type: "Box", diff --git a/scripts/developer/utilities/render/photobooth/photobooth.js b/scripts/developer/utilities/render/photobooth/photobooth.js index 2a17fd8da0..e822955563 100644 --- a/scripts/developer/utilities/render/photobooth/photobooth.js +++ b/scripts/developer/utilities/render/photobooth/photobooth.js @@ -8,12 +8,11 @@ var PhotoBooth = {}; PhotoBooth.init = function () { var success = Clipboard.importEntities(PHOTOBOOTH_SETUP_JSON_URL); - var frontFactor = 10; - var frontUnitVec = Vec3.normalize(Quat.getForward(MyAvatar.orientation)); - var frontOffset = Vec3.multiply(frontUnitVec,frontFactor); + var forwardFactor = 10; + var forwardUnitVector = Vec3.normalize(Quat.getForward(MyAvatar.orientation)); + var forwardOffset = Vec3.multiply(forwardUnitVector,forwardFactor); var rightFactor = 3; - var rightUnitVec = Vec3.normalize(Quat.getRight(MyAvatar.orientation)); - var spawnLocation = Vec3.sum(Vec3.sum(MyAvatar.position,frontOffset),rightFactor); + var spawnLocation = Vec3.sum(Vec3.sum(MyAvatar.position,forwardOffset),rightFactor); if (success) { this.pastedEntityIDs = Clipboard.pasteEntities(spawnLocation); this.processPastedEntities(); diff --git a/scripts/system/away.js b/scripts/system/away.js index 1b11612ef0..4ca938d492 100644 --- a/scripts/system/away.js +++ b/scripts/system/away.js @@ -87,8 +87,8 @@ function moveCloserToCamera(positionAtHUD) { // we don't actually want to render at the slerped look at... instead, we want to render // slightly closer to the camera than that. var MOVE_CLOSER_TO_CAMERA_BY = -0.25; - var cameraFront = Quat.getForward(Camera.orientation); - var closerToCamera = Vec3.multiply(cameraFront, MOVE_CLOSER_TO_CAMERA_BY); // slightly closer to camera + var cameraForward = Quat.getForward(Camera.orientation); + var closerToCamera = Vec3.multiply(cameraForward, MOVE_CLOSER_TO_CAMERA_BY); // slightly closer to camera var slightlyCloserPosition = Vec3.sum(positionAtHUD, closerToCamera); return slightlyCloserPosition; diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 8e2aaec2d5..32f45188dc 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -78,9 +78,9 @@ function calcSpawnInfo(hand, height) { rotation: lookAtRot }; } else { - var front = Quat.getForward(headRot); - finalPosition = Vec3.sum(headPos, Vec3.multiply(0.6, front)); - var orientation = Quat.lookAt({x: 0, y: 0, z: 0}, front, {x: 0, y: 1, z: 0}); + 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: Quat.multiply(orientation, {x: 0, y: 1, z: 0, w: 0}) diff --git a/scripts/system/pal.js b/scripts/system/pal.js index b47ad754f7..d85fbce19a 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -298,7 +298,7 @@ function populateUserList(selectData, oldAudioData) { verticalHalfAngle = filter && (frustum.fieldOfView / 2), horizontalHalfAngle = filter && (verticalHalfAngle * frustum.aspectRatio), orientation = filter && Camera.orientation, - front = filter && Quat.getForward(orientation), + forward = filter && Quat.getForward(orientation), verticalAngleNormal = filter && Quat.getRight(orientation), horizontalAngleNormal = filter && Quat.getUp(orientation); avatars.forEach(function (id) { // sorting the identifiers is just an aid for debugging @@ -316,8 +316,8 @@ function populateUserList(selectData, oldAudioData) { return; } var normal = id && filter && Vec3.normalize(Vec3.subtract(avatar.position, myPosition)); - var horizontal = normal && angleBetweenVectorsInPlane(normal, front, horizontalAngleNormal); - var vertical = normal && angleBetweenVectorsInPlane(normal, front, verticalAngleNormal); + var horizontal = normal && angleBetweenVectorsInPlane(normal, forward, horizontalAngleNormal); + var vertical = normal && angleBetweenVectorsInPlane(normal, forward, verticalAngleNormal); if (id && filter && ((Math.abs(horizontal) > horizontalHalfAngle) || (Math.abs(vertical) > verticalHalfAngle))) { return; } diff --git a/scripts/tutorials/entity_scripts/pingPongGun.js b/scripts/tutorials/entity_scripts/pingPongGun.js index aaaf1bd1e1..5ba4b15ea7 100644 --- a/scripts/tutorials/entity_scripts/pingPongGun.js +++ b/scripts/tutorials/entity_scripts/pingPongGun.js @@ -94,9 +94,9 @@ }, shootBall: function(gunProperties) { - var forwardVec = Quat.getForward(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0))); - forwardVec = Vec3.normalize(forwardVec); - forwardVec = Vec3.multiply(forwardVec, GUN_FORCE); + var forwardVector = Quat.getForward(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0))); + forwardVector = Vec3.normalize(forwardVector); + forwardVector = Vec3.multiply(forwardVector, GUN_FORCE); var properties = { name: 'Tutorial Ping Pong Ball', @@ -111,7 +111,7 @@ rotation: gunProperties.rotation, position: this.getGunTipPosition(gunProperties), gravity: PING_PONG_GUN_GRAVITY, - velocity: forwardVec, + velocity: forwardVector, lifetime: 10 }; @@ -131,12 +131,12 @@ getGunTipPosition: function(properties) { //the tip of the gun is going to be in a different place than the center, so we move in space relative to the model to find that position - var frontVector = Quat.getForward(properties.rotation); - var frontOffset = Vec3.multiply(frontVector, GUN_TIP_FWD_OFFSET); + var forwardVector = Quat.getForward(properties.rotation); + var forwardOffset = Vec3.multiply(forwardVector, GUN_TIP_FWD_OFFSET); var upVector = Quat.getUp(properties.rotation); var upOffset = Vec3.multiply(upVector, GUN_TIP_UP_OFFSET); - var gunTipPosition = Vec3.sum(properties.position, frontOffset); + var gunTipPosition = Vec3.sum(properties.position, forwardOffset); gunTipPosition = Vec3.sum(gunTipPosition, upOffset); return gunTipPosition; diff --git a/scripts/tutorials/makeBlocks.js b/scripts/tutorials/makeBlocks.js index 9a3e649e7a..11311f6a59 100644 --- a/scripts/tutorials/makeBlocks.js +++ b/scripts/tutorials/makeBlocks.js @@ -34,8 +34,8 @@ var SCRIPT_URL = Script.resolvePath("./entity_scripts/magneticBlock.js"); - var frontVector = Quat.getForward(MyAvatar.orientation); - frontVector.y += VERTICAL_OFFSET; + var forwardVector = Quat.getForward(MyAvatar.orientation); + forwardVector.y += VERTICAL_OFFSET; for (var x = 0; x < COLUMNS; x++) { for (var y = 0; y < ROWS; y++) { @@ -61,7 +61,7 @@ cloneLimit: 9999 } }), - position: Vec3.sum(MyAvatar.position, Vec3.sum(frontOffset, frontVector)), + position: Vec3.sum(MyAvatar.position, Vec3.sum(forwardOffset, forwardVector)), color: newColor(), script: SCRIPT_URL }); From 2fc8dd48de68699301507f098de7d87056e177a6 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 17:13:45 +0000 Subject: [PATCH 26/42] change testFront to testForward --- scripts/developer/tests/mat4test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/developer/tests/mat4test.js b/scripts/developer/tests/mat4test.js index 2d7c994631..4e835ec82f 100644 --- a/scripts/developer/tests/mat4test.js +++ b/scripts/developer/tests/mat4test.js @@ -141,7 +141,7 @@ function testInverse() { assert(mat4FuzzyEqual(IDENTITY, Mat4.multiply(test2, Mat4.inverse(test2)))); } -function testFront() { +function testForward() { var test0 = IDENTITY; assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getForward(test0))); @@ -157,7 +157,7 @@ function testMat4() { testTransformPoint(); testTransformVector(); testInverse(); - testFront(); + testForward(); print("MAT4 TEST complete! (" + (testCount - failureCount) + "/" + testCount + ") tests passed!"); } From c2cff55427fefb7f61de7e44f18018d8fffced00 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 18:41:06 +0000 Subject: [PATCH 27/42] rename fronts to forwards --- libraries/animation/src/Rig.cpp | 6 +++--- libraries/animation/src/Rig.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 88cfacbd66..0520e5c5a1 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -558,7 +558,7 @@ static const std::vector LATERAL_SPEEDS = { 0.2f, 0.65f }; // m/s void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation, CharacterControllerState ccState) { - glm::vec3 front = worldRotation * IDENTITY_FORWARD; + glm::vec3 forward = worldRotation * IDENTITY_FORWARD; glm::vec3 workingVelocity = worldVelocity; { @@ -566,7 +566,7 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos float forwardSpeed = glm::dot(localVel, IDENTITY_FORWARD); float lateralSpeed = glm::dot(localVel, IDENTITY_RIGHT); - float turningSpeed = glm::orientedAngle(front, _lastFront, IDENTITY_UP) / deltaTime; + float turningSpeed = glm::orientedAngle(forward, _lastForward, IDENTITY_UP) / deltaTime; // filter speeds using a simple moving average. _averageForwardSpeed.updateAverage(forwardSpeed); @@ -852,7 +852,7 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos _lastEnableInverseKinematics = _enableInverseKinematics; } - _lastFront = front; + _lastForward = forward; _lastPosition = worldPosition; _lastVelocity = workingVelocity; } diff --git a/libraries/animation/src/Rig.h b/libraries/animation/src/Rig.h index b2cc877460..41cc5cabc6 100644 --- a/libraries/animation/src/Rig.h +++ b/libraries/animation/src/Rig.h @@ -267,7 +267,7 @@ protected: int _rightElbowJointIndex { -1 }; int _rightShoulderJointIndex { -1 }; - glm::vec3 _lastFront; + glm::vec3 _lastForward; glm::vec3 _lastPosition; glm::vec3 _lastVelocity; From 31ec9b832fbe7f460961b9c36abb55c040fbd973 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 18:43:30 +0000 Subject: [PATCH 28/42] rename fronts to forwards --- libraries/avatars/src/HeadData.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index d2b9e8cee4..bf8593f1d9 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -65,8 +65,8 @@ glm::quat HeadData::getOrientation() const { void HeadData::setOrientation(const glm::quat& orientation) { // rotate body about vertical axis glm::quat bodyOrientation = _owningAvatar->getOrientation(); - glm::vec3 newFront = glm::inverse(bodyOrientation) * (orientation * IDENTITY_FORWARD); - bodyOrientation = bodyOrientation * glm::angleAxis(atan2f(-newFront.x, -newFront.z), glm::vec3(0.0f, 1.0f, 0.0f)); + glm::vec3 newForward = glm::inverse(bodyOrientation) * (orientation * IDENTITY_FORWARD); + bodyOrientation = bodyOrientation * glm::angleAxis(atan2f(-newForward.x, -newForward.z), glm::vec3(0.0f, 1.0f, 0.0f)); _owningAvatar->setOrientation(bodyOrientation); // the rest goes to the head From fd312f6bf83322b74229464a53684277875d8e78 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 18:49:34 +0000 Subject: [PATCH 29/42] rename fronts to forwards --- interface/src/avatar/Avatar.h | 4 +++- interface/src/avatar/MyAvatar.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index d8c78d972b..ef45eeb1b5 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -236,7 +236,9 @@ protected: glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getBodyUpDirection() const { return getOrientation() * IDENTITY_UP; } - glm::vec3 getBodyFrontDirection() const { return getOrientation() * IDENTITY_FORWARD; } + // redundant, calls getBodyForwardDirection which better describes the returned vector as a direction + glm::vec3 getBodyFrontDirection() const { return getBodyForwardDirection(); } + glm::vec3 getBodyForwardDirection() const { return getOrientation() * IDENTITY_FORWARD; } glm::quat computeRotationFromBodyToWorldUp(float proportion = 1.0f) const; void measureMotionDerivatives(float deltaTime); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index bf43a457b7..e0f4b55393 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1770,10 +1770,10 @@ void MyAvatar::updateActionMotor(float deltaTime) { } // compute action input - glm::vec3 front = (getDriveKey(TRANSLATE_Z)) * IDENTITY_FORWARD; + glm::vec3 forward = (getDriveKey(TRANSLATE_Z)) * IDENTITY_FORWARD; glm::vec3 right = (getDriveKey(TRANSLATE_X)) * IDENTITY_RIGHT; - glm::vec3 direction = front + right; + glm::vec3 direction = forward + right; CharacterController::State state = _characterController.getState(); if (state == CharacterController::State::Hover) { // we're flying --> support vertical motion From d1db04f93a68f9724ee150e78965de14fe735184 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 18:57:00 +0000 Subject: [PATCH 30/42] fix lost forwardOffset declaration --- scripts/tutorials/makeBlocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tutorials/makeBlocks.js b/scripts/tutorials/makeBlocks.js index 11311f6a59..432f7444c4 100644 --- a/scripts/tutorials/makeBlocks.js +++ b/scripts/tutorials/makeBlocks.js @@ -39,7 +39,7 @@ for (var x = 0; x < COLUMNS; x++) { for (var y = 0; y < ROWS; y++) { - var frontOffset = { + var forwardOffset = { x: 0, y: SIZE * y + SIZE, z: SIZE * x + SIZE From 216f20ed2c4db85cb982af993e3358a61e40b67e Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 19:03:39 +0000 Subject: [PATCH 31/42] rename fronts to forwards --- tests/render-perf/src/Camera.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/render-perf/src/Camera.hpp b/tests/render-perf/src/Camera.hpp index a3b33ceb14..ada1277c47 100644 --- a/tests/render-perf/src/Camera.hpp +++ b/tests/render-perf/src/Camera.hpp @@ -123,16 +123,16 @@ public: void update(float deltaTime) { if (moving()) { - glm::vec3 camFront = getOrientation() * Vectors::FRONT; + glm::vec3 camForward = getOrientation() * Vectors::FRONT; glm::vec3 camRight = getOrientation() * Vectors::RIGHT; glm::vec3 camUp = getOrientation() * Vectors::UP; float moveSpeed = deltaTime * movementSpeed; if (keys[FORWARD]) { - position += camFront * moveSpeed; + position += camForward * moveSpeed; } if (keys[BACK]) { - position -= camFront * moveSpeed; + position -= camForward * moveSpeed; } if (keys[LEFT]) { position -= camRight * moveSpeed; From 36619cd2e4bc2ceb1d0ec153e3f17cfa95815f01 Mon Sep 17 00:00:00 2001 From: trent Date: Wed, 22 Mar 2017 15:07:29 -0400 Subject: [PATCH 32/42] Fixed issue with duplicate physics status icons per sub-object. --- interface/src/avatar/CauterizedModel.cpp | 6 +- libraries/render-utils/src/Model.cpp | 82 ++++++++++++------------ libraries/render-utils/src/Model.h | 10 +-- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/interface/src/avatar/CauterizedModel.cpp b/interface/src/avatar/CauterizedModel.cpp index d8db83fbb7..f479ed9a35 100644 --- a/interface/src/avatar/CauterizedModel.cpp +++ b/interface/src/avatar/CauterizedModel.cpp @@ -56,9 +56,9 @@ void CauterizedModel::createVisibleRenderItemSet() { } // We should not have any existing renderItems if we enter this section of code - Q_ASSERT(_modelMeshRenderItemsSet.isEmpty()); + Q_ASSERT(_modelMeshRenderItems.isEmpty()); - _modelMeshRenderItemsSet.clear(); + _modelMeshRenderItems.clear(); Transform transform; transform.setTranslation(_translation); @@ -81,7 +81,7 @@ void CauterizedModel::createVisibleRenderItemSet() { int numParts = (int)mesh->getNumParts(); for (int partIndex = 0; partIndex < numParts; partIndex++) { auto ptr = std::make_shared(this, i, partIndex, shapeID, transform, offset); - _modelMeshRenderItemsSet << std::static_pointer_cast(ptr); + _modelMeshRenderItems << std::static_pointer_cast(ptr); shapeID++; } } diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index c584b0bc21..3448c9e8da 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -176,11 +176,11 @@ void Model::setOffset(const glm::vec3& offset) { } void Model::calculateTextureInfo() { - if (!_hasCalculatedTextureInfo && isLoaded() && getGeometry()->areTexturesLoaded() && !_modelMeshRenderItems.isEmpty()) { + if (!_hasCalculatedTextureInfo && isLoaded() && getGeometry()->areTexturesLoaded() && !_modelMeshRenderItemsMap.isEmpty()) { size_t textureSize = 0; int textureCount = 0; bool allTexturesLoaded = true; - foreach(auto renderItem, _modelMeshRenderItemsSet) { + foreach(auto renderItem, _modelMeshRenderItems) { auto meshPart = renderItem.get(); textureSize += meshPart->getMaterialTextureSize(); textureCount += meshPart->getMaterialTextureCount(); @@ -236,7 +236,7 @@ void Model::updateRenderItems() { uint32_t deleteGeometryCounter = self->_deleteGeometryCounter; render::PendingChanges pendingChanges; - foreach (auto itemID, self->_modelMeshRenderItems.keys()) { + foreach (auto itemID, self->_modelMeshRenderItemsMap.keys()) { pendingChanges.updateItem(itemID, [deleteGeometryCounter](ModelMeshPartPayload& data) { if (data._model && data._model->isLoaded()) { // Ensure the model geometry was not reset between frames @@ -259,7 +259,7 @@ void Model::updateRenderItems() { Transform collisionMeshOffset; collisionMeshOffset.setIdentity(); Transform modelTransform = self->getTransform(); - foreach (auto itemID, self->_collisionRenderItems.keys()) { + foreach(auto itemID, self->_collisionRenderItemsMap.keys()) { pendingChanges.updateItem(itemID, [modelTransform, collisionMeshOffset](MeshPartPayload& data) { // update the model transform for this render item. data.updateTransform(modelTransform, collisionMeshOffset); @@ -539,11 +539,11 @@ void Model::setVisibleInScene(bool newValue, std::shared_ptr scen _isVisible = newValue; render::PendingChanges pendingChanges; - foreach (auto item, _modelMeshRenderItems.keys()) { - pendingChanges.resetItem(item, _modelMeshRenderItems[item]); + foreach (auto item, _modelMeshRenderItemsMap.keys()) { + pendingChanges.resetItem(item, _modelMeshRenderItemsMap[item]); } - foreach (auto item, _collisionRenderItems.keys()) { - pendingChanges.resetItem(item, _collisionRenderItems[item]); + foreach(auto item, _collisionRenderItemsMap.keys()) { + pendingChanges.resetItem(item, _collisionRenderItemsMap[item]); } scene->enqueuePendingChanges(pendingChanges); } @@ -555,11 +555,11 @@ void Model::setLayeredInFront(bool layered, std::shared_ptr scene _isLayeredInFront = layered; render::PendingChanges pendingChanges; - foreach(auto item, _modelMeshRenderItems.keys()) { - pendingChanges.resetItem(item, _modelMeshRenderItems[item]); + foreach(auto item, _modelMeshRenderItemsMap.keys()) { + pendingChanges.resetItem(item, _modelMeshRenderItemsMap[item]); } - foreach(auto item, _collisionRenderItems.keys()) { - pendingChanges.resetItem(item, _collisionRenderItems[item]); + foreach(auto item, _collisionRenderItemsMap.keys()) { + pendingChanges.resetItem(item, _collisionRenderItemsMap[item]); } scene->enqueuePendingChanges(pendingChanges); } @@ -576,39 +576,39 @@ bool Model::addToScene(std::shared_ptr scene, bool somethingAdded = false; if (_collisionGeometry) { if (_collisionRenderItems.empty()) { - foreach (auto renderItem, _collisionRenderItemsSet) { + foreach (auto renderItem, _collisionRenderItems) { auto item = scene->allocateID(); auto renderPayload = std::make_shared(renderItem); - if (statusGetters.size()) { + if (_collisionRenderItems.empty() && statusGetters.size()) { renderPayload->addStatusGetters(statusGetters); } pendingChanges.resetItem(item, renderPayload); - _collisionRenderItems.insert(item, renderPayload); + _collisionRenderItemsMap.insert(item, renderPayload); } somethingAdded = !_collisionRenderItems.empty(); } } else { - if (_modelMeshRenderItems.empty()) { + if (_modelMeshRenderItemsMap.empty()) { bool hasTransparent = false; size_t verticesCount = 0; - foreach(auto renderItem, _modelMeshRenderItemsSet) { + foreach(auto renderItem, _modelMeshRenderItems) { auto item = scene->allocateID(); auto renderPayload = std::make_shared(renderItem); - if (statusGetters.size()) { + if (_modelMeshRenderItemsMap.empty() && statusGetters.size()) { renderPayload->addStatusGetters(statusGetters); } pendingChanges.resetItem(item, renderPayload); hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent(); verticesCount += renderItem.get()->getVerticesCount(); - _modelMeshRenderItems.insert(item, renderPayload); + _modelMeshRenderItemsMap.insert(item, renderPayload); _modelMeshRenderItemIDs.emplace_back(item); } - somethingAdded = !_modelMeshRenderItems.empty(); + somethingAdded = !_modelMeshRenderItemsMap.empty(); _renderInfoVertexCount = verticesCount; - _renderInfoDrawCalls = _modelMeshRenderItems.count(); + _renderInfoDrawCalls = _modelMeshRenderItemsMap.count(); _renderInfoHasTransparent = hasTransparent; } } @@ -623,18 +623,18 @@ bool Model::addToScene(std::shared_ptr scene, } void Model::removeFromScene(std::shared_ptr scene, render::PendingChanges& pendingChanges) { - foreach (auto item, _modelMeshRenderItems.keys()) { + foreach (auto item, _modelMeshRenderItemsMap.keys()) { pendingChanges.removeItem(item); } _modelMeshRenderItemIDs.clear(); + _modelMeshRenderItemsMap.clear(); _modelMeshRenderItems.clear(); - _modelMeshRenderItemsSet.clear(); - foreach (auto item, _collisionRenderItems.keys()) { + foreach(auto item, _collisionRenderItemsMap.keys()) { pendingChanges.removeItem(item); } _collisionRenderItems.clear(); - _collisionRenderItemsSet.clear(); + _collisionRenderItems.clear(); _addedToScene = false; _renderInfoVertexCount = 0; @@ -1052,8 +1052,8 @@ void Model::updateRig(float deltaTime, glm::mat4 parentTransform) { } void Model::computeMeshPartLocalBounds() { - for (auto& part : _modelMeshRenderItemsSet) { - assert(part->_meshIndex < _modelMeshRenderItemsSet.size()); + for (auto& part : _modelMeshRenderItems) { + assert(part->_meshIndex < _modelMeshRenderItems.size()); const Model::MeshState& state = _meshStates.at(part->_meshIndex); part->computeAdjustedLocalBound(state.clusterMatrices); } @@ -1167,7 +1167,7 @@ AABox Model::getRenderableMeshBound() const { } else { // Build a bound using the last known bound from all the renderItems. AABox totalBound; - for (auto& renderItem : _modelMeshRenderItemsSet) { + for (auto& renderItem : _modelMeshRenderItems) { totalBound += renderItem->getBound(); } return totalBound; @@ -1180,11 +1180,11 @@ const render::ItemIDs& Model::fetchRenderItemIDs() const { void Model::createRenderItemSet() { if (_collisionGeometry) { - if (_collisionRenderItemsSet.empty()) { + if (_collisionRenderItems.empty()) { createCollisionRenderItemSet(); } } else { - if (_modelMeshRenderItemsSet.empty()) { + if (_modelMeshRenderItems.empty()) { createVisibleRenderItemSet(); } } @@ -1201,9 +1201,9 @@ void Model::createVisibleRenderItemSet() { } // We should not have any existing renderItems if we enter this section of code - Q_ASSERT(_modelMeshRenderItemsSet.isEmpty()); + Q_ASSERT(_modelMeshRenderItems.isEmpty()); - _modelMeshRenderItemsSet.clear(); + _modelMeshRenderItems.clear(); Transform transform; transform.setTranslation(_translation); @@ -1225,7 +1225,7 @@ void Model::createVisibleRenderItemSet() { // Create the render payloads int numParts = (int)mesh->getNumParts(); for (int partIndex = 0; partIndex < numParts; partIndex++) { - _modelMeshRenderItemsSet << std::make_shared(this, i, partIndex, shapeID, transform, offset); + _modelMeshRenderItems << std::make_shared(this, i, partIndex, shapeID, transform, offset); shapeID++; } } @@ -1241,7 +1241,7 @@ void Model::createCollisionRenderItemSet() { const auto& meshes = _collisionGeometry->getMeshes(); // We should not have any existing renderItems if we enter this section of code - Q_ASSERT(_collisionRenderItemsSet.isEmpty()); + Q_ASSERT(_collisionRenderItems.isEmpty()); Transform identity; identity.setIdentity(); @@ -1262,7 +1262,7 @@ void Model::createCollisionRenderItemSet() { model::MaterialPointer& material = _collisionMaterials[partIndex % NUM_COLLISION_HULL_COLORS]; auto payload = std::make_shared(mesh, partIndex, material); payload->updateTransform(identity, offset); - _collisionRenderItemsSet << payload; + _collisionRenderItems << payload; } } } @@ -1283,28 +1283,28 @@ bool Model::initWhenReady(render::ScenePointer scene) { bool addedPendingChanges = false; if (_collisionGeometry) { - foreach (auto renderItem, _collisionRenderItemsSet) { + foreach (auto renderItem, _collisionRenderItems) { auto item = scene->allocateID(); auto renderPayload = std::make_shared(renderItem); - _collisionRenderItems.insert(item, renderPayload); + _collisionRenderItemsMap.insert(item, renderPayload); pendingChanges.resetItem(item, renderPayload); } addedPendingChanges = !_collisionRenderItems.empty(); } else { bool hasTransparent = false; size_t verticesCount = 0; - foreach (auto renderItem, _modelMeshRenderItemsSet) { + foreach (auto renderItem, _modelMeshRenderItems) { auto item = scene->allocateID(); auto renderPayload = std::make_shared(renderItem); hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent(); verticesCount += renderItem.get()->getVerticesCount(); - _modelMeshRenderItems.insert(item, renderPayload); + _modelMeshRenderItemsMap.insert(item, renderPayload); pendingChanges.resetItem(item, renderPayload); } - addedPendingChanges = !_modelMeshRenderItems.empty(); + addedPendingChanges = !_modelMeshRenderItemsMap.empty(); _renderInfoVertexCount = verticesCount; - _renderInfoDrawCalls = _modelMeshRenderItems.count(); + _renderInfoDrawCalls = _modelMeshRenderItemsMap.count(); _renderInfoHasTransparent = hasTransparent; } _addedToScene = addedPendingChanges; diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 41821736f7..bb283cce1f 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -248,7 +248,7 @@ public: const MeshState& getMeshState(int index) { return _meshStates.at(index); } uint32_t getGeometryCounter() const { return _deleteGeometryCounter; } - const QMap& getRenderItems() const { return _modelMeshRenderItems; } + const QMap& getRenderItems() const { return _modelMeshRenderItemsMap; } void renderDebugMeshBoxes(gpu::Batch& batch); @@ -373,11 +373,11 @@ protected: static AbstractViewStateInterface* _viewState; - QSet> _collisionRenderItemsSet; - QMap _collisionRenderItems; + QVector> _collisionRenderItems; + QMap _collisionRenderItemsMap; - QSet> _modelMeshRenderItemsSet; - QMap _modelMeshRenderItems; + QVector> _modelMeshRenderItems; + QMap _modelMeshRenderItemsMap; render::ItemIDs _modelMeshRenderItemIDs; From c7b949262019704eda4763b70adff390d8712f2e Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 19:14:20 +0000 Subject: [PATCH 33/42] revert removing rightUnitVec ..... --- scripts/developer/utilities/render/photobooth/photobooth.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/developer/utilities/render/photobooth/photobooth.js b/scripts/developer/utilities/render/photobooth/photobooth.js index e822955563..b78986be1a 100644 --- a/scripts/developer/utilities/render/photobooth/photobooth.js +++ b/scripts/developer/utilities/render/photobooth/photobooth.js @@ -12,6 +12,8 @@ var forwardUnitVector = Vec3.normalize(Quat.getForward(MyAvatar.orientation)); var forwardOffset = Vec3.multiply(forwardUnitVector,forwardFactor); var rightFactor = 3; + // TODO: rightUnitVec is unused and spawnLocation declaration is incorrect + var rightUnitVec = Vec3.normalize(Quat.getRight(MyAvatar.orientation)); var spawnLocation = Vec3.sum(Vec3.sum(MyAvatar.position,forwardOffset),rightFactor); if (success) { this.pastedEntityIDs = Clipboard.pasteEntities(spawnLocation); From c71e57753be6ff9daf31e8404b84f53b7978206c Mon Sep 17 00:00:00 2001 From: trent Date: Wed, 22 Mar 2017 15:23:40 -0400 Subject: [PATCH 34/42] Removing changes (albeit benign ones) from another PR. --- libraries/fbx/src/OBJReader.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/fbx/src/OBJReader.cpp b/libraries/fbx/src/OBJReader.cpp index c1bb72dff8..0cb932b375 100644 --- a/libraries/fbx/src/OBJReader.cpp +++ b/libraries/fbx/src/OBJReader.cpp @@ -267,7 +267,7 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) { } if (token == "map_Kd") { currentMaterial.diffuseTextureFilename = filename; - } else if( token == "map_Ks" ) { + } else { currentMaterial.specularTextureFilename = filename; } } @@ -612,9 +612,6 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping, if (!objMaterial.diffuseTextureFilename.isEmpty()) { fbxMaterial.albedoTexture.filename = objMaterial.diffuseTextureFilename; } - if (!objMaterial.specularTextureFilename.isEmpty()) { - fbxMaterial.specularTexture.filename = objMaterial.specularTextureFilename; - } modelMaterial->setEmissive(fbxMaterial.emissiveColor); modelMaterial->setAlbedo(fbxMaterial.diffuseColor); From 09cbace975b5eb4e605758b69fca4518af11d3ab Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 22 Mar 2017 21:54:21 +0000 Subject: [PATCH 35/42] remove unused getBodyForwardDirection --- interface/src/avatar/Avatar.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index ef45eeb1b5..d4bd03367e 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -236,9 +236,6 @@ protected: glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getBodyUpDirection() const { return getOrientation() * IDENTITY_UP; } - // redundant, calls getBodyForwardDirection which better describes the returned vector as a direction - glm::vec3 getBodyFrontDirection() const { return getBodyForwardDirection(); } - glm::vec3 getBodyForwardDirection() const { return getOrientation() * IDENTITY_FORWARD; } glm::quat computeRotationFromBodyToWorldUp(float proportion = 1.0f) const; void measureMotionDerivatives(float deltaTime); From 944255a37b4bf8e3c8f16500231f876279e64b16 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 22 Mar 2017 22:44:05 -0700 Subject: [PATCH 36/42] Fix crash in render-perf-test --- libraries/entities-renderer/src/EntityTreeRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 8c4498edc6..fb6054a514 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -996,7 +996,7 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, const } bool shouldLoad = entity->shouldPreloadScript() && _entitiesScriptEngine; QString scriptUrl = entity->getScript(); - if ((unloadFirst && shouldLoad) || scriptUrl.isEmpty()) { + if (shouldLoad && (unloadFirst || scriptUrl.isEmpty())) { _entitiesScriptEngine->unloadEntityScript(entityID); entity->scriptHasUnloaded(); } From b53cb5934bf6ded9999cfec9b2eef028fa7343bc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Mar 2017 23:35:29 -0700 Subject: [PATCH 37/42] make sure the AC agent has an AudioScriptingInterface --- assignment-client/src/Agent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index a0c80453e0..a5063b09b6 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -62,6 +62,7 @@ Agent::Agent(ReceivedMessage& message) : DependencyManager::set(); DependencyManager::set(); + DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); From 56c5f06365d1ad043293af1d06cd93d3a85e2805 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 23 Mar 2017 16:29:08 -0700 Subject: [PATCH 38/42] Fix Oculus Touch + Remote not being detected after initial launch --- .../oculus/src/OculusControllerManager.cpp | 23 ++++++++++++++----- plugins/oculus/src/OculusControllerManager.h | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/plugins/oculus/src/OculusControllerManager.cpp b/plugins/oculus/src/OculusControllerManager.cpp index ce59eafd50..87c52de3e7 100644 --- a/plugins/oculus/src/OculusControllerManager.cpp +++ b/plugins/oculus/src/OculusControllerManager.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include "OculusHelpers.h" Q_DECLARE_LOGGING_CATEGORY(oculus) @@ -42,26 +44,33 @@ bool OculusControllerManager::activate() { } Q_ASSERT(_session); - // register with UserInputMapper - auto userInputMapper = DependencyManager::get(); + checkForConnectedDevices(); + + return true; +} + +void OculusControllerManager::checkForConnectedDevices() { + if (_touch && _remote) { + return; + } unsigned int controllerConnected = ovr_GetConnectedControllerTypes(_session); - if ((controllerConnected & ovrControllerType_Remote) == ovrControllerType_Remote) { + if (!_remote && (controllerConnected & ovrControllerType_Remote) == ovrControllerType_Remote) { if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Remote, &_inputState))) { + auto userInputMapper = DependencyManager::get(); _remote = std::make_shared(*this); userInputMapper->registerDevice(_remote); } } - if ((controllerConnected & ovrControllerType_Touch) != 0) { + if (!_touch && (controllerConnected & ovrControllerType_Touch) != 0) { if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Touch, &_inputState))) { + auto userInputMapper = DependencyManager::get(); _touch = std::make_shared(*this); userInputMapper->registerDevice(_touch); } } - - return true; } void OculusControllerManager::deactivate() { @@ -85,6 +94,8 @@ void OculusControllerManager::deactivate() { void OculusControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { PerformanceTimer perfTimer("OculusControllerManager::TouchDevice::update"); + checkForConnectedDevices(); + if (_touch) { if (OVR_SUCCESS(ovr_GetInputState(_session, ovrControllerType_Touch, &_inputState))) { _touch->update(deltaTime, inputCalibrationData); diff --git a/plugins/oculus/src/OculusControllerManager.h b/plugins/oculus/src/OculusControllerManager.h index 98e0e3d650..23ef52ab64 100644 --- a/plugins/oculus/src/OculusControllerManager.h +++ b/plugins/oculus/src/OculusControllerManager.h @@ -91,6 +91,8 @@ private: friend class OculusControllerManager; }; + void checkForConnectedDevices(); + ovrSession _session { nullptr }; ovrInputState _inputState {}; RemoteDevice::Pointer _remote; From 4f8d9b190b4a8f2d04409c4b953e46cf5929dda0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 23 Mar 2017 17:49:55 -0700 Subject: [PATCH 39/42] Show green box when model entity has bad url --- .../src/RenderableModelEntityItem.cpp | 211 +++++++++--------- .../src/RenderableModelEntityItem.h | 2 +- 2 files changed, 109 insertions(+), 104 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 935dd4e796..613bd5d543 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -371,109 +371,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) { _model->updateRenderItems(); } - if (hasModel()) { - // Prepare the current frame - { - if (!_model || _needsModelReload) { - // TODO: this getModel() appears to be about 3% of model render time. We should optimize - PerformanceTimer perfTimer("getModel"); - auto renderer = qSharedPointerCast(args->_renderer); - getModel(renderer); - - // Remap textures immediately after loading to avoid flicker - remapTextures(); - } - - if (_model) { - if (hasRenderAnimation()) { - if (!jointsMapped()) { - QStringList modelJointNames = _model->getJointNames(); - mapJoints(modelJointNames); - } - } - - _jointDataLock.withWriteLock([&] { - getAnimationFrame(); - - // relay any inbound joint changes from scripts/animation/network to the model/rig - for (int index = 0; index < _localJointRotations.size(); index++) { - if (_localJointRotationsDirty[index]) { - glm::quat rotation = _localJointRotations[index]; - _model->setJointRotation(index, true, rotation, 1.0f); - _localJointRotationsDirty[index] = false; - } - } - for (int index = 0; index < _localJointTranslations.size(); index++) { - if (_localJointTranslationsDirty[index]) { - glm::vec3 translation = _localJointTranslations[index]; - _model->setJointTranslation(index, true, translation, 1.0f); - _localJointTranslationsDirty[index] = false; - } - } - }); - updateModelBounds(); - } - } - - // Enqueue updates for the next frame - if (_model) { - -#ifdef WANT_EXTRA_RENDER_DEBUGGING - // debugging... - gpu::Batch& batch = *args->_batch; - _model->renderDebugMeshBoxes(batch); -#endif - - render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene(); - - // FIXME: this seems like it could be optimized if we tracked our last known visible state in - // the renderable item. As it stands now the model checks it's visible/invisible state - // so most of the time we don't do anything in this function. - _model->setVisibleInScene(getVisible(), scene); - - // Remap textures for the next frame to avoid flicker - remapTextures(); - - // update whether the model should be showing collision mesh (this may flag for fixupInScene) - bool showingCollisionGeometry = (bool)(args->_debugFlags & (int)RenderArgs::RENDER_DEBUG_HULLS); - if (showingCollisionGeometry != _showCollisionGeometry) { - ShapeType type = getShapeType(); - _showCollisionGeometry = showingCollisionGeometry; - if (_showCollisionGeometry && type != SHAPE_TYPE_STATIC_MESH && type != SHAPE_TYPE_NONE) { - // NOTE: it is OK if _collisionMeshKey is nullptr - model::MeshPointer mesh = collisionMeshCache.getMesh(_collisionMeshKey); - // NOTE: the model will render the collisionGeometry if it has one - _model->setCollisionMesh(mesh); - } else { - // release mesh - if (_collisionMeshKey) { - collisionMeshCache.releaseMesh(_collisionMeshKey); - } - // clear model's collision geometry - model::MeshPointer mesh = nullptr; - _model->setCollisionMesh(mesh); - } - } - - if (_model->needsFixupInScene()) { - render::PendingChanges pendingChanges; - - _model->removeFromScene(scene, pendingChanges); - - render::Item::Status::Getters statusGetters; - makeEntityItemStatusGetters(getThisPointer(), statusGetters); - _model->addToScene(scene, pendingChanges, statusGetters); - - scene->enqueuePendingChanges(pendingChanges); - } - - auto& currentURL = getParsedModelURL(); - if (currentURL != _model->getURL()) { - // Defer setting the url to the render thread - getModel(_myRenderer); - } - } - } else { + if (!hasModel() || (_model && _model->didVisualGeometryRequestFail())) { static glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f); gpu::Batch& batch = *args->_batch; bool success; @@ -482,6 +380,109 @@ void RenderableModelEntityItem::render(RenderArgs* args) { batch.setModelTransform(shapeTransform); // we want to include the scale as well DependencyManager::get()->renderWireCubeInstance(batch, greenColor); } + return; + } + + // Prepare the current frame + { + if (!_model || _needsModelReload) { + // TODO: this getModel() appears to be about 3% of model render time. We should optimize + PerformanceTimer perfTimer("getModel"); + auto renderer = qSharedPointerCast(args->_renderer); + getModel(renderer); + + // Remap textures immediately after loading to avoid flicker + remapTextures(); + } + + if (_model) { + if (hasRenderAnimation()) { + if (!jointsMapped()) { + QStringList modelJointNames = _model->getJointNames(); + mapJoints(modelJointNames); + } + } + + _jointDataLock.withWriteLock([&] { + getAnimationFrame(); + + // relay any inbound joint changes from scripts/animation/network to the model/rig + for (int index = 0; index < _localJointRotations.size(); index++) { + if (_localJointRotationsDirty[index]) { + glm::quat rotation = _localJointRotations[index]; + _model->setJointRotation(index, true, rotation, 1.0f); + _localJointRotationsDirty[index] = false; + } + } + for (int index = 0; index < _localJointTranslations.size(); index++) { + if (_localJointTranslationsDirty[index]) { + glm::vec3 translation = _localJointTranslations[index]; + _model->setJointTranslation(index, true, translation, 1.0f); + _localJointTranslationsDirty[index] = false; + } + } + }); + updateModelBounds(); + } + } + + // Enqueue updates for the next frame + if (_model) { + +#ifdef WANT_EXTRA_RENDER_DEBUGGING + // debugging... + gpu::Batch& batch = *args->_batch; + _model->renderDebugMeshBoxes(batch); +#endif + + render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene(); + + // FIXME: this seems like it could be optimized if we tracked our last known visible state in + // the renderable item. As it stands now the model checks it's visible/invisible state + // so most of the time we don't do anything in this function. + _model->setVisibleInScene(getVisible(), scene); + + // Remap textures for the next frame to avoid flicker + remapTextures(); + + // update whether the model should be showing collision mesh (this may flag for fixupInScene) + bool showingCollisionGeometry = (bool)(args->_debugFlags & (int)RenderArgs::RENDER_DEBUG_HULLS); + if (showingCollisionGeometry != _showCollisionGeometry) { + ShapeType type = getShapeType(); + _showCollisionGeometry = showingCollisionGeometry; + if (_showCollisionGeometry && type != SHAPE_TYPE_STATIC_MESH && type != SHAPE_TYPE_NONE) { + // NOTE: it is OK if _collisionMeshKey is nullptr + model::MeshPointer mesh = collisionMeshCache.getMesh(_collisionMeshKey); + // NOTE: the model will render the collisionGeometry if it has one + _model->setCollisionMesh(mesh); + } else { + // release mesh + if (_collisionMeshKey) { + collisionMeshCache.releaseMesh(_collisionMeshKey); + } + // clear model's collision geometry + model::MeshPointer mesh = nullptr; + _model->setCollisionMesh(mesh); + } + } + + if (_model->needsFixupInScene()) { + render::PendingChanges pendingChanges; + + _model->removeFromScene(scene, pendingChanges); + + render::Item::Status::Getters statusGetters; + makeEntityItemStatusGetters(getThisPointer(), statusGetters); + _model->addToScene(scene, pendingChanges, statusGetters); + + scene->enqueuePendingChanges(pendingChanges); + } + + auto& currentURL = getParsedModelURL(); + if (currentURL != _model->getURL()) { + // Defer setting the url to the render thread + getModel(_myRenderer); + } } } @@ -587,6 +588,10 @@ EntityItemProperties RenderableModelEntityItem::getProperties(EntityPropertyFlag return properties; } +bool RenderableModelEntityItem::supportsDetailedRayIntersection() const { + return _model && _model->isLoaded(); +} + bool RenderableModelEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElementPointer& element, float& distance, BoxFace& face, glm::vec3& surfaceNormal, void** intersectedObject, bool precisionPicking) const { diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.h b/libraries/entities-renderer/src/RenderableModelEntityItem.h index bac2118326..057ca36e13 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.h +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.h @@ -46,7 +46,7 @@ public: void updateModelBounds(); virtual void render(RenderArgs* args) override; - virtual bool supportsDetailedRayIntersection() const override { return true; } + virtual bool supportsDetailedRayIntersection() const override; virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElementPointer& element, float& distance, BoxFace& face, glm::vec3& surfaceNormal, From e1e51614d9549f000b9db43b78445118c4d8d527 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 24 Mar 2017 11:16:54 -0700 Subject: [PATCH 40/42] don't hang loop if entity isDead --- libraries/physics/src/PhysicalEntitySimulation.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index bd76b2d70f..6f5b474810 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -208,6 +208,7 @@ void PhysicalEntitySimulation::getObjectsToAddToPhysics(VectorOfMotionStates& re assert(!entity->getPhysicsInfo()); if (entity->isDead()) { prepareEntityForDelete(entity); + entityItr = _entitiesToAddToPhysics.erase(entityItr); } else if (!entity->shouldBePhysical()) { // this entity should no longer be on the internal _entitiesToAddToPhysics entityItr = _entitiesToAddToPhysics.erase(entityItr); From aaa78d108b380726fe374a782d30f7ffdb38e284 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 24 Mar 2017 11:17:24 -0700 Subject: [PATCH 41/42] if a model has too many meshes, give up. --- .../entities-renderer/src/RenderableModelEntityItem.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 935dd4e796..f865e39b21 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -807,6 +807,13 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { auto& meshes = _model->getGeometry()->getMeshes(); int32_t numMeshes = (int32_t)(meshes.size()); + const int MAX_ALLOWED_MESH_COUNT = 500; + if (numMeshes > MAX_ALLOWED_MESH_COUNT) { + // too many will cause the deadlock timer to throw... + shapeInfo.setParams(SHAPE_TYPE_BOX, 0.5f * dimensions); + return; + } + ShapeInfo::PointCollection& pointCollection = shapeInfo.getPointCollection(); pointCollection.clear(); if (type == SHAPE_TYPE_SIMPLE_COMPOUND) { From fa606446a794bdfec7b7ce430df8a62f56ad681b Mon Sep 17 00:00:00 2001 From: Lexx Date: Fri, 24 Mar 2017 18:27:38 +0000 Subject: [PATCH 42/42] remove cache buster --- scripts/system/audioMuteOverlay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/audioMuteOverlay.js b/scripts/system/audioMuteOverlay.js index 473e06b556..cf07402d64 100644 --- a/scripts/system/audioMuteOverlay.js +++ b/scripts/system/audioMuteOverlay.js @@ -15,7 +15,7 @@ // (function() { // BEGIN LOCAL_SCOPE - var utilsPath = Script.resolvePath('../developer/libraries/utils.js?v='+ Date.now()); + var utilsPath = Script.resolvePath('../developer/libraries/utils.js'); Script.include(utilsPath); var TWEEN_SPEED = 0.025;