improving bullet sweep test performance

pildanovak
Posts: 50
Joined: Thu Jul 14, 2005 1:55 pm

improving bullet sweep test performance

Post by pildanovak »

Hello, I've implemented a convex sweep test function(inside blender 3d ) and want to improve the performance of it.
Is it possible to use multithreading when testing collision against the same meshes somehow? if yes, how?
thanks
Last edited by pildanovak on Tue Aug 13, 2013 12:24 pm, edited 1 time in total.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: improving bullet performance

Post by Erwin Coumans »

There is no out-of-the-box switch to improve performance. Still, improving performance is possible but it will require someone to work on that.

Performance depends on many things, so it is not totally trivial.
Do you have many sweep queries? What kind of collision shapes are in the world? Are there many static objects, or many moving objects? , and how many static concave triangle meshes? For each case, the optimizations might be different. Most importantly, you need to motivate someone to actually implement those optimizations.
pildanovak
Posts: 50
Joined: Thu Jul 14, 2005 1:55 pm

Re: improving bullet performance

Post by pildanovak »

Thanks for you reply.
My use case is :

I am testing the same convex shape(so far only sphere, cone, cylinder) many times against a single or maximally several complex not-moving triangle mesh(es)(concave). I am interested only in the first hit. The mesh can have up to hunderds of thousands of triangles.
Currently, I get almost same performance if testing againtst a moving object, and passive object, but building BVH for static mesh takes a much longer time, so using active object is actually faster. The performance goes down significantly depending on the density of the mesh compared to the size of the convex shape which is "swept"- a tiny body collides fast, with growing diameter the performance decreases rapidly.
Also, these other things I tried didn't change performance:
-I tried splitting the object into more meshes.
- I tried to send the start/end positions just where I estimate from previous sampled position could be the hitpoint.
These changed performance, but not significantly:
- removing bottom-facing faces (this is not good if testing from more angles, but so far I tested just from one side.. Still it takes time to search and delete the faces, quite a lot inside blender, so the gain is not so interesting.)
- choosing dynamic object rather than passive BVH object(this was very surprising), because of BVH building time, and the testing also performed a tiny bit faster(only about 0.2%)


To explain my motivation, I am developing a CAM addon(computer aided machining) for Blender, the website is here:
blendercam.blogspot.com,
so the test is performed to test a tool position against an object to be machined. Currently, it's only for 3 axis milling, which means the cutter is dropped on Z axis, but the addon should be extensible also for 4 and 5 axis milling. There are usually several thousand up to more than a million tests against the mesh.

Regarding motivation, I have mostly my enthusiasm to motivate others :) I could also re-send some, or all of the donations I got so far for the project, which is still rather symbolic for such work.

I was asking because I thought there allready might be a method to achieve better results. Also, blender's rigid body simulation(in editor not in game engine), is probably not multithreaded, but I thought the convex_sweept_test might be multithreadable somehow, when passing e.g. all start-end positions for the sweep tests in lists.

I will be glad for any hints.
pildanovak
Posts: 50
Joined: Thu Jul 14, 2005 1:55 pm

Re: improving bullet performance

Post by pildanovak »

Hello,
I am still struggling with this, anybody has an idea about how the performance could become better with the way it is currently implemented in bullet?
thanks..
pildanovak
Posts: 50
Joined: Thu Jul 14, 2005 1:55 pm

Re: improving bullet performance

Post by pildanovak »

Hello, I am still trying to find any advice on how to optimize sweep test performance.

Could HACD potentially be used to optimize sweep tests, even when I need best precission possible?
Is that possible also for non-manifold meshes?

Sorry for asking again, but I just didn't find any solution to this anywhere else.
pildanovak
Posts: 50
Joined: Thu Jul 14, 2005 1:55 pm

Re: improving bullet sweep test performance

Post by pildanovak »

Hello, still got no answer, after several months. Am I asking wrong question, or in wrong forum?
I would be willing to pay for a solution to this...
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: improving bullet sweep test performance

Post by Erwin Coumans »

As far as I know, there is no developer with plans to improve the Bullet sweep performance at the moment, so don't expect for a miracle to happen.

Until someone can motivate a developer to improve it, it won't happen. I am busy with other things, so don't count on me.
If there was a team working on Bullet, it would be nice to assign someone improving it, but there is no such team.


You might want to switch to PhysX 3.x, it has faster sweep tests.
Thanks,
Erwin
pildanovak
Posts: 50
Joined: Thu Jul 14, 2005 1:55 pm

Re: improving bullet sweep test performance

Post by pildanovak »

Thanks for your reply.
I am not planning to switch to PhysX, for these reasons:
I develop in blender, and want to keep my development synced with it's current version. Also, I am mainly python developer, so from your point of view, an amateur ;)
I am big fan of open source and bullet too, so I won't switch also for these reasons.

I have saved so far all donations which have gone to my project and that is currently a bit more than 500Euro. I know that's not much, but I am offering this money to anybody wanting to improve this area in bullet -> blender.

the project page is here:
blendercam.blogspot.com

I totally understand that it is not your priority, and sorry if my questions sounded annoying. I didn't know how many people develop bullet. I just thougth that probably I used the sweep function wrong in some way. Maybe I could use regular collision for the CAM software I am developing, but I am not sure how that could be done, since I simply need to find a path for a cutter, which goes along an axis, e.t.c.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: improving bullet sweep test performance

Post by Erwin Coumans »

It helps if we first have some reproduction cases in a Bullet demo, that shows the slow sweep test. Then we file some issue in the issue tracker, https://code.google.com/p/bullet/issues/list, and sooner or later it will be addressed.

What kind of collision shapes are involved in the sweep test? Are the basic primitives (box, sphere) against a static triangle mesh?
pildanovak
Posts: 50
Joined: Thu Jul 14, 2005 1:55 pm

Re: improving bullet sweep test performance

Post by pildanovak »

The shapes involved are : Sphere, Cone, Cylinder, and will also probably involve convex and combined shape in future. The collision happens against a static triangle mesh. Basically a "cutter" is dropped on the surface of the object to be milled. So, only first hit is important for this code(and I guess many uses of this function will be about first hit).
The speed is lower when the basic shape is rotated, but I would have to test again to see how this exactly influences performance, I did my tests half a year ago, and didn't save results.
But I think the test time was growing linearly with the number of faces in the collision mesh.