CCD TimeOfImpact performance with btBvhTriangleMeshShape

jcarew
Posts: 9
Joined: Sun Jul 13, 2008 8:31 pm

CCD TimeOfImpact performance with btBvhTriangleMeshShape

Post by jcarew »

Hi, I have question about performance of TimeOfImpact. In my project I use btBvhTriangleMeshShape with btTriangleMesh for static level meshand btBoxShape for my moving test object. I try implementation CCD for this movable box and I use calcTimeOfImpact from btContinuousConvexCollision. When I run ~200x calcTimeOfImpact application speed drop from 1000FPS to 15FPS, but if I need many objects (100 units+) with calcTimeOfImpact my application performance will be very poor. What is the best and the fastest function (between btBoxShape/btCapsuleShape etc. and btBvhTriangleMeshShape) to CCD avaiable in Bullet? btContinuousConvexCollision, btGjkConvexCast or ConvexSweepTest? Can I improve performence of btBvhTriangleMeshShape in calcTimeOfImpact test (if I don't use btBvhTriangleMeshShape, but btBoxShape my FPS go down to ~600 for 200 TOI tests, but I can't use for static level data this shape)? btTriangleMesh only need more memory than btTriangleIndexVertexArray but performance for this to structures is similar?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: CCD TimeOfImpact performance with btBvhTriangleMeshShape

Post by Erwin Coumans »

jcarew wrote:Hi, I have question about performance of TimeOfImpact. In my project I use btBvhTriangleMeshShape with btTriangleMesh for static level meshand btBoxShape for my moving test object. I try implementation CCD for this movable box and I use calcTimeOfImpact from btContinuousConvexCollision. When I run ~200x calcTimeOfImpact application speed drop from 1000FPS to 15FPS, but if I need many objects (100 units+) with calcTimeOfImpact my application performance will be very poor. What is the best and the fastest function (between btBoxShape/btCapsuleShape etc. and btBvhTriangleMeshShape) to CCD avaiable in Bullet? btContinuousConvexCollision, btGjkConvexCast or ConvexSweepTest?
btSubSimplexConvexCast is fastest, but it only supports pure linear motion, just like the btGjkConvexCast. btContinuousConvexCollision is slower, but it supports both angular and linear motion.
Can I improve performence of btBvhTriangleMeshShape in calcTimeOfImpact test?
Yes, use the btConvexcastBatch, check out Demos\ConcaveConvexcastDemo\ConcaveConvexcastDemo.cpp
btTriangleMesh only need more memory than btTriangleIndexVertexArray but performance for this to structures is similar?
btTriangleMesh is derived from btTriangleIndexVertexArray, so performance is the same, it just provides a storage container instead of re-using existing triangle/index data.

Hope this helps,
Erwin
jcarew
Posts: 9
Joined: Sun Jul 13, 2008 8:31 pm

Re: CCD TimeOfImpact performance with btBvhTriangleMeshShape

Post by jcarew »

Thank You for your help :)

I have problem with TOI via btSubSimplexConvexCast. If I use in this test btBvhTriangleMeshShape my program crash, this is normal situation? btSubSimplexConvexCast don't work with btBvhTriangleMeshShape?

How with this btConvexcastBatch can I speed up TOI test with btBvhTriangleMeshShape? In this demo I don't see any function for partition btBvhTriangleMeshShape etc.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: CCD TimeOfImpact performance with btBvhTriangleMeshShape

Post by Erwin Coumans »

jcarew wrote:Thank You for your help :)

I have problem with TOI via btSubSimplexConvexCast. If I use in this test btBvhTriangleMeshShape my program crash, this is normal situation? btSubSimplexConvexCast don't work with btBvhTriangleMeshShape?

How with this btConvexcastBatch can I speed up TOI test with btBvhTriangleMeshShape? In this demo I don't see any function for partition btBvhTriangleMeshShape etc.
Demos\ConcaveConvexcastDemo\ConcaveConvexcastDemo.cpp shows how to use the btConvexcastBatch against a btBvhTriangleMeshShape.

In short: create a btCollisionWorld or btDiscreteDynamicsWorld, add a btCollisionObject with the btBvhTriangleMeshShape to this world, and use "convexcastBatch.cast (collisionWorld)".

You can't directly use the btSubSimplexConvexCast against a btBvhTriangleMeshShape. The query against a btBvhTriangleMeshShape has been implemented within the btCollisionWorld::objectQuerySingle around line 444.

Hope this helps,
Erwin
jcarew
Posts: 9
Joined: Sun Jul 13, 2008 8:31 pm

Re: CCD TimeOfImpact performance with btBvhTriangleMeshShape

Post by jcarew »

How btConvexcastBatch can optimize my btBvhTriangleMeshShape? In this demo I see than btConvexcastBatch is multiple rayTest, so what can I use it for optimize? I should calculate all collision with btBvhTriangleMeshShape by rayTests? I don't understand how it can improve speed of btContinuousConvexCollision TOI test between btBoxShape and btBvhTriangleMeshShape? Maybe I can automatic partition my btBvhTriangleMeshShape by some Bullet functions for many small fragments, I think than less vertex in multiple mesh for collision = better speed?