From bddbe89c865b228b43496f0c73942cb00d93e661 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 19 Oct 2015 16:13:53 -0700 Subject: [PATCH] don't accept incoming location edits if an entity is being controlled by a shouldSuppressLocationEdits action --- libraries/entities/src/EntityItem.cpp | 36 +++++++++------------------ libraries/entities/src/EntityItem.h | 8 +++--- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 00ba6e8d42..1fd9acc1e2 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1301,6 +1301,9 @@ void EntityItem::computeShapeInfo(ShapeInfo& info) { } void EntityItem::updatePosition(const glm::vec3& value) { + if (shouldSuppressLocationEdits()) { + return; + } auto delta = glm::distance(getPosition(), value); if (delta > IGNORE_POSITION_DELTA) { _dirtyFlags |= Simulation::DIRTY_POSITION; @@ -1323,6 +1326,9 @@ void EntityItem::updateDimensions(const glm::vec3& value) { } void EntityItem::updateRotation(const glm::quat& rotation) { + if (shouldSuppressLocationEdits()) { + return; + } if (getRotation() != rotation) { setRotation(rotation); @@ -1363,6 +1369,9 @@ void EntityItem::updateMass(float mass) { } void EntityItem::updateVelocity(const glm::vec3& value) { + if (shouldSuppressLocationEdits()) { + return; + } auto delta = glm::distance(_velocity, value); if (delta > IGNORE_LINEAR_VELOCITY_DELTA) { _dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY; @@ -1399,6 +1408,9 @@ void EntityItem::updateGravity(const glm::vec3& value) { } void EntityItem::updateAngularVelocity(const glm::vec3& value) { + if (shouldSuppressLocationEdits()) { + return; + } auto delta = glm::distance(_angularVelocity, value); if (delta > IGNORE_ANGULAR_VELOCITY_DELTA) { _dirtyFlags |= Simulation::DIRTY_ANGULAR_VELOCITY; @@ -1808,27 +1820,3 @@ bool EntityItem::shouldSuppressLocationEdits() const { return false; } - -void EntityItem::setPosition(const glm::vec3& value) { - if (!shouldSuppressLocationEdits()) { - _transform.setTranslation(value); requiresRecalcBoxes(); - } -} - -void EntityItem::setRotation(const glm::quat& rotation) { - if (!shouldSuppressLocationEdits()) { - _transform.setRotation(rotation); requiresRecalcBoxes(); - } -} - -void EntityItem::setVelocity(const glm::vec3& value) { - if (!shouldSuppressLocationEdits()) { - _velocity = value; - } -} - -void EntityItem::setAcceleration(const glm::vec3& value) { - if (!shouldSuppressLocationEdits()) { - _acceleration = value; - } -} diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 172ff79276..858dc7e326 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -209,10 +209,10 @@ public: /// Position in meters (-TREE_SCALE - TREE_SCALE) inline const glm::vec3& getPosition() const { return _transform.getTranslation(); } - void setPosition(const glm::vec3& value); + inline void setPosition(const glm::vec3& value) { _transform.setTranslation(value); requiresRecalcBoxes(); } inline const glm::quat& getRotation() const { return _transform.getRotation(); } - inline void setRotation(const glm::quat& rotation); + inline void setRotation(const glm::quat& rotation) { _transform.setRotation(rotation); requiresRecalcBoxes(); } inline void requiresRecalcBoxes() { _recalcAABox = true; _recalcMinAACube = true; _recalcMaxAACube = true; } @@ -240,7 +240,7 @@ public: float getDensity() const { return _density; } const glm::vec3& getVelocity() const { return _velocity; } /// get velocity in meters - void setVelocity(const glm::vec3& value); + void setVelocity(const glm::vec3& value) { _velocity = value; } /// velocity in meters bool hasVelocity() const { return _velocity != ENTITY_ITEM_ZERO_VEC3; } const glm::vec3& getGravity() const { return _gravity; } /// get gravity in meters @@ -248,7 +248,7 @@ public: bool hasGravity() const { return _gravity != ENTITY_ITEM_ZERO_VEC3; } const glm::vec3& getAcceleration() const { return _acceleration; } /// get acceleration in meters/second/second - void setAcceleration(const glm::vec3& value); /// acceleration in meters/second/second + void setAcceleration(const glm::vec3& value) { _acceleration = value; } /// acceleration in meters/second/second bool hasAcceleration() const { return _acceleration != ENTITY_ITEM_ZERO_VEC3; } float getDamping() const { return _damping; }