mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
Get the half-extents from the physicactor
This commit is contained in:
parent
1c604445ba
commit
82e4da4e64
@ -191,8 +191,7 @@ Ogre::Vector3 CharacterController::update(float duration)
|
||||
Ogre::Quaternion(Ogre::Radian(-refpos.rot[2]), Ogre::Vector3::UNIT_Z)) *
|
||||
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(15,15,30));
|
||||
Ogre::Vector3 res = mMovementSolver->move(mPtr, movement, duration);
|
||||
MWBase::Environment::get().getWorld()->moveObject(mPtr, res.x, res.y, res.z);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
@ -96,6 +96,7 @@ Ogre::Vector3 MovementSolver::move(const MWWorld::Ptr &ptr, const Ogre::Vector3
|
||||
float remainingTime = time;
|
||||
bool isInterior = !ptr.getCell()->isExterior();
|
||||
float verticalRotation = mPhysicActor->getRotation().getYaw().valueDegrees();
|
||||
Ogre::Vector3 halfExtents = mPhysicActor->getHalfExtents();
|
||||
|
||||
Ogre::Vector3 lastNormal(0.0f);
|
||||
Ogre::Vector3 currentNormal(0.0f);
|
||||
|
@ -25,7 +25,7 @@ namespace MWMechanics
|
||||
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:
|
||||
bool stepMove(Ogre::Vector3& position, const Ogre::Vector3 &velocity, float remainingTime, float verticalRotation, const Ogre::Vector3 &halfExtents, bool isInterior);
|
||||
|
@ -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(){
|
||||
Pmove(pmove);
|
||||
Ogre::Vector3 newpos = pmove->ps.origin;
|
||||
|
@ -117,6 +117,11 @@ namespace Physic
|
||||
*/
|
||||
void setScale(float scale);
|
||||
|
||||
/**
|
||||
* Returns the half extents for this PhysiActor
|
||||
*/
|
||||
Ogre::Vector3 getHalfExtents() const;
|
||||
|
||||
/**
|
||||
* Runs pmove for this PhysicActor
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user