Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites
Thanks for the reply.

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 this post


Link to post
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 this post


Link to post
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.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this