Compound shapes and Character Controller to Plane collision

Brunstgnegg

04-12-2010 07:31:01

Hello everyone!

New user here, first post.

This is not technically an OgreBullet question but hopefully someone can help anyway. From what I understand OgreBullet doesn't have any kinetic character controller so using the character demo from Bullet I created a Kinetic Character controller and added it to my world. This works for everything except planes. I've tested it against dynamic and static boxes, trimeshes, dynamic and static convex hulls and they all work but every time the character controller collides with a plane the program crashes with the exception "Access violation when reading location..". Also, dynamic boxes and convex hulls collide correctly with the plane, only the character controller to plane collision behaves this way. Any ideas?

Second question is about compound shapes. Whenever I create a compound shape it straight away goes flying and spinning through the air at an enormous speed even though I explicitly set LinearVelocity to 0 and clear all forces after creation. My guess is that this has something to do with some SceneNode - Shape interaction that I am unaware of. I create the compound shape likea this:

Create a SceneNode n
for every Entity e I want to include create a child c in n
- add e to c
- add transforms to c as required
send n to PhysicsHandler
create compound shape comp
for every child c in n
- get entity e from c
- create convex shape conv from e
- add conv to comp
create body with n and comp

Am I doing it wrong?

Fish

04-12-2010 13:10:56

For both issues did you try searching the Bullet Physics Forum? I don't use Kinematics or compound shapes.

Bullet has a Kinematic character controller that handles basic functionality, but since each application has widely different requirements they left it up to the user to implement actions like jumping. Take a look at the Bullet demos to see the implementation of the kinematic controller. There is a fully functional implementation of the kinematic controller in the Bullet Game Kit.

Also, did you see this regarding compound shapes? Also, take a look at the demos that come with bullet to determine if you are creating the compound shape correctly.

-Fish

Brunstgnegg

04-12-2010 23:26:11

Thanks for the reply Fish.

I did search the bullet forums but came up empty handed. I still have not figured out how to solve the KinematicCharacterController-Plane crash but I will let you guys know if I manage to solve it. I am a bit confused about the things you said about KinematicCharacterController though.

they left it up to the user to implement actions like jumping

The btKinematicCharacterController comes with onFloor(), canJump() and jump() functions which all work fine for me.

Take a look at the Bullet demos to see the implementation of the kinematic controller

Like I said in the OP I already have, it just crashes with planes.

As for the compound shape I managed to solve it. When adding a child to the compound shape one of the optional arguments is position relative to the compound. The standard value is (0,0,0) which meant that the two children I added were at the exact same place. When supplying the addChild function with relative positions resulting in the children not colliding the compound behaves as expected.

Fish

05-12-2010 01:01:50

I guess they filled those methods out then. For the longest time the jump method was empty.

- Fish

xtxy

18-12-2010 08:37:39

I had the same problem, and I solve it by below method, you can try it.
my bullet version is bullet-svn-r2243

in file: bullet-svn-r2243\src\BulletDynamics\Character\btKinematicCharacterController.cpp
add a code line in below function (in my comments) :


class btKinematicClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback
{
public:
btKinematicClosestNotMeConvexResultCallback (btCollisionObject* me, const btVector3& up, btScalar minSlopeDot)
: btCollisionWorld::ClosestConvexResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0))
, m_me(me)
, m_up(up)
, m_minSlopeDot(minSlopeDot)
{
}

virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult,bool normalInWorldSpace)
{
if (convexResult.m_hitCollisionObject == m_me)
return btScalar(1.0);

btVector3 hitNormalWorld;
// Added by Clark
m_hitCollisionObject = convexResult.m_hitCollisionObject;
// Added end by Clark
if (normalInWorldSpace)
{
hitNormalWorld = convexResult.m_hitNormalLocal;
} else
{
///need to transform normal into worldspace
hitNormalWorld = m_hitCollisionObject->getWorldTransform().getBasis()*convexResult.m_hitNormalLocal;
}

btScalar dotUp = m_up.dot(hitNormalWorld);
if (dotUp < m_minSlopeDot) {
return btScalar(1.0);
}

return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace);
}


rebuild bullet, it is OK now