1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 22:20:33 +00:00

Replace movement() with eraseMovementIf()

This commit is contained in:
Mads Buvik Sandvei 2023-12-18 22:50:17 +01:00
parent 5a6dbf8714
commit 00b1cd8c08
2 changed files with 3 additions and 4 deletions

View File

@ -207,8 +207,7 @@ namespace
osg::Vec3f takeMovement(MWPhysics::PtrHolder& actor, float startTime, float endTime) const osg::Vec3f takeMovement(MWPhysics::PtrHolder& actor, float startTime, float endTime) const
{ {
osg::Vec3f movement = osg::Vec3f(); osg::Vec3f movement = osg::Vec3f();
auto it = actor.movement().begin(); actor.eraseMovementIf([&](MWPhysics::Movement& v) {
std::erase_if(actor.movement(), [&](MWPhysics::Movement& v) {
if (v.mJump) if (v.mJump)
return false; return false;
float start = std::max(v.mSimulationTimeStart, startTime); float start = std::max(v.mSimulationTimeStart, startTime);
@ -225,7 +224,7 @@ namespace
std::optional<osg::Vec3f> takeInertia(MWPhysics::PtrHolder& actor, float startTime) const std::optional<osg::Vec3f> takeInertia(MWPhysics::PtrHolder& actor, float startTime) const
{ {
std::optional<osg::Vec3f> inertia = std::nullopt; std::optional<osg::Vec3f> inertia = std::nullopt;
std::erase_if(actor.movement(), [&](MWPhysics::Movement& v) { actor.eraseMovementIf([&](MWPhysics::Movement& v) {
if (v.mJump && v.mSimulationTimeStart >= startTime) if (v.mJump && v.mSimulationTimeStart >= startTime)
{ {
inertia = v.mVelocity; inertia = v.mVelocity;

View File

@ -47,7 +47,7 @@ namespace MWPhysics
mMovement.push_back(Movement{ velocity, simulationTimeStart, simulationTimeStop, jump }); mMovement.push_back(Movement{ velocity, simulationTimeStart, simulationTimeStop, jump });
} }
std::list<Movement>& movement() { return mMovement; } void eraseMovementIf(const auto& predicate) { std::erase_if(mMovement, predicate); }
void setSimulationPosition(const osg::Vec3f& position) { mSimulationPosition = position; } void setSimulationPosition(const osg::Vec3f& position) { mSimulationPosition = position; }