diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 9cd0c2e4e4..24b4786759 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -575,26 +575,7 @@ namespace MWWorld return cellsPositionsToLoad; }; - for(const auto& cell : mActiveCells) - { - cell->forEach([&](const MWWorld::Ptr& ptr) - { - if(ptr.mRef->mData.mPhysicsPostponed) - { - ptr.mRef->mData.mPhysicsPostponed = false; - if (ptr.mRef->mData.isEnabled() && ptr.mRef->mData.getCount() > 0) - { - std::string model = getModel(ptr, MWBase::Environment::get().getResourceSystem()->getVFS()); - if (!model.empty()) - { - const auto rotation = makeNodeRotation(ptr, RotationOrder::direct); - ptr.getClass().insertObjectPhysics(ptr, model, rotation, *mPhysics); - } - } - } - return true; - }); - } + addPostponedPhysicsObjects(); auto cellsPositionsToLoad = cellsToLoad(mActiveCells,mHalfGridSize); @@ -637,6 +618,30 @@ namespace MWWorld mNavigator.wait(*loadingListener, DetourNavigator::WaitConditionType::requiredTilesPresent); } + void Scene::addPostponedPhysicsObjects() + { + for(const auto& cell : mActiveCells) + { + cell->forEach([&](const MWWorld::Ptr& ptr) + { + if(ptr.mRef->mData.mPhysicsPostponed) + { + ptr.mRef->mData.mPhysicsPostponed = false; + if (ptr.mRef->mData.isEnabled() && ptr.mRef->mData.getCount() > 0) + { + std::string model = getModel(ptr, MWBase::Environment::get().getResourceSystem()->getVFS()); + if (!model.empty()) + { + const auto rotation = makeNodeRotation(ptr, RotationOrder::direct); + ptr.getClass().insertObjectPhysics(ptr, model, rotation, *mPhysics); + } + } + } + return true; + }); + } + } + void Scene::testExteriorCells() { // Note: temporary disable ICO to decrease memory usage diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index fd66d71cf2..c504a2cf73 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -174,6 +174,8 @@ namespace MWWorld void removeObjectFromScene (const Ptr& ptr, bool keepActive = false); ///< Remove an object from the scene, but not from the world model. + void addPostponedPhysicsObjects(); + void removeFromPagedRefs(const Ptr &ptr); void updateObjectRotation(const Ptr& ptr, RotationOrder order); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 0c0b3d593d..bec6a9064a 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -881,7 +881,10 @@ namespace MWWorld } if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end() && reference.getRefData().getCount()) + { mWorldScene->removeObjectFromScene (reference); + mWorldScene->addPostponedPhysicsObjects(); + } } void World::advanceTime (double hours, bool incremental)