Merge branch 'revert-78a8f9d6' into 'master'

Revert "Merge branch 'skating-olympics' into 'master'"

See merge request OpenMW/openmw!3696
macos_ci_fix
AnyOldName3 1 year ago
commit 647bd2b572

@ -2,7 +2,6 @@
------
Bug #2623: Snowy Granius doesn't prioritize conjuration spells
Bug #3330: Backward displacement of the character when attacking in 3rd person
Bug #3438: NPCs can't hit bull netch with melee weapons
Bug #3842: Body part skeletons override the main skeleton
Bug #4127: Weapon animation looks choppy

@ -295,13 +295,9 @@ namespace MWBase
/// relative to \a referenceObject (but the object may be placed somewhere else if the wanted location is
/// obstructed).
virtual void queueMovement(
const MWWorld::Ptr& ptr, const osg::Vec3f& velocity, float duration, bool jump = false)
= 0;
virtual void queueMovement(const MWWorld::Ptr& ptr, const osg::Vec3f& velocity) = 0;
///< Queues movement for \a ptr (in local space), to be applied in the next call to
/// doPhysics.
/// \param duration The duration this speed shall be held, starting at current simulation time
/// \param jump Whether the movement shall be run over time, or immediately added as inertia instead
virtual void updateAnimatedCollisionShape(const MWWorld::Ptr& ptr) = 0;

@ -2416,9 +2416,7 @@ namespace MWMechanics
}
if (!isMovementAnimationControlled() && !isScriptedAnimPlaying())
{
world->queueMovement(mPtr, vec, duration, mInJump && mJumpState == JumpState_None);
}
world->queueMovement(mPtr, vec);
}
movement = vec;
@ -2491,7 +2489,7 @@ namespace MWMechanics
}
// Update movement
world->queueMovement(mPtr, movement, duration, mInJump && mJumpState == JumpState_None);
world->queueMovement(mPtr, movement);
}
mSkipAnim = false;

@ -170,8 +170,6 @@ namespace MWPhysics
}
// Now that we have the effective movement vector, apply wind forces to it
// TODO: This will cause instability in idle animations and other in-place animations. Should include a flag for
// this when queueing up movement
if (worldData.mIsInStorm && velocity.length() > 0)
{
osg::Vec3f stormDirection = worldData.mStormDirection;
@ -202,8 +200,7 @@ namespace MWPhysics
for (int iterations = 0; iterations < sMaxIterations && remainingTime > 0.0001f; ++iterations)
{
osg::Vec3f diff = velocity * remainingTime;
osg::Vec3f nextpos = newPosition + diff;
osg::Vec3f nextpos = newPosition + velocity * remainingTime;
bool underwater = newPosition.z() < swimlevel;
// If not able to fly, don't allow to swim up into the air
@ -215,11 +212,7 @@ namespace MWPhysics
continue; // velocity updated, calculate nextpos again
}
// Note, we use an epsilon of 1e-6 instead of std::numeric_limits<float>::epsilon() to avoid doing extremely
// small steps. But if we make it any larger we'll start rejecting subtle movements from e.g. idle
// animations. Note that, although both these comparisons to 1e-6 are logically the same, they test separate
// floating point accuracy cases.
if (diff.length2() > 1e-6 && (newPosition - nextpos).length2() > 1e-6)
if ((newPosition - nextpos).length2() > 0.0001)
{
// trace to where character would go if there were no obstructions
tracer.doTrace(actor.mCollisionObject, newPosition, nextpos, collisionWorld, actor.mIsOnGround);

@ -25,7 +25,6 @@
#include "../mwrender/bulletdebugdraw.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/datetimemanager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -36,7 +35,6 @@
#include "object.hpp"
#include "physicssystem.hpp"
#include "projectile.hpp"
#include "ptrholder.hpp"
namespace MWPhysics
{
@ -197,67 +195,6 @@ namespace
void operator()(MWPhysics::ProjectileSimulation& /*sim*/) const {}
};
struct InitMovement
{
int mSteps = 0;
float mDelta = 0.f;
float mSimulationTime = 0.f;
// Returns how the actor or projectile wants to move between startTime and endTime
osg::Vec3f takeMovement(MWPhysics::PtrHolder& actor, float startTime, float endTime) const
{
osg::Vec3f movement = osg::Vec3f();
actor.eraseMovementIf([&](MWPhysics::Movement& v) {
if (v.mJump)
return false;
float start = std::max(v.mSimulationTimeStart, startTime);
float stop = std::min(v.mSimulationTimeStop, endTime);
movement += v.mVelocity * (stop - start);
if (std::abs(stop - v.mSimulationTimeStop) < 0.0001f)
return true;
return false;
});
return movement;
}
std::optional<osg::Vec3f> takeInertia(MWPhysics::PtrHolder& actor, float startTime) const
{
std::optional<osg::Vec3f> inertia = std::nullopt;
actor.eraseMovementIf([&](MWPhysics::Movement& v) {
if (v.mJump && v.mSimulationTimeStart >= startTime)
{
inertia = v.mVelocity;
return true;
}
return false;
});
return inertia;
}
void operator()(auto& sim) const
{
if (mSteps <= 0 || mDelta < 0.00001f)
return;
auto locked = sim.lock();
if (!locked.has_value())
return;
auto& [ptrHolder, frameDataRef] = *locked;
// Because takeMovement() returns movement instead of velocity, convert it back to velocity for the
// movement solver
osg::Vec3f velocity
= takeMovement(*ptrHolder, mSimulationTime, mSimulationTime + mDelta * mSteps) / (mSteps * mDelta);
// takeInertia() returns a velocity and should be taken over the velocity calculated above to initiate a
// jump
auto inertia = takeInertia(*ptrHolder, mSimulationTime);
frameDataRef.get().mMovement += inertia.value_or(velocity);
}
};
struct PreStep
{
btCollisionWorld* mCollisionWorld;
@ -564,18 +501,18 @@ namespace MWPhysics
return std::make_tuple(numSteps, actualDelta);
}
void PhysicsTaskScheduler::applyQueuedMovements(float& timeAccum, float simulationTime,
std::vector<Simulation>& simulations, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats)
void PhysicsTaskScheduler::applyQueuedMovements(float& timeAccum, std::vector<Simulation>& simulations,
osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats)
{
assert(mSimulations != &simulations);
waitForWorkers();
prepareWork(timeAccum, simulationTime, simulations, frameStart, frameNumber, stats);
prepareWork(timeAccum, simulations, frameStart, frameNumber, stats);
if (mWorkersSync != nullptr)
mWorkersSync->wakeUpWorkers();
}
void PhysicsTaskScheduler::prepareWork(float& timeAccum, float simulationTime, std::vector<Simulation>& simulations,
void PhysicsTaskScheduler::prepareWork(float& timeAccum, std::vector<Simulation>& simulations,
osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats)
{
// This function run in the main thread.
@ -585,9 +522,6 @@ namespace MWPhysics
double timeStart = mTimer->tick();
// The simulation time when the movement solving begins.
float simulationTimeStart = simulationTime - timeAccum;
// start by finishing previous background computation
if (mNumThreads != 0)
{
@ -602,15 +536,10 @@ namespace MWPhysics
timeAccum -= numSteps * newDelta;
// init
const Visitors::InitPosition initPositionVisitor{ mCollisionWorld };
const Visitors::InitPosition vis{ mCollisionWorld };
for (auto& sim : simulations)
{
std::visit(initPositionVisitor, sim);
}
const Visitors::InitMovement initMovementVisitor{ numSteps, newDelta, simulationTimeStart };
for (auto& sim : simulations)
{
std::visit(initMovementVisitor, sim);
std::visit(vis, sim);
}
mPrevStepCount = numSteps;
mRemainingSteps = numSteps;
@ -623,10 +552,10 @@ namespace MWPhysics
mNextJob.store(0, std::memory_order_release);
if (mAdvanceSimulation)
{
mWorldFrameData = std::make_unique<WorldFrameData>();
if (mAdvanceSimulation)
mBudgetCursor += 1;
}
if (mNumThreads == 0)
{
@ -935,7 +864,6 @@ namespace MWPhysics
std::remove_if(mLOSCache.begin(), mLOSCache.end(), [](const LOSRequest& req) { return req.mStale; }),
mLOSCache.end());
}
mTimeEnd = mTimer->tick();
if (mWorkersSync != nullptr)
mWorkersSync->workIsDone();

@ -46,8 +46,8 @@ namespace MWPhysics
/// @param timeAccum accumulated time from previous run to interpolate movements
/// @param actorsData per actor data needed to compute new positions
/// @return new position of each actor
void applyQueuedMovements(float& timeAccum, float simulationTime, std::vector<Simulation>& simulations,
osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats);
void applyQueuedMovements(float& timeAccum, std::vector<Simulation>& simulations, osg::Timer_t frameStart,
unsigned int frameNumber, osg::Stats& stats);
void resetSimulation(const ActorMap& actors);
@ -87,8 +87,8 @@ namespace MWPhysics
void afterPostSim();
void syncWithMainThread();
void waitForWorkers();
void prepareWork(float& timeAccum, float simulationTime, std::vector<Simulation>& simulations,
osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats);
void prepareWork(float& timeAccum, std::vector<Simulation>& simulations, osg::Timer_t frameStart,
unsigned int frameNumber, osg::Stats& stats);
std::unique_ptr<WorldFrameData> mWorldFrameData;
std::vector<Simulation>* mSimulations = nullptr;

@ -43,7 +43,6 @@
#include "../mwrender/bulletdebugdraw.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/datetimemanager.hpp"
#include "actor.hpp"
#include "collisiontype.hpp"
@ -624,20 +623,18 @@ namespace MWPhysics
return false;
}
void PhysicsSystem::queueObjectMovement(
const MWWorld::Ptr& ptr, const osg::Vec3f& velocity, float duration, bool jump)
void PhysicsSystem::queueObjectMovement(const MWWorld::Ptr& ptr, const osg::Vec3f& velocity)
{
float start = MWBase::Environment::get().getWorld()->getTimeManager()->getSimulationTime();
ActorMap::iterator found = mActors.find(ptr.mRef);
if (found != mActors.end())
found->second->queueMovement(velocity, start, start + duration, jump);
found->second->setVelocity(velocity);
}
void PhysicsSystem::clearQueuedMovement()
{
for (const auto& [_, actor] : mActors)
{
actor->clearMovement();
actor->setVelocity(osg::Vec3f());
actor->setInertialForce(osg::Vec3f());
}
}
@ -725,10 +722,8 @@ namespace MWPhysics
{
std::vector<Simulation>& simulations = mSimulations[mSimulationsCounter++ % mSimulations.size()];
prepareSimulation(mTimeAccum >= mPhysicsDt, simulations);
float simulationTime = MWBase::Environment::get().getWorld()->getTimeManager()->getSimulationTime() + dt;
// modifies mTimeAccum
mTaskScheduler->applyQueuedMovements(
mTimeAccum, simulationTime, simulations, frameStart, frameNumber, stats);
mTaskScheduler->applyQueuedMovements(mTimeAccum, simulations, frameStart, frameNumber, stats);
}
}
@ -912,7 +907,7 @@ namespace MWPhysics
->mValue.getFloat()))
, mSlowFall(slowFall)
, mRotation()
, mMovement()
, mMovement(actor.velocity())
, mWaterlevel(waterlevel)
, mHalfExtentsZ(actor.getHalfExtents().z())
, mOldHeight(0)
@ -927,7 +922,7 @@ namespace MWPhysics
ProjectileFrameData::ProjectileFrameData(Projectile& projectile)
: mPosition(projectile.getPosition())
, mMovement()
, mMovement(projectile.velocity())
, mCaster(projectile.getCasterCollisionObject())
, mCollisionObject(projectile.getCollisionObject())
, mProjectile(&projectile)

@ -245,8 +245,7 @@ namespace MWPhysics
/// Queues velocity movement for a Ptr. If a Ptr is already queued, its velocity will
/// be overwritten. Valid until the next call to stepSimulation
void queueObjectMovement(
const MWWorld::Ptr& ptr, const osg::Vec3f& velocity, float duration, bool jump = false);
void queueObjectMovement(const MWWorld::Ptr& ptr, const osg::Vec3f& velocity);
/// Clear the queued movements list without applying.
void clearQueuedMovement();

@ -1,7 +1,6 @@
#ifndef OPENMW_MWPHYSICS_PTRHOLDER_H
#define OPENMW_MWPHYSICS_PTRHOLDER_H
#include <list>
#include <memory>
#include <mutex>
#include <utility>
@ -14,14 +13,6 @@
namespace MWPhysics
{
struct Movement
{
osg::Vec3f mVelocity = osg::Vec3f();
float mSimulationTimeStart = 0.f; // The time at which this movement begun
float mSimulationTimeStop = 0.f; // The time at which this movement finished
bool mJump = false;
};
class PtrHolder
{
public:
@ -41,13 +32,9 @@ namespace MWPhysics
btCollisionObject* getCollisionObject() const { return mCollisionObject.get(); }
void clearMovement() { mMovement = {}; }
void queueMovement(osg::Vec3f velocity, float simulationTimeStart, float simulationTimeStop, bool jump = false)
{
mMovement.push_back(Movement{ velocity, simulationTimeStart, simulationTimeStop, jump });
}
void setVelocity(osg::Vec3f velocity) { mVelocity = velocity; }
void eraseMovementIf(const auto& predicate) { std::erase_if(mMovement, predicate); }
osg::Vec3f velocity() { return std::exchange(mVelocity, osg::Vec3f()); }
void setSimulationPosition(const osg::Vec3f& position) { mSimulationPosition = position; }
@ -66,7 +53,7 @@ namespace MWPhysics
protected:
MWWorld::Ptr mPtr;
std::unique_ptr<btCollisionObject> mCollisionObject;
std::list<Movement> mMovement;
osg::Vec3f mVelocity;
osg::Vec3f mSimulationPosition;
osg::Vec3d mPosition;
osg::Vec3d mPreviousPosition;

@ -30,7 +30,6 @@
#include <components/settings/values.hpp>
#include "../mwworld/class.hpp"
#include "../mwworld/datetimemanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/manualref.hpp"
@ -455,8 +454,7 @@ namespace MWWorld
}
osg::Vec3f direction = orient * osg::Vec3f(0, 1, 0);
direction.normalize();
float start = MWBase::Environment::get().getWorld()->getTimeManager()->getSimulationTime();
projectile->queueMovement(direction * speed, start, start + duration);
projectile->setVelocity(direction * speed);
update(magicBoltState, duration);
@ -484,8 +482,7 @@ namespace MWWorld
projectileState.mVelocity
-= osg::Vec3f(0, 0, Constants::GravityConst * Constants::UnitsPerMeter * 0.1f) * duration;
float start = MWBase::Environment::get().getWorld()->getTimeManager()->getSimulationTime();
projectile->queueMovement(projectileState.mVelocity, start, start + duration);
projectile->setVelocity(projectileState.mVelocity);
// rotation does not work well for throwing projectiles - their roll angle will depend on shooting
// direction.

@ -1448,9 +1448,9 @@ namespace MWWorld
return placed;
}
void World::queueMovement(const Ptr& ptr, const osg::Vec3f& velocity, float duration, bool jump)
void World::queueMovement(const Ptr& ptr, const osg::Vec3f& velocity)
{
mPhysics->queueObjectMovement(ptr, velocity, duration, jump);
mPhysics->queueObjectMovement(ptr, velocity);
}
void World::updateAnimatedCollisionShape(const Ptr& ptr)

@ -383,11 +383,9 @@ namespace MWWorld
float getMaxActivationDistance() const override;
void queueMovement(const Ptr& ptr, const osg::Vec3f& velocity, float duration, bool jump = false) override;
void queueMovement(const Ptr& ptr, const osg::Vec3f& velocity) override;
///< Queues movement for \a ptr (in local space), to be applied in the next call to
/// doPhysics.
/// \param duration The duration this speed shall be held, starting at current simulation time
/// \param jump Whether the movement shall be run over time, or immediately added as inertia instead
void updateAnimatedCollisionShape(const Ptr& ptr) override;

Loading…
Cancel
Save