Optimizing Bullet raycast performance?

rrg
Posts: 3
Joined: Fri Nov 02, 2007 1:56 am

Optimizing Bullet raycast performance?

Post by rrg »

Hello all,

I’m using Bullet 2.64 to cast against both heightfield collision and compound collision built from a set of convex shapes. In my tests, performing a raycast against a compound shape is more expensive than raycasting against the heightfield. On my machine (a good, fairly new desktop) the additional cost per raycast can be .01 - .02 milliseconds. Given that I intend to perform a large # of raycasts, I’m curious if I can optimize raycast performance in the compound shape case.

Typically, the compound shape is comprised of 4-5 boxShapes. In profiling the Bullet code, I find that the majority of the additional time is spent in calls to localGetSupportingVertex inside of btSubSimplexConvexCast::calcTimeOfImpact.

Can anyone tell me if this is expected behavior, or if it means I should be using Bullet’s raycasting support some other way?

Thanks for reading!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Optimizing Bullet raycast performance?

Post by Erwin Coumans »

We haven't optimized the raycasting much yet.

We are planning to add some benchmarks to improve performance. I'll make sure we address this issue for upcoming versions (2.67 will be released today if all goes fine)

To make sure the issue gets addressed, it has been added to the tracker here:
http://code.google.com/p/bullet/issues/detail?id=25

Thanks for the feedback,
Erwin
rrg
Posts: 3
Joined: Fri Nov 02, 2007 1:56 am

Re: Optimizing Bullet raycast performance?

Post by rrg »

Hi Erwin, thanks for the response. Just to follow up, I implemented a ray-box test using the standard GraphicsGems implementation and found I was able to improve my application's raycast performance time from around 2.6 ms to 0.6 ms for 100 raycasts versus btBoxShapes. So, optimized ray-convexShape code is definitely something I'll be adding to my project's Bullet-based physics system, and I'd be happy to submit some form of that work for inclusion in the Bullet library, if that'd be helpful.