1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 16:45:33 +00:00

hacky solution with debug; seems that player is added before cell so tracing down will not find anything

This commit is contained in:
Bret Curtis 2021-03-14 01:02:44 +01:00
parent 19ad7d7f0c
commit 1479f98793
2 changed files with 18 additions and 1 deletions

View file

@ -72,7 +72,6 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic
updatePosition();
addCollisionMask(getCollisionMask());
updateCollisionObjectPosition();
mOnGround.store(false, std::memory_order_release);
}
Actor::~Actor()

View file

@ -2,6 +2,7 @@
#include <LinearMath/btIDebugDraw.h>
#include <LinearMath/btVector3.h>
#include <algorithm>
#include <memory>
#include <osg/Group>
#include <osg/Stats>
@ -680,7 +681,24 @@ namespace MWPhysics
return;
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));
}
int PhysicsSystem::addProjectile (const MWWorld::Ptr& caster, const osg::Vec3f& position, const std::string& mesh, bool computeRadius, bool canTraverseWater)