History

lock the entity tree during physics operations that access then entity tree. if the simulation and entity-tree are both going to be locked, be sure to lock the entity tree first (and unlock it last), because this is what the network-reading thread does

Seth Alves committed 11 years ago

Commit a0d77c01 parent 63812f23 files · +95 −22Browse files

Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all

Unified · Split

interface/src/Application.cpp+21−0
@@ -2496,24 +2496,45 @@ void Application::update(float deltaTime) { · 2495 unmodified lines
2496 2496
2497 _entitySimulation.lock();2497 _entitySimulation.lock();
2498 _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete());2498 _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete());
2499 _entitySimulation.unlock();
2500
2501 _entities.getTree()->lockForWrite();
2502 _entitySimulation.lock();
2499 _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd());2503 _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd());
2504 _entitySimulation.unlock();
2505 _entities.getTree()->unlock();
2506
2507 _entities.getTree()->lockForWrite();
2508 _entitySimulation.lock();
2500 _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());2509 _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());
2510 _entitySimulation.unlock();
2511 _entities.getTree()->unlock();
2512
2513 _entitySimulation.lock();
2501 _entitySimulation.applyActionChanges();2514 _entitySimulation.applyActionChanges();
2502 _entitySimulation.unlock();2515 _entitySimulation.unlock();
2503 2516
2517
2504 AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();2518 AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();
2505 _physicsEngine.deleteObjects(avatarManager->getObjectsToDelete());2519 _physicsEngine.deleteObjects(avatarManager->getObjectsToDelete());
2506 _physicsEngine.addObjects(avatarManager->getObjectsToAdd());2520 _physicsEngine.addObjects(avatarManager->getObjectsToAdd());
2507 _physicsEngine.changeObjects(avatarManager->getObjectsToChange());2521 _physicsEngine.changeObjects(avatarManager->getObjectsToChange());
2508 2522
2523 _entities.getTree()->lockForWrite();
2509 _physicsEngine.stepSimulation();2524 _physicsEngine.stepSimulation();
2525 _entities.getTree()->unlock();
2510 2526
2511 if (_physicsEngine.hasOutgoingChanges()) {2527 if (_physicsEngine.hasOutgoingChanges()) {
2528 _entities.getTree()->lockForWrite();
2512 _entitySimulation.lock();2529 _entitySimulation.lock();
2513 _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges(), _physicsEngine.getSessionID());2530 _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges(), _physicsEngine.getSessionID());
2514 _entitySimulation.unlock();2531 _entitySimulation.unlock();
2532 _entities.getTree()->unlock();
2515 2533
2534 _entities.getTree()->lockForWrite();
2516 avatarManager->handleOutgoingChanges(_physicsEngine.getOutgoingChanges());2535 avatarManager->handleOutgoingChanges(_physicsEngine.getOutgoingChanges());
2536 _entities.getTree()->unlock();
2537
2517 auto collisionEvents = _physicsEngine.getCollisionEvents();2538 auto collisionEvents = _physicsEngine.getCollisionEvents();
2518 avatarManager->handleCollisionEvents(collisionEvents);2539 avatarManager->handleCollisionEvents(collisionEvents);
2519 2540

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t