mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:01:06 +02:00
Merge pull request #7061 from AndrewMeadows/crash-fix
Fix crash when deleting many moving dynamic objects.
This commit is contained in:
commit
3b1db7a522
4 changed files with 7 additions and 5 deletions
|
@ -3158,8 +3158,9 @@ void Application::update(float deltaTime) {
|
||||||
PerformanceTimer perfTimer("havestChanges");
|
PerformanceTimer perfTimer("havestChanges");
|
||||||
if (_physicsEngine->hasOutgoingChanges()) {
|
if (_physicsEngine->hasOutgoingChanges()) {
|
||||||
getEntities()->getTree()->withWriteLock([&] {
|
getEntities()->getTree()->withWriteLock([&] {
|
||||||
_entitySimulation.handleOutgoingChanges(_physicsEngine->getOutgoingChanges(), Physics::getSessionUUID());
|
const VectorOfMotionStates& outgoingChanges = _physicsEngine->getOutgoingChanges();
|
||||||
avatarManager->handleOutgoingChanges(_physicsEngine->getOutgoingChanges());
|
_entitySimulation.handleOutgoingChanges(outgoingChanges, Physics::getSessionUUID());
|
||||||
|
avatarManager->handleOutgoingChanges(outgoingChanges);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto collisionEvents = _physicsEngine->getCollisionEvents();
|
auto collisionEvents = _physicsEngine->getCollisionEvents();
|
||||||
|
|
|
@ -169,6 +169,7 @@ void PhysicalEntitySimulation::getObjectsToRemoveFromPhysics(VectorOfMotionState
|
||||||
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
|
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
|
||||||
assert(motionState);
|
assert(motionState);
|
||||||
_pendingChanges.remove(motionState);
|
_pendingChanges.remove(motionState);
|
||||||
|
_outgoingChanges.remove(motionState);
|
||||||
_physicalObjects.remove(motionState);
|
_physicalObjects.remove(motionState);
|
||||||
result.push_back(motionState);
|
result.push_back(motionState);
|
||||||
_entitiesToRelease.insert(entity);
|
_entitiesToRelease.insert(entity);
|
||||||
|
|
|
@ -115,8 +115,8 @@ void ThreadSafeDynamicsWorld::synchronizeMotionState(btRigidBody* body) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadSafeDynamicsWorld::synchronizeMotionStates() {
|
void ThreadSafeDynamicsWorld::synchronizeMotionStates() {
|
||||||
_changedMotionStates.clear();
|
|
||||||
BT_PROFILE("synchronizeMotionStates");
|
BT_PROFILE("synchronizeMotionStates");
|
||||||
|
_changedMotionStates.clear();
|
||||||
if (m_synchronizeAllMotionStates) {
|
if (m_synchronizeAllMotionStates) {
|
||||||
//iterate over all collision objects
|
//iterate over all collision objects
|
||||||
for (int i=0;i<m_collisionObjects.size();i++) {
|
for (int i=0;i<m_collisionObjects.size();i++) {
|
||||||
|
|
|
@ -40,14 +40,14 @@ public:
|
||||||
int stepSimulationWithSubstepCallback(btScalar timeStep, int maxSubSteps = 1,
|
int stepSimulationWithSubstepCallback(btScalar timeStep, int maxSubSteps = 1,
|
||||||
btScalar fixedTimeStep = btScalar(1.)/btScalar(60.),
|
btScalar fixedTimeStep = btScalar(1.)/btScalar(60.),
|
||||||
SubStepCallback onSubStep = []() { });
|
SubStepCallback onSubStep = []() { });
|
||||||
void synchronizeMotionStates();
|
virtual void synchronizeMotionStates() 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
|
||||||
// smoother rendering of objects when the physics simulation loop is ansynchronous to the render loop).
|
// smoother rendering of objects when the physics simulation loop is ansynchronous to the render loop).
|
||||||
float getLocalTimeAccumulation() const { return m_localTime; }
|
float getLocalTimeAccumulation() const { return m_localTime; }
|
||||||
|
|
||||||
VectorOfMotionStates& getChangedMotionStates() { return _changedMotionStates; }
|
const VectorOfMotionStates& getChangedMotionStates() const { return _changedMotionStates; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// call this instead of non-virtual btDiscreteDynamicsWorld::synchronizeSingleMotionState()
|
// call this instead of non-virtual btDiscreteDynamicsWorld::synchronizeSingleMotionState()
|
||||||
|
|
Loading…
Reference in a new issue