forked from mirror/openmw-tes3mp
Better performance but less tolerant of collision induced glitches. Also had to use const_cast to cache on ground status.
This commit is contained in:
parent
3e6e325e5b
commit
966ed46870
1 changed files with 13 additions and 7 deletions
|
@ -1721,13 +1721,18 @@ namespace MWWorld
|
||||||
// below the actor is detected and ignored. A value of 1.5 is used here, but
|
// below the actor is detected and ignored. A value of 1.5 is used here, but
|
||||||
// something larger may be more suitable. This change should resolve Bug#1271.
|
// something larger may be more suitable. This change should resolve Bug#1271.
|
||||||
//
|
//
|
||||||
// FIXME: Collision detection each time may have a performance impact.
|
// TODO: There might be better places to update PhysicActor::mOnGround.
|
||||||
// There might be better places to update PhysicActor::mOnGround.
|
|
||||||
bool World::isOnGround(const MWWorld::Ptr &ptr) const
|
bool World::isOnGround(const MWWorld::Ptr &ptr) const
|
||||||
{
|
{
|
||||||
RefData &refdata = ptr.getRefData();
|
RefData &refdata = ptr.getRefData();
|
||||||
const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle());
|
const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle());
|
||||||
if(physactor)
|
|
||||||
|
if(!physactor)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(physactor->getOnGround())
|
||||||
|
return true;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Ogre::Vector3 pos(ptr.getRefData().getPosition().pos);
|
Ogre::Vector3 pos(ptr.getRefData().getPosition().pos);
|
||||||
OEngine::Physic::ActorTracer tracer;
|
OEngine::Physic::ActorTracer tracer;
|
||||||
|
@ -1737,12 +1742,13 @@ namespace MWWorld
|
||||||
pos - Ogre::Vector3(0, 0, 1.5f), // trace a small amount down
|
pos - Ogre::Vector3(0, 0, 1.5f), // trace a small amount down
|
||||||
mPhysEngine);
|
mPhysEngine);
|
||||||
if(tracer.mFraction < 1.0f) // collision, must be close to something below
|
if(tracer.mFraction < 1.0f) // collision, must be close to something below
|
||||||
return true; // TODO: should update physactor
|
{
|
||||||
|
const_cast<OEngine::Physic::PhysicActor *> (physactor)->setOnGround(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return physactor->getOnGround();
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool World::vanityRotateCamera(float * rot)
|
bool World::vanityRotateCamera(float * rot)
|
||||||
|
|
Loading…
Reference in a new issue