Multithreading problem, cubes floating.

mkultra333
Posts: 3
Joined: Mon Nov 15, 2010 2:48 pm

Multithreading problem, cubes floating.

Post by mkultra333 »

Single threading in my project was going fine, I have stacks of cubes in a trimesh room, and using pre-tickcallback I can make them bounce up into the air when I press a key. The cubes fly up then tumble to the ground.

Added multithreading, coping virtually directly from the multithreaded demo. It compiles and runs, but there are problems.

The cubes are behaving badly. When I apply an upward force via the pre-tickcallback, they fly up but then most of them won't tumble again once they lose momentum, they just stop in mid-air, though others will fall and hit the ground. It seems mostly the cubes at the bottom of the stacks with tend to just halt in the air. Other cubes will still collide with them though.

(I tried setting the cubes to always being activated, but this didn't help. I've also checked to see if there's some invisible collision objects beneath floating cubes, but as best as I can tell from raytesting and watching other falling cubes there isn't.)

A few other cubes will slowly drift up, as if held by one corner, swinging slowly. When these cubes finally touch the roof, they fall all the way to the ground again.

Any suggestions for fixing this? I'm using VC9 on XP with a dual core AMD processor.
mkultra333
Posts: 3
Joined: Mon Nov 15, 2010 2:48 pm

Re: Multithreading problem, cubes floating.

Post by mkultra333 »

Problem seems somehow related to the btBvhTriangleMeshShape I build the map out of. When I build the map out of convex hulls instead the problem disappears and it multithreads find. (The map is a bsp so I can easily switch between either convex hulls or trimesh for the level geometry.)

Even though the btBvhTriangleMeshShape works fine with a single thread, it goes weird when multithreaded. Perhaps the mesh being a fundamentally concave shape is a problem for multithreading. (Its a Quake 3 Arena dungeon style map.)

Not sure what to do. I'd really like to have multithreading, but the map definitely needs some shapes that aren't convex hulls, such as patch mesh curves that smooth interior corners. I wonder how performance will go if I convert every triangle on those patch meshes into individual little convex hulls?