From 6a646f1c249b0d1b860c34bf7757cb9c009c4503 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 10 Feb 2016 19:01:41 -0800 Subject: [PATCH] put isMoving back and change all uses to isMovingRelativeToParent --- .../entities-renderer/src/RenderableModelEntityItem.cpp | 2 +- libraries/entities/src/EntityItem.cpp | 6 +++++- libraries/entities/src/EntityItem.h | 1 + libraries/entities/src/EntitySimulation.cpp | 6 +++--- libraries/physics/src/EntityMotionState.cpp | 6 +++--- libraries/physics/src/PhysicalEntitySimulation.cpp | 8 ++++---- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 84c53e05da..cc202dde37 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -412,7 +412,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) { } }); - bool movingOrAnimating = isMoving() || isAnimatingSomething(); + bool movingOrAnimating = isMovingRelativeToParent() || isAnimatingSomething(); if ((movingOrAnimating || _needsInitialSimulation || _model->getTranslation() != getPosition() || diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 7c5ba72096..bc1a848724 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -993,6 +993,10 @@ void EntityItem::simulateKinematicMotion(float timeElapsed, bool setFlags) { } bool EntityItem::isMoving() const { + return hasVelocity() || hasAngularVelocity(); +} + +bool EntityItem::isMovingRelativeToParent() const { return hasLocalVelocity() || hasLocalAngularVelocity(); } @@ -1558,7 +1562,7 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask } else { if (_dynamic) { group = BULLET_COLLISION_GROUP_DYNAMIC; - } else if (isMoving() || hasActions()) { + } else if (isMovingRelativeToParent() || hasActions()) { group = BULLET_COLLISION_GROUP_KINEMATIC; } else { group = BULLET_COLLISION_GROUP_STATIC; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index a1e5257d29..55741823f1 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -345,6 +345,7 @@ public: void clearDirtyFlags(uint32_t mask = 0xffffffff) { _dirtyFlags &= ~mask; } bool isMoving() const; + bool isMovingRelativeToParent() const; bool isSimulated() const { return _simulated; } diff --git a/libraries/entities/src/EntitySimulation.cpp b/libraries/entities/src/EntitySimulation.cpp index 23e5b99337..014ab33094 100644 --- a/libraries/entities/src/EntitySimulation.cpp +++ b/libraries/entities/src/EntitySimulation.cpp @@ -70,7 +70,7 @@ void EntitySimulation::prepareEntityForDelete(EntityItemPointer entity) { } void EntitySimulation::addEntityInternal(EntityItemPointer entity) { - if (entity->isMoving() && !entity->getPhysicsInfo()) { + if (entity->isMovingRelativeToParent() && !entity->getPhysicsInfo()) { QMutexLocker lock(&_mutex); _simpleKinematicEntities.insert(entity); } @@ -78,7 +78,7 @@ void EntitySimulation::addEntityInternal(EntityItemPointer entity) { void EntitySimulation::changeEntityInternal(EntityItemPointer entity) { QMutexLocker lock(&_mutex); - if (entity->isMoving() && !entity->getPhysicsInfo()) { + if (entity->isMovingRelativeToParent() && !entity->getPhysicsInfo()) { _simpleKinematicEntities.insert(entity); } else { _simpleKinematicEntities.remove(entity); @@ -254,7 +254,7 @@ void EntitySimulation::moveSimpleKinematics(const quint64& now) { SetOfEntities::iterator itemItr = _simpleKinematicEntities.begin(); while (itemItr != _simpleKinematicEntities.end()) { EntityItemPointer entity = *itemItr; - if (entity->isMoving() && !entity->getPhysicsInfo()) { + if (entity->isMovingRelativeToParent() && !entity->getPhysicsInfo()) { entity->simulate(now); _entitiesToSort.insert(entity); ++itemItr; diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index c798e07d52..8c0dab98db 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -158,12 +158,12 @@ PhysicsMotionType EntityMotionState::computePhysicsMotionType() const { } return MOTION_TYPE_DYNAMIC; } - return (_entity->isMoving() || _entity->hasActions()) ? MOTION_TYPE_KINEMATIC : MOTION_TYPE_STATIC; + return (_entity->isMovingRelativeToParent() || _entity->hasActions()) ? MOTION_TYPE_KINEMATIC : MOTION_TYPE_STATIC; } bool EntityMotionState::isMoving() const { assert(entityTreeIsLocked()); - return _entity && _entity->isMoving(); + return _entity && _entity->isMovingRelativeToParent(); } // This callback is invoked by the physics simulation in two cases: @@ -555,7 +555,7 @@ uint32_t EntityMotionState::getIncomingDirtyFlags() { } // we add DIRTY_MOTION_TYPE if the body's motion type disagrees with entity velocity settings int bodyFlags = _body->getCollisionFlags(); - bool isMoving = _entity->isMoving(); + bool isMoving = _entity->isMovingRelativeToParent(); if (((bodyFlags & btCollisionObject::CF_STATIC_OBJECT) && isMoving) || (bodyFlags & btCollisionObject::CF_KINEMATIC_OBJECT && !isMoving)) { dirtyFlags |= Simulation::DIRTY_MOTION_TYPE; diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index aaa706b370..4a70c248c6 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -51,7 +51,7 @@ void PhysicalEntitySimulation::addEntityInternal(EntityItemPointer entity) { if (!motionState) { _entitiesToAddToPhysics.insert(entity); } - } else if (entity->isMoving()) { + } else if (entity->isMovingRelativeToParent()) { _simpleKinematicEntities.insert(entity); } } @@ -98,7 +98,7 @@ void PhysicalEntitySimulation::changeEntityInternal(EntityItemPointer entity) { _physicalObjects.remove(motionState); _outgoingChanges.remove(motionState); _entitiesToRemoveFromPhysics.insert(entity); - if (entity->isMoving()) { + if (entity->isMovingRelativeToParent()) { _simpleKinematicEntities.insert(entity); } } else { @@ -109,7 +109,7 @@ void PhysicalEntitySimulation::changeEntityInternal(EntityItemPointer entity) { // Perhaps it's shape has changed and it can now be added? _entitiesToAddToPhysics.insert(entity); _simpleKinematicEntities.remove(entity); // just in case it's non-physical-kinematic - } else if (entity->isMoving()) { + } else if (entity->isMovingRelativeToParent()) { _simpleKinematicEntities.insert(entity); } else { _simpleKinematicEntities.remove(entity); // just in case it's non-physical-kinematic @@ -208,7 +208,7 @@ void PhysicalEntitySimulation::getObjectsToAddToPhysics(VectorOfMotionStates& re } else if (!entity->shouldBePhysical()) { // this entity should no longer be on the internal _entitiesToAddToPhysics entityItr = _entitiesToAddToPhysics.erase(entityItr); - if (entity->isMoving()) { + if (entity->isMovingRelativeToParent()) { _simpleKinematicEntities.insert(entity); } } else if (entity->isReadyToComputeShape()) {