History

Merge pull request #11965 from AndrewMeadows/expose-physics-perf-stats-to-js

Cleanup names of debug stats and trace contexts.

Andrew Meadows committed 8 years ago

Commit cfd20972 parents 4d42dba 87fa91918 files · +264 −120Browse files

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

Unified · Split

interface/src/Application.cpp+13−12
@@ -3222,8 +3222,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3221 unmodified lines
3222 }3222 }
3223}3223}
3224 3224
3225
3226
3227void Application::keyReleaseEvent(QKeyEvent* event) {3225void Application::keyReleaseEvent(QKeyEvent* event) {
3228 _keysPressed.remove(event->key());3226 _keysPressed.remove(event->key());
3229 3227
@@ -4848,8 +4846,7 @@ void Application::update(float deltaTime) { · 1618 unmodified lines
4848 if (_physicsEnabled) {4846 if (_physicsEnabled) {
4849 {4847 {
4850 PROFILE_RANGE(simulation_physics, "PreStep");4848 PROFILE_RANGE(simulation_physics, "PreStep");
4851 4849 PerformanceTimer perfTimer("preStep)");
4852 PerformanceTimer perfTimer("updateStates)");
4853 static VectorOfMotionStates motionStates;4850 static VectorOfMotionStates motionStates;
4854 _entitySimulation->getObjectsToRemoveFromPhysics(motionStates);4851 _entitySimulation->getObjectsToRemoveFromPhysics(motionStates);
4855 _physicsEngine->removeObjects(motionStates);4852 _physicsEngine->removeObjects(motionStates);
@@ -4882,22 +4879,22 @@ void Application::update(float deltaTime) { · 26 unmodified lines
4882 }4879 }
4883 {4880 {
4884 PROFILE_RANGE(simulation_physics, "Step");4881 PROFILE_RANGE(simulation_physics, "Step");
4885 PerformanceTimer perfTimer("stepSimulation");4882 PerformanceTimer perfTimer("step");
4886 getEntities()->getTree()->withWriteLock([&] {4883 getEntities()->getTree()->withWriteLock([&] {
4887 _physicsEngine->stepSimulation();4884 _physicsEngine->stepSimulation();
4888 });4885 });
4889 }4886 }
4890 {4887 {
4891 PROFILE_RANGE(simulation_physics, "PostStep");4888 PROFILE_RANGE(simulation_physics, "PostStep");
4892 PerformanceTimer perfTimer("harvestChanges");4889 PerformanceTimer perfTimer("postStep");
4893 if (_physicsEngine->hasOutgoingChanges()) {4890 if (_physicsEngine->hasOutgoingChanges()) {
4894 // grab the collision events BEFORE handleOutgoingChanges() because at this point4891 // grab the collision events BEFORE handleOutgoingChanges() because at this point
4895 // 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.
4896 auto& collisionEvents = _physicsEngine->getCollisionEvents();4893 auto& collisionEvents = _physicsEngine->getCollisionEvents();
4897 4894
4898 getEntities()->getTree()->withWriteLock([&] {4895 getEntities()->getTree()->withWriteLock([&] {
4899 PROFILE_RANGE(simulation_physics, "Harvest");4896 PROFILE_RANGE(simulation_physics, "HandleChanges");
4900 PerformanceTimer perfTimer("handleOutgoingChanges");4897 PerformanceTimer perfTimer("handleChanges");
4901 4898
4902 const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates();4899 const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates();
4903 _entitySimulation->handleChangedMotionStates(outgoingChanges);4900 _entitySimulation->handleChangedMotionStates(outgoingChanges);
@@ -4908,17 +4905,15 @@ void Application::update(float deltaTime) { · 4 unmodified lines
4908 });4905 });
4909 4906
4910 if (!_aboutToQuit) {4907 if (!_aboutToQuit) {
4911 // handleCollisionEvents() AFTER handleOutgoinChanges()4908 // handleCollisionEvents() AFTER handleOutgoingChanges()
4912 {4909 {
4913 PROFILE_RANGE(simulation_physics, "CollisionEvents");4910 PROFILE_RANGE(simulation_physics, "CollisionEvents");
4914 PerformanceTimer perfTimer("entities");
4915 avatarManager->handleCollisionEvents(collisionEvents);4911 avatarManager->handleCollisionEvents(collisionEvents);
4916 // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk4912 // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk
4917 // deadlock.)4913 // deadlock.)
4918 _entitySimulation->handleCollisionEvents(collisionEvents);4914 _entitySimulation->handleCollisionEvents(collisionEvents);
4919 }4915 }
4920 4916
4921 PROFILE_RANGE(simulation_physics, "UpdateEntities");
4922 // NOTE: the getEntities()->update() call below will wait for lock4917 // NOTE: the getEntities()->update() call below will wait for lock
4923 // 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).
4924 getEntities()->update(true); // update the models...4919 getEntities()->update(true); // update the models...
@@ -4929,7 +4924,8 @@ void Application::update(float deltaTime) { · 4 unmodified lines
4929 myAvatar->harvestResultsFromPhysicsSimulation(deltaTime);4924 myAvatar->harvestResultsFromPhysicsSimulation(deltaTime);
4930 }4925 }
4931 4926
4932 if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) &&4927 if (PerformanceTimer::isActive() &&
4928 Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) &&
4933 Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming)) {4929 Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming)) {
4934 _physicsEngine->harvestPerformanceStats();4930 _physicsEngine->harvestPerformanceStats();
4935 }4931 }
@@ -7506,4 +7502,9 @@ void Application::setAvatarOverrideUrl(const QUrl& url, bool save) { · 2570 unmodified lines
7506 _avatarOverrideUrl = url;7502 _avatarOverrideUrl = url;
7507 _saveAvatarOverrideUrl = save;7503 _saveAvatarOverrideUrl = save;
7508}7504}
7505
7506void Application::saveNextPhysicsStats(QString filename) {
7507 _physicsEngine->saveNextPhysicsStats(filename);
7508}
7509
7509#include "Application.moc"7510#include "Application.moc"