Fix BulletCapsuleShape creation from Panda CollisionTube

Functions get_point_a() and get_point_b() appear to return the top of the cylinder section of the tube, not the tip of the endcap, making subtracting the radius unnecessary.
This commit is contained in:
David Staer 2018-11-29 23:02:40 +08:00
parent 97d4e32a06
commit aa750f4046

View File

@ -93,8 +93,8 @@ BulletCapsuleShape *BulletCapsuleShape::
make_from_solid(const CollisionTube *solid) { make_from_solid(const CollisionTube *solid) {
PN_stdfloat radius = solid->get_radius(); PN_stdfloat radius = solid->get_radius();
// CollisionTube height includes the hemispheres, Bullet only wants the cylinder height. // Get tube's cylinder height: length from point A to point B
PN_stdfloat height = (solid->get_point_b() - solid->get_point_a()).length() - (radius * 2); PN_stdfloat height = (solid->get_point_b() - solid->get_point_a()).length();
// CollisionTubes are always Z-Up. // CollisionTubes are always Z-Up.
return new BulletCapsuleShape(radius, height, Z_up); return new BulletCapsuleShape(radius, height, Z_up);