oops, forgot to add entities to Bullet simulation

This commit is contained in:
Andrew Meadows 2014-12-02 15:44:07 -08:00
parent a21ebe4f6a
commit 9f11121df2

View file

@ -50,7 +50,6 @@ void PhysicsEngine::updateEntities(QSet<EntityItem*>& entitiesToDelete) {
updateObject(motionState, entity->getUpdateFlags()); updateObject(motionState, entity->getUpdateFlags());
} }
entity->clearUpdateFlags(); entity->clearUpdateFlags();
// TODO: implement this
++item_itr; ++item_itr;
} }
@ -81,11 +80,16 @@ void PhysicsEngine::addEntity(EntityItem* entity) {
assert(entity); assert(entity);
void* physicsInfo = entity->getPhysicsInfo(); void* physicsInfo = entity->getPhysicsInfo();
if (!physicsInfo) { if (!physicsInfo) {
EntityMotionState* motionState = new EntityMotionState(entity);
entity->setPhysicsInfo(static_cast<void*>(motionState));
if (entity->isMortal()) { if (entity->isMortal()) {
_mortalEntities.insert(entity); _mortalEntities.insert(entity);
} }
EntityMotionState* motionState = new EntityMotionState(entity);
if (addObject(motionState)) {
entity->setPhysicsInfo(static_cast<void*>(motionState));
} else {
// We failed to add the object to the simulation. Probably because we couldn't create a shape for it.
delete motionState;
}
} }
} }