Skip to content

Commit

Permalink
Fixed NPC activation. Might require some more work when NPC physic wi…
Browse files Browse the repository at this point in the history
…ll be used.

Note: some NPC seems to be smaller than other, but for now, the capsule shae size is the same for every NPC
  • Loading branch information
gugus committed Jan 23, 2012
1 parent 26b9d0f commit 0a55fe0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 9 additions & 7 deletions bullet/physic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -62,6 +62,8 @@ namespace Physic

mCharacter->mCollision = false;
setGravity(0);

mTranslation = btVector3(0,0,70);
}

PhysicActor::~PhysicActor()
Expand Down Expand Up @@ -113,7 +115,7 @@ namespace Physic

btVector3 PhysicActor::getPosition(void)
{
return internalGhostObject->getWorldTransform().getOrigin();
return internalGhostObject->getWorldTransform().getOrigin() -mTranslation;
}

btQuaternion PhysicActor::getRotation(void)
Expand All @@ -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);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions bullet/physic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ namespace Physic
btCollisionShape* externalCollisionShape;

std::string mName;

btVector3 mTranslation;
};

/**
Expand Down

0 comments on commit 0a55fe0

Please sign in to comment.