Bullet API how to stop an object after collision has happend

This topic is 2545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am not sure the correct way to do this is, but I am thinking of cheating and having bullet drop my coins onto my track point cloud mesh so the coins position themselves onto the track correctly. Now the issue is when I drop them I am sure they are going to behave as any other object would and roll or move at least. All I want is to drop and once the coin hits stop it there. So do I need a trigger setup for this and if so what attributes of the btRidgidBody do I need to set to stop the coins from moving anymore.

Thanks!

Share on other sites
I'd probably be easier to just use the btCollisionWorld::rayTestSingle() to "drop" a line down from reasonable start locations to the track surface. You could then place your coins. Then make them static, infinite inertia (and 0 mass), no gravity.

If you do actually go with dropping your coins, you can just walk the manafolds after the physics update to generate lists of game objects to notify of collisions. Then, on collision, btRigidBody::clearForces(), then btRigidBody::setLinearVelocity and btRigidBody::setAngularVelocity to zero.

Share on other sites

From the looks of it I have to code up some virtual function for RayResultCallback()? If so is there anyway to allow Bullet to do this without have to code up something specific? Seems like a common issue where one would want to know where a hit was performed on a point cloud or any object....

BTW the fromTrans I am assuming this is the starting point, toTrans would be the final point where you want to cast to? Is that correct? So what is colObjWorldTransform? I am assuming this is the location of the object which we are going to test against? e.g. track's world transform matrix?

Thanks!

btCollisionWorld::RayResultCallback test;	btCollisionWorld::rayTestSingle(fromTrans, toTrans, 									resources->physicsManager.Get("Track")->GetRigidBody(), 									resources->physicsManager.Get("Track")->GetCollisionShape(),									resources->physicsManager.Get("Track")->GetMatrixWorldTransform(),									test);

Share on other sites
First off, sorry for the slow reply. Vacation!(tm) and all.

Quote:
 From the looks of it I have to code up some virtual function for RayResultCallback()? If so is there anyway to allow Bullet to do this without have to code up something specific? Seems like a common issue where one would want to know where a hit was performed on a point cloud or any object....

Yeah, you have to code stuff for those. But for the most part, they are reusable everywhere once written. I'm sure there are a few in bullet, but I don't recall the names they used. ClosestRayResultCallback? The idea is to just make generic result callback classes that store all the information you need about the collisions.

Quote:
 BTW the fromTrans I am assuming this is the starting point, toTrans would be the final point where you want to cast to? Is that correct?

Yes.

Quote:
 So what is colObjWorldTransform? I am assuming this is the location of the object which we are going to test against? e.g. track's world transform matrix?

Yup.

Ok, so sorry I didn't find the other one of these...
If you take your btDynamicsWorld you can btDynamicsWorld::GetCollisionWorld() and call btCollisionWorld::rayTest() to test against all objects in the world.

Share on other sites
Thanks KulSeran!

I will take a look at it!

Share on other sites

This topic is 2545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628764
• Total Posts
2984564

• 13
• 9
• 25
• 12
• 9