Showing the changes to interface/src/Application.cpp (1 of 9 files). Show all
Unified · Split
| @@ -4846,8 +4846,7 @@ void Application::update(float deltaTime) { · 4845 unmodified lines | |||
| 4846 | if (_physicsEnabled) { | 4846 | if (_physicsEnabled) { |
| 4847 | { | 4847 | { |
| 4848 | PROFILE_RANGE(simulation_physics, "PreStep"); | 4848 | PROFILE_RANGE(simulation_physics, "PreStep"); |
| 4849 | 4849 | PerformanceTimer perfTimer("preStep)"); | |
| 4850 | PerformanceTimer perfTimer("updateStates)"); | ||
| 4851 | static VectorOfMotionStates motionStates; | 4850 | static VectorOfMotionStates motionStates; |
| 4852 | _entitySimulation->getObjectsToRemoveFromPhysics(motionStates); | 4851 | _entitySimulation->getObjectsToRemoveFromPhysics(motionStates); |
| 4853 | _physicsEngine->removeObjects(motionStates); | 4852 | _physicsEngine->removeObjects(motionStates); |
| @@ -4880,22 +4879,22 @@ void Application::update(float deltaTime) { · 26 unmodified lines | |||
| 4880 | } | 4879 | } |
| 4881 | { | 4880 | { |
| 4882 | PROFILE_RANGE(simulation_physics, "Step"); | 4881 | PROFILE_RANGE(simulation_physics, "Step"); |
| 4883 | PerformanceTimer perfTimer("stepSimulation"); | 4882 | PerformanceTimer perfTimer("step"); |
| 4884 | getEntities()->getTree()->withWriteLock([&] { | 4883 | getEntities()->getTree()->withWriteLock([&] { |
| 4885 | _physicsEngine->stepSimulation(); | 4884 | _physicsEngine->stepSimulation(); |
| 4886 | }); | 4885 | }); |
| 4887 | } | 4886 | } |
| 4888 | { | 4887 | { |
| 4889 | PROFILE_RANGE(simulation_physics, "PostStep"); | 4888 | PROFILE_RANGE(simulation_physics, "PostStep"); |
| 4890 | PerformanceTimer perfTimer("harvestChanges"); | 4889 | PerformanceTimer perfTimer("postStep"); |
| 4891 | if (_physicsEngine->hasOutgoingChanges()) { | 4890 | if (_physicsEngine->hasOutgoingChanges()) { |
| 4892 | // grab the collision events BEFORE handleOutgoingChanges() because at this point | 4891 | // grab the collision events BEFORE handleOutgoingChanges() because at this point |
| 4893 | // we have a better idea of which objects we own or should own. | 4892 | // we have a better idea of which objects we own or should own. |
| 4894 | auto& collisionEvents = _physicsEngine->getCollisionEvents(); | 4893 | auto& collisionEvents = _physicsEngine->getCollisionEvents(); |
| 4895 | 4894 | ||
| 4896 | getEntities()->getTree()->withWriteLock([&] { | 4895 | getEntities()->getTree()->withWriteLock([&] { |
| 4897 | PROFILE_RANGE(simulation_physics, "Harvest"); | 4896 | PROFILE_RANGE(simulation_physics, "HandleChanges"); |
| 4898 | PerformanceTimer perfTimer("handleOutgoingChanges"); | 4897 | PerformanceTimer perfTimer("handleChanges"); |
| 4899 | 4898 | ||
| 4900 | const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); | 4899 | const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); |
| 4901 | _entitySimulation->handleChangedMotionStates(outgoingChanges); | 4900 | _entitySimulation->handleChangedMotionStates(outgoingChanges); |
| @@ -4906,17 +4905,15 @@ void Application::update(float deltaTime) { · 4 unmodified lines | |||
| 4906 | }); | 4905 | }); |
| 4907 | 4906 | ||
| 4908 | if (!_aboutToQuit) { | 4907 | if (!_aboutToQuit) { |
| 4909 | // handleCollisionEvents() AFTER handleOutgoinChanges() | 4908 | // handleCollisionEvents() AFTER handleOutgoingChanges() |
| 4910 | { | 4909 | { |
| 4911 | PROFILE_RANGE(simulation_physics, "CollisionEvents"); | 4910 | PROFILE_RANGE(simulation_physics, "CollisionEvents"); |
| 4912 | PerformanceTimer perfTimer("entities"); | ||
| 4913 | avatarManager->handleCollisionEvents(collisionEvents); | 4911 | avatarManager->handleCollisionEvents(collisionEvents); |
| 4914 | // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk | 4912 | // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk |
| 4915 | // deadlock.) | 4913 | // deadlock.) |
| 4916 | _entitySimulation->handleCollisionEvents(collisionEvents); | 4914 | _entitySimulation->handleCollisionEvents(collisionEvents); |
| 4917 | } | 4915 | } |
| 4918 | 4916 | ||
| 4919 | PROFILE_RANGE(simulation_physics, "UpdateEntities"); | ||
| 4920 | // NOTE: the getEntities()->update() call below will wait for lock | 4917 | // NOTE: the getEntities()->update() call below will wait for lock |
| 4921 | // and will simulate entity motion (the EntityTree has been given an EntitySimulation). | 4918 | // and will simulate entity motion (the EntityTree has been given an EntitySimulation). |
| 4922 | getEntities()->update(true); // update the models... | 4919 | getEntities()->update(true); // update the models... |
| @@ -4927,7 +4924,8 @@ void Application::update(float deltaTime) { · 4 unmodified lines | |||
| 4927 | myAvatar->harvestResultsFromPhysicsSimulation(deltaTime); | 4924 | myAvatar->harvestResultsFromPhysicsSimulation(deltaTime); |
| 4928 | } | 4925 | } |
| 4929 | 4926 | ||
| 4930 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) && | 4927 | if (PerformanceTimer::isActive() && |
| 4928 | Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) && | ||
| 4931 | Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming)) { | 4929 | Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming)) { |
| 4932 | _physicsEngine->harvestPerformanceStats(); | 4930 | _physicsEngine->harvestPerformanceStats(); |
| 4933 | } | 4931 | } |