Improved the Box2D engine, have a few problems
Posted: Sat Aug 19, 2006 12:46 am
Hi everyone, I started working to add some new features to the Box2D engine and Iv succeeded with:
-a hash table based broadphase collision detection method that is about O(1) (plus a little overhead for clearing / updating the table)
-sleeping for bodies that dont move over a period of time
-basic shape system (have added a circle shape, working on capsule)
-few optimizations here and there
-restitution
-multi-threaded (collision detection / dynamics on different threads)
Most of these work pretty well, but I have a few problems and need some suggestions for solutions
Before I forget, heres the code for what I currently have: Source Code (Right click, save target as)
First off, the main problem is that when I enable multi-threading and the number of bodies gets over about 600 or so, it becomes unstable and eventually crashes. I believe this is because teh dynamics thread is trying to access an arbiter, but the collision detection thread is deleting it at the same time, though I am not completely sure.
In the demos, multi-threading is not enabled by default, to enable it go into Flags.h and uncomment the MULTI_THREAD line and recompile
Secondly, unless the bodies are moving at high speeds, restitution only seems to work in between similar shapes (for example, boxes only bounce off of boxes and circle off of circles)
I am baffled as to why this would happen...
The last thing is that the circles can be "inside" the boxes as if they were hollow. This is because I am using lines as the boxes boundry and the spheres only check for collisions on those lines. Im not too knolegable in the collision detection field yet so I havent been able to figure out how to do correct box-circle collisions
Any hints/suggestions/solutions to these problems would be greatly appreciated.
The statistics for the various processes are cout'd
As you will see, the collision detection and dynamics phases take about the same amount of time, so if the multithreading worked properly all the time it would cut the amount of time normaly needed in half
-a hash table based broadphase collision detection method that is about O(1) (plus a little overhead for clearing / updating the table)
-sleeping for bodies that dont move over a period of time
-basic shape system (have added a circle shape, working on capsule)
-few optimizations here and there
-restitution
-multi-threaded (collision detection / dynamics on different threads)
Most of these work pretty well, but I have a few problems and need some suggestions for solutions
Before I forget, heres the code for what I currently have: Source Code (Right click, save target as)
First off, the main problem is that when I enable multi-threading and the number of bodies gets over about 600 or so, it becomes unstable and eventually crashes. I believe this is because teh dynamics thread is trying to access an arbiter, but the collision detection thread is deleting it at the same time, though I am not completely sure.
In the demos, multi-threading is not enabled by default, to enable it go into Flags.h and uncomment the MULTI_THREAD line and recompile
Secondly, unless the bodies are moving at high speeds, restitution only seems to work in between similar shapes (for example, boxes only bounce off of boxes and circle off of circles)
I am baffled as to why this would happen...
The last thing is that the circles can be "inside" the boxes as if they were hollow. This is because I am using lines as the boxes boundry and the spheres only check for collisions on those lines. Im not too knolegable in the collision detection field yet so I havent been able to figure out how to do correct box-circle collisions
Any hints/suggestions/solutions to these problems would be greatly appreciated.
The statistics for the various processes are cout'd
As you will see, the collision detection and dynamics phases take about the same amount of time, so if the multithreading worked properly all the time it would cut the amount of time normaly needed in half