mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 21:39:41 +00:00
Merge branch 'reuse_actors_positions_buffer' into 'master'
Reuse physics actors positions buffer See merge request OpenMW/openmw!2384
This commit is contained in:
commit
b9ff117dfe
2 changed files with 5 additions and 4 deletions
|
@ -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…
Reference in a new issue