17 #ifndef GAZEBO_PHYSICS_BULLET_BULLETBOXSHAPE_HH_
18 #define GAZEBO_PHYSICS_BULLET_BULLETBOXSHAPE_HH_
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";
77 this->collisionParent);
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);
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(
121 private: ignition::math::Vector3d initialSize;
Bullet collisions.
Definition: BulletCollision.hh:43
Bullet Link class.
Definition: BulletLink.hh:37
static btTransform ConvertPose(const ignition::math::Pose3d &_pose)
Convert an ignition math pose to a bullet transform.
Definition: BulletTypes.hh:111
BulletBoxShape(CollisionPtr _parent)
Constructor.
Definition: BulletBoxShape.hh:40
boost::shared_ptr< BulletCollision > BulletCollisionPtr
Definition: BulletTypes.hh:39
#define gzwarn
Output a warning message.
Definition: Console.hh:47
#define gzerr
Output an error message.
Definition: Console.hh:50
Bullet wrapper forward declarations and typedefs.
boost::shared_ptr< BulletLink > BulletLinkPtr
Definition: BulletTypes.hh:42
virtual ~BulletBoxShape()
Destructor.
Definition: BulletBoxShape.hh:44
void SetSize(const ignition::math::Vector3d &_size)
Set the size of the box.
Definition: BulletBoxShape.hh:47
Box geometry primitive.
Definition: BoxShape.hh:34
btCollisionShape * GetCollisionShape() const
Get the bullet collision shape.
virtual void SetSize(const ignition::math::Vector3d &_size)
Set the size of the box.
Bullet box collision.
Definition: BulletBoxShape.hh:37
void ClearCollisionCache()
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113