ragdoll collisions

bsanders
Posts: 6
Joined: Wed Sep 19, 2007 10:09 pm
Location: California, USA

ragdoll collisions

Post by bsanders »

hello,

I'm currently trying to make a ragdoll without using bullet dynamics. (I am using ode dynamics). I would like to use bullet collisions, but cannot find a way to make the forearm and upperarm (for example) not collide without using a dynamics world. I apologize if this question has been answered already, but I couldn't find an answer when searching in the forums.

Basically, what I have found is this: when using a dynamics world, you can use the function "addConstraint( param1, disableCollisionsBetweenLinkedBodies=true )" to get this to work. However, the only "linked bodies" info I can find for a collisionworld is the compound shape. As far as I understand, using compound shapes reduces the performance drastically (at least in the program I tried).

Does anyone know of a way to disable the collisions between linked bodies for a collision world?

thanks.
User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Re: ragdoll collisions

Post by projectileman »

If you take look the btDiscreteDynamicsWorld class you will see this function prototype:

Code: Select all


void	addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
When adding constraints (joints), don't forget set the second parameter to true.

I also recommend take a look to the GenericJointDemo in Bullet; it implements ragdols with 6DOF joints which work much better that the existing joints in the ODE library.
bsanders
Posts: 6
Joined: Wed Sep 19, 2007 10:09 pm
Location: California, USA

Re: ragdoll collisions

Post by bsanders »

Thanks for responding. however, I know about the function for the dynamics world. I'm curious if there is a way to make the adjacent bodies not collide for a ragdoll for the collision world.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: ragdoll collisions

Post by Erwin Coumans »

Hi,

Yes this is possible, when just using Bullet collision detection, without the dynamics.

The best is to create a custom 'btOverlapFilterCallback', override the 'needBroadphaseCollision' and register it to the btOverlappingPairCache:

Code: Select all

struct btOverlapFilterCallback
{
	virtual ~btOverlapFilterCallback()
	{}
	// return true when pairs need collision
	virtual bool	needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const = 0;
};
You will need to return 'false' when you don't want a collision to happen given a pair of objects.

Code: Select all

class	btOverlappingPairCache
{
[...]
	void setOverlapFilterCallback(btOverlapFilterCallback* callback)
	{
	    m_overlapFilterCallback = callback;
	}

Hope this helps,
Erwin
bsanders
Posts: 6
Joined: Wed Sep 19, 2007 10:09 pm
Location: California, USA

Re: ragdoll collisions

Post by bsanders »

Yes, that looks good.
Thank you,
Ben
bsanders
Posts: 6
Joined: Wed Sep 19, 2007 10:09 pm
Location: California, USA

Re: ragdoll collisions

Post by bsanders »

Does anyone know of a tutorial for btBroadphaseProxy objects? I would like to see an example of how they are created and used with existing geometries, if possible.
thanks.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: ragdoll collisions

Post by Erwin Coumans »

Hi,

If you add a btCollisionObject using btCollisionWorld::addCollisionObject, it will automatically create a broadphase proxy.

Code: Select all

collisionObject->setBroadphaseHandle( getBroadphase()->createProxy(
			minAabb,
			maxAabb,
			type,
			collisionObject,
			collisionFilterGroup,
			collisionFilterMask
			))	;
This means, you can get from a btBroadphaseProxy to btCollisionObject using:

Code: Select all

btCollisionObject* colObj0 = (btCollisionObject*)broadphaseProxy0->m_clientObject;
Hope this helps,
Erwin
bsanders
Posts: 6
Joined: Wed Sep 19, 2007 10:09 pm
Location: California, USA

Re: ragdoll collisions

Post by bsanders »

Thanks for all the help. Do you know if there will be a demo with ODE using Bullet Collisions in an upcoming release of Bullet? I've looked at the test_BulletODE.cpp, but it seems to have a runtime error (could not load accelerators) so it doesn't help me much.
thanks.