btCapsuleShape suggestion

btmorex
Posts: 11
Joined: Wed May 23, 2007 12:58 am

btCapsuleShape suggestion

Post by btmorex »

I'd suggest either making the height parameter apply to the full capsule or adding documentation that it only applies to the "cylinder" portion.

This had be scratching my head for a while (collisions with positions that I didn't expect).
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

The btCapsuleShape constructor takes height as input, which is the full height. The btCylinderShape, btBoxShape, btSphereShape all take 'half Extents' or radius.

Should we make it more consistent, and construct the btCapsuleShape using halfHeight?

Thanks,
Erwin
btmorex
Posts: 11
Joined: Wed May 23, 2007 12:58 am

Post by btmorex »

Erwin Coumans wrote:The btCapsuleShape constructor takes height as input, which is the full height. The btCylinderShape, btBoxShape, btSphereShape all take 'half Extents' or radius.

Should we make it more consistent, and construct the btCapsuleShape using halfHeight?

Thanks,
Erwin
I'm almost positive that (2 * radius + height) ends up being the full height of btCapsuleShape... unless I'm completely misunderstanding my results.

I can give you specific collision scenarios I'm seeing in my program if you'd like.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

It is supposed to be like this picture: red line is the halfheight, and green is radius. Right now, the capsule is specified by the full height and the green radius. So you are right, the total height is input height + 2*radius.

Image

If you make the radius (margin) zero, you will see an inconsistency I'm talking about: the cylinder is specified by its halfHeight, and capsule by its full height. This will be proper documented, or fixed.
btmorex
Posts: 11
Joined: Wed May 23, 2007 12:58 am

Post by btmorex »

Erwin Coumans wrote:It is supposed to be like this picture: red line is the halfheight, and green is radius. Right now, the capsule is specified by the full height and the green radius. So you are right, the total height is input height + 2*radius.

Image

If you make the radius (margin) zero, you will see an inconsistency I'm talking about: the cylinder is specified by its halfHeight, and capsule by its full height. This will be proper documented, or fixed.
Thanks for your responses Erwin.

I guess it wasn't so much half height vs. full height that threw me off rather it's the fact that the height didn't include the half sphere caps. If I look at the capsule shape as a compound shape between a cylinder and 2 spheres, I can see why the height parameter would only affect the cylinder shape. I think it could go either way, but a comment in the sources that gets picked up by doxygen would help a lot (I'm learning from doxygen and the demos exclusively).

My thoughts on consistent half height vs. a mix: the only dimension that I regularly see as "half height" in formulas/equations is the radius (as opposed to diameter). Of course, I'm not so familiar with collision detection so using half height might be the more natural form. Either way works for me as long as it's documented. If there were no other considerations, I would probably go with half height for radius and full height for all other dimensions.