From 6f3028b8f9c81e430a0d884906af9fc46e62c9ef Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 21 Apr 2018 15:27:25 +0300 Subject: [PATCH] Update navigator when unload cell or add/remove object to scene --- apps/openmw/mwworld/scene.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index cee9310bd8..026d067dd8 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -266,7 +266,8 @@ namespace MWWorld ListAndResetObjectsVisitor visitor; (*iter)->forEach(visitor); - const auto playerHalfExtents = mPhysics->getHalfExtents(MWBase::Environment::get().getWorld()->getPlayerPtr()); + const auto player = MWBase::Environment::get().getWorld()->getPlayerPtr(); + const auto playerHalfExtents = mPhysics->getHalfExtents(player); for (const auto& ptr : visitor.mObjects) { if (const auto object = mPhysics->getObject(ptr)) @@ -293,6 +294,8 @@ namespace MWWorld } } + navigator->update(player.getRefData().getPosition().asVec3()); + MWBase::Environment::get().getMechanicsManager()->drop (*iter); mRendering.removeCell(*iter); @@ -689,6 +692,9 @@ namespace MWWorld { addObject(ptr, *mPhysics, mRendering); MWBase::Environment::get().getWorld()->scaleObject(ptr, ptr.getCellRef().getScale()); + const auto navigator = MWBase::Environment::get().getWorld()->getNavigator(); + const auto player = MWBase::Environment::get().getWorld()->getPlayerPtr(); + navigator->update(player.getRefData().getPosition().asVec3()); } catch (std::exception& e) { @@ -702,7 +708,11 @@ namespace MWWorld MWBase::Environment::get().getSoundManager()->stopSound3D (ptr); const auto navigator = MWBase::Environment::get().getWorld()->getNavigator(); if (const auto object = mPhysics->getObject(ptr)) + { navigator->removeObject(reinterpret_cast(object)); + const auto player = MWBase::Environment::get().getWorld()->getPlayerPtr(); + navigator->update(player.getRefData().getPosition().asVec3()); + } else if (const auto actor = mPhysics->getActor(ptr)) { const auto playerHalfExtents = mPhysics->getHalfExtents(MWBase::Environment::get().getWorld()->getPlayerPtr());