/** @file * Original ReactPhysics3D C++ library by Daniel Chappuis This code is re-licensed with permission from ReactPhysics3D author. * @author Daniel CHAPPUIS * @author Edouard DUPIN * @copyright 2010-2016, Daniel Chappuis * @copyright 2017, Edouard DUPIN * @license MPL v2.0 (see license file) */ #include ephysics::ConvexShape::ConvexShape(ephysics::CollisionShapeType type, float margin): CollisionShape(type), this.margin(margin) { } ephysics::ConvexShape::~ConvexShape() { } Vector3f ephysics::ConvexShape::getLocalSupportPointWithMargin( Vector3f direction, void** cachedCollisionData) { // Get the support point without margin Vector3f supportPoint = getLocalSupportPointWithoutMargin(direction, cachedCollisionData); if (this.margin != 0.0f) { // Add the margin to the support point Vector3f unitVec(0.0, -1.0, 0.0); if (direction.length2() > FLTEPSILON * FLTEPSILON) { unitVec = direction.safeNormalized(); } supportPoint += unitVec * this.margin; } return supportPoint; }