From 96b4517e6ede70d4f02f55c5a552560780898af7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 22 Apr 2015 16:05:31 -0700 Subject: [PATCH] when removing something from bullet, attempt to wake up anything that was touching it --- libraries/entities/src/EntitySimulation.h | 2 -- libraries/entities/src/EntityTree.cpp | 3 --- libraries/physics/src/EntityMotionState.cpp | 2 -- libraries/physics/src/PhysicsEngine.cpp | 8 ++++++++ libraries/physics/src/PhysicsEngine.h | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/entities/src/EntitySimulation.h b/libraries/entities/src/EntitySimulation.h index 913f431186..1eb4fdc951 100644 --- a/libraries/entities/src/EntitySimulation.h +++ b/libraries/entities/src/EntitySimulation.h @@ -61,8 +61,6 @@ public: void clearEntities(); - virtual void bump(EntityItem* bumpEntity) {} - EntityTree* getEntityTree() { return _entityTree; } signals: diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index a41deb174f..5b15aa26b4 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -269,9 +269,6 @@ void EntityTree::deleteEntity(const EntityItemID& entityID, bool force, bool ign return; } - // in case something is resting on top of this, give it a bump in the simulation. - _simulation->bump(existingEntity); - if (existingEntity->getLocked() && !force) { if (!ignoreWarnings) { qCDebug(entities) << "ERROR! EntityTree::deleteEntity() trying to delete locked entity. entityID=" << entityID; diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 20472b625c..382cc5a734 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -328,8 +328,6 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ qCDebug(physics) << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()..."; #endif - qDebug() << "sending"; - entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties); } else { #ifdef WANT_DEBUG diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 074500f719..88d6112772 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -386,9 +386,15 @@ void PhysicsEngine::bump(EntityItem* bumpEntity) { if (entityA && entityB) { if (entityA == bumpEntity) { entityB->setShouldClaimSimulationOwnership(true); + if (!objectB->isActive()) { + objectB->setActivationState(ACTIVE_TAG); + } } if (entityB == bumpEntity) { entityA->setShouldClaimSimulationOwnership(true); + if (!objectA->isActive()) { + objectA->setActivationState(ACTIVE_TAG); + } } } } @@ -564,6 +570,8 @@ void PhysicsEngine::addObject(const ShapeInfo& shapeInfo, btCollisionShape* shap void PhysicsEngine::removeObjectFromBullet(ObjectMotionState* motionState) { assert(motionState); + EntityItem* entity = static_cast(motionState)->getEntity(); + bump(entity); btRigidBody* body = motionState->getRigidBody(); if (body) { const btCollisionShape* shape = body->getCollisionShape(); diff --git a/libraries/physics/src/PhysicsEngine.h b/libraries/physics/src/PhysicsEngine.h index 63ec96d04e..148261c6d2 100644 --- a/libraries/physics/src/PhysicsEngine.h +++ b/libraries/physics/src/PhysicsEngine.h @@ -68,7 +68,6 @@ public: void stepSimulation(); void stepNonPhysicalKinematics(const quint64& now); - virtual void bump(EntityItem* bumpEntity); void computeCollisionEvents(); void dumpStatsIfNecessary(); @@ -99,6 +98,7 @@ private: // return 'true' of update was successful bool updateObjectHard(btRigidBody* body, ObjectMotionState* motionState, uint32_t flags); void updateObjectEasy(btRigidBody* body, ObjectMotionState* motionState, uint32_t flags); + void bump(EntityItem* bumpEntity); btClock _clock; btDefaultCollisionConfiguration* _collisionConfig = NULL;