From 129a3a82da30f077b176d1800fc4d23aeeb0cd55 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 6 May 2015 11:20:39 -0700 Subject: [PATCH] clear incoming flags after adding an entity to simulation. If an entity has a shape-type of none, don't keep asking it for a shape --- libraries/physics/src/ObjectMotionState.cpp | 1 + libraries/physics/src/PhysicalEntitySimulation.cpp | 3 ++- libraries/physics/src/PhysicsEngine.cpp | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 2eb63c26d7..022a466ae7 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -158,6 +158,7 @@ void ObjectMotionState::handleHardAndEasyChanges(uint32_t flags, PhysicsEngine* computeObjectShapeInfo(shapeInfo); btCollisionShape* newShape = getShapeManager()->getShape(shapeInfo); if (!newShape) { + qCDebug(physics) << "Warning: failed to generate new shape!"; // failed to generate new shape! --> keep old shape and remove shape-change flag flags &= ~EntityItem::DIRTY_SHAPE; // TODO: force this object out of PhysicsEngine rather than just use the old shape diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index 8d2bd4f7c5..81f147540a 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -153,7 +153,7 @@ VectorOfMotionStates& PhysicalEntitySimulation::getObjectsToAdd() { while (entityItr != _pendingAdds.end()) { EntityItem* entity = *entityItr; assert(!entity->getPhysicsInfo()); - if (entity->getIgnoreForCollisions()) { + if (entity->getShapeType() == SHAPE_TYPE_NONE || entity->getIgnoreForCollisions()) { // this entity should no longer be on the internal _pendingAdds entityItr = _pendingAdds.erase(entityItr); } else if (entity->isReadyToComputeShape()) { @@ -168,6 +168,7 @@ VectorOfMotionStates& PhysicalEntitySimulation::getObjectsToAdd() { _tempVector.push_back(motionState); entityItr = _pendingAdds.erase(entityItr); } else { + qDebug() << "Warning! Failed to generate new shape for entity." << entity->getName(); ++entityItr; } } else { diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 4b90866ce7..b3cde1a9dd 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -126,6 +126,8 @@ void PhysicsEngine::addObject(ObjectMotionState* motionState) { motionState->updateBodyMaterialProperties(); _dynamicsWorld->addRigidBody(body); + + motionState->getAndClearIncomingDirtyFlags(); } void PhysicsEngine::removeObject(ObjectMotionState* object) {