diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 07a822ffa..55b6e532c 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -25,7 +25,7 @@ namespace MWWorld } - void PhysicsSystem::doPhysics (float duration, MWWorld::World& world, + std::vector< std::pair > PhysicsSystem::doPhysics (float duration, const std::vector >& actors) { // stop changes to world from being reported back to the physics system @@ -71,13 +71,15 @@ namespace MWWorld } mEngine->stepSimulation(duration); + std::vector< std::pair > response; for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { - OEngine::Physic::PhysicActor* act = it->second; - btVector3 newPos = act->getPosition(); - MWWorld::Ptr ptr = world.getPtrViaHandle (it->first); - world.moveObject (ptr, newPos.x(), newPos.y(), newPos.z()); + btVector3 newPos = it->second->getPosition(); + Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z()); + + response.push_back(std::pair(&it->first, coord)); } + return response; } void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh, diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index 3465c0eae..fde3162ea 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -14,7 +14,7 @@ namespace MWWorld PhysicsSystem (OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng); ~PhysicsSystem (); - void doPhysics (float duration, MWWorld::World& world, + std::vector< std::pair > doPhysics (float duration, const std::vector >& actors); void addObject (const std::string& handle, const std::string& mesh, diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 17830248f..02d0d0d5c 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -713,7 +713,12 @@ namespace MWWorld void World::doPhysics (const std::vector >& actors, float duration) { - mPhysics->doPhysics (duration, *this, actors); + std::vector< std::pair > vectors = mPhysics->doPhysics (duration, actors); + std::vector< std::pair >::iterator it; + for(it = vectors.begin(); it != vectors.end(); it++) { + MWWorld::Ptr ptr = getPtrViaHandle (*it->first); + moveObject (ptr, it->second.x, it->second.y, it->second.z); + } } bool World::toggleCollisionMode()