26 BulletCylinderShape(
const LVector3 &half_extents, BulletUpAxis up) :
27 _half_extents(half_extents),
30 btVector3 btHalfExtents = LVecBase3_to_btVector3(half_extents);
34 _shape =
new btCylinderShapeX(btHalfExtents);
37 _shape =
new btCylinderShape(btHalfExtents);
40 _shape =
new btCylinderShapeZ(btHalfExtents);
43 bullet_cat.error() <<
"invalid up-axis:" << up << endl;
48 _shape->setUserPointer(
this);
55 BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) :
60 _shape =
new btCylinderShapeX(btVector3(0.5 * height, radius, radius));
61 _half_extents = btVector3_to_LVector3(btVector3(0.5 * height, radius, radius));
64 _shape =
new btCylinderShape(btVector3(radius, 0.5 * height, radius));
65 _half_extents = btVector3_to_LVector3(btVector3(radius, 0.5 * height, radius));
68 _shape =
new btCylinderShapeZ(btVector3(radius, radius, 0.5 * height));
69 _half_extents = btVector3_to_LVector3(btVector3(radius, radius, 0.5 * height));
72 bullet_cat.error() <<
"invalid up-axis:" << up << endl;
77 _shape->setUserPointer(
this);
88 _half_extents = copy._half_extents;
90 btVector3 btHalfExtents = LVecBase3_to_btVector3(_half_extents);
94 _shape =
new btCylinderShapeX(btHalfExtents);
97 _shape =
new btCylinderShape(btHalfExtents);
100 _shape =
new btCylinderShapeZ(btHalfExtents);
103 bullet_cat.error() <<
"invalid up-axis:" << _up << endl;
108 _shape->setUserPointer(
this);
114 btCollisionShape *BulletCylinderShape::
123 PN_stdfloat BulletCylinderShape::
127 return (PN_stdfloat)_shape->getRadius();
133 LVecBase3 BulletCylinderShape::
134 get_half_extents_without_margin()
const {
137 return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin());
143 LVecBase3 BulletCylinderShape::
144 get_half_extents_with_margin()
const {
147 return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin());
168 _half_extents.write_datagram(dg);
185 param->fillin(scan, manager);
194 void BulletCylinderShape::
197 nassertv(_shape ==
nullptr);
202 _half_extents.read_datagram(scan);
203 _up = (BulletUpAxis) scan.
get_int8();
205 btVector3 btHalfExtents = LVecBase3_to_btVector3(_half_extents);
209 _shape =
new btCylinderShapeX(btHalfExtents);
212 _shape =
new btCylinderShape(btHalfExtents);
215 _shape =
new btCylinderShapeZ(btHalfExtents);
218 bullet_cat.error() <<
"invalid up-axis:" << _up << endl;
223 _shape->setUserPointer(
this);
224 _shape->setMargin(margin);