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

This commit is contained in:
Seth Alves 2015-05-06 11:20:39 -07:00
parent 7a5fe8a34e
commit 129a3a82da
3 changed files with 5 additions and 1 deletions

View file

@ -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

View file

@ -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 {

View file

@ -126,6 +126,8 @@ void PhysicsEngine::addObject(ObjectMotionState* motionState) {
motionState->updateBodyMaterialProperties();
_dynamicsWorld->addRigidBody(body);
motionState->getAndClearIncomingDirtyFlags();
}
void PhysicsEngine::removeObject(ObjectMotionState* object) {