Forcing deactivation properly?

Cliff
Posts: 1
Joined: Tue Nov 13, 2007 10:56 pm

Forcing deactivation properly?

Post by Cliff »

Howdy!

I'm looking for a way to force btRigidBodies to go to sleep until they come into contact with a dynamic rigid body (or it contacts them). So far nothing I have tried has worked perfectly.

How I'm going about doing it so far is trying to change the rigid bodies from static to dynamic once something movable gets near them. I'm using a custom near callback like I saw in one of the demos for this.

I noticed from older posts that a rigid body should be removed from the world before making changes to it (like teleporting) and then adding it back in later once it has been changed. When I did this inside the callback, I was getting corrupt stacks. It didn't like me referring to the old btCollidableObjects at the end of the near callback once I added them back into the world with addRigidBody. Specifically the processCollision function call is crashing it.

I tried not removing them from the world, but changing the mass and inertia with setMassProperties and updating the collision filter info of the rigid bodies to ensure they changed from static to dynamic rigid bodies. Currently this gets the rigid bodies to deactivate, but they are falling through the world unless they are far from it when they "wake up". There's a stack of barrels and the ones on the bottom fall through the world when a car gets near them, but the ones on the top don't. If I fling the barrels way up into the air, they land on the ground correctly though. Something about the world being near or possibly inside the barrels makes them fall through. The barrels also collide properly with a btRaycastVehicle wandering about the world, just not with the world.

The btRigidBodies I'm trying to sleep are all btConvexHulls and the world (landscape) is made out of btBvhTriangleMeshes with a few buildings scattered about made out of btConvexHulls.

Is there a proper, or at least better way to force rigid bodies to sleep that makes them work correctly with the world? I can't just let the simulation make them fall asleep for performance issues and the fact that a lot of the objects are sitting on hills and gravity will naturally awaken them (which I don't want) and make the simulation very slow.

Thanks,

Cliff
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Forcing deactivation properly?

Post by Erwin Coumans »

Can you try this, after you constructed a rigidbody and added it to the world:

Code: Select all

rigidbody->setActivationState(ISLAND_SLEEPING);
hope this helps,
Erwin