1
votes

I'm currenty writing an application that should check if it is possible to align different bars and connectors the way a designer has intended it. To do that I want to load the 3D-Models (Wavefront Objects) of the bars and connectors, place them the way the designer intended and check for collisions between the different models.

Now when I'm searching for collision detection I usually read that you should never ever check for collisions based on the mesh but rather simplify the model, therefore most tools I tried do not even allow you to check for collisions based on the mesh or they simplify that process. The problem is that people are talking about game development most of the time, but my use case is completely different. I don't even need to be very efficient. One detection per second would be more than enough, while games of course need those checks way more often.

Right now I'm working with BulletSharp (a .Net wrapper for the bullet physics engine) and I get decent results. When I simplify my mesh (with HACD convex decomposition) first and then check for collisions it works most of the time, but sometimes when the parts are very close to each other I get collisions when there shouldn't be any, like you can see on the picture (the red color indicates, that there is a collision between the parts). Interesting is, that it works even worse when I use the detailed object model instead of the simplified one.

Example of not really colliding objects

Are there any other approaches for such a use case? Maybe other engines or libraries that could help me (preferable but not necessarily in .Net)?

1
in what way do you simplify the model?Rob85

1 Answers

0
votes

you can use Z-Buffer for this

  1. render scene without tested object

    the view must be set so the tested object is full visible in front of camera. Render all objects except the tested one. This will fill the Z-Buffer.

    Sometimes for complex scenes is better to use cuts so place camera inside your tested object and render/test ... When done turn/move the camera in opposite direction and do the process again or you can use 6 directions not just 2 ...

    It depends also on the precision you need (the best precision is gained on plane coplanar with camera projection plane

  2. now use GLSL or any other shading language and test object

    so the shader (fragment shader) will not render anything instead will only query z-buffer value and test if "rendered" fragment is inside something already rendered or not.

    if it is then set some output to true or with index of rendered primitive for example to color buffer at the same position ...

    Do not render anything to depth buffer so use this shader and render only the tested object (without clearing buffers)

  3. scan the output image/buffer/what ever

    so scan all the outputs for overlapping primitives when you got the index of primitive crossing the scene. You have all the info you need including 3D position. You can use this as fast as you can render your scene so for modern 3D gfx cards no problem even on 30fps for medium complex objects