From 96b6a2f013678afcf7c30be3916cb73505cf4953 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 28 Sep 2017 16:07:15 -0700 Subject: [PATCH 01/11] Fix entity add after incomplete rezCertified implementation (cherry picked from commit 0f66fb41fd3ff2b58c4fcdef8f5145830559e3bf) --- libraries/entities/src/EntityTree.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 5c5aee97ff..c8675bdcba 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -1148,11 +1148,8 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c } else if (!senderNode->getCanRez() && !senderNode->getCanRezTmp()) { failedAdd = true; qCDebug(entities) << "User without 'rez rights' [" << senderNode->getUUID() - << "] attempted to add an entity ID:" << entityItemID; - // FIXME after Cert ID property integrated - } else if (/*!properties.getCertificateID().isNull() && */!senderNode->getCanRezCertified() && !senderNode->getCanRezTmpCertified()) { - qCDebug(entities) << "User without 'certified rez rights' [" << senderNode->getUUID() - << "] attempted to add a certified entity with ID:" << entityItemID; + << "] attempted to add an entity ID:" << entityItemID; + } else { // this is a new entity... assign a new entityID properties.setCreated(properties.getLastEdited()); From 4fd447949776adceb83f7dd920f361031652c6c7 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 28 Sep 2017 16:20:09 -0700 Subject: [PATCH 02/11] Oculus: Bug fix for head offset on large/small scaled avatars. (cherry picked from commit d8e2cbf871fd1b10a7507b979e832f65e13f8c44) --- plugins/oculus/src/OculusControllerManager.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/oculus/src/OculusControllerManager.cpp b/plugins/oculus/src/OculusControllerManager.cpp index 6f7be26554..d0c717bd20 100644 --- a/plugins/oculus/src/OculusControllerManager.cpp +++ b/plugins/oculus/src/OculusControllerManager.cpp @@ -334,10 +334,8 @@ void OculusControllerManager::TouchDevice::handleHeadPose(float deltaTime, glm::mat4 defaultHeadOffset = glm::inverse(inputCalibrationData.defaultCenterEyeMat) * inputCalibrationData.defaultHeadMat; - controller::Pose hmdHeadPose = pose.transform(sensorToAvatar); - pose.valid = true; - _poseStateMap[controller::HEAD] = hmdHeadPose.postTransform(defaultHeadOffset); + _poseStateMap[controller::HEAD] = pose.postTransform(defaultHeadOffset).transform(sensorToAvatar); } void OculusControllerManager::TouchDevice::handleRotationForUntrackedHand(const controller::InputCalibrationData& inputCalibrationData, From b8ea6c22fa55cdc840a0f803433ff745edc873a0 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 29 Sep 2017 11:14:29 -0700 Subject: [PATCH 03/11] no tpose when switching avatars (cherry picked from commit fcfac9efc0b4787872eda616165cc70f43be093c) --- libraries/animation/src/Rig.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 86a1e629b4..712c728dcb 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -249,6 +249,7 @@ void Rig::reset(const FBXGeometry& geometry) { _rightShoulderJointIndex = _rightElbowJointIndex >= 0 ? geometry.joints.at(_rightElbowJointIndex).parentIndex : -1; if (!_animGraphURL.isEmpty()) { + _animNode.reset(); initAnimGraph(_animGraphURL); } } @@ -1619,7 +1620,7 @@ void Rig::updateFromControllerParameters(const ControllerParameters& params, flo } void Rig::initAnimGraph(const QUrl& url) { - if (_animGraphURL != url) { + if (_animGraphURL != url || !_animNode) { _animGraphURL = url; _animNode.reset(); From 572986bfad264e63ff25481ce0cc3decbe128cf2 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 29 Sep 2017 17:48:59 -0700 Subject: [PATCH 04/11] fix modeloverlay visible change (cherry picked from commit 0bb27a7165a874766b7625928fd00eed444d87af) --- interface/src/ui/overlays/Base3DOverlay.h | 2 +- interface/src/ui/overlays/ModelOverlay.cpp | 39 ++++++++++++++-------- interface/src/ui/overlays/ModelOverlay.h | 8 ++++- interface/src/ui/overlays/Overlay.h | 2 +- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index 93a973e60a..3e65f163e2 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -47,7 +47,7 @@ public: void setIsSolid(bool isSolid) { _isSolid = isSolid; } void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; } void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; } - void setDrawInFront(bool value) { _drawInFront = value; } + virtual void setDrawInFront(bool value) { _drawInFront = value; } void setIsGrabbable(bool value) { _isGrabbable = value; } virtual AABox getBounds() const override = 0; diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index ca5ca54144..d19668af37 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -60,6 +60,24 @@ void ModelOverlay::update(float deltatime) { _model->simulate(deltatime); } _isLoaded = _model->isActive(); + + // check to see if when we added our model to the scene they were ready, if they were not ready, then + // fix them up in the scene + render::ScenePointer scene = qApp->getMain3DScene(); + render::Transaction transaction; + if (_model->needsFixupInScene()) { + _model->removeFromScene(scene, transaction); + _model->addToScene(scene, transaction); + } + if (_visibleDirty) { + _visibleDirty = false; + _model->setVisibleInScene(getVisible(), scene); + } + if (_drawInFrontDirty) { + _drawInFrontDirty = false; + _model->setLayeredInFront(getDrawInFront(), scene); + } + scene->enqueueTransaction(transaction); } bool ModelOverlay::addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) { @@ -73,21 +91,14 @@ void ModelOverlay::removeFromScene(Overlay::Pointer overlay, const render::Scene _model->removeFromScene(scene, transaction); } -void ModelOverlay::render(RenderArgs* args) { +void ModelOverlay::setVisible(bool visible) { + Overlay::setVisible(visible); + _visibleDirty = true; +} - // check to see if when we added our model to the scene they were ready, if they were not ready, then - // fix them up in the scene - render::ScenePointer scene = qApp->getMain3DScene(); - render::Transaction transaction; - if (_model->needsFixupInScene()) { - _model->removeFromScene(scene, transaction); - _model->addToScene(scene, transaction); - } - - _model->setVisibleInScene(_visible, scene); - _model->setLayeredInFront(getDrawInFront(), scene); - - scene->enqueueTransaction(transaction); +void ModelOverlay::setDrawInFront(bool drawInFront) { + Base3DOverlay::setDrawInFront(drawInFront); + _drawInFrontDirty = true; } void ModelOverlay::setProperties(const QVariantMap& properties) { diff --git a/interface/src/ui/overlays/ModelOverlay.h b/interface/src/ui/overlays/ModelOverlay.h index 8d8429b29e..c1403cadbe 100644 --- a/interface/src/ui/overlays/ModelOverlay.h +++ b/interface/src/ui/overlays/ModelOverlay.h @@ -28,7 +28,7 @@ public: ModelOverlay(const ModelOverlay* modelOverlay); virtual void update(float deltatime) override; - virtual void render(RenderArgs* args) override; + virtual void render(RenderArgs* args) override {}; void setProperties(const QVariantMap& properties) override; QVariant getProperty(const QString& property) override; virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, @@ -45,6 +45,9 @@ public: float getLoadPriority() const { return _loadPriority; } + void setVisible(bool visible) override; + void setDrawInFront(bool drawInFront) override; + protected: Transform evalRenderTransform() override; @@ -62,6 +65,9 @@ private: bool _updateModel = { false }; bool _scaleToFit = { false }; float _loadPriority { 0.0f }; + + bool _visibleDirty { false }; + bool _drawInFrontDirty { false }; }; #endif // hifi_ModelOverlay_h diff --git a/interface/src/ui/overlays/Overlay.h b/interface/src/ui/overlays/Overlay.h index db2979b4d5..775c597397 100644 --- a/interface/src/ui/overlays/Overlay.h +++ b/interface/src/ui/overlays/Overlay.h @@ -73,7 +73,7 @@ public: float getAlphaPulse() const { return _alphaPulse; } // setters - void setVisible(bool visible) { _visible = visible; } + virtual void setVisible(bool visible) { _visible = visible; } void setDrawHUDLayer(bool drawHUDLayer); void setColor(const xColor& color) { _color = color; } void setAlpha(float alpha) { _alpha = alpha; } From 7dfa80f666a00a31d3973fff12233725e41b93fd Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 28 Sep 2017 18:03:22 -0700 Subject: [PATCH 05/11] Bug fix for offset of animated parts of oculus touch controller display Ensure position/rotations are updated with a consistent scale and are animated correctly as the controller values change. --- .../system/controllers/controllerDisplay.js | 153 +++++++++--------- 1 file changed, 74 insertions(+), 79 deletions(-) diff --git a/scripts/system/controllers/controllerDisplay.js b/scripts/system/controllers/controllerDisplay.js index af8cfa74f4..3c2794cf96 100644 --- a/scripts/system/controllers/controllerDisplay.js +++ b/scripts/system/controllers/controllerDisplay.js @@ -49,6 +49,7 @@ createControllerDisplay = function(config) { partOverlays: {}, parts: {}, mappingName: "mapping-display-" + Math.random(), + partValues: {}, setVisible: function(visible) { for (var i = 0; i < this.overlays.length; ++i) { @@ -109,12 +110,53 @@ createControllerDisplay = function(config) { for (var partName in controller.parts) { overlayID = this.overlays[i++]; var part = controller.parts[partName]; - var partPosition = Vec3.multiply(sensorScaleFactor, Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, part.naturalPosition))); - var partDimensions = Vec3.multiply(sensorScaleFactor, part.naturalDimensions); - Overlays.editOverlay(overlayID, { - dimensions: partDimensions, - localPosition: partPosition - }); + localPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, part.naturalPosition)); + var localRotation; + var value = this.partValues[partName]; + var offset, rotation; + if (value !== undefined) { + if (part.type === "linear") { + var axis = Vec3.multiplyQbyV(controller.rotation, part.axis); + offset = Vec3.multiply(part.maxTranslation * value, axis); + localPosition = Vec3.sum(localPosition, offset); + localRotation = undefined; + } else if (part.type === "joystick") { + rotation = Quat.fromPitchYawRollDegrees(value.y * part.xHalfAngle, 0, value.x * part.yHalfAngle); + if (part.originOffset) { + offset = Vec3.multiplyQbyV(rotation, part.originOffset); + offset = Vec3.subtract(part.originOffset, offset); + } else { + offset = { x: 0, y: 0, z: 0 }; + } + localPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, Vec3.sum(offset, part.naturalPosition))); + localRotation = Quat.multiply(controller.rotation, rotation); + } else if (part.type === "rotational") { + value = clamp(value, part.minValue, part.maxValue); + var pct = (value - part.minValue) / part.maxValue; + var angle = pct * part.maxAngle; + rotation = Quat.angleAxis(angle, part.axis); + if (part.origin) { + offset = Vec3.multiplyQbyV(rotation, part.origin); + offset = Vec3.subtract(offset, part.origin); + } else { + offset = { x: 0, y: 0, z: 0 }; + } + localPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, Vec3.sum(offset, part.naturalPosition))); + localRotation = Quat.multiply(controller.rotation, rotation); + } + } + if (localRotation !== undefined) { + Overlays.editOverlay(overlayID, { + dimensions: Vec3.multiply(sensorScaleFactor, part.naturalDimensions), + localPosition: Vec3.multiply(sensorScaleFactor, localPosition), + localRotation: localRotation + }); + } else { + Overlays.editOverlay(overlayID, { + dimensions: Vec3.multiply(sensorScaleFactor, part.naturalDimensions), + localPosition: Vec3.multiply(sensorScaleFactor, localPosition) + }); + } } } } @@ -172,29 +214,13 @@ createControllerDisplay = function(config) { if (part.type === "rotational") { var input = resolveHardware(part.input); print("Mapping to: ", part.input, input); - mapping.from([input]).peek().to(function(controller, overlayID, part) { + mapping.from([input]).peek().to(function(partName) { return function(value) { - value = clamp(value, part.minValue, part.maxValue); - - var pct = (value - part.minValue) / part.maxValue; - var angle = pct * part.maxAngle; - var rotation = Quat.angleAxis(angle, part.axis); - - var offset = { x: 0, y: 0, z: 0 }; - if (part.origin) { - offset = Vec3.multiplyQbyV(rotation, part.origin); - offset = Vec3.subtract(offset, part.origin); - } - - var partPosition = Vec3.sum(controller.position, - Vec3.multiplyQbyV(controller.rotation, Vec3.sum(offset, part.naturalPosition))); - - Overlays.editOverlay(overlayID, { - localPosition: partPosition, - localRotation: Quat.multiply(controller.rotation, rotation) - }); + // insert the most recent controller value into controllerDisplay.partValues. + controllerDisplay.partValues[partName] = value; + controllerDisplay.resize(MyAvatar.sensorToWorldScale); }; - }(controller, overlayID, part)); + }(partName)); } else if (part.type === "touchpad") { var visibleInput = resolveHardware(part.visibleInput); var xInput = resolveHardware(part.xInput); @@ -210,69 +236,38 @@ createControllerDisplay = function(config) { mapping.from([yInput]).peek().invert().to(function(value) { }); } else if (part.type === "joystick") { - (function(controller, overlayID, part) { + (function(part, partName) { var xInput = resolveHardware(part.xInput); var yInput = resolveHardware(part.yInput); - - var xvalue = 0; - var yvalue = 0; - - function calculatePositionAndRotation(xValue, yValue) { - var rotation = Quat.fromPitchYawRollDegrees(yValue * part.xHalfAngle, 0, xValue * part.yHalfAngle); - - var offset = { x: 0, y: 0, z: 0 }; - if (part.originOffset) { - offset = Vec3.multiplyQbyV(rotation, part.originOffset); - offset = Vec3.subtract(part.originOffset, offset); - } - - var partPosition = Vec3.sum(controller.position, - Vec3.multiplyQbyV(controller.rotation, Vec3.sum(offset, part.naturalPosition))); - - var partRotation = Quat.multiply(controller.rotation, rotation); - - return { - position: partPosition, - rotation: partRotation - }; - } - mapping.from([xInput]).peek().to(function(value) { - xvalue = value; - var posRot = calculatePositionAndRotation(xvalue, yvalue); - Overlays.editOverlay(overlayID, { - localPosition: posRot.position, - localRotation: posRot.rotation - }); + // insert the most recent controller value into controllerDisplay.partValues. + if (controllerDisplay.partValues[partName]) { + controllerDisplay.partValues[partName].x = value; + } else { + controllerDisplay.partValues[partName] = {x: value, y: 0}; + } + controllerDisplay.resize(MyAvatar.sensorToWorldScale); }); - mapping.from([yInput]).peek().to(function(value) { - yvalue = value; - var posRot = calculatePositionAndRotation(xvalue, yvalue); - Overlays.editOverlay(overlayID, { - localPosition: posRot.position, - localRotation: posRot.rotation - }); + // insert the most recent controller value into controllerDisplay.partValues. + if (controllerDisplay.partValues[partName]) { + controllerDisplay.partValues[partName].y = value; + } else { + controllerDisplay.partValues[partName] = {x: 0, y: value}; + } + controllerDisplay.resize(MyAvatar.sensorToWorldScale); }); - })(controller, overlayID, part); + })(part, partName); } else if (part.type === "linear") { - (function(controller, overlayID, part) { + (function(part, partName) { var input = resolveHardware(part.input); - mapping.from([input]).peek().to(function(value) { - var axis = Vec3.multiplyQbyV(controller.rotation, part.axis); - var offset = Vec3.multiply(part.maxTranslation * value, axis); - - var partPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, part.naturalPosition)); - var position = Vec3.sum(partPosition, offset); - - Overlays.editOverlay(overlayID, { - localPosition: position - }); + // insert the most recent controller value into controllerDisplay.partValues. + controllerDisplay.partValues[partName] = value; + controllerDisplay.resize(MyAvatar.sensorToWorldScale); }); - - })(controller, overlayID, part); + })(part, partName); } else if (part.type === "static") { // do nothing From a6f254551166707a3bd62a277f28bafd592c8710 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 3 Oct 2017 12:51:37 -0700 Subject: [PATCH 06/11] fix local t pose --- libraries/animation/src/Rig.cpp | 4 +++- libraries/animation/src/Rig.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 712c728dcb..0897c26a12 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -1620,13 +1620,14 @@ void Rig::updateFromControllerParameters(const ControllerParameters& params, flo } void Rig::initAnimGraph(const QUrl& url) { - if (_animGraphURL != url || !_animNode) { + if (_animGraphURL != url || (!_animNode && !_animLoading)) { _animGraphURL = url; _animNode.reset(); // load the anim graph _animLoader.reset(new AnimNodeLoader(url)); + _animLoading = true; connect(_animLoader.get(), &AnimNodeLoader::success, [this](AnimNode::Pointer nodeIn) { _animNode = nodeIn; _animNode->setSkeleton(_animSkeleton); @@ -1637,6 +1638,7 @@ void Rig::initAnimGraph(const QUrl& url) { _userAnimState = { UserAnimState::None, "", 30.0f, false, 0.0f, 0.0f }; overrideAnimation(origState.url, origState.fps, origState.loop, origState.firstFrame, origState.lastFrame); } + _animLoading = false; emit onLoadComplete(); }); diff --git a/libraries/animation/src/Rig.h b/libraries/animation/src/Rig.h index eabc62ab75..18d49c5f1e 100644 --- a/libraries/animation/src/Rig.h +++ b/libraries/animation/src/Rig.h @@ -303,6 +303,7 @@ protected: std::shared_ptr _animNode; std::shared_ptr _animSkeleton; std::unique_ptr _animLoader; + bool _animLoading { false }; AnimVariantMap _animVars; enum class RigRole { Idle = 0, From 33e9a71000c95d3ab4d8434023b3a9f8aa859b2c Mon Sep 17 00:00:00 2001 From: druiz17 Date: Tue, 3 Oct 2017 12:51:51 -0700 Subject: [PATCH 07/11] grab attachments --- .../controllers/controllerModules/nearParentGrabEntity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 9323f651a2..70d91bf1ec 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -223,7 +223,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); (distance > NEAR_GRAB_RADIUS * sensorScaleFactor)) { continue; } - if (entityIsGrabbable(props)) { + if (entityIsGrabbable(props) || entityIsCloneable(props)) { // give haptic feedback if (props.id !== this.hapticTargetID) { Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand); From c9d2d40e1e0817e197ff385364e2c0d88eb0b23f Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 3 Oct 2017 14:44:11 -0700 Subject: [PATCH 08/11] possibly fix registration offset issue --- libraries/entities/src/EntityItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 107af837fe..cd00a7a211 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1368,7 +1368,7 @@ void EntityItem::recordCreationTime() { const Transform EntityItem::getTransformToCenter(bool& success) const { Transform result = getTransform(success); if (getRegistrationPoint() != ENTITY_ITEM_HALF_VEC3) { // If it is not already centered, translate to center - result.postTranslate(ENTITY_ITEM_HALF_VEC3 - getRegistrationPoint()); // Position to center + result.postTranslate((ENTITY_ITEM_HALF_VEC3 - getRegistrationPoint()) * getDimensions()); // Position to center } return result; } From fc6e5df2cbb52a105a9b8118126a9148fdadf145 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 3 Oct 2017 15:02:21 -0700 Subject: [PATCH 09/11] fix text/web registration point usage --- libraries/entities/src/TextEntityItem.cpp | 2 +- libraries/entities/src/WebEntityItem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/TextEntityItem.cpp b/libraries/entities/src/TextEntityItem.cpp index 1d8cb50a4b..3ade5879c5 100644 --- a/libraries/entities/src/TextEntityItem.cpp +++ b/libraries/entities/src/TextEntityItem.cpp @@ -136,7 +136,7 @@ bool TextEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec2 xyDimensions(dimensions.x, dimensions.y); glm::quat rotation = getRotation(); glm::vec3 position = getPosition() + rotation * - (dimensions * (getRegistrationPoint() - ENTITY_ITEM_DEFAULT_REGISTRATION_POINT)); + (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint())); // FIXME - should set face and surfaceNormal return findRayRectangleIntersection(origin, direction, rotation, position, xyDimensions, distance); diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index 61c6c8d80e..9595f2959c 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -112,7 +112,7 @@ bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const g glm::vec3 dimensions = getDimensions(); glm::vec2 xyDimensions(dimensions.x, dimensions.y); glm::quat rotation = getRotation(); - glm::vec3 position = getPosition() + rotation * (dimensions * (getRegistrationPoint() - ENTITY_ITEM_DEFAULT_REGISTRATION_POINT)); + glm::vec3 position = getPosition() + rotation * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint())); if (findRayRectangleIntersection(origin, direction, rotation, position, xyDimensions, distance)) { surfaceNormal = rotation * Vectors::UNIT_Z; From ad9677f63e3b7e3efdf89f4e443631f7f82c0321 Mon Sep 17 00:00:00 2001 From: druiz17 Date: Thu, 28 Sep 2017 11:18:40 -0700 Subject: [PATCH 10/11] fixing grabbing and tablet bugs --- .../controllerModules/equipEntity.js | 16 +++++++++++++--- .../controllerModules/farActionGrabEntity.js | 4 ++-- .../controllerModules/tabletStylusInput.js | 17 ++++++++++++++++- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/scripts/system/controllers/controllerModules/equipEntity.js b/scripts/system/controllers/controllerModules/equipEntity.js index 29db02c6de..4978f225ce 100644 --- a/scripts/system/controllers/controllerModules/equipEntity.js +++ b/scripts/system/controllers/controllerModules/equipEntity.js @@ -255,6 +255,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa this.messageGrabEntity = false; this.grabEntityProps = null; this.shouldSendStart = false; + this.equipedWithSecondary = false; this.parameters = makeDispatcherModuleParameters( 300, @@ -370,6 +371,10 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa return this.rawSecondaryValue < BUMPER_ON_VALUE; }; + this.secondarySmoothedSqueezed = function() { + return this.rawSecondaryValue > BUMPER_ON_VALUE; + }; + this.chooseNearEquipHotspots = function(candidateEntityProps, controllerData) { var _this = this; var collectedHotspots = flatten(candidateEntityProps.map(function(props) { @@ -592,11 +597,13 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa // if the potentialHotspot os not cloneable and locked return null if (potentialEquipHotspot && - ((this.triggerSmoothedSqueezed() && !this.waitForTriggerRelease) || this.messageGrabEntity)) { + (((this.triggerSmoothedSqueezed() || this.secondarySmoothedSqueezed()) && !this.waitForTriggerRelease) || + this.messageGrabEntity)) { this.grabbedHotspot = potentialEquipHotspot; this.targetEntityID = this.grabbedHotspot.entityID; this.startEquipEntity(controllerData); this.messageGrabEnity = false; + this.equipedWithSecondary = this.secondarySmoothedSqueezed(); return makeRunningValues(true, [potentialEquipHotspot.entityID], []); } else { return makeRunningValues(false, [], []); @@ -627,7 +634,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa return this.checkNearbyHotspots(controllerData, deltaTime, timestamp); } - if (controllerData.secondaryValues[this.hand]) { + if (controllerData.secondaryValues[this.hand] && !this.equipedWithSecondary) { // this.secondaryReleased() will always be true when not depressed // so we cannot simply rely on that for release - ensure that the // trigger was first "prepared" by being pushed in before the release @@ -644,7 +651,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa var dropDetected = this.dropGestureProcess(deltaTime); - if (this.triggerSmoothedReleased()) { + if (this.triggerSmoothedReleased() || this.secondaryReleased()) { if (this.shouldSendStart) { // we don't want to send startEquip message until the trigger is released. otherwise, // guns etc will fire right as they are equipped. @@ -653,6 +660,9 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa this.shouldSendStart = false; } this.waitForTriggerRelease = false; + if (this.secondaryReleased() && this.equipedWithSecondary) { + this.equipedWithSecondary = false; + } } if (dropDetected && this.prevDropDetected !== dropDetected) { diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 5c31c859e9..c5b82f75f0 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -132,7 +132,7 @@ Script.include("/~/system/libraries/controllers.js"); this.updateLaserPointer = function(controllerData) { var SEARCH_SPHERE_SIZE = 0.011; var MIN_SPHERE_SIZE = 0.0005; - var radius = Math.max(1.2 * SEARCH_SPHERE_SIZE * this.intersectionDistance, MIN_SPHERE_SIZE); + var radius = Math.max(1.2 * SEARCH_SPHERE_SIZE * this.intersectionDistance, MIN_SPHERE_SIZE) * MyAvatar.sensorToWorldScale; var dim = {x: radius, y: radius, z: radius}; var mode = "hold"; if (!this.distanceHolding && !this.distanceRotating) { @@ -424,7 +424,7 @@ Script.include("/~/system/libraries/controllers.js"); this.laserPointerOff(); return makeRunningValues(false, [], []); } - + this.intersectionDistance = controllerData.rayPicks[this.hand].distance; this.updateLaserPointer(controllerData); var otherModuleName =this.hand === RIGHT_HAND ? "LeftFarActionGrabEntity" : "RightFarActionGrabEntity"; diff --git a/scripts/system/controllers/controllerModules/tabletStylusInput.js b/scripts/system/controllers/controllerModules/tabletStylusInput.js index def958b223..0a3b2b8adc 100644 --- a/scripts/system/controllers/controllerModules/tabletStylusInput.js +++ b/scripts/system/controllers/controllerModules/tabletStylusInput.js @@ -152,6 +152,20 @@ Script.include("/~/system/libraries/controllers.js"); } }; + this.updateStylus = function() { + if (this.stylus) { + var X_ROT_NEG_90 = { x: -0.70710678, y: 0, z: 0, w: 0.70710678 }; + var modelOrientation = Quat.multiply(this.stylusTip.orientation, X_ROT_NEG_90); + var modelPositionOffset = Vec3.multiplyQbyV(modelOrientation, { x: 0, y: 0, z: MyAvatar.sensorToWorldScale * -WEB_STYLUS_LENGTH / 2 }); + + var stylusProps = { + position: Vec3.sum(this.stylusTip.position, modelPositionOffset), + rotation: modelOrientation + }; + Overlays.editOverlay(this.stylus, stylusProps); + } + }; + this.showStylus = function() { if (this.stylus) { return; @@ -320,6 +334,7 @@ Script.include("/~/system/libraries/controllers.js"); if (this.isNearStylusTarget) { if (!this.useFingerInsteadOfStylus) { this.showStylus(); + this.updateStylus(); } else { this.pointFinger(true); } @@ -335,7 +350,7 @@ Script.include("/~/system/libraries/controllers.js"); var SCALED_TABLET_MAX_HOVER_DISTANCE = TABLET_MAX_HOVER_DISTANCE * sensorScaleFactor; if (nearestStylusTarget && nearestStylusTarget.distance > SCALED_TABLET_MIN_TOUCH_DISTANCE && - nearestStylusTarget.distance < SCALED_TABLET_MAX_HOVER_DISTANCE) { + nearestStylusTarget.distance < SCALED_TABLET_MAX_HOVER_DISTANCE && !this.getOtherHandController().stylusTouchingTarget) { this.requestTouchFocus(nearestStylusTarget); From 13feec89c272736c03b129b8ac1de0354d45f1e7 Mon Sep 17 00:00:00 2001 From: druiz17 Date: Thu, 28 Sep 2017 13:23:28 -0700 Subject: [PATCH 11/11] remove update stylus --- .../controllerModules/tabletStylusInput.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/scripts/system/controllers/controllerModules/tabletStylusInput.js b/scripts/system/controllers/controllerModules/tabletStylusInput.js index 0a3b2b8adc..36ed7920dd 100644 --- a/scripts/system/controllers/controllerModules/tabletStylusInput.js +++ b/scripts/system/controllers/controllerModules/tabletStylusInput.js @@ -152,20 +152,6 @@ Script.include("/~/system/libraries/controllers.js"); } }; - this.updateStylus = function() { - if (this.stylus) { - var X_ROT_NEG_90 = { x: -0.70710678, y: 0, z: 0, w: 0.70710678 }; - var modelOrientation = Quat.multiply(this.stylusTip.orientation, X_ROT_NEG_90); - var modelPositionOffset = Vec3.multiplyQbyV(modelOrientation, { x: 0, y: 0, z: MyAvatar.sensorToWorldScale * -WEB_STYLUS_LENGTH / 2 }); - - var stylusProps = { - position: Vec3.sum(this.stylusTip.position, modelPositionOffset), - rotation: modelOrientation - }; - Overlays.editOverlay(this.stylus, stylusProps); - } - }; - this.showStylus = function() { if (this.stylus) { return; @@ -334,7 +320,6 @@ Script.include("/~/system/libraries/controllers.js"); if (this.isNearStylusTarget) { if (!this.useFingerInsteadOfStylus) { this.showStylus(); - this.updateStylus(); } else { this.pointFinger(true); }