mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
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.
This commit is contained in:
parent
1479f98793
commit
c067782814
2 changed files with 4 additions and 17 deletions
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
#include <LinearMath/btIDebugDraw.h>
|
||||||
#include <LinearMath/btVector3.h>
|
#include <LinearMath/btVector3.h>
|
||||||
#include <algorithm>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
#include <osg/Stats>
|
#include <osg/Stats>
|
||||||
|
@ -682,21 +681,6 @@ namespace MWPhysics
|
||||||
|
|
||||||
auto actor = std::make_shared<Actor>(ptr, shape, mTaskScheduler.get());
|
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));
|
mActors.emplace(ptr, std::move(actor));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,11 +447,14 @@ namespace MWWorld
|
||||||
mPhysics->disableWater();
|
mPhysics->disableWater();
|
||||||
|
|
||||||
const auto player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
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());
|
navigator->update(player.getRefData().getPosition().asVec3());
|
||||||
|
|
||||||
if (!cell->isExterior() && !(cell->getCell()->mData.mFlags & ESM::Cell::QuasiEx))
|
if (!cell->isExterior() && !(cell->getCell()->mData.mFlags & ESM::Cell::QuasiEx))
|
||||||
{
|
{
|
||||||
|
|
||||||
mRendering.configureAmbient(cell->getCell());
|
mRendering.configureAmbient(cell->getCell());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue