Merge branch 'reuse_actors_positions_buffer' into 'master'

Reuse physics actors positions buffer

See merge request OpenMW/openmw!2384
crashfix_debugdraw
psi29a 2 years ago
commit b9ff117dfe

@ -798,16 +798,16 @@ namespace MWPhysics
const auto world = MWBase::Environment::get().getWorld();
// 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);
mActorsPositions.clear();
mActorsPositions.reserve(mActors.size() - 1);
for (const auto& [ptr, physicActor] : mActors)
{
if (physicActor.get() == player)
continue;
newPositions.emplace_back(physicActor->getPtr(), physicActor->getSimulationPosition());
mActorsPositions.emplace_back(physicActor->getPtr(), physicActor->getSimulationPosition());
}
for (auto& [ptr, pos] : newPositions)
for (const auto& [ptr, pos] : mActorsPositions)
world->moveObject(ptr, pos, false, false);
world->moveObject(player->getPtr(), player->getSimulationPosition(), false, false);

@ -335,6 +335,7 @@ namespace MWPhysics
std::size_t mSimulationsCounter = 0;
std::array<std::vector<Simulation>, 2> mSimulations;
std::vector<std::pair<MWWorld::Ptr, osg::Vec3f>> mActorsPositions;
PhysicsSystem (const PhysicsSystem&);
PhysicsSystem& operator= (const PhysicsSystem&);

Loading…
Cancel
Save