mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 07:17:43 +02:00
Fix collision start/end in single physics simulation to be lost
This commit is contained in:
parent
5cf936f132
commit
837430329b
3 changed files with 13 additions and 5 deletions
|
@ -251,7 +251,12 @@ void PhysicsEngine::stepSimulation() {
|
||||||
_characterController->preSimulation(timeStep);
|
_characterController->preSimulation(timeStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, PHYSICS_ENGINE_MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP);
|
auto onSubStep = [this]() {
|
||||||
|
updateContactMap();
|
||||||
|
_hasOutgoingChanges = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, PHYSICS_ENGINE_MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP, onSubStep);
|
||||||
if (numSubsteps > 0) {
|
if (numSubsteps > 0) {
|
||||||
BT_PROFILE("postSimulation");
|
BT_PROFILE("postSimulation");
|
||||||
_numSubsteps += (uint32_t)numSubsteps;
|
_numSubsteps += (uint32_t)numSubsteps;
|
||||||
|
@ -260,8 +265,6 @@ void PhysicsEngine::stepSimulation() {
|
||||||
if (_characterController) {
|
if (_characterController) {
|
||||||
_characterController->postSimulation();
|
_characterController->postSimulation();
|
||||||
}
|
}
|
||||||
updateContactMap();
|
|
||||||
_hasOutgoingChanges = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ ThreadSafeDynamicsWorld::ThreadSafeDynamicsWorld(
|
||||||
: btDiscreteDynamicsWorld(dispatcher, pairCache, constraintSolver, collisionConfiguration) {
|
: btDiscreteDynamicsWorld(dispatcher, pairCache, constraintSolver, collisionConfiguration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThreadSafeDynamicsWorld::stepSimulation( btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep) {
|
int ThreadSafeDynamicsWorld::stepSimulation( btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep, SubStepCallback onSubStep) {
|
||||||
BT_PROFILE("stepSimulation");
|
BT_PROFILE("stepSimulation");
|
||||||
int subSteps = 0;
|
int subSteps = 0;
|
||||||
if (maxSubSteps) {
|
if (maxSubSteps) {
|
||||||
|
@ -70,6 +70,7 @@ int ThreadSafeDynamicsWorld::stepSimulation( btScalar timeStep, int maxSubSteps,
|
||||||
|
|
||||||
for (int i=0;i<clampedSimulationSteps;i++) {
|
for (int i=0;i<clampedSimulationSteps;i++) {
|
||||||
internalSingleStepSimulation(fixedTimeStep);
|
internalSingleStepSimulation(fixedTimeStep);
|
||||||
|
onSubStep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
#include "ObjectMotionState.h"
|
#include "ObjectMotionState.h"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
using SubStepCallback = std::function<void()>;
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(class) ThreadSafeDynamicsWorld : public btDiscreteDynamicsWorld {
|
ATTRIBUTE_ALIGNED16(class) ThreadSafeDynamicsWorld : public btDiscreteDynamicsWorld {
|
||||||
public:
|
public:
|
||||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
@ -34,7 +38,7 @@ public:
|
||||||
btCollisionConfiguration* collisionConfiguration);
|
btCollisionConfiguration* collisionConfiguration);
|
||||||
|
|
||||||
// virtual overrides from btDiscreteDynamicsWorld
|
// virtual overrides from btDiscreteDynamicsWorld
|
||||||
int stepSimulation( btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
|
int stepSimulation( btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.), SubStepCallback onSubStep = []() { });
|
||||||
void synchronizeMotionStates();
|
void synchronizeMotionStates();
|
||||||
|
|
||||||
// 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
|
||||||
|
|
Loading…
Reference in a new issue