mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Merge branch 'copy_before_move' into 'master'
Maybe fix #6259 Closes #6259 See merge request OpenMW/openmw!1197
This commit is contained in:
commit
f8c7664234
@ -813,12 +813,20 @@ namespace MWPhysics
|
|||||||
{
|
{
|
||||||
auto* player = getActor(MWMechanics::getPlayer());
|
auto* player = getActor(MWMechanics::getPlayer());
|
||||||
auto* world = MWBase::Environment::get().getWorld();
|
auto* world = MWBase::Environment::get().getWorld();
|
||||||
for (auto& [ptr, physicActor] : mActors)
|
|
||||||
|
// copy new ptr position in temporary vector. player is handled separately as its movement might change active cell.
|
||||||
|
std::vector<std::pair<MWWorld::Ptr, osg::Vec3f>> newPositions;
|
||||||
|
newPositions.reserve(mActors.size() - 1);
|
||||||
|
for (const auto& [ptr, physicActor] : mActors)
|
||||||
{
|
{
|
||||||
if (physicActor.get() == player)
|
if (physicActor.get() == player)
|
||||||
continue;
|
continue;
|
||||||
world->moveObject(physicActor->getPtr(), physicActor->getSimulationPosition(), false, false);
|
newPositions.emplace_back(physicActor->getPtr(), physicActor->getSimulationPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& [ptr, pos] : newPositions)
|
||||||
|
world->moveObject(ptr, pos, false, false);
|
||||||
|
|
||||||
world->moveObject(player->getPtr(), player->getSimulationPosition(), false, false);
|
world->moveObject(player->getPtr(), player->getSimulationPosition(), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user