cleanup: split stats dump out of stepSimulation

This commit is contained in:
Andrew Meadows 2015-04-14 09:00:36 -07:00
parent f969517ab0
commit abb40ca080
3 changed files with 67 additions and 64 deletions

View file

@ -2226,6 +2226,7 @@ void Application::update(float deltaTime) {
PerformanceTimer perfTimer("physics");
_myAvatar->relayDriveKeysToCharacterController();
_physicsEngine.stepSimulation();
_physicsEngine.dumpStatsIfNecessary();
}
if (!_aboutToQuit) {

View file

@ -288,7 +288,6 @@ void PhysicsEngine::init(EntityEditPacketSender* packetSender) {
}
void PhysicsEngine::stepSimulation() {
{
lock();
CProfileManager::Reset();
BT_PROFILE("stepSimulation");
@ -336,6 +335,7 @@ void PhysicsEngine::stepSimulation() {
// lock on the tree before we re-lock ourselves.
//
// TODO: untangle these lock sequences.
ObjectMotionState::setSimulationStep(_numSubsteps);
_entityTree->lockForWrite();
lock();
_dynamicsWorld->synchronizeMotionStates();
@ -349,16 +349,12 @@ void PhysicsEngine::stepSimulation() {
computeCollisionEvents();
}
}
if (_dumpNextStats) {
_dumpNextStats = false;
CProfileManager::dumpAll();
}
}
void PhysicsEngine::stepNonPhysicalKinematics(const quint64& now) {
BT_PROFILE("nonPhysicalKinematics");
QSet<ObjectMotionState*>::iterator stateItr = _nonPhysicalKinematicObjects.begin();
// TODO?: need to occasionally scan for stopped non-physical kinematics objects
while (stateItr != _nonPhysicalKinematicObjects.end()) {
ObjectMotionState* motionState = *stateItr;
motionState->stepKinematicSimulation(now);
@ -366,8 +362,6 @@ void PhysicsEngine::stepNonPhysicalKinematics(const quint64& now) {
}
}
// TODO?: need to occasionally scan for stopped non-physical kinematics objects
void PhysicsEngine::computeCollisionEvents() {
BT_PROFILE("computeCollisionEvents");
// update all contacts every frame
@ -445,6 +439,13 @@ void PhysicsEngine::computeCollisionEvents() {
}
}
void PhysicsEngine::dumpStatsIfNecessary() {
if (_dumpNextStats) {
_dumpNextStats = false;
CProfileManager::dumpAll();
}
}
// Bullet collision flags are as follows:
// CF_STATIC_OBJECT= 1,
// CF_KINEMATIC_OBJECT= 2,

View file

@ -68,9 +68,10 @@ public:
void stepSimulation();
void stepNonPhysicalKinematics(const quint64& now);
void computeCollisionEvents();
void dumpStatsIfNecessary();
/// \param offset position of simulation origin in domain-frame
void setOriginOffset(const glm::vec3& offset) { _originOffset = offset; }