From 9f11121df2d8832608773157521b1fd2e141172d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 2 Dec 2014 15:44:07 -0800 Subject: [PATCH] oops, forgot to add entities to Bullet simulation --- libraries/physics/src/PhysicsEngine.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 8e192e4279..80eb43a0cf 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -50,7 +50,6 @@ void PhysicsEngine::updateEntities(QSet& entitiesToDelete) { updateObject(motionState, entity->getUpdateFlags()); } entity->clearUpdateFlags(); - // TODO: implement this ++item_itr; } @@ -81,11 +80,16 @@ void PhysicsEngine::addEntity(EntityItem* entity) { assert(entity); void* physicsInfo = entity->getPhysicsInfo(); if (!physicsInfo) { - EntityMotionState* motionState = new EntityMotionState(entity); - entity->setPhysicsInfo(static_cast(motionState)); if (entity->isMortal()) { _mortalEntities.insert(entity); } + EntityMotionState* motionState = new EntityMotionState(entity); + if (addObject(motionState)) { + entity->setPhysicsInfo(static_cast(motionState)); + } else { + // We failed to add the object to the simulation. Probably because we couldn't create a shape for it. + delete motionState; + } } }