From f6384574dae1c31acb0dd7adc96e98838a589ac7 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 15 Sep 2012 18:17:42 -0400 Subject: [PATCH] Starting to introduce pmove --- libs/openengine/bullet/physic.cpp | 28 +++++++++++++++------------- libs/openengine/bullet/physic.hpp | 10 +++++++++- libs/openengine/bullet/trace.h | 2 +- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 9c387e140d..a9f483aa4a 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -2,6 +2,7 @@ #include #include #include +#include "pmove.h" #include #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 (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) diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index 1598d3e870..f516753989 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -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 RigidBodyContainer; - RigidBodyContainer RigidBodyMap; + RigidBodyContainer ObjectMap; typedef std::map PhysicActorContainer; PhysicActorContainer PhysicActorMap; @@ -293,6 +300,7 @@ namespace Physic BtOgre::DebugDrawer* mDebugDrawer; bool isDebugCreated; bool mDebugActive; + }; diff --git a/libs/openengine/bullet/trace.h b/libs/openengine/bullet/trace.h index bd554031a5..1bfe0c7178 100644 --- a/libs/openengine/bullet/trace.h +++ b/libs/openengine/bullet/trace.h @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include "pmove.h" enum traceWorldType