From 9db839bc138c3acd01f6ed2b4a4e020772bee8f4 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 4 May 2016 15:01:00 -0700 Subject: [PATCH] don't allow someone else to delete an action that I own. reset dynamic property when releasing and entity, even if refCount isn't 0 --- libraries/entities/src/EntityItem.cpp | 7 +++++-- libraries/entities/src/EntityTree.cpp | 4 ++-- libraries/physics/src/ObjectActionSpring.cpp | 6 ++++-- scripts/system/controllers/handControllerGrab.js | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 7bdd88ae5a..f0022245ad 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1740,6 +1740,7 @@ bool EntityItem::removeActionInternal(const QUuid& actionID, EntitySimulation* s EntityActionPointer action = _objectActions[actionID]; action->setOwnerEntity(nullptr); + action->setIsMine(false); _objectActions.remove(actionID); if (simulation) { @@ -1846,8 +1847,10 @@ void EntityItem::deserializeActionsInternal() { QUuid id = i.key(); if (!updated.contains(id)) { EntityActionPointer action = i.value(); - // if we've just added this action, don't remove it due to lack of mention in an incoming packet. - if (! action->locallyAddedButNotYetReceived) { + // don't let someone else delete my action. + if (!action->isMine() && + // if we've just added this action, don't remove it due to lack of mention in an incoming packet. + !action->locallyAddedButNotYetReceived) { _actionsToRemove << id; _previouslyDeletedActions.insert(id, now); } diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 6a0d0c968f..8a3395f9dc 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -213,8 +213,8 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI properties.setVelocityChanged(false); properties.setAngularVelocityChanged(false); properties.setAccelerationChanged(false); - properties.setParentID(QUuid()); - properties.setParentJointIndex(false); + properties.setParentIDChanged(false); + properties.setParentJointIndexChanged(false); if (wantTerseEditLogging()) { qCDebug(entities) << (senderNode ? senderNode->getUUID() : "null") << "physical edits suppressed"; diff --git a/libraries/physics/src/ObjectActionSpring.cpp b/libraries/physics/src/ObjectActionSpring.cpp index 563733ea2d..49944d6ed9 100644 --- a/libraries/physics/src/ObjectActionSpring.cpp +++ b/libraries/physics/src/ObjectActionSpring.cpp @@ -45,10 +45,9 @@ bool ObjectActionSpring::getTarget(float deltaTimeStep, glm::quat& rotation, glm position = _desiredPositionalTarget; linearVelocity = glm::vec3(); angularVelocity = glm::vec3(); - return true; + return true; } - bool ObjectActionSpring::prepareForSpringUpdate(btScalar deltaTimeStep) { glm::quat rotation; glm::vec3 position; @@ -140,10 +139,13 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) { float speed = glm::min(offsetLength / _linearTimeScale, SPRING_MAX_SPEED); targetVelocity = (-speed / offsetLength) * offset; if (speed > rigidBody->getLinearSleepingThreshold()) { + qDebug() << "HERE"; + forceBodyNonStatic(); rigidBody->activate(); } } // this action is aggresively critically damped and defeats the current velocity + qDebug() << targetVelocity.x() << targetVelocity.y() << targetVelocity.z(); rigidBody->setLinearVelocity(targetVelocity); } diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 8bbbfcdd88..0fdaed58f2 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1895,7 +1895,8 @@ function MyController(hand) { Entities.editEntity(entityID, deactiveProps); } else if (noVelocity) { Entities.editEntity(entityID, {velocity: {x: 0.0, y: 0.0, z: 0.0}, - angularVelocity: {x: 0.0, y: 0.0, z: 0.0}}); + angularVelocity: {x: 0.0, y: 0.0, z: 0.0}, + dynamic: data["dynamic"]}); } } else { data = null;