mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 20:15:33 +00:00
Remove unneeded playerMove from PhysicActor
This commit is contained in:
parent
ca6f8b6d88
commit
cbdd459500
3 changed files with 3 additions and 113 deletions
|
@ -267,8 +267,7 @@ namespace MWWorld
|
||||||
|
|
||||||
void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight)
|
void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight)
|
||||||
{
|
{
|
||||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
// TODO: store and use
|
||||||
it->second->setCurrentWater(hasWater, waterHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btVector3 PhysicsSystem::getRayPoint(float extent)
|
btVector3 PhysicsSystem::getRayPoint(float extent)
|
||||||
|
@ -405,13 +404,6 @@ namespace MWWorld
|
||||||
mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, position, node->getOrientation());
|
mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, position, node->getOrientation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
|
||||||
{
|
|
||||||
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
|
||||||
// start positions others than 0, 0, 0
|
|
||||||
if (handle != "player")
|
|
||||||
act->setPosition(position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::rotateObject (const Ptr& ptr)
|
void PhysicsSystem::rotateObject (const Ptr& ptr)
|
||||||
|
|
|
@ -34,14 +34,6 @@ namespace Physic
|
||||||
Ogre::Quaternion inverse = mBoxRotation.Inverse();
|
Ogre::Quaternion inverse = mBoxRotation.Inverse();
|
||||||
mBoxRotationInverse = btQuaternion(inverse.x, inverse.y, inverse.z,inverse.w);
|
mBoxRotationInverse = btQuaternion(inverse.x, inverse.y, inverse.z,inverse.w);
|
||||||
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
||||||
pmove = new playerMove;
|
|
||||||
pmove->mEngine = mEngine;
|
|
||||||
btBoxShape* box = static_cast<btBoxShape*> (mBody->getCollisionShape());
|
|
||||||
if(box != NULL){
|
|
||||||
btVector3 size = box->getHalfExtentsWithMargin();
|
|
||||||
Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ());
|
|
||||||
pmove->ps.halfExtents = halfExtents;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicActor::~PhysicActor()
|
PhysicActor::~PhysicActor()
|
||||||
|
@ -50,38 +42,11 @@ namespace Physic
|
||||||
mEngine->dynamicsWorld->removeRigidBody(mBody);
|
mEngine->dynamicsWorld->removeRigidBody(mBody);
|
||||||
delete mBody;
|
delete mBody;
|
||||||
}
|
}
|
||||||
delete pmove;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicActor::setCurrentWater(bool hasWater, int waterHeight){
|
|
||||||
pmove->hasWater = hasWater;
|
|
||||||
if(hasWater){
|
|
||||||
pmove->waterHeight = waterHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicActor::setGravity(float gravity)
|
|
||||||
{
|
|
||||||
pmove->ps.gravity = gravity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicActor::setSpeed(float speed)
|
|
||||||
{
|
|
||||||
pmove->ps.speed = speed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicActor::enableCollisions(bool collision)
|
void PhysicActor::enableCollisions(bool collision)
|
||||||
{
|
{
|
||||||
collisionMode = collision;
|
collisionMode = collision;
|
||||||
if(collisionMode)
|
|
||||||
pmove->ps.move_type=PM_NORMAL;
|
|
||||||
else
|
|
||||||
pmove->ps.move_type=PM_NOCLIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicActor::setJumpVelocity(float velocity)
|
|
||||||
{
|
|
||||||
pmove->ps.jump_velocity = velocity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicActor::getCollisionMode()
|
bool PhysicActor::getCollisionMode()
|
||||||
|
@ -89,23 +54,8 @@ namespace Physic
|
||||||
return collisionMode;
|
return collisionMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicActor::setMovement(signed char rightmove, signed char forwardmove, signed char upmove)
|
|
||||||
{
|
|
||||||
playerMove::playercmd& pm_ref = pmove->cmd;
|
|
||||||
pm_ref.rightmove = rightmove;
|
|
||||||
pm_ref.forwardmove = forwardmove;
|
|
||||||
pm_ref.upmove = upmove;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicActor::setPmoveViewAngles(float pitch, float yaw, float roll){
|
void PhysicActor::setRotation(const Ogre::Quaternion &quat)
|
||||||
pmove->ps.viewangles.x = pitch;
|
|
||||||
pmove->ps.viewangles.y = yaw;
|
|
||||||
pmove->ps.viewangles.z = roll;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PhysicActor::setRotation(const Ogre::Quaternion quat)
|
|
||||||
{
|
{
|
||||||
if(!quat.equals(getRotation(), Ogre::Radian(0))){
|
if(!quat.equals(getRotation(), Ogre::Radian(0))){
|
||||||
mEngine->adjustRigidBody(mBody, getPosition(), quat, mBoxScaledTranslation, mBoxRotation);
|
mEngine->adjustRigidBody(mBody, getPosition(), quat, mBoxScaledTranslation, mBoxRotation);
|
||||||
|
@ -128,13 +78,6 @@ namespace Physic
|
||||||
return Ogre::Quaternion(quat.getW(), quat.getX(), quat.getY(), quat.getZ());
|
return Ogre::Quaternion(quat.getW(), quat.getX(), quat.getY(), quat.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicActor::setPosition(const Ogre::Vector3 pos)
|
|
||||||
{
|
|
||||||
mEngine->adjustRigidBody(mBody, pos, getRotation(), mBoxScaledTranslation, mBoxRotation);
|
|
||||||
btVector3 vec = mBody->getWorldTransform().getOrigin();
|
|
||||||
pmove->ps.origin = Ogre::Vector3(vec.getX(), vec.getY(), vec.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicActor::setScale(float scale){
|
void PhysicActor::setScale(float scale){
|
||||||
Ogre::Vector3 position = getPosition();
|
Ogre::Vector3 position = getPosition();
|
||||||
Ogre::Quaternion rotation = getRotation();
|
Ogre::Quaternion rotation = getRotation();
|
||||||
|
@ -148,12 +91,6 @@ namespace Physic
|
||||||
//Create the newly scaled rigid body
|
//Create the newly scaled rigid body
|
||||||
mBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, position, rotation);
|
mBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, position, rotation);
|
||||||
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
||||||
btBoxShape* box = static_cast<btBoxShape*> (mBody->getCollisionShape());
|
|
||||||
if(box != NULL){
|
|
||||||
btVector3 size = box->getHalfExtentsWithMargin();
|
|
||||||
Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ());
|
|
||||||
pmove->ps.halfExtents = halfExtents;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::Vector3 PhysicActor::getHalfExtents() const
|
Ogre::Vector3 PhysicActor::getHalfExtents() const
|
||||||
|
@ -190,12 +127,6 @@ namespace Physic
|
||||||
return collisionMode && onGround;
|
return collisionMode && onGround;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicActor::runPmove(){
|
|
||||||
Pmove(pmove);
|
|
||||||
Ogre::Vector3 newpos = pmove->ps.origin;
|
|
||||||
mBody->getWorldTransform().setOrigin(btVector3(newpos.x, newpos.y, newpos.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ class btSequentialImpulseConstraintSolver;
|
||||||
class btCollisionDispatcher;
|
class btCollisionDispatcher;
|
||||||
class btDiscreteDynamicsWorld;
|
class btDiscreteDynamicsWorld;
|
||||||
class btHeightfieldTerrainShape;
|
class btHeightfieldTerrainShape;
|
||||||
struct playerMove;
|
|
||||||
|
|
||||||
namespace BtOgre
|
namespace BtOgre
|
||||||
{
|
{
|
||||||
|
@ -65,25 +64,12 @@ namespace Physic
|
||||||
|
|
||||||
~PhysicActor();
|
~PhysicActor();
|
||||||
|
|
||||||
void setCurrentWater(bool hasWater, int waterHeight);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function sets the movement keys for pmove
|
|
||||||
*/
|
|
||||||
void setMovement(signed char rightmove, signed char forwardmove, signed char upmove);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This adjusts the rotation of a PhysicActor
|
* This adjusts the rotation of a PhysicActor
|
||||||
* If we have any problems with this (getting stuck in pmove) we should change it
|
* If we have any problems with this (getting stuck in pmove) we should change it
|
||||||
* from setting the visual orientation to setting the orientation of the rigid body directly.
|
* from setting the visual orientation to setting the orientation of the rigid body directly.
|
||||||
*/
|
*/
|
||||||
void setRotation(const Ogre::Quaternion quat);
|
void setRotation(const Ogre::Quaternion &quat);
|
||||||
|
|
||||||
void setGravity(float gravity);
|
|
||||||
|
|
||||||
void setSpeed(float speed);
|
|
||||||
|
|
||||||
void setJumpVelocity(float velocity);
|
|
||||||
|
|
||||||
void enableCollisions(bool collision);
|
void enableCollisions(bool collision);
|
||||||
|
|
||||||
|
@ -100,18 +86,6 @@ namespace Physic
|
||||||
*/
|
*/
|
||||||
Ogre::Quaternion getRotation();
|
Ogre::Quaternion getRotation();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the position of mBody from a visual position input.
|
|
||||||
* For most cases this should not be used. We should instead let pmove move the PhysicActor around for us
|
|
||||||
*/
|
|
||||||
void setPosition(const Ogre::Vector3 pos);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the view angles for pmove directly.
|
|
||||||
* Remember, add 90 for yaw. Set roll to 0.
|
|
||||||
*/
|
|
||||||
void setPmoveViewAngles(float pitch, float yaw, float roll);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the scale of the PhysicActor
|
* Sets the scale of the PhysicActor
|
||||||
*/
|
*/
|
||||||
|
@ -136,11 +110,6 @@ namespace Physic
|
||||||
|
|
||||||
bool getOnGround() const;
|
bool getOnGround() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs pmove for this PhysicActor
|
|
||||||
*/
|
|
||||||
void runPmove();
|
|
||||||
|
|
||||||
//HACK: in Visual Studio 2010 and presumably above, this structures alignment
|
//HACK: in Visual Studio 2010 and presumably above, this structures alignment
|
||||||
// must be 16, but the built in operator new & delete don't properly
|
// must be 16, but the built in operator new & delete don't properly
|
||||||
// perform this alignment.
|
// perform this alignment.
|
||||||
|
@ -161,8 +130,6 @@ namespace Physic
|
||||||
std::string mMesh;
|
std::string mMesh;
|
||||||
PhysicEngine* mEngine;
|
PhysicEngine* mEngine;
|
||||||
std::string mName;
|
std::string mName;
|
||||||
playerMove* pmove;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue