47 public:
void SetSize(
const ignition::math::Vector3d &_size)
49 if (_size.X() < 0 || _size.Y() < 0 || _size.Z() < 0)
51 gzerr <<
"Box shape does not support negative size\n";
54 ignition::math::Vector3d size = _size;
55 if (ignition::math::equal(size.X(), 0.0))
60 gzwarn <<
"Setting box shape's x to zero \n";
63 if (ignition::math::equal(size.Y(), 0.0))
65 gzwarn <<
"Setting box shape's y to zero \n";
68 if (ignition::math::equal(size.Z(), 0.0))
70 gzwarn <<
"Setting box shape's z to zero \n";
74 BoxShape::SetSize(size);
76 bParent = boost::dynamic_pointer_cast<BulletCollision>(
77 this->collisionParent);
80 btCollisionShape *shape = bParent->GetCollisionShape();
83 this->initialSize = size;
84 bParent->SetCollisionShape(
new btBoxShape(
85 btVector3(size.X()*0.5, size.Y()*0.5, size.Z()*0.5)));
89 btVector3 boxScale = shape->getLocalScaling();
90 boxScale.setX(size.X() / this->initialSize.X());
91 boxScale.setY(size.Y() / this->initialSize.Y());
92 boxScale.setZ(size.Z() / this->initialSize.Z());
94 shape->setLocalScaling(boxScale);
99 boost::dynamic_pointer_cast<BulletLink>(
101 bLink->ClearCollisionCache();
104 if (bLink->GetBulletLink()->getCollisionShape()->isCompound())
106 btCompoundShape *compoundShape =
107 dynamic_cast<btCompoundShape *
>(
108 bLink->GetBulletLink()->getCollisionShape());
110 compoundShape->removeChildShape(shape);
111 ignition::math::Pose3d relativePose =
112 this->collisionParent->RelativePose()
113 - bLink->GetInertial()->Pose();
114 compoundShape->addChildShape(
115 BulletTypes::ConvertPose(relativePose), shape);