mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-24 18:39:59 +00:00
Set mCanWaterWalk and mOnGround when adding Actor to the scene.
mCanWaterWalk was set to false and updated during next frame's simulation mOnGround is set to true but then was updated as part of the scene loading logic.
This commit is contained in:
parent
59c7e9f7c4
commit
f348b70733
@ -19,8 +19,8 @@ namespace MWPhysics
|
||||
{
|
||||
|
||||
|
||||
Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, PhysicsTaskScheduler* scheduler)
|
||||
: mStandingOnPtr(nullptr), mCanWaterWalk(false), mWalkingOnWater(false)
|
||||
Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, PhysicsTaskScheduler* scheduler, bool canWaterWalk)
|
||||
: mStandingOnPtr(nullptr), mCanWaterWalk(canWaterWalk), mWalkingOnWater(false)
|
||||
, mCollisionObject(nullptr), mMeshTranslation(shape->mCollisionBox.center), mHalfExtents(shape->mCollisionBox.extents)
|
||||
, mVelocity(0,0,0), mStuckFrames(0), mLastStuckPosition{0, 0, 0}
|
||||
, mForce(0.f, 0.f, 0.f), mOnGround(true), mOnSlope(false)
|
||||
|
@ -27,7 +27,7 @@ namespace MWPhysics
|
||||
class Actor final : public PtrHolder
|
||||
{
|
||||
public:
|
||||
Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, PhysicsTaskScheduler* scheduler);
|
||||
Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, PhysicsTaskScheduler* scheduler, bool canWaterWalk);
|
||||
~Actor() override;
|
||||
|
||||
/**
|
||||
|
@ -688,7 +688,15 @@ namespace MWPhysics
|
||||
if (!shape)
|
||||
return;
|
||||
|
||||
auto actor = std::make_shared<Actor>(ptr, shape, mTaskScheduler.get());
|
||||
// check if Actor should spawn above water
|
||||
const MWMechanics::MagicEffects& effects = ptr.getClass().getCreatureStats(ptr).getMagicEffects();
|
||||
const bool canWaterWalk = effects.get(ESM::MagicEffect::WaterWalking).getMagnitude() > 0;
|
||||
|
||||
auto actor = std::make_shared<Actor>(ptr, shape, mTaskScheduler.get(), canWaterWalk);
|
||||
|
||||
// check if Actor is on the ground or in the air
|
||||
traceDown(ptr, ptr.getRefData().getPosition().asVec3(), 10.f);
|
||||
|
||||
mActors.emplace(ptr, std::move(actor));
|
||||
}
|
||||
|
||||
|
@ -486,12 +486,6 @@ namespace MWWorld
|
||||
|
||||
const auto player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
|
||||
// By default the player is grounded, with the scene fully loaded, we validate and correct this.
|
||||
if (player.mCell == cell) // Only run once, during initial cell load.
|
||||
{
|
||||
mPhysics->traceDown(player, player.getRefData().getPosition().asVec3(), 10.f);
|
||||
}
|
||||
|
||||
navigator->update(player.getRefData().getPosition().asVec3());
|
||||
|
||||
if (!cell->isExterior() && !(cell->getCell()->mData.mFlags & ESM::Cell::QuasiEx))
|
||||
|
Loading…
x
Reference in New Issue
Block a user