btPairCachingGhostObject weirdness

theyesfish
Posts: 10
Joined: Sat Apr 11, 2009 7:12 pm

btPairCachingGhostObject weirdness

Post by theyesfish »

Hi, I've been having some weird problemes with the ghost objects.

ghost = new btPairCachingGhostObject();
ghost->setCollisionShape(new btSphereShape(1.0f));
ghost->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
dynamicsWorld->addCollisionObject(ghost);

Nothing special, position updated by keyboard events (no character controllers) and when I get the pairs for the object against others in the physics step callback, it works perfectly.

But then I want to use another collision shape other than sphere. So I change the line to

new btBoxShape(1.0f, 1.0f, 1.0f) or new btCapsuleShape(1.0f, 2.0f); etc. etc.


And instead of working as expected, when I launch the program, suddenly the framerate has dropped like crazy. I can barely move the ghost. It does this for about 7 seconds and then suddenly the framerate is restored, but there is not a single pair registering as a collision. It seems btSphere is the only shape that works with the ghost.

It's not an urgent problem, I'm just wondering if anyone else has got this, or if I'm doing something wrong?
Enlight
Posts: 8
Joined: Tue May 05, 2009 8:35 pm

Re: btPairCachingGhostObject weirdness

Post by Enlight »

I was having a similar problem, everything was working very very slow (GJK always reached the maximum number of iterations), and the problem was very simple: for some objects, I wasn't initializing the world transformation matrix.

Code: Select all

btTransform startTransform;
startTransform.setIdentity ();
ghost->setWorldTransform(startTransform);
I don't know if this is the problem you're having but... maybe it helps.
theyesfish
Posts: 10
Joined: Sat Apr 11, 2009 7:12 pm

Re: btPairCachingGhostObject weirdness

Post by theyesfish »

Of course! The sphere must only use the transformation part of the matrix whereas all the others warp. Thanks, I didn't think of that.