mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 14:45:39 +00:00
Starting to introduce pmove
This commit is contained in:
parent
f586f53a42
commit
f6384574da
3 changed files with 25 additions and 15 deletions
|
@ -2,6 +2,7 @@
|
|||
#include <btBulletDynamicsCommon.h>
|
||||
#include <btBulletCollisionCommon.h>
|
||||
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
|
||||
#include "pmove.h"
|
||||
#include <components/nifbullet/bullet_nif_loader.hpp>
|
||||
#include "CMotionState.h"
|
||||
#include "OgreRoot.h"
|
||||
|
@ -33,6 +34,7 @@ namespace Physic
|
|||
Ogre::Quaternion inverse = mBoxRotation.Inverse();
|
||||
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
|
||||
pmove = new playerMove;
|
||||
}
|
||||
|
||||
PhysicActor::~PhysicActor()
|
||||
|
@ -41,6 +43,7 @@ namespace Physic
|
|||
mEngine->dynamicsWorld->removeRigidBody(mBody);
|
||||
delete mBody;
|
||||
}
|
||||
delete pmove;
|
||||
}
|
||||
|
||||
void PhysicActor::setGravity(float gravity)
|
||||
|
@ -210,8 +213,8 @@ namespace Physic
|
|||
delete hf_it->second.mBody;
|
||||
}
|
||||
|
||||
RigidBodyContainer::iterator rb_it = RigidBodyMap.begin();
|
||||
for (; rb_it != RigidBodyMap.end(); ++rb_it)
|
||||
RigidBodyContainer::iterator rb_it = ObjectMap.begin();
|
||||
for (; rb_it != ObjectMap.end(); ++rb_it)
|
||||
{
|
||||
if (rb_it->second != NULL)
|
||||
{
|
||||
|
@ -380,22 +383,22 @@ namespace Physic
|
|||
}
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
if(addToMap){
|
||||
RigidBody* oldBody = RigidBodyMap[body->mName];
|
||||
RigidBody* oldBody = ObjectMap[body->mName];
|
||||
if (oldBody != NULL)
|
||||
{
|
||||
dynamicsWorld->removeRigidBody(oldBody);
|
||||
delete oldBody;
|
||||
}
|
||||
|
||||
RigidBodyMap[body->mName] = body;
|
||||
ObjectMap[body->mName] = body;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicEngine::removeRigidBody(std::string name)
|
||||
{
|
||||
RigidBodyContainer::iterator it = RigidBodyMap.find(name);
|
||||
if (it != RigidBodyMap.end() )
|
||||
RigidBodyContainer::iterator it = ObjectMap.find(name);
|
||||
if (it != ObjectMap.end() )
|
||||
{
|
||||
RigidBody* body = it->second;
|
||||
if(body != NULL)
|
||||
|
@ -414,8 +417,8 @@ namespace Physic
|
|||
|
||||
void PhysicEngine::deleteRigidBody(std::string name)
|
||||
{
|
||||
RigidBodyContainer::iterator it = RigidBodyMap.find(name);
|
||||
if (it != RigidBodyMap.end() )
|
||||
RigidBodyContainer::iterator it = ObjectMap.find(name);
|
||||
if (it != ObjectMap.end() )
|
||||
{
|
||||
RigidBody* body = it->second;
|
||||
//btScaledBvhTriangleMeshShape* scaled = dynamic_cast<btScaledBvhTriangleMeshShape*> (body->getCollisionShape());
|
||||
|
@ -428,16 +431,16 @@ namespace Physic
|
|||
{
|
||||
delete scaled;
|
||||
}*/
|
||||
RigidBodyMap.erase(it);
|
||||
ObjectMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
RigidBody* PhysicEngine::getRigidBody(std::string name)
|
||||
{
|
||||
RigidBodyContainer::iterator it = RigidBodyMap.find(name);
|
||||
if (it != RigidBodyMap.end() )
|
||||
RigidBodyContainer::iterator it = ObjectMap.find(name);
|
||||
if (it != ObjectMap.end() )
|
||||
{
|
||||
RigidBody* body = RigidBodyMap[name];
|
||||
RigidBody* body = ObjectMap[name];
|
||||
return body;
|
||||
}
|
||||
else
|
||||
|
@ -483,7 +486,6 @@ namespace Physic
|
|||
}
|
||||
PhysicActorMap.erase(it);
|
||||
}
|
||||
//std::cout << "ok";
|
||||
}
|
||||
|
||||
PhysicActor* PhysicEngine::getCharacter(std::string name)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "BulletShapeLoader.h"
|
||||
#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
|
||||
|
||||
|
||||
|
||||
class btRigidBody;
|
||||
class btBroadphaseInterface;
|
||||
class btDefaultCollisionConfiguration;
|
||||
|
@ -16,6 +18,7 @@ class btSequentialImpulseConstraintSolver;
|
|||
class btCollisionDispatcher;
|
||||
class btDiscreteDynamicsWorld;
|
||||
class btHeightfieldTerrainShape;
|
||||
struct playerMove;
|
||||
|
||||
namespace BtOgre
|
||||
{
|
||||
|
@ -27,6 +30,7 @@ namespace MWWorld
|
|||
class World;
|
||||
}
|
||||
|
||||
|
||||
namespace OEngine {
|
||||
namespace Physic
|
||||
{
|
||||
|
@ -109,6 +113,7 @@ namespace Physic
|
|||
|
||||
|
||||
private:
|
||||
|
||||
OEngine::Physic::RigidBody* mBody;
|
||||
Ogre::Vector3 mBoxScaledTranslation;
|
||||
btQuaternion mBoxRotationInverse;
|
||||
|
@ -117,6 +122,8 @@ namespace Physic
|
|||
std::string mMesh;
|
||||
PhysicEngine* mEngine;
|
||||
std::string mName;
|
||||
playerMove* pmove;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -284,7 +291,7 @@ namespace Physic
|
|||
HeightFieldContainer mHeightFieldMap;
|
||||
|
||||
typedef std::map<std::string,RigidBody*> RigidBodyContainer;
|
||||
RigidBodyContainer RigidBodyMap;
|
||||
RigidBodyContainer ObjectMap;
|
||||
|
||||
typedef std::map<std::string, PhysicActor*> PhysicActorContainer;
|
||||
PhysicActorContainer PhysicActorMap;
|
||||
|
@ -293,6 +300,7 @@ namespace Physic
|
|||
BtOgre::DebugDrawer* mDebugDrawer;
|
||||
bool isDebugCreated;
|
||||
bool mDebugActive;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <btBulletDynamicsCommon.h>
|
||||
#include <btBulletCollisionCommon.h>
|
||||
#include <components/nifbullet/bullet_nif_loader.hpp>
|
||||
#include <openengine/bullet/pmove.h>
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
#include "pmove.h"
|
||||
|
||||
|
||||
enum traceWorldType
|
||||
|
|
Loading…
Reference in a new issue