46 public:
void SetSize(
double _radius,
double _length)
50 gzerr <<
"Cylinder shape does not support negative radius\n";
55 gzerr <<
"Cylinder shape does not support negative length\n";
58 if (ignition::math::equal(_radius, 0.0))
63 gzwarn <<
"Setting cylinder shape's radius to zero \n";
66 if (ignition::math::equal(_length, 0.0))
68 gzwarn <<
"Setting cylinder shape's length to zero \n";
72 CylinderShape::SetSize(_radius, _length);
74 bParent = boost::dynamic_pointer_cast<BulletCollision>(
75 this->collisionParent);
77 btCollisionShape *shape = bParent->GetCollisionShape();
81 ignition::math::Vector3d(_radius, _radius, _length);
82 bParent->SetCollisionShape(
new btCylinderShapeZ(
83 btVector3(_radius, _radius, _length * 0.5)));
87 btVector3 cylinderScale;
88 cylinderScale.setX(_radius / this->initialSize.X());
89 cylinderScale.setY(_radius / this->initialSize.Y());
90 cylinderScale.setZ(_length / this->initialSize.Z());
92 shape->setLocalScaling(cylinderScale);
97 boost::dynamic_pointer_cast<BulletLink>(
99 bLink->ClearCollisionCache();
102 if (bLink->GetBulletLink()->getCollisionShape()->isCompound())
104 btCompoundShape *compoundShape =
105 dynamic_cast<btCompoundShape *
>(
106 bLink->GetBulletLink()->getCollisionShape());
108 compoundShape->removeChildShape(shape);
109 ignition::math::Pose3d relativePose =
110 this->collisionParent->RelativePose()
111 - bLink->GetInertial()->Pose();
112 compoundShape->addChildShape(
113 BulletTypes::ConvertPose(relativePose), shape);