1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Get the half-extents from the physicactor

This commit is contained in:
Chris Robinson 2013-02-05 07:41:57 -08:00
parent 1c604445ba
commit 82e4da4e64
5 changed files with 23 additions and 4 deletions

View File

@ -191,8 +191,7 @@ Ogre::Vector3 CharacterController::update(float duration)
Ogre::Quaternion(Ogre::Radian(-refpos.rot[2]), Ogre::Vector3::UNIT_Z)) * Ogre::Quaternion(Ogre::Radian(-refpos.rot[2]), Ogre::Vector3::UNIT_Z)) *
movement; movement;
// FIXME: Get the actual radius for the object. Maybe this should go into mwworld to replace pmove? Ogre::Vector3 res = mMovementSolver->move(mPtr, movement, duration);
Ogre::Vector3 res = mMovementSolver->move(mPtr, movement, duration, Ogre::Vector3(15,15,30));
MWBase::Environment::get().getWorld()->moveObject(mPtr, res.x, res.y, res.z); MWBase::Environment::get().getWorld()->moveObject(mPtr, res.x, res.y, res.z);
} }

View File

@ -76,7 +76,7 @@ float MovementSolver::getSlope(const Ogre::Vector3 &normal)
} }
Ogre::Vector3 MovementSolver::move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time, const Ogre::Vector3 &halfExtents) Ogre::Vector3 MovementSolver::move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time)
{ {
Ogre::Vector3 position(ptr.getRefData().getPosition().pos); Ogre::Vector3 position(ptr.getRefData().getPosition().pos);
@ -96,6 +96,7 @@ Ogre::Vector3 MovementSolver::move(const MWWorld::Ptr &ptr, const Ogre::Vector3
float remainingTime = time; float remainingTime = time;
bool isInterior = !ptr.getCell()->isExterior(); bool isInterior = !ptr.getCell()->isExterior();
float verticalRotation = mPhysicActor->getRotation().getYaw().valueDegrees(); float verticalRotation = mPhysicActor->getRotation().getYaw().valueDegrees();
Ogre::Vector3 halfExtents = mPhysicActor->getHalfExtents();
Ogre::Vector3 lastNormal(0.0f); Ogre::Vector3 lastNormal(0.0f);
Ogre::Vector3 currentNormal(0.0f); Ogre::Vector3 currentNormal(0.0f);

View File

@ -25,7 +25,7 @@ namespace MWMechanics
MovementSolver(); MovementSolver();
virtual ~MovementSolver(); virtual ~MovementSolver();
Ogre::Vector3 move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time, const Ogre::Vector3 &halfExtents); Ogre::Vector3 move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time);
private: private:
bool stepMove(Ogre::Vector3& position, const Ogre::Vector3 &velocity, float remainingTime, float verticalRotation, const Ogre::Vector3 &halfExtents, bool isInterior); bool stepMove(Ogre::Vector3& position, const Ogre::Vector3 &velocity, float remainingTime, float verticalRotation, const Ogre::Vector3 &halfExtents, bool isInterior);

View File

@ -156,6 +156,20 @@ namespace Physic
} }
} }
Ogre::Vector3 PhysicActor::getHalfExtents() const
{
if(mBody)
{
btBoxShape *box = static_cast<btBoxShape*>(mBody->getCollisionShape());
if(box != NULL)
{
btVector3 size = box->getHalfExtentsWithMargin();
return Ogre::Vector3(size.getX(), size.getY(), size.getZ());
}
}
return Ogre::Vector3(0.0f);
}
void PhysicActor::runPmove(){ void PhysicActor::runPmove(){
Pmove(pmove); Pmove(pmove);
Ogre::Vector3 newpos = pmove->ps.origin; Ogre::Vector3 newpos = pmove->ps.origin;

View File

@ -117,6 +117,11 @@ namespace Physic
*/ */
void setScale(float scale); void setScale(float scale);
/**
* Returns the half extents for this PhysiActor
*/
Ogre::Vector3 getHalfExtents() const;
/** /**
* Runs pmove for this PhysicActor * Runs pmove for this PhysicActor
*/ */