Split physics perf timing into three parts: updateStates, stepSimulation,

and harvestChanges.
This commit is contained in:
howard-stearns 2016-01-13 13:31:37 -08:00
parent 6f85ee135f
commit 8a77e2ee95

View file

@ -3102,7 +3102,10 @@ void Application::update(float deltaTime) {
if (_physicsEnabled) {
PerformanceTimer perfTimer("physics");
AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();
{
PerformanceTimer perfTimer("updateStates)");
static VectorOfMotionStates motionStates;
_entitySimulation.getObjectsToRemoveFromPhysics(motionStates);
_physicsEngine->removeObjects(motionStates);
@ -3120,7 +3123,6 @@ void Application::update(float deltaTime) {
_entitySimulation.applyActionChanges();
AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data();
avatarManager->getObjectsToRemoveFromPhysics(motionStates);
_physicsEngine->removeObjects(motionStates);
avatarManager->getObjectsToAddToPhysics(motionStates);
@ -3132,11 +3134,15 @@ void Application::update(float deltaTime) {
_physicsEngine->forEachAction([&](EntityActionPointer action) {
action->prepareForPhysicsSimulation();
});
}
{
PerformanceTimer perfTimer("stepSimulation");
getEntities()->getTree()->withWriteLock([&] {
_physicsEngine->stepSimulation();
});
}
{
PerformanceTimer perfTimer("havestChanges");
if (_physicsEngine->hasOutgoingChanges()) {
getEntities()->getTree()->withWriteLock([&] {
_entitySimulation.handleOutgoingChanges(_physicsEngine->getOutgoingChanges(), _physicsEngine->getSessionID());
@ -3161,6 +3167,7 @@ void Application::update(float deltaTime) {
myAvatar->harvestResultsFromPhysicsSimulation(deltaTime);
}
}
}
{
PerformanceTimer perfTimer("overlays");