What is the simplest way to detect collisions between two any meshes? Without any physics, only detect collisions in every simulation step, with information which objects have collisions.
Is there any way to set distance (a margin) to detect a collision?
Thanks in advance,
Even If you don’t want actual physical interations, you can use Bullet for just the collision detection. And I belive that’s what you should do.
Thank you for answer. I tried collision detection from sample 18_Characted_Demo. If I set SetUseGravity(false) for my objects and subscribe to E_NODECOLLISIONSTART then I have almost what I want. Gravity does not work, I have a collision notification, but Physics is still blocking me from programically move one object into another. How to completely turn off physics, leave only collision checking?
Have you tried to mark your object as Trigger?
However, I don’t know whether the triggers are colliding with each other.
Trigger should work. If it does not, or you have some other motion related issues, you can also try turning on Kinematic mode for your rigid body.
If I mark objects as Trigger, it is ok if I set setBox() for CollisionShape. But if I set SetTriangleMesh() for CollisionShape, and mark objects as triggers , then the collision notification will stop working. Turning on Kinematic mode for rigid body does not help.
Triangle meshes and heightfields couldn’t be dynamic. Does other shapes work?
Yes, other meshes work (sphere, capsule itd). So, is it not possible to do it with only triangle meshes (for example mushroom objects)?
There are two shape types except trimesh (ConvexHull and GImpactMesh) that have model as input. Try them.
Why you need tri-meshes exactly? Can you give more specific info on what you are trying to do?
Is it two meshes like static level and some entity in it, or it’s several movable meshes?
I need Tri-Mesh because i have one irregular body and several other U-shaped bodies. The first body is similar to the capsule, but it has a lot of irregular elements on the surface. I need to know when this first body is in collision with any of the U-shaped bodies, but I can not simplify the shape very much, I must have high accuracy. All meshes are static, I only programmatically change the position of the first object, but no object uses the mechanisms of physics etc. But now it’s ok, I set the first body as ConvexHull and the U-shape bodies as Tri-Mesh (I can’t set them as convexhull because it simplifies the model and fills the space) and it works ok. I have a question if I can somehow detect the closest distance to a collision? If there is no collision but it is close, how to check the distance?
Thanks in advance.
Remember that you also can use compound shapes if convex hull is not enough.
There is no easy way to get closest distance between two surfaces, I’m afraid. With convexes you can adjust collision margin one step at a time and see if it collides or not.
I would like to try use GImpactMesh, is there any example how to use it?
Nope, but there is no interface difference between Convex, Trimesh and GImpactMesh except shape type. You set the type, you set the mesh.
But there is no GImpactMesh type in CollisionShape.
SHAPE_BOX = 0,
I’ve added this shape type about a month ago. Use fresh master revision.