What shape for best convex cast performance?

pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

What shape for best convex cast performance?

Post by pico »

Hi,

currently i use a sphere primitive shape for convex casts. This works very fine, but its often too slow for my game.

Are there any guidelines or tips to improve performance for convex casts? I don't exactly need a sphere cast, just some volume.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: What shape for best convex cast performance?

Post by Erwin Coumans »

It is likely not the btSphereShape primitive that impacts performance, but all the other objects.

Can you share a sample of your world objects? Would it be possible to share it using the Collada exporter, so we can do some performance benchmarks?
Thanks,
Erwin

By the way, we started a IRC #bulletphysics discussion channel on freenode.net server
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: What shape for best convex cast performance?

Post by pico »

Erwin Coumans wrote:It is likely not the btSphereShape primitive that impacts performance, but all the other objects.

Can you share a sample of your world objects? Would it be possible to share it using the Collada exporter, so we can do some performance benchmarks?
Thanks,
Erwin

By the way, we started a IRC #bulletphysics discussion channel on freenode.net server
Hi Erwin,

i use the sphere cast to detect camera obstrusion. When using a single ray the performance is almost not countable. When using a convex cast it takes 6-8% on the Wii. I guess the AABB area within the cast has around 300 AABBs on peak.

So it doesn't matter if a sphere is tested or let say a swept triangle?

In this special case I could even get away with no exact collision data, but just that a collision happended. I guess this could speed things alot. Is there a way to test just for a collision without further costly evaluations?

I will take a look if i can get collision data for you.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: What shape for best convex cast performance?

Post by Erwin Coumans »

Code: Select all

When using a single ray the performance is almost not countable. When using a convex cast it takes 6-8% on the Wii. 
The ray cast is actually performing a sphere cast internally, with radius zero:

Code: Select all

void	btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
					  btCollisionObject* collisionObject,
					  const btCollisionShape* collisionShape,
					  const btTransform& colObjWorldTransform,
					  RayResultCallback& resultCallback)
{
	btSphereShape pointShape(btScalar(0.0));
	pointShape.setMargin(0.f);
	const btConvexShape* castShape = &pointShape;
However, the convex cast lacks some broadphase optimizations, so once they are added it should be much faster.

The btSphereShape has the best performance for the btCollisionWorld::convexSweepTest, it should be faster than casting a btTriangleShape.
Thanks,
Erwin
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: What shape for best convex cast performance?

Post by pico »

Hi,

thanks for the infos. For curiosity i tested it also with a box and cpu usage nearly doubled.

I think the main problem are the missing boradphase optmizations. When you added them for the rayTests the performance increase was dramatic.
Then i have to wait for those optimizations and disable sweep tests for now.

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

Re: What shape for best convex cast performance?

Post by Erwin Coumans »

Both ray cast and convex cast are using the broadphase acceleration structure now:

http://code.google.com/p/bullet/issues/detail?id=144

Please let us know if you notice some performance improvements for the btCollisionWorld::convexSweepTest on Wii,
Thanks,
Erwin