proper fix that traces down the player when a cell is loaded; we also only run once if the current cell being loaded is the one that the player is in.

pull/593/head
Bret Curtis 4 years ago
parent 1479f98793
commit c067782814

@ -2,7 +2,6 @@
#include <LinearMath/btIDebugDraw.h>
#include <LinearMath/btVector3.h>
#include <algorithm>
#include <memory>
#include <osg/Group>
#include <osg/Stats>
@ -682,21 +681,6 @@ namespace MWPhysics
auto actor = std::make_shared<Actor>(ptr, shape, mTaskScheduler.get());
if (ptr == MWMechanics::getPlayer())
{
osg::Vec3f offset = actor->getCollisionObjectPosition() - ptr.getRefData().getPosition().asVec3();
std::cout << "DEBUG Player position: " << actor->getPosition() << std::endl;
auto terrainHeight = std::max(0.f, MWBase::Environment::get().getWorld()->getTerrainHeightAt(actor->getPosition()));
std::cout << "DEBUG terrain height " << terrainHeight << std::endl;
ActorTracer tracer;
tracer.findGround(actor.get(), actor->getPosition() + offset, actor->getPosition() + offset - osg::Vec3f(0, 0, 100.f), mCollisionWorld.get());
std::cout << "DEBUG mFraction " << tracer.mFraction << std::endl; // it seems that player is loaded before the cell so we can't find the ground.
std::cout << "DEBUG calculation :: " << actor->getPosition().z() - terrainHeight << std::endl;
if (actor->getPosition().z() - terrainHeight > 300.f)
actor->setOnGround(false);
}
mActors.emplace(ptr, std::move(actor));
}

@ -447,11 +447,14 @@ namespace MWWorld
mPhysics->disableWater();
const auto player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (player.getCell() == cell) {
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))
{
mRendering.configureAmbient(cell->getCell());
}
}

Loading…
Cancel
Save