From 9b467e94da0791663b53f75e4fbf3ff1ead77285 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 10 Feb 2016 10:30:06 -0800 Subject: [PATCH 1/4] constify and explicit override --- libraries/physics/src/ThreadSafeDynamicsWorld.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/physics/src/ThreadSafeDynamicsWorld.h b/libraries/physics/src/ThreadSafeDynamicsWorld.h index de37554f56..e9708149da 100644 --- a/libraries/physics/src/ThreadSafeDynamicsWorld.h +++ b/libraries/physics/src/ThreadSafeDynamicsWorld.h @@ -40,14 +40,14 @@ public: int stepSimulationWithSubstepCallback(btScalar timeStep, int maxSubSteps = 1, btScalar fixedTimeStep = btScalar(1.)/btScalar(60.), SubStepCallback onSubStep = []() { }); - void synchronizeMotionStates(); + virtual void synchronizeMotionStates() override; // 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 // smoother rendering of objects when the physics simulation loop is ansynchronous to the render loop). float getLocalTimeAccumulation() const { return m_localTime; } - VectorOfMotionStates& getChangedMotionStates() { return _changedMotionStates; } + const VectorOfMotionStates& getChangedMotionStates() const { return _changedMotionStates; } private: // call this instead of non-virtual btDiscreteDynamicsWorld::synchronizeSingleMotionState() From 4bcb7b1ba90d1940a41bb0009d4fd6ab576375b9 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 10 Feb 2016 10:30:50 -0800 Subject: [PATCH 2/4] more correct profiling --- libraries/physics/src/ThreadSafeDynamicsWorld.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/physics/src/ThreadSafeDynamicsWorld.cpp b/libraries/physics/src/ThreadSafeDynamicsWorld.cpp index d06a9b8e07..b6f3487f1a 100644 --- a/libraries/physics/src/ThreadSafeDynamicsWorld.cpp +++ b/libraries/physics/src/ThreadSafeDynamicsWorld.cpp @@ -115,8 +115,8 @@ void ThreadSafeDynamicsWorld::synchronizeMotionState(btRigidBody* body) { } void ThreadSafeDynamicsWorld::synchronizeMotionStates() { - _changedMotionStates.clear(); BT_PROFILE("synchronizeMotionStates"); + _changedMotionStates.clear(); if (m_synchronizeAllMotionStates) { //iterate over all collision objects for (int i=0;i Date: Wed, 10 Feb 2016 10:31:38 -0800 Subject: [PATCH 3/4] use const reference for std:vector --- interface/src/Application.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index efc482a3b4..e0a6fd967c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3158,8 +3158,9 @@ void Application::update(float deltaTime) { PerformanceTimer perfTimer("havestChanges"); if (_physicsEngine->hasOutgoingChanges()) { getEntities()->getTree()->withWriteLock([&] { - _entitySimulation.handleOutgoingChanges(_physicsEngine->getOutgoingChanges(), Physics::getSessionUUID()); - avatarManager->handleOutgoingChanges(_physicsEngine->getOutgoingChanges()); + const VectorOfMotionStates& outgoingChanges = _physicsEngine->getOutgoingChanges(); + _entitySimulation.handleOutgoingChanges(outgoingChanges, Physics::getSessionUUID()); + avatarManager->handleOutgoingChanges(outgoingChanges); }); auto collisionEvents = _physicsEngine->getCollisionEvents(); From 84fb983da763d237e1b01323d5935b8597df240d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 10 Feb 2016 10:35:33 -0800 Subject: [PATCH 4/4] don't forget to remove from _outgoingChanges --- libraries/physics/src/PhysicalEntitySimulation.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index 71c78b8b86..aaa706b370 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -169,6 +169,7 @@ void PhysicalEntitySimulation::getObjectsToRemoveFromPhysics(VectorOfMotionState EntityMotionState* motionState = static_cast(entity->getPhysicsInfo()); assert(motionState); _pendingChanges.remove(motionState); + _outgoingChanges.remove(motionState); _physicalObjects.remove(motionState); result.push_back(motionState); _entitiesToRelease.insert(entity);