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";
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);
121 private: ignition::math::Vector3d initialSize;
Bullet wrapper forward declarations and typedefs.
Box geometry primitive.
Definition BoxShape.hh:35
virtual void SetSize(const ignition::math::Vector3d &_size)
Set the size of the box.
Bullet box collision.
Definition BulletBoxShape.hh:38
void SetSize(const ignition::math::Vector3d &_size)
Set the size of the box.
Definition BulletBoxShape.hh:47
virtual ~BulletBoxShape()
Destructor.
Definition BulletBoxShape.hh:44
BulletBoxShape(CollisionPtr _parent)
Constructor.
Definition BulletBoxShape.hh:40
static btTransform ConvertPose(const ignition::math::Pose3d &_pose)
Convert an ignition math pose to a bullet transform.
Definition BulletTypes.hh:111
CollisionPtr collisionParent
This shape's collision parent.
Definition Shape.hh:79
#define gzerr
Output an error message.
Definition Console.hh:50
#define gzwarn
Output a warning message.
Definition Console.hh:47
boost::shared_ptr< BulletCollision > BulletCollisionPtr
Definition BulletTypes.hh:41
boost::shared_ptr< BulletLink > BulletLinkPtr
Definition BulletTypes.hh:42
boost::shared_ptr< Collision > CollisionPtr
Definition PhysicsTypes.hh:113
Forward declarations for the common classes.
Definition Animation.hh:27