don't accept incoming location edits if an entity is being controlled by a shouldSuppressLocationEdits action

This commit is contained in:
Seth Alves 2015-10-19 16:13:53 -07:00
parent 9e24542c0b
commit bddbe89c86
2 changed files with 16 additions and 28 deletions

View file

@ -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;
}
}

View file

@ -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; }