From 0a55fe0219b60b549c1d8c5e29e37d1f49f92917 Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 23 Jan 2012 21:49:51 +0100 Subject: [PATCH 1/2] Fixed NPC activation. Might require some more work when NPC physic will be used. Note: some NPC seems to be smaller than other, but for now, the capsule shae size is the same for every NPC --- bullet/physic.cpp | 16 +++++++++------- bullet/physic.hpp | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bullet/physic.cpp b/bullet/physic.cpp index 8cf7b8eb6..8fa54a9e6 100644 --- a/bullet/physic.cpp +++ b/bullet/physic.cpp @@ -34,8 +34,8 @@ namespace Physic externalGhostObject = new PairCachingGhostObject(name); externalGhostObject->setWorldTransform( transform ); - btScalar externalCapsuleHeight = 130; - btScalar externalCapsuleWidth = 16; + btScalar externalCapsuleHeight = 120; + btScalar externalCapsuleWidth = 19; externalCollisionShape = new btCapsuleShapeZ( externalCapsuleWidth, externalCapsuleHeight ); externalCollisionShape->setMargin( 0.1 ); @@ -47,8 +47,8 @@ namespace Physic internalGhostObject = new PairCachingGhostObject(name); internalGhostObject->setWorldTransform( transform ); //internalGhostObject->getBroadphaseHandle()->s - btScalar internalCapsuleHeight = 120; - btScalar internalCapsuleWidth = 15; + btScalar internalCapsuleHeight = 110; + btScalar internalCapsuleWidth = 17; internalCollisionShape = new btCapsuleShapeZ( internalCapsuleWidth, internalCapsuleHeight ); internalCollisionShape->setMargin( 0.1 ); @@ -62,6 +62,8 @@ namespace Physic mCharacter->mCollision = false; setGravity(0); + + mTranslation = btVector3(0,0,70); } PhysicActor::~PhysicActor() @@ -113,7 +115,7 @@ namespace Physic btVector3 PhysicActor::getPosition(void) { - return internalGhostObject->getWorldTransform().getOrigin(); + return internalGhostObject->getWorldTransform().getOrigin() -mTranslation; } btQuaternion PhysicActor::getRotation(void) @@ -123,8 +125,8 @@ namespace Physic void PhysicActor::setPosition(const btVector3& pos) { - internalGhostObject->getWorldTransform().setOrigin(pos); - externalGhostObject->getWorldTransform().setOrigin(pos); + internalGhostObject->getWorldTransform().setOrigin(pos+mTranslation); + externalGhostObject->getWorldTransform().setOrigin(pos+mTranslation); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/bullet/physic.hpp b/bullet/physic.hpp index d4dfde467..9f554dd0e 100644 --- a/bullet/physic.hpp +++ b/bullet/physic.hpp @@ -89,6 +89,8 @@ namespace Physic btCollisionShape* externalCollisionShape; std::string mName; + + btVector3 mTranslation; }; /** From 6c15aec5e4c791c01030ea3b6d3e8352a8577a61 Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 23 Jan 2012 22:16:08 +0100 Subject: [PATCH 2/2] added some comments --- bullet/physic.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bullet/physic.hpp b/bullet/physic.hpp index 9f554dd0e..750761965 100644 --- a/bullet/physic.hpp +++ b/bullet/physic.hpp @@ -90,6 +90,10 @@ namespace Physic std::string mName; + /** + *NPC scenenode is located on there feet, and you can't simply translate a btShape, so this vector is used + *each time get/setposition is called. + */ btVector3 mTranslation; };