From 5fc7965042a8b7aa4a3f2e61e134431eb3362bc4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Sep 2015 13:04:58 -0700 Subject: [PATCH 01/10] Throw held objects with velocity from fingertip --- examples/controllers/handControllerGrab.js | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index a13f1de86d..975c1d2e0b 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -41,10 +41,10 @@ var LINE_LENGTH = 500; // var GRAB_RADIUS = 0.3; // if the ray misses but an object is this close, it will still be selected -var NEAR_GRABBING_ACTION_TIMEFRAME = 0.05; // how quickly objects move to their new position +var NEAR_GRABBING_ACTION_TIMEFRAME = 0.01; // how quickly objects move to their new position var NEAR_GRABBING_VELOCITY_SMOOTH_RATIO = 1.0; // adjust time-averaging of held object's velocity. 1.0 to disable. var NEAR_PICK_MAX_DISTANCE = 0.6; // max length of pick-ray for close grabbing to be selected -var RELEASE_VELOCITY_MULTIPLIER = 1.5; // affects throwing things +var RELEASE_VELOCITY_MULTIPLIER = 1.0; // affects throwing things ///////////////////////////////////////////////////////////////// // @@ -86,7 +86,7 @@ function MyController(hand, triggerAction) { this.triggerAction = triggerAction; this.palm = 2 * hand; - // this.tip = 2 * hand + 1; // unused, but I'm leaving this here for fear it will be needed + this.tip = 2 * hand + 1; this.actionID = null; // action this script created... this.grabbedEntity = null; // on this entity. @@ -343,7 +343,8 @@ function MyController(hand, triggerAction) { } - this.currentHandControllerPosition = Controller.getSpatialControlPosition(this.palm); + this.currentHandControllerTipPosition = Controller.getSpatialControlPosition(this.tip); + this.currentObjectTime = Date.now(); }; @@ -353,15 +354,21 @@ function MyController(hand, triggerAction) { return; } - // keep track of the measured velocity of the held object - var handControllerPosition = Controller.getSpatialControlPosition(this.palm); + // Keep track of the fingertip velocity to impart when we release the object + // Note that the idea of using a constant 'tip' velocity regardless of the + // object's actual held offset is an idea intended to make it easier to throw things: + // Because we might catch something or transfer it between hands without a good idea + // of it's actual offset, let's try imparting a velocity which is at a fixed radius + // from the palm. + + var handControllerPosition = Controller.getSpatialControlPosition(this.tip); var now = Date.now(); - var deltaPosition = Vec3.subtract(handControllerPosition, this.currentHandControllerPosition); // meters + var deltaPosition = Vec3.subtract(handControllerPosition, this.currentHandControllerTipPosition); // meters var deltaTime = (now - this.currentObjectTime) / MSEC_PER_SEC; // convert to seconds this.computeReleaseVelocity(deltaPosition, deltaTime, true); - this.currentHandControllerPosition = handControllerPosition; + this.currentHandControllerTipPosition = handControllerPosition; this.currentObjectTime = now; Entities.callEntityMethod(this.grabbedEntity, "continueNearGrab"); }; From 5c7cf76035271ab53cf590d353204a1cb6f4848f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Sep 2015 16:13:35 -0700 Subject: [PATCH 02/10] Distance grab works with walking and turning --- examples/controllers/handControllerGrab.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 975c1d2e0b..011a9d434b 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -256,6 +256,9 @@ function MyController(hand, triggerAction) { Entities.callEntityMethod(this.grabbedEntity, "startDistantGrab"); } + this.currentAvatarPosition = MyAvatar.position; + this.currentAvatarOrientation = MyAvatar.orientation; + }; this.continueDistanceHolding = function() { @@ -274,11 +277,44 @@ function MyController(hand, triggerAction) { // the action was set up on a previous call. update the targets. var radius = Math.max(Vec3.distance(this.currentObjectPosition, handControllerPosition) * DISTANCE_HOLDING_RADIUS_FACTOR, DISTANCE_HOLDING_RADIUS_FACTOR); + // how far did avatar move this timestep? + var currentPosition = MyAvatar.position; + var avatarDeltaPosition = Vec3.subtract(currentPosition, this.currentAvatarPosition); + this.currentAvatarPosition = currentPosition; + + // How far did the avatar turn this timestep? + // Note: The following code is too long because we need a Quat.quatBetween() function + // that returns the minimum quaternion between two quaternions. + var currentOrientation = MyAvatar.orientation; + if (Quat.dot(currentOrientation, this.currentAvatarOrientation) < 0.0) { + var negativeCurrentOrientation = { x: -currentOrientation.x, + y: -currentOrientation.y, + z: -currentOrientation.z, + w: -currentOrientation.w }; + var avatarDeltaOrientation = Quat.multiply(negativeCurrentOrientation, Quat.inverse(this.currentAvatarOrientation)); + } else { + var avatarDeltaOrientation = Quat.multiply(currentOrientation, Quat.inverse(this.currentAvatarOrientation)); + } + var handToAvatar = Vec3.subtract(handControllerPosition, this.currentAvatarPosition); + var objectToAvatar = Vec3.subtract(this.currentObjectPosition, this.currentAvatarPosition); + var handMovementFromTurning = Vec3.subtract(Quat.multiply(avatarDeltaOrientation, handToAvatar), handToAvatar); + var objectMovementFromTurning = Vec3.subtract(Quat.multiply(avatarDeltaOrientation, objectToAvatar), objectToAvatar); + this.currentAvatarOrientation = currentOrientation; + + // how far did hand move this timestep? var handMoved = Vec3.subtract(handControllerPosition, this.handPreviousPosition); this.handPreviousPosition = handControllerPosition; + + // magnify the hand movement but not the change from avatar movement & rotation + handMoved = Vec3.subtract(handMoved, avatarDeltaPosition); + handMoved = Vec3.subtract(handMoved, handMovementFromTurning); var superHandMoved = Vec3.multiply(handMoved, radius); + // Move the object by the magnified amount and then by amount from avatar movement & rotation var newObjectPosition = Vec3.sum(this.currentObjectPosition, superHandMoved); + newObjectPosition = Vec3.sum(newObjectPosition, avatarDeltaPosition); + newObjectPosition = Vec3.sum(newObjectPosition, objectMovementFromTurning); + var deltaPosition = Vec3.subtract(newObjectPosition, this.currentObjectPosition); // meters var now = Date.now(); var deltaTime = (now - this.currentObjectTime) / MSEC_PER_SEC; // convert to seconds From 7b1c04512a34258c7c8ffccb80c9f4a416424160 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 28 Sep 2015 16:20:27 -0700 Subject: [PATCH 03/10] Adding support for accessing IPD in scripts --- examples/example/hmd/colorCube.fs | 10 ++++ examples/example/hmd/colorCube.js | 52 +++++++++++++++++++ .../src/scripting/HMDScriptingInterface.cpp | 6 ++- .../src/scripting/HMDScriptingInterface.h | 2 + .../src/display-plugins/DisplayPlugin.h | 4 ++ .../oculus/OculusBaseDisplayPlugin.cpp | 8 +++ .../oculus/OculusBaseDisplayPlugin.h | 1 + libraries/render-utils/src/simple.slf | 1 + libraries/render-utils/src/simple.slv | 2 + 9 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 examples/example/hmd/colorCube.fs create mode 100644 examples/example/hmd/colorCube.js diff --git a/examples/example/hmd/colorCube.fs b/examples/example/hmd/colorCube.fs new file mode 100644 index 0000000000..2687b70807 --- /dev/null +++ b/examples/example/hmd/colorCube.fs @@ -0,0 +1,10 @@ + +float getProceduralColors(inout vec3 diffuse, inout vec3 specular, inout float shininess) { + + specular = _modelNormal.rgb; + if (any(lessThan(specular, vec3(0.0)))) { + specular = vec3(1.0) + specular; + } + diffuse = vec3(1.0, 1.0, 1.0); + return 1.0; +} \ No newline at end of file diff --git a/examples/example/hmd/colorCube.js b/examples/example/hmd/colorCube.js new file mode 100644 index 0000000000..b36fa6362b --- /dev/null +++ b/examples/example/hmd/colorCube.js @@ -0,0 +1,52 @@ +function avatarRelativePosition(position) { + return Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, position)); +} + +ColorCube = function() {}; +ColorCube.prototype.NAME = "ColorCube"; +ColorCube.prototype.POSITION = { x: 0, y: 0.5, z: -0.5 }; +ColorCube.prototype.USER_DATA = { ProceduralEntity: { + version: 2, shaderUrl: Script.resolvePath("colorCube.fs"), +} }; + +// Clear any previous entities within 50 meters +ColorCube.prototype.clear = function() { + var ids = Entities.findEntities(MyAvatar.position, 50); + var that = this; + ids.forEach(function(id) { + var properties = Entities.getEntityProperties(id); + if (properties.name == that.NAME) { + Entities.deleteEntity(id); + } + }, this); +} + +ColorCube.prototype.create = function() { + var that = this; + var size = HMD.ipd; + var id = Entities.addEntity({ + type: "Box", + position: avatarRelativePosition(that.POSITION), + name: that.NAME, + color: that.COLOR, + ignoreCollisions: true, + collisionsWillMove: false, + dimensions: { x: size, y: size, z: size }, + lifetime: 3600, + userData: JSON.stringify(that.USER_DATA) + }); +} + +var ColorCube = new ColorCube(); +ColorCube.clear(); +ColorCube.create(); + + +var ids = Entities.findEntities(MyAvatar.position, 50); +var that = this; +ids.forEach(function(id) { + var properties = Entities.getEntityProperties(id); + if (properties.name == that.NAME) { + Entities.deleteEntity(id); + } +}, this); diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index f65d638ccc..68ac511eaf 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -10,7 +10,7 @@ // #include "HMDScriptingInterface.h" - +#include "display-plugins/DisplayPlugin.h" #include HMDScriptingInterface& HMDScriptingInterface::getInstance() { @@ -53,3 +53,7 @@ QScriptValue HMDScriptingInterface::getHUDLookAtPosition3D(QScriptContext* conte } return QScriptValue::NullValue; } + +float HMDScriptingInterface::getIPD() const { + return Application::getInstance()->getActiveDisplayPlugin()->getIPD(); +} diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index 4bcced1fa2..82b444abaa 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -20,6 +20,7 @@ class HMDScriptingInterface : public QObject { Q_OBJECT Q_PROPERTY(bool magnifier READ getMagnifier) Q_PROPERTY(bool active READ isHMDMode) + Q_PROPERTY(float ipd READ getIPD) public: static HMDScriptingInterface& getInstance(); @@ -33,6 +34,7 @@ private: HMDScriptingInterface() {}; bool getMagnifier() const { return Application::getInstance()->getApplicationCompositor().hasMagnifier(); }; bool isHMDMode() const { return Application::getInstance()->isHMDMode(); } + float getIPD() const; bool getHUDLookAtPosition3D(glm::vec3& result) const; diff --git a/libraries/display-plugins/src/display-plugins/DisplayPlugin.h b/libraries/display-plugins/src/display-plugins/DisplayPlugin.h index 86cfabe724..2aaf4ddbc5 100644 --- a/libraries/display-plugins/src/display-plugins/DisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/DisplayPlugin.h @@ -121,6 +121,10 @@ public: static const glm::mat4 pose; return pose; } + virtual float getIPD() const { + return 0.0f; + } + virtual void abandonCalibration() {} virtual void resetSensors() {} virtual float devicePixelRatio() { return 1.0; } diff --git a/libraries/display-plugins/src/display-plugins/oculus/OculusBaseDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/oculus/OculusBaseDisplayPlugin.cpp index fa9d09e392..f2a7b06510 100644 --- a/libraries/display-plugins/src/display-plugins/oculus/OculusBaseDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/oculus/OculusBaseDisplayPlugin.cpp @@ -149,3 +149,11 @@ void OculusBaseDisplayPlugin::deactivate() { void OculusBaseDisplayPlugin::display(GLuint finalTexture, const glm::uvec2& sceneSize) { ++_frameIndex; } + +float OculusBaseDisplayPlugin::getIPD() const { + float result = 0.0f; +#if (OVR_MAJOR_VERSION >= 6) + result = ovr_GetFloat(_hmd, OVR_KEY_IPD, OVR_DEFAULT_IPD); +#endif + return result; +} \ No newline at end of file diff --git a/libraries/display-plugins/src/display-plugins/oculus/OculusBaseDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/oculus/OculusBaseDisplayPlugin.h index 12023db1ae..d879085b8f 100644 --- a/libraries/display-plugins/src/display-plugins/oculus/OculusBaseDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/oculus/OculusBaseDisplayPlugin.h @@ -31,6 +31,7 @@ public: virtual void resetSensors() override final; virtual glm::mat4 getEyePose(Eye eye) const override final; virtual glm::mat4 getHeadPose() const override final; + virtual float getIPD() const override final; protected: virtual void preRender() override final; diff --git a/libraries/render-utils/src/simple.slf b/libraries/render-utils/src/simple.slf index 5901a72838..576acf9340 100644 --- a/libraries/render-utils/src/simple.slf +++ b/libraries/render-utils/src/simple.slf @@ -17,6 +17,7 @@ // the interpolated normal in vec3 _normal; +in vec3 _modelNormal; in vec3 _color; in vec2 _texCoord0; in vec4 _position; diff --git a/libraries/render-utils/src/simple.slv b/libraries/render-utils/src/simple.slv index e7fed4a6b4..823654ec27 100644 --- a/libraries/render-utils/src/simple.slv +++ b/libraries/render-utils/src/simple.slv @@ -22,6 +22,7 @@ uniform bool Instanced = false; // the interpolated normal out vec3 _normal; +out vec3 _modelNormal; out vec3 _color; out vec2 _texCoord0; out vec4 _position; @@ -30,6 +31,7 @@ void main(void) { _color = inColor.rgb; _texCoord0 = inTexCoord0.st; _position = inPosition; + _modelNormal = inNormal.xyz; // standard transform TransformCamera cam = getTransformCamera(); From 56a0456f705e634b6889f5b2967406aef784a8bf Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Sep 2015 16:49:55 -0700 Subject: [PATCH 04/10] Adjust force multiplier and timestep --- examples/controllers/handControllerGrab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 011a9d434b..024b40a885 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -41,10 +41,10 @@ var LINE_LENGTH = 500; // var GRAB_RADIUS = 0.3; // if the ray misses but an object is this close, it will still be selected -var NEAR_GRABBING_ACTION_TIMEFRAME = 0.01; // how quickly objects move to their new position +var NEAR_GRABBING_ACTION_TIMEFRAME = 0.05; // how quickly objects move to their new position var NEAR_GRABBING_VELOCITY_SMOOTH_RATIO = 1.0; // adjust time-averaging of held object's velocity. 1.0 to disable. var NEAR_PICK_MAX_DISTANCE = 0.6; // max length of pick-ray for close grabbing to be selected -var RELEASE_VELOCITY_MULTIPLIER = 1.0; // affects throwing things +var RELEASE_VELOCITY_MULTIPLIER = 1.5; // affects throwing things ///////////////////////////////////////////////////////////////// // From 35e4ec17ea2ccbe8a135b6cf9c15c01b33e20798 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 29 Sep 2015 10:35:38 -0700 Subject: [PATCH 05/10] add which hand for near grab of non physical objects --- examples/controllers/handControllerGrab.js | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 41f36c19d5..1b891f56b5 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -29,9 +29,21 @@ var TRIGGER_ON_VALUE = 0.2; var DISTANCE_HOLDING_RADIUS_FACTOR = 5; // multiplied by distance between hand and object var DISTANCE_HOLDING_ACTION_TIMEFRAME = 0.1; // how quickly objects move to their new position var DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR = 2.0; // object rotates this much more than hand did -var NO_INTERSECT_COLOR = { red: 10, green: 10, blue: 255}; // line color when pick misses -var INTERSECT_COLOR = { red: 250, green: 10, blue: 10}; // line color when pick hits -var LINE_ENTITY_DIMENSIONS = { x: 1000, y: 1000, z: 1000}; +var NO_INTERSECT_COLOR = { + red: 10, + green: 10, + blue: 255 +}; // line color when pick misses +var INTERSECT_COLOR = { + red: 250, + green: 10, + blue: 10 +}; // line color when pick hits +var LINE_ENTITY_DIMENSIONS = { + x: 1000, + y: 1000, + z: 1000 +}; var LINE_LENGTH = 500; @@ -54,7 +66,11 @@ var RELEASE_VELOCITY_MULTIPLIER = 1.5; // affects throwing things var RIGHT_HAND = 1; var LEFT_HAND = 0; -var ZERO_VEC = { x: 0, y: 0, z: 0}; +var ZERO_VEC = { + x: 0, + y: 0, + z: 0 +}; var NULL_ACTION_ID = "{00000000-0000-0000-000000000000}"; var MSEC_PER_SEC = 1000.0; @@ -391,6 +407,11 @@ function MyController(hand, triggerAction) { this.state = STATE_RELEASE; return; } + if (this.hand === RIGHT_HAND) { + Entities.callEntityMethod(this.grabbedEntity, "setRightHand"); + } else { + Entities.callEntityMethod(this.grabbedEntity, "setLeftHand"); + } Entities.callEntityMethod(this.grabbedEntity, "startNearGrabNonColliding"); this.state = STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING; }; @@ -546,4 +567,4 @@ function cleanup() { } Script.scriptEnding.connect(cleanup); -Script.update.connect(update); +Script.update.connect(update); \ No newline at end of file From 06194b6088cdf779fdb644dbb7ba803222827fc4 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 29 Sep 2015 12:51:01 -0700 Subject: [PATCH 06/10] fixed formatting --- examples/controllers/handControllerGrab.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 1b891f56b5..52b1e94e4b 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -29,21 +29,9 @@ var TRIGGER_ON_VALUE = 0.2; var DISTANCE_HOLDING_RADIUS_FACTOR = 5; // multiplied by distance between hand and object var DISTANCE_HOLDING_ACTION_TIMEFRAME = 0.1; // how quickly objects move to their new position var DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR = 2.0; // object rotates this much more than hand did -var NO_INTERSECT_COLOR = { - red: 10, - green: 10, - blue: 255 -}; // line color when pick misses -var INTERSECT_COLOR = { - red: 250, - green: 10, - blue: 10 -}; // line color when pick hits -var LINE_ENTITY_DIMENSIONS = { - x: 1000, - y: 1000, - z: 1000 -}; +var NO_INTERSECT_COLOR = { red: 10, green: 10, blue: 255 }; // line color when pick misses +var INTERSECT_COLOR = { red: 250, green: 10, blue: 10}; // line color when pick hits +var LINE_ENTITY_DIMENSIONS = { x: 1000, y: 1000, z: 1000}; var LINE_LENGTH = 500; From 96e3c722ed2f0df97012ba840fe3dd30bb026343 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Tue, 29 Sep 2015 13:04:59 -0700 Subject: [PATCH 07/10] Quiet once/second logging/updating of other people's default avatars. --- libraries/avatars/src/AvatarData.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 104b592c1a..3bd147d398 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -989,8 +989,11 @@ void AvatarData::setFaceModelURL(const QUrl& faceModelURL) { } void AvatarData::setSkeletonModelURL(const QUrl& skeletonModelURL) { - _skeletonModelURL = skeletonModelURL.isEmpty() ? AvatarData::defaultFullAvatarModelUrl() : skeletonModelURL; - + const QUrl& expanded = skeletonModelURL.isEmpty() ? AvatarData::defaultFullAvatarModelUrl() : skeletonModelURL; + if (expanded == _skeletonModelURL) { + return; + } + _skeletonModelURL = expanded; qCDebug(avatars) << "Changing skeleton model for avatar to" << _skeletonModelURL.toString(); updateJointMappings(); From 644687f3303bdff30dd9ead7e246836cc4513569 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 29 Sep 2015 14:04:03 -0700 Subject: [PATCH 08/10] releaseGrab event now triggered for non physical entities --- examples/controllers/handControllerGrab.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 52b1e94e4b..ea22d77bbc 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -29,7 +29,7 @@ var TRIGGER_ON_VALUE = 0.2; var DISTANCE_HOLDING_RADIUS_FACTOR = 5; // multiplied by distance between hand and object var DISTANCE_HOLDING_ACTION_TIMEFRAME = 0.1; // how quickly objects move to their new position var DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR = 2.0; // object rotates this much more than hand did -var NO_INTERSECT_COLOR = { red: 10, green: 10, blue: 255 }; // line color when pick misses +var NO_INTERSECT_COLOR = { red: 10, green: 10, blue: 255}; // line color when pick misses var INTERSECT_COLOR = { red: 250, green: 10, blue: 10}; // line color when pick hits var LINE_ENTITY_DIMENSIONS = { x: 1000, y: 1000, z: 1000}; var LINE_LENGTH = 500; @@ -502,8 +502,10 @@ function MyController(hand, triggerAction) { this.release = function() { this.lineOff(); - if (this.grabbedEntity !== null && this.actionID !== null) { - Entities.deleteAction(this.grabbedEntity, this.actionID); + if (this.grabbedEntity !== null) { + if(this.actionID !== null) { + Entities.deleteAction(this.grabbedEntity, this.actionID); + } Entities.callEntityMethod(this.grabbedEntity, "releaseGrab"); } From 9b13aac37db162a126b7ae1bcf51fa79d50959d6 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 29 Sep 2015 14:23:56 -0700 Subject: [PATCH 09/10] PR comments --- examples/example/hmd/colorCube.js | 16 +++------------- .../src/display-plugins/DisplayPlugin.h | 4 +--- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/examples/example/hmd/colorCube.js b/examples/example/hmd/colorCube.js index b36fa6362b..a138f38190 100644 --- a/examples/example/hmd/colorCube.js +++ b/examples/example/hmd/colorCube.js @@ -37,16 +37,6 @@ ColorCube.prototype.create = function() { }); } -var ColorCube = new ColorCube(); -ColorCube.clear(); -ColorCube.create(); - - -var ids = Entities.findEntities(MyAvatar.position, 50); -var that = this; -ids.forEach(function(id) { - var properties = Entities.getEntityProperties(id); - if (properties.name == that.NAME) { - Entities.deleteEntity(id); - } -}, this); +var colorCube = new ColorCube(); +colorCube.clear(); +colorCube.create(); diff --git a/libraries/display-plugins/src/display-plugins/DisplayPlugin.h b/libraries/display-plugins/src/display-plugins/DisplayPlugin.h index 2aaf4ddbc5..8b9d249bd4 100644 --- a/libraries/display-plugins/src/display-plugins/DisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/DisplayPlugin.h @@ -121,9 +121,7 @@ public: static const glm::mat4 pose; return pose; } - virtual float getIPD() const { - return 0.0f; - } + virtual float getIPD() const { return 0.0f; } virtual void abandonCalibration() {} virtual void resetSensors() {} From 006650f23bba7672bbeb81063948a76280c23291 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 Sep 2015 14:34:23 -0700 Subject: [PATCH 10/10] Fix for PR comments --- examples/controllers/handControllerGrab.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 024b40a885..4b1d6e9648 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -84,9 +84,11 @@ function MyController(hand, triggerAction) { this.getHandRotation = MyAvatar.getLeftPalmRotation; } + var SPATIAL_CONTROLLERS_PER_PALM = 2; + var TIP_CONTROLLER_OFFSET = 1; this.triggerAction = triggerAction; - this.palm = 2 * hand; - this.tip = 2 * hand + 1; + this.palm = SPATIAL_CONTROLLERS_PER_PALM * hand; + this.tip = SPATIAL_CONTROLLERS_PER_PALM * hand + TIP_CONTROLLER_OFFSET; this.actionID = null; // action this script created... this.grabbedEntity = null; // on this entity. @@ -287,10 +289,12 @@ function MyController(hand, triggerAction) { // that returns the minimum quaternion between two quaternions. var currentOrientation = MyAvatar.orientation; if (Quat.dot(currentOrientation, this.currentAvatarOrientation) < 0.0) { - var negativeCurrentOrientation = { x: -currentOrientation.x, - y: -currentOrientation.y, - z: -currentOrientation.z, - w: -currentOrientation.w }; + var negativeCurrentOrientation = { + x: -currentOrientation.x, + y: -currentOrientation.y, + z: -currentOrientation.z, + w: -currentOrientation.w + }; var avatarDeltaOrientation = Quat.multiply(negativeCurrentOrientation, Quat.inverse(this.currentAvatarOrientation)); } else { var avatarDeltaOrientation = Quat.multiply(currentOrientation, Quat.inverse(this.currentAvatarOrientation)); @@ -482,17 +486,14 @@ function MyController(hand, triggerAction) { }; this.startTouch = function(entityID) { - // print('START TOUCH' + entityID); Entities.callEntityMethod(entityID, "startTouch"); }; this.continueTouch = function(entityID) { - // print('CONTINUE TOUCH' + entityID); Entities.callEntityMethod(entityID, "continueTouch"); }; this.stopTouch = function(entityID) { - // print('STOP TOUCH' + entityID); Entities.callEntityMethod(entityID, "stopTouch"); };