Better performance but less tolerant of collision induced glitches. Also had to use const_cast to cache on ground status.

actorid
cc9cii 11 years ago
parent 3e6e325e5b
commit 966ed46870

@ -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…
Cancel
Save