Merge branch 'nova' of github.com:AndrewMeadows/hifi into dice-on-table-1

This commit is contained in:
Seth Alves 2015-05-06 16:05:13 -07:00
commit e73503a53d
3 changed files with 10 additions and 3 deletions

View file

@ -2419,15 +2419,19 @@ void Application::update(float deltaTime) {
PerformanceTimer perfTimer("physics"); PerformanceTimer perfTimer("physics");
_myAvatar->relayDriveKeysToCharacterController(); _myAvatar->relayDriveKeysToCharacterController();
_entitySimulation.lock();
_physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete()); _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete());
_physicsEngine.addObjects(_entitySimulation.getObjectsToAdd()); _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd());
_physicsEngine.changeObjects(_entitySimulation.getObjectsToChange()); _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());
_entitySimulation.unlock();
_physicsEngine.stepSimulation(); _physicsEngine.stepSimulation();
if (_physicsEngine.hasOutgoingChanges()) { if (_physicsEngine.hasOutgoingChanges()) {
_entitySimulation.lock();
_entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges()); _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges());
_entitySimulation.handleCollisionEvents(_physicsEngine.getCollisionEvents()); _entitySimulation.handleCollisionEvents(_physicsEngine.getCollisionEvents());
_entitySimulation.unlock();
_physicsEngine.dumpStatsIfNecessary(); _physicsEngine.dumpStatsIfNecessary();
} }
} }

View file

@ -194,8 +194,11 @@ void PhysicalEntitySimulation::handleOutgoingChanges(VectorOfMotionStates& motio
ObjectMotionState* state = &(*stateItr); ObjectMotionState* state = &(*stateItr);
if (state && state->getType() == MOTION_STATE_TYPE_ENTITY) { if (state && state->getType() == MOTION_STATE_TYPE_ENTITY) {
EntityMotionState* entityState = static_cast<EntityMotionState*>(state); EntityMotionState* entityState = static_cast<EntityMotionState*>(state);
_outgoingChanges.insert(entityState); EntityItem* entity = entityState->getEntity();
_entitiesToSort.insert(entityState->getEntity()); if (entity) {
_outgoingChanges.insert(entityState);
_entitiesToSort.insert(entityState->getEntity());
}
} }
} }

View file

@ -178,7 +178,7 @@ void PhysicsEngine::changeObjects(VectorOfMotionStates& objects) {
uint32_t flags = object->getAndClearIncomingDirtyFlags() & DIRTY_PHYSICS_FLAGS; uint32_t flags = object->getAndClearIncomingDirtyFlags() & DIRTY_PHYSICS_FLAGS;
if (flags & HARD_DIRTY_PHYSICS_FLAGS) { if (flags & HARD_DIRTY_PHYSICS_FLAGS) {
object->handleHardAndEasyChanges(flags, this); object->handleHardAndEasyChanges(flags, this);
} else { } else if (flags & EASY_DIRTY_PHYSICS_FLAGS) {
object->handleEasyChanges(flags); object->handleEasyChanges(flags);
} }
} }