Soft bodies passing through Rigid bodies...

Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Soft bodies passing through Rigid bodies...

Post by Zeal »

I have a world setup like so...

Code: Select all

mCollisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
	mDispatcher = new btCollisionDispatcher( mCollisionConfiguration );

	mSoftBodyWorldInfo.m_dispatcher = mDispatcher;

	#define maxProxies 8192
	btVector3 worldAabbMin( -10000, -10000, -10000 );
	btVector3 worldAabbMax( 10000, 10000, 10000 );
	mOverlappingPairCache = new btAxisSweep3( worldAabbMin, worldAabbMax, maxProxies );

	mSoftBodyWorldInfo.m_broadphase = mOverlappingPairCache;

	mSolver = new btSequentialImpulseConstraintSolver;

	mCollisionConfig = new btDefaultCollisionConfiguration();
 
	mWorld = new btSoftRigidDynamicsWorld( 
		mDispatcher, mOverlappingPairCache, mSolver, mCollisionConfig );

	mWorld->setGravity( btVector3(0,-9.8,0) );

	mSoftBodyWorldInfo.m_gravity.setValue(0,-9.8,0);

	mSoftBodyWorldInfo.m_sparsesdf.Initialize();
My Rigid bodies work great. I just implemented softbodies, and I can see them moving around, and while they seem to 'touch' the other ridigd bodies, they eventually fall right through them. Imagine a scene where there is a soft ellipsoid above a static rigid body cube.The Soft ellipsoid will fall right through the Rigid cube (although it does seem to slow down when it hits the cube).

Here is how im creating the ellipsoid...

Code: Select all

	btSoftBody* body = btSoftBodyHelpers::CreateEllipsoid(mSoftBodyWorldInfo,
		btVector3(0,5,0), btVector3(1,1,1)*1, 512 );

	body->m_materials[0]->m_kLST	=	0.1;
	body->m_cfg.kDF				=	1;
	body->m_cfg.kDP				=	0.001; // fun factor...
	body->m_cfg.kPR				=	2500;
	body->setTotalMass(30,true);
	mWorld->addSoftBody(body);
Anything I should double check to make sure my Soft bodies play nice with the Rigid bodies?

Thanks
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Soft bodies passing through Rigid bodies...

Post by Zeal »

Anyone have any ideas? Whats the most common problem when people say 'mah soft bodies dun passed right through my rigid bodies'? Im stepping the simulation at a fixed 16ms and the rigid body is twice as thick as the soft body, so I dont think its one of 'those' problems. Are there any other settings/params I should check?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Soft bodies passing through Rigid bodies...

Post by Erwin Coumans »

Interaction between rigid body and soft body is under active development. In the current implementation there is only collision detection between soft body vertices and rigid bodies. So make sure to use a fine tesselation for the soft bodies, just like in the Bullet demos.

Nathanael already has some improvements in collision detection (not just using vertices), but that is planned for a future release (not 2.70 yet).
Thanks,
Erwin
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Soft bodies passing through Rigid bodies...

Post by Zeal »

Hmm im confused im using a 512 tesselated ellipsoid (roughly 1 unit size), and a giant rigid body box (roughly 100 meters in length/width and 4 meters thick). The ellipsoid starts about 4 meters above the box/floor, but still falls right through it.

In the demo I saw a ellipsoid blob roll down some stairs like a slinky. I assume the stairs are just staic rigid boxes right?

What am I missing?
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Soft bodies passing through Rigid bodies...

Post by Zeal »

I still cant get a Soft Ellipsoid to roll down some stairs like in the demo :( . Judging by the code I posted above can anyone suggest anything else to check?

Im a bit hesitant to try implementing another Helper shape until I can get this one working..
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Soft bodies passing through Rigid bodies...

Post by Zeal »

Gah well I went over the demo today, and made sure my 'world setup' was exactly how it is in the softbodies demo. See my world setup below, it should be EXACT...

Code: Select all

//m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
	mCollisionConfig = new btSoftBodyRigidBodyCollisionConfiguration();

	//m_dispatcher = new	btCollisionDispatcher(m_collisionConfiguration);
	mDispatcher = new btCollisionDispatcher( mCollisionConfig );
	mSoftBodyWorldInfo.m_dispatcher = mDispatcher;

	#define maxProxies 8192
	btVector3 worldAabbMin( -10000, -10000, -10000 );
	btVector3 worldAabbMax( 10000, 10000, 10000 );

	//m_broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
	mBroadphase = new btAxisSweep3( worldAabbMin, worldAabbMax, maxProxies );
	mSoftBodyWorldInfo.m_broadphase = mBroadphase;

	//btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
	mSolver = new btSequentialImpulseConstraintSolver;

	//btDiscreteDynamicsWorld* world = new btSoftRigidDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
	mWorld = new btSoftRigidDynamicsWorld( 
		mDispatcher, mBroadphase, mSolver, mCollisionConfig );

	//m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
	//m_dynamicsWorld->setGravity(btVector3(0,-10,0));
	//m_softBodyWorldInfo.m_gravity.setValue(0,-10,0);

	mWorld->getDispatchInfo().m_enableSPU = true;
	mWorld->setGravity( btVector3(0,-9.8,0) );
	mSoftBodyWorldInfo.m_gravity.setValue(0,-9.8,0);

	//m_softBodyWorldInfo.m_sparsesdf.Initialize();
	mSoftBodyWorldInfo.m_sparsesdf.Initialize();
Now I create a simple ellipsoid (using the soft body helpers)....

Code: Select all

	btSoftBody* body = btSoftBodyHelpers::CreateEllipsoid(mSoftBodyWorldInfo,
		btVector3(0,7,0), btVector3(1,1,1)*2.5, 256 );

	mWorld->addSoftBody(body);
Every frame I pump my world like so...

Code: Select all

mWorld->stepSimulation( 0.016 );
The above code should create a 2.5 radius 'squishy sphere' floating 7 units in the air, correct? Well it does (I have my rendering engine set up to visualize the body), the problem is, it falls straight down through the ground (I have a static rigid body box, 4 units thick, and the blob just passes right through it).

Now the strange thing is that there DOES seem to be some collision detection going on between my soft/rigid bodies. If I put some basic rigid body cubes below the blob, the blob WILL knock them out of the way as it falls (but they dont seem to slow the blob down much).

This is driven me nuts :( ... anyone have any ideas?
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Soft bodies passing through Rigid bodies...

Post by Zeal »

Has anyone had a chance to take a look at the above code? Ive spent more time on this today and still have made no progress. It would be helpful to know if the code I posted above at least SHOULD work (so I know to look elsewhere for the culprit).
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Soft bodies passing through Rigid bodies...

Post by Erwin Coumans »

Bullet 2.70 will have improved softbody - rigid body collision detection using clusters.

Please compare more closely with the Bullet softbody demos. Otherwise can you post the full source code of a modified Bullet demo that has the same issue?

Hope this helps,
Erwin
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Soft bodies passing through Rigid bodies...

Post by Zeal »

Well I upgraded to 2.70 today, but my soft ellipsoid still falls right through my floor :( . I will tripple check the code with the new 2.70 demos...

The only other thing I can think of, should I try linking to the double precision libs? I would have just tried it, but even after doing a FULL build, my out/debug_dbl8 directory only has a "build" folder, but no "libs" folder (my regular out/debug8 has a "build" AND "libs" folder). Did I goof something up when building?

(using vs2005 express)
Shreejan Shrestha
Posts: 7
Joined: Fri Aug 08, 2008 2:51 am

Re: Soft bodies passing through Rigid bodies...

Post by Shreejan Shrestha »

Hello Zeal

Anyway I think that I also went through the same problem. I tried creating one rigid body and one soft body(rope). Rope is created using btSoftBodyHelpers::CreateRopes(...). Rope used to pass through my rigid body. I created my rigid body using motionstate of identity transforms and afterward set the transforms. When I do this kind of - setting the transforms afterward then rope passes through my rigid body. But if I create my rigid body with the motionstate not with the identity transforms but with the transform which I set afterward then it seems ok.

So, how are you creating the rigid bodies and transforming in the dynamics world?

Hope it helps for you.
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Soft bodies passing through Rigid bodies...

Post by Zeal »

Hmm I am a little confused, here is how I create the rigid body (a static box shape representing the floor).

Code: Select all

//=============
//Create Body()
//=============
btRigidBody* Physics::createBody( float mass, const btTransform& transform, btCollisionShape* shape ) {
	
	//rigidbody is dynamic if and only if mass is non zero, otherwise static
	bool isDynamic = (mass != 0.f);

	btVector3 localInertia(0,0,0);
	if (isDynamic)
		shape->calculateLocalInertia(mass,localInertia);

	//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects

#define USE_MOTIONSTATE 1
#ifdef USE_MOTIONSTATE
	btDefaultMotionState* myMotionState = new btDefaultMotionState( transform );
	btRigidBody* body = new btRigidBody(mass,myMotionState,shape,localInertia);
#else
	btRigidBody* body = new btRigidBody(mass,transform,shape,localInertia);	
#endif

	if ( isDynamic ) mDynamicBodies.push_back(body);
	//else

	mWorld->addRigidBody(body);
	
	return body;

}
Shreejan Shrestha
Posts: 7
Joined: Fri Aug 08, 2008 2:51 am

Re: Soft bodies passing through Rigid bodies...

Post by Shreejan Shrestha »

Sorry this doesn't tell how do you change the transform of the body created using the function. Anyway do you change the transform of the static box shape after creating the body? I think the problem is after creating, if you change the transform then the collision between rigid and soft body doesn't function well.

Well which didn't worked.
-----------------------------------------------
void InitDynamics()
{
// create rigid body using motion state of transform
// identity origin at (0,0,0) and rotation as (0,0,0)

// add it to the dynamics world

// create soft body
// add it to the dynamics world

// call the function to position the rigid body
InitPosition();
}

void InitPosition()
{
// the position of the rigid body created in function InitDynamics()
}

But this worked
-----------------------------------------------
void InitDynamics()
{
// create rigid body using motion state of transform
// as required say origin at (x, y, z) and rotation
}
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Soft bodies passing through Rigid bodies...

Post by Zeal »

Akk sorry didnt see this got a response :(
Anyway do you change the transform of the static box shape after creating the body
I do create rigid bodies AFTER I have created the soft body, but I do NOT change the transform (I only use the transform to initialize the motion state).
Are you saying there is no way to have proper collision between rigid/soft bodies if you do mBody->setWorldTransform( transform ); after the bodies have all been creted?
Shreejan Shrestha
Posts: 7
Joined: Fri Aug 08, 2008 2:51 am

Re: Soft bodies passing through Rigid bodies...

Post by Shreejan Shrestha »

Hello Zeal,

Hmm... this doesn't mean that there is no way. I just mean to say you should also change other transforms for that. Anyway if you don't change the transform then the problem is not what I thought.

Sorry if I have messed you up :( .

Shreejan.
qtsohg
Posts: 14
Joined: Fri Oct 24, 2008 3:32 pm

Re: Soft bodies passing through Rigid bodies...

Post by qtsohg »

Have you found a solution for this yet?
:)