GhostObject collision with narrowphase instead of AABB?

Post Reply
Aperico
Posts: 7
Joined: Mon Feb 03, 2014 2:15 pm

GhostObject collision with narrowphase instead of AABB?

Post by Aperico »

I am in need of some clarification about ghost objects. I have implemented collision detection that works but the collision detection is not for the actual shapes but of their corresponding AABB's. I have tried to find the information about how to do this myself but I only get more confused as there is a lot of info about this and it seems like ghost objects can be used in a lot of ways and I am also not sure which information is outdated. For example the wiki and the CharacterDemo sample code the wiki refers to does it differently.

What is the difference between initialization: (wiki uses the first and the demo the second)
collisionWorld.getPairCache().setInternalGhostPairCallback(ghostPairCallback);
and
collisionWorld.getBroadphase().getOverlappingPairCache().setInternalGhostPairCallback(ghostPairCallback);

I have tried to set it up both ways but it does not seem to make any difference for what I want. I am not interested in any contact points/normals I only want the objects which collides with the ghost object, but I do not want AABB collisions I want the actual collisions were the shapes actually overlaps.

I also tried using both GhostObject and PairCachingGhostObject but I'm not sure the difference, neither worked for me though, both returns AABB collisions.

Below is how I set it up currently:

Code: Select all

collisionConfiguration = new btDefaultCollisionConfiguration();
		dispatcher = new btCollisionDispatcher(collisionConfiguration);
		broadphase = new btDbvtBroadphase();
		
		solver = new btSequentialImpulseConstraintSolver();
		collisionWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
		
		((btDynamicsWorld)collisionWorld).setGravity(gravity);
		
		ghostPairCallback = new btGhostPairCallback();
		collisionWorld.getPairCache().setInternalGhostPairCallback(ghostPairCallback);

Code: Select all

ghostObject = new btPairCachingGhostObject();
			ghostObject.setCollisionShape(skillInfo.shape);
			ghostObject.setWorldTransform(worldTrans);
			
			ghostObject.setCollisionFlags((short) btCollisionObject.CollisionFlags.CF_NO_CONTACT_RESPONSE);
			world.collisionWorld.addCollisionObject(ghostObject,
					(short) btBroadphaseProxy.CollisionFilterGroups.SensorTrigger,
					(short) (btBroadphaseProxy.CollisionFilterGroups.AllFilter ^ btBroadphaseProxy.CollisionFilterGroups.SensorTrigger));

Code: Select all

for(int i=0;i<ghostObject.getNumOverlappingObjects();i++){
					
					GameObject go  = ((GameObject) ghostObject.getOverlappingObject(i).userData);
...
...
}
And yes I am using JBullet ;) Any help greatly appreciated!
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: GhostObject collision with narrowphase instead of AABB?

Post by Flix »

  • First, sorry, I've just read the post title (= not its content).
  • Second, this link is rather old, but it might still work (expecially the ghost object demo included in it): please tell me if it's useful for you or not: http://www.bulletphysics.org/Bullet/php ... bject+demo
Post Reply