Page MenuHome

Unstable triangle mesh collision bounds
Closed, ArchivedPublic

Description

Category: Physics

Problem is that two objects that do not intersect seems to collide when running game engine physics. The margin setting is at 0 and collision bounds is set to triangle mesh.

See file for example. When you hit "P" you can see that the two objects repel each other. They should just fall down in a straight line.

Details

Event Timeline

The initial impulse should be fixed by using bullet's "split impulse" option, not sure if it's implemented in the game engine. I could look into it.

However using dynamic triangle meshes is always problematic, especially when you stack them on top of each other.
A more stable way of dealing with concave objects it to use compound shapes consisting of convex parts.

Moved from Blender 2.6 Bug Tracker to Game Engine

Sergej, would be cool if you'll look into this.

Since it's an issue with GE, moving to it's own tracker.

After looking into this it seems that gimpact (the library used for dynamic mesh collision) has problems with parallel triangles and gives wrong contact point normals that cause objects to move sideways. So dynamic triangle meshes work better if the mesh doesn't have sharp edges and is more round.
There is an alternate algorithm that behaves better in this case but fails in other cases (you can enable it by uncommenting "#define BULLET_TRIANGLE_COLLISION 1" in btGimpactCollisionAlgorithm.h).
I'm not sure if this should be considered a bug or a limitation but it seems that nobody really worked on improving gimpact in the last few years and since I'm not familiar with it at all I won't be able to solve it myself in the near future either.

As I mentioned before using split impulse reduces the initial impulse so the objects don't fly apart but they're still moved because of the problem above.
I've attached a patch that adds a split impulse option for the game engine.

In the end it's best to avoid using dynamic mesh shapes (or at least make them more round) right now.

Attached a simpler testfile: bullet_gimpact_bug.blend

In my opinion, this bug/limitation is quite annoying, because triangle mesh collision bounds is unavoidable for physics precision in some cases (while generally not recommended). Split impulse already exists in rigid body world outside of the game engine, but not inside. I haven't tried the patch, but could we give it a try?

Unfortunately this is a complicated problem.

One good way to work around it would be to use convex decomposition to break concave meshes into convex parts and make compound shapes out of them. This can also be automated.
I've experimented with this and had mixed results. I'll definitely come back to it though, so we should have convex decomposition in some form in future releases.

Also see this bullet bug for more details: http://code.google.com/p/bullet/issues/detail?id=662&colspec=Modified%20ID%20Type%20Stars%20Status%20Owner%20Summary

taking a look at the patch..
@Sergej Reich (sergof) shouldn't "(lowers stacking stability slightly)" be increases stability?
Reading the linked bullet bug report, it seems that Erwin added a btConvexHullComputer that blender is not using.
Is it possible to use this for all triangles mesh shapes? Would it be a good idea? @Sergej Reich (sergof) would this be the way of automatically building a 'compound capsule' shape that I have been emailing you about?

Inês Almeida (brita_) lowered the priority of this task from Confirmed, High to Normal.Aug 7 2014, 3:03 PM

No, it does lower stacking stability. If you use it you'll need more solver iterations/simulation steps.
The thing is that in this case split impulse might only marginally help and only sometimes.

As for the bullet bug report, what Erwin added is a utility to create compound shapes from Gimpact collision shapes. We tried using it in the GE but it caused problems (was much slower and had bugs when doing raycasts).

As for btConvexHullComputer, we do use it in blender, but not in the GE, which still uses the older hull computer. Not sure if it's needed.

blender already uses btConvexHullComputer? Can you point me to where?
So using this new one would possibly not have the previous bugs/ problems? it's worth a try?

@Inês Almeida (brita_)
Look in intern/rigidbody/rb_bullet_api.cpp, also the convex hull mesh operator in edit mode uses it.
As for whether the GE should use it or not, I didn't make quality comparisons but the new hull computer should be much faster with bigger meshes.
So for games this shouldn't be that important since you generally don't use big meshes and we didn't get any complaints about convex hull generation afaik.

Aaron Carlisle (Blendify) closed this task as Archived.Jun 29 2019, 2:20 AM
Aaron Carlisle (Blendify) claimed this task.

This task is being closed because the BGE has been removed in Blender 2.8.