mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:19:05 +02:00
more finely grained Bullet profiling
This commit is contained in:
parent
c35ddccba1
commit
771727890c
3 changed files with 27 additions and 1 deletions
|
@ -252,6 +252,7 @@ void PhysicsEngine::stepSimulation() {
|
||||||
float timeStep = btMin(dt, MAX_TIMESTEP);
|
float timeStep = btMin(dt, MAX_TIMESTEP);
|
||||||
|
|
||||||
if (_myAvatarController) {
|
if (_myAvatarController) {
|
||||||
|
BT_PROFILE("avatarController");
|
||||||
// TODO: move this stuff outside and in front of stepSimulation, because
|
// TODO: move this stuff outside and in front of stepSimulation, because
|
||||||
// the updateShapeIfNecessary() call needs info from MyAvatar and should
|
// the updateShapeIfNecessary() call needs info from MyAvatar and should
|
||||||
// be done on the main thread during the pre-simulation stuff
|
// be done on the main thread during the pre-simulation stuff
|
||||||
|
|
|
@ -67,7 +67,10 @@ int ThreadSafeDynamicsWorld::stepSimulationWithSubstepCallback(btScalar timeStep
|
||||||
|
|
||||||
saveKinematicState(fixedTimeStep*clampedSimulationSteps);
|
saveKinematicState(fixedTimeStep*clampedSimulationSteps);
|
||||||
|
|
||||||
applyGravity();
|
{
|
||||||
|
BT_PROFILE("applyGravity");
|
||||||
|
applyGravity();
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0;i<clampedSimulationSteps;i++) {
|
for (int i=0;i<clampedSimulationSteps;i++) {
|
||||||
internalSingleStepSimulation(fixedTimeStep);
|
internalSingleStepSimulation(fixedTimeStep);
|
||||||
|
@ -143,3 +146,24 @@ void ThreadSafeDynamicsWorld::synchronizeMotionStates() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThreadSafeDynamicsWorld::saveKinematicState(btScalar timeStep) {
|
||||||
|
///would like to iterate over m_nonStaticRigidBodies, but unfortunately old API allows
|
||||||
|
///to switch status _after_ adding kinematic objects to the world
|
||||||
|
///fix it for Bullet 3.x release
|
||||||
|
BT_PROFILE("saveKinematicState");
|
||||||
|
for (int i=0;i<m_collisionObjects.size();i++)
|
||||||
|
{
|
||||||
|
btCollisionObject* colObj = m_collisionObjects[i];
|
||||||
|
btRigidBody* body = btRigidBody::upcast(colObj);
|
||||||
|
if (body && body->getActivationState() != ISLAND_SLEEPING)
|
||||||
|
{
|
||||||
|
if (body->isKinematicObject())
|
||||||
|
{
|
||||||
|
//to calculate velocities next frame
|
||||||
|
body->saveKinematicState(timeStep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
btScalar fixedTimeStep = btScalar(1.)/btScalar(60.),
|
btScalar fixedTimeStep = btScalar(1.)/btScalar(60.),
|
||||||
SubStepCallback onSubStep = []() { });
|
SubStepCallback onSubStep = []() { });
|
||||||
virtual void synchronizeMotionStates() override;
|
virtual void synchronizeMotionStates() override;
|
||||||
|
virtual void saveKinematicState(btScalar timeStep) override;
|
||||||
|
|
||||||
// btDiscreteDynamicsWorld::m_localTime is the portion of real-time that has not yet been simulated
|
// btDiscreteDynamicsWorld::m_localTime is the portion of real-time that has not yet been simulated
|
||||||
// but is used for MotionState::setWorldTransform() extrapolation (a feature that Bullet uses to provide
|
// but is used for MotionState::setWorldTransform() extrapolation (a feature that Bullet uses to provide
|
||||||
|
|
Loading…
Reference in a new issue