mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 22:45:35 +00:00
Physics: Use capsule shapes for actors if possible (Fixes #1437)
This commit is contained in:
parent
e23a7694f3
commit
33ed11d8e6
2 changed files with 10 additions and 3 deletions
|
@ -29,7 +29,14 @@ namespace Physic
|
||||||
mMeshOrientation = Ogre::Quaternion::IDENTITY;
|
mMeshOrientation = Ogre::Quaternion::IDENTITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
mShape.reset(new btBoxShape(BtOgre::Convert::toBullet(mHalfExtents)));
|
// Use capsule shape only if base is square (nonuniform scaling apparently doesn't work on it)
|
||||||
|
if (std::abs(mHalfExtents.x-mHalfExtents.y)<mHalfExtents.x*0.05 && mHalfExtents.z >= mHalfExtents.x)
|
||||||
|
{
|
||||||
|
mShape.reset(new btCapsuleShapeZ(mHalfExtents.x, mHalfExtents.z*2.f - mHalfExtents.x*2.f));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mShape.reset(new btBoxShape(BtOgre::Convert::toBullet(mHalfExtents)));
|
||||||
|
|
||||||
mShape->setLocalScaling(btVector3(scale,scale,scale));
|
mShape->setLocalScaling(btVector3(scale,scale,scale));
|
||||||
|
|
||||||
btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo
|
btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo
|
||||||
|
@ -102,7 +109,7 @@ namespace Physic
|
||||||
|
|
||||||
Ogre::Vector3 PhysicActor::getHalfExtents() const
|
Ogre::Vector3 PhysicActor::getHalfExtents() const
|
||||||
{
|
{
|
||||||
return mHalfExtents;
|
return mHalfExtents * mScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicActor::setInertialForce(const Ogre::Vector3 &force)
|
void PhysicActor::setInertialForce(const Ogre::Vector3 &force)
|
||||||
|
|
|
@ -107,7 +107,7 @@ void ActorTracer::findGround(const OEngine::Physic::PhysicActor* actor, const Og
|
||||||
btVector3 halfExtents(actor->getHalfExtents().x, actor->getHalfExtents().y, actor->getHalfExtents().z);
|
btVector3 halfExtents(actor->getHalfExtents().x, actor->getHalfExtents().y, actor->getHalfExtents().z);
|
||||||
|
|
||||||
halfExtents[2] = 1.0f;
|
halfExtents[2] = 1.0f;
|
||||||
btBoxShape base(halfExtents);
|
btCylinderShapeZ base(halfExtents);
|
||||||
|
|
||||||
enginePass->mDynamicsWorld->convexSweepTest(&base, from, to, newTraceCallback);
|
enginePass->mDynamicsWorld->convexSweepTest(&base, from, to, newTraceCallback);
|
||||||
if(newTraceCallback.hasHit())
|
if(newTraceCallback.hasHit())
|
||||||
|
|
Loading…
Reference in a new issue