From fc41155ce1be98f42b85b3985541e3947dfc1cae Mon Sep 17 00:00:00 2001 From: druiz17 Date: Tue, 10 Oct 2017 09:17:01 -0700 Subject: [PATCH 1/5] saving work --- .../controllerModules/farActionGrabEntity.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 0ef0e67471..8f6a0be163 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -119,6 +119,7 @@ Script.include("/~/system/libraries/controllers.js"); this.reticleMaxX; this.reticleMinY = MARGIN; this.reticleMaxY; + this.madeDynamic = false; var ACTION_TTL = 15; // seconds @@ -344,6 +345,13 @@ Script.include("/~/system/libraries/controllers.js"); var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; Entities.callEntityMethod(this.grabbedThingID, "releaseGrab", args); + if (this.madeDynamic) { + var props = Entities.getEntityProperties(this.grabbedThingID, ["dynamic", "localVelocity"]); + props.dynamic = false; + props.localVelocity = {x: 0, y: 0, z: 0}; + Entities.editEntity(this.grabbedThingID, props); + this.madeDynamic = false; + } this.actionID = null; this.grabbedThingID = null; }; @@ -503,12 +511,19 @@ Script.include("/~/system/libraries/controllers.js"); this.destroyContextOverlay(); } - if (entityIsDistanceGrabbable(targetProps)) { + if (entityIsGrabbable(targetProps)) { + if (!entityIsDistanceGrabbable(targetProps)) { + targetProps.dynamic = true; + Entities.editEntity(entityID, targetProps); + this.madeDynamic = true; + // make distance grabbale + } + if (!this.distanceRotating) { this.grabbedThingID = entityID; this.grabbedDistance = rayPickInfo.distance; } - + if (otherFarGrabModule.grabbedThingID === this.grabbedThingID && otherFarGrabModule.distanceHolding) { this.prepareDistanceRotatingData(controllerData); this.distanceRotate(otherFarGrabModule); From 003395b256303798b8430f8aa0bbf3144333183b Mon Sep 17 00:00:00 2001 From: druiz17 Date: Tue, 10 Oct 2017 09:43:02 -0700 Subject: [PATCH 2/5] removing whitespace --- .../system/controllers/controllerModules/farActionGrabEntity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 8f6a0be163..4b5a489531 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -523,7 +523,7 @@ Script.include("/~/system/libraries/controllers.js"); this.grabbedThingID = entityID; this.grabbedDistance = rayPickInfo.distance; } - + if (otherFarGrabModule.grabbedThingID === this.grabbedThingID && otherFarGrabModule.distanceHolding) { this.prepareDistanceRotatingData(controllerData); this.distanceRotate(otherFarGrabModule); From d0eb6a3ad090694a2d2735fbaf6e08816d501180 Mon Sep 17 00:00:00 2001 From: druiz17 Date: Tue, 10 Oct 2017 09:45:41 -0700 Subject: [PATCH 3/5] remove comments --- .../system/controllers/controllerModules/farActionGrabEntity.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 4b5a489531..1ebed27b0e 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -516,7 +516,6 @@ Script.include("/~/system/libraries/controllers.js"); targetProps.dynamic = true; Entities.editEntity(entityID, targetProps); this.madeDynamic = true; - // make distance grabbale } if (!this.distanceRotating) { From a179df29fbc4d0d0ac506598aac1e1b2aa9de709 Mon Sep 17 00:00:00 2001 From: druiz17 Date: Tue, 10 Oct 2017 10:31:40 -0700 Subject: [PATCH 4/5] mouse grab non-dynamic entities --- scripts/system/controllers/grab.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index 0e9b8569ae..40b1bfd23b 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -15,12 +15,13 @@ // /* global MyAvatar, Entities, Script, Camera, Vec3, Reticle, Overlays, getEntityCustomData, Messages, Quat, Controller, - isInEditMode, HMD */ + isInEditMode, HMD entityIsGrabbable*/ (function() { // BEGIN LOCAL_SCOPE -Script.include("/~/system/libraries/utils.js"); + Script.include("/~/system/libraries/utils.js"); + Script.include("/~/system/libraries/controllerDispatcherUtils.js"); var MAX_SOLID_ANGLE = 0.01; // objects that appear smaller than this can't be grabbed var DELAY_FOR_30HZ = 33; // milliseconds @@ -330,9 +331,11 @@ Grabber.prototype.pressEvent = function(event) { return; } - var isDynamic = Entities.getEntityProperties(pickResults.objectID, "dynamic").dynamic; - if (!isDynamic) { - // only grab dynamic objects + var props = Entities.getEntityProperties(pickResults.objectID, ["dynamic", "userData", "locked", "type"]); + var isDynamic = props.dynamic; + var isGrabbable = props.grabbable; + if (!entityIsGrabbable(props)) { + // only grab grabbable objects return; } @@ -350,6 +353,7 @@ Grabber.prototype.pressEvent = function(event) { var entityProperties = Entities.getEntityProperties(clickedEntity); this.startPosition = entityProperties.position; this.lastRotation = entityProperties.rotation; + this.madeDynamic = false; var cameraPosition = Camera.getPosition(); var objectBoundingDiameter = Vec3.length(entityProperties.dimensions); @@ -361,6 +365,11 @@ Grabber.prototype.pressEvent = function(event) { return; } + if (entityIsGrabbable(props) && !isDynamic) { + entityProperties.dynamic = true; + Entities.editEntity(clickedEntity, entityProperties); + this.madeDynamic = true; + } // this.activateEntity(clickedEntity, entityProperties); this.isGrabbing = true; @@ -416,6 +425,14 @@ Grabber.prototype.releaseEvent = function(event) { if (this.actionID) { Entities.deleteAction(this.entityID, this.actionID); } + + if (this.madeDynamic) { + var entityProps = Entities.getEntityProperties(this.entityID, ["dynamic", "localVelocity"]); + entityProps.dynamic = false; + entityProps.localVelocity = {x: 0, y: 0, z: 0}; + Entities.editEntity(this.entityID, entityProps); + } + this.actionID = null; LaserPointers.setRenderState(this.mouseRayEntities, ""); From 013e15c9a2cac45f6256d4a1c101bee396bf696b Mon Sep 17 00:00:00 2001 From: druiz17 Date: Tue, 10 Oct 2017 10:54:56 -0700 Subject: [PATCH 5/5] made requested changes --- .../system/controllers/controllerModules/farActionGrabEntity.js | 2 +- scripts/system/controllers/grab.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 1ebed27b0e..fb380f992b 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -346,7 +346,7 @@ Script.include("/~/system/libraries/controllers.js"); Entities.callEntityMethod(this.grabbedThingID, "releaseGrab", args); if (this.madeDynamic) { - var props = Entities.getEntityProperties(this.grabbedThingID, ["dynamic", "localVelocity"]); + var props = {}; props.dynamic = false; props.localVelocity = {x: 0, y: 0, z: 0}; Entities.editEntity(this.grabbedThingID, props); diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index 40b1bfd23b..2f046cbce3 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -427,7 +427,7 @@ Grabber.prototype.releaseEvent = function(event) { } if (this.madeDynamic) { - var entityProps = Entities.getEntityProperties(this.entityID, ["dynamic", "localVelocity"]); + var entityProps = {}; entityProps.dynamic = false; entityProps.localVelocity = {x: 0, y: 0, z: 0}; Entities.editEntity(this.entityID, entityProps);