Massive Raycasting speedup against Gimpact objects

0xc0deface
Posts: 5
Joined: Mon Aug 27, 2012 4:55 am

Massive Raycasting speedup against Gimpact objects

Post by 0xc0deface »

Hi.

I use bullet with btBvhTriangleMeshShape and btGImpactMeshShape for acurate raycasting in an editor like application.

I noticed that meshes approaching 2,000,000 tris would perform fine with btBvhTriangleMeshShape but grind to a halt with btGImpactMeshShape.

By that I mean the frame rate would plunge from 40fps to 3fps.

I found that btBvhTriangleMeshShape has a special case in btCollisionWorld::rayTestSingle which was letting it cast optimally where as btGImpactMeshShape was using the default case despite also being able to cast optimally.

I added a new function to btGImpactMeshShape called processAllTrianglesRay and made rayTestSingle use this for btGImpactMeshShapes. This boosted performance back up to the same level that btBvhTriangleMeshShape enjoys for raycasting; an order of magnitude improvement.

processAllTrianglesRay behaves the same as processAllTriangles however rather than using boxQuery internally it uses rayQuery.

I have attached a patch along with the final copies of the 3 files I changed.

I there are any problems that would stop this going into bullet let me know.

Thanks!
You do not have the required permissions to view the files attached to this post.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Massive Raycasting speedup against Gimpact objects

Post by Erwin Coumans »

That sounds good. Can you report the fix in the issue tracker?

https://code.google.com/p/bullet/issues/list
0xc0deface
Posts: 5
Joined: Mon Aug 27, 2012 4:55 am

Re: Massive Raycasting speedup against Gimpact objects

Post by 0xc0deface »

Submit as issue 664. I attached the zip there also, and made the issue refer to this thread. Thanks!