From 5f6e6082071998a6f5bbfe036fc6bd93f386bdd2 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 19 Jul 2016 11:23:21 -0700 Subject: [PATCH 1/3] don't overwrite physical properties with those from the entity during editEntity -- only set those that the script didn't. --- libraries/entities/src/EntityItem.cpp | 20 +++++++++++++++----- libraries/entities/src/EntityTree.cpp | 11 ++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index f0a4d40860..f774d52274 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1211,11 +1211,21 @@ EntityItemProperties EntityItem::getProperties(EntityPropertyFlags desiredProper void EntityItem::getAllTerseUpdateProperties(EntityItemProperties& properties) const { // a TerseUpdate includes the transform and its derivatives - properties._position = getLocalPosition(); - properties._velocity = getLocalVelocity(); - properties._rotation = getLocalOrientation(); - properties._angularVelocity = getLocalAngularVelocity(); - properties._acceleration = _acceleration; + if (!properties._positionChanged) { + properties._position = getLocalPosition(); + } + if (!properties._velocityChanged) { + properties._velocity = getLocalVelocity(); + } + if (!properties._rotationChanged) { + properties._rotation = getLocalOrientation(); + } + if (!properties._angularVelocityChanged) { + properties._angularVelocity = getLocalAngularVelocity(); + } + if (!properties._accelerationChanged) { + properties._acceleration = _acceleration; + } properties._positionChanged = true; properties._velocityChanged = true; diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index ef0401ceaf..848d473321 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -723,13 +723,10 @@ void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList= 0) { glm::vec3 value = properties.getVelocity(); - QString changeHint = "0"; - if (value.x + value.y + value.z > 0) { - changeHint = "+"; - } else if (value.x + value.y + value.z < 0) { - changeHint = "-"; - } - changedProperties[index] = QString("velocity:") + changeHint; + changedProperties[index] = QString("velocity:") + + QString::number((int)value.x) + "," + + QString::number((int)value.y) + "," + + QString::number((int)value.z); } } From be001a652ffdf6aea2ba3ce468618b6893d3c91c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 19 Jul 2016 11:50:53 -0700 Subject: [PATCH 2/3] when doing a parenting grab, zero velocity --- scripts/system/controllers/handControllerGrab.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index cf8146fba9..e5fb48abcd 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1922,7 +1922,9 @@ function MyController(hand) { var handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"); var reparentProps = { parentID: MyAvatar.sessionUUID, - parentJointIndex: handJointIndex + parentJointIndex: handJointIndex, + velocity: {x: 0, y: 0, z: 0}, + angularVelocity: {x: 0, y: 0, z: 0} }; if (hasPresetPosition) { reparentProps["localPosition"] = this.offsetPosition; From 56726183f6674980d58eb996e8ab3977460bda0d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 19 Jul 2016 16:45:57 -0700 Subject: [PATCH 3/3] clear internal bullet flag before switching entity to kinematic --- libraries/physics/src/PhysicsEngine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index d3247ec62c..aa6c1b4e40 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -88,6 +88,7 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) { motionState->updateBodyVelocities(); motionState->updateLastKinematicStep(); body->setSleepingThresholds(KINEMATIC_LINEAR_SPEED_THRESHOLD, KINEMATIC_ANGULAR_SPEED_THRESHOLD); + motionState->clearInternalKinematicChanges(); break; } case MOTION_TYPE_DYNAMIC: {