VerletCapsuleShape::VerletCapsuleShape(VerletPoint* startPoint, VerletPoint* endPoint) : CapsuleShape(), _startPoint(startPoint), _endPoint(endPoint), _startLagrangeCoef(0.5f), _endLagrangeCoef(0.5f) { assert(startPoint); assert(endPoint); _halfHeight = 0.5f * glm::distance(_startPoint->_position, _endPoint->_position); updateBoundingRadius(); }
void CapsuleShape::setEndPoints(const glm::vec3& startPoint, const glm::vec3& endPoint) { glm::vec3 axis = endPoint - startPoint; _translation = 0.5f * (endPoint + startPoint); float height = glm::length(axis); if (height > EPSILON) { _halfHeight = 0.5f * height; axis /= height; _rotation = computeNewRotation(axis); } updateBoundingRadius(); }
CapsuleShape::CapsuleShape(float radius, const glm::vec3& startPoint, const glm::vec3& endPoint) : Shape(Shape::CAPSULE_SHAPE), _radius(radius), _halfHeight(0.f) { glm::vec3 axis = endPoint - startPoint; float height = glm::length(axis); if (height > EPSILON) { _halfHeight = 0.5f * height; axis /= height; glm::vec3 yAxis(0.f, 1.f, 0.f); float angle = glm::angle(axis, yAxis); if (angle > EPSILON) { axis = glm::normalize(glm::cross(yAxis, axis)); _rotation = glm::angleAxis(angle, axis); } } updateBoundingRadius(); }
void CapsuleShape::setRadiusAndHalfHeight(float radius, float halfHeight) { _radius = radius; _halfHeight = halfHeight; updateBoundingRadius(); }
void CapsuleShape::setHalfHeight(float halfHeight) { _halfHeight = halfHeight; updateBoundingRadius(); }
void CapsuleShape::setRadius(float radius) { _radius = radius; updateBoundingRadius(); }
CapsuleShape::CapsuleShape(float radius, float halfHeight, const glm::vec3& position, const glm::quat& rotation) : Shape(Shape::CAPSULE_SHAPE, position, rotation), _radius(radius), _halfHeight(halfHeight) { updateBoundingRadius(); }
CapsuleShape::CapsuleShape(float radius, float halfHeight) : Shape(Shape::CAPSULE_SHAPE), _radius(radius), _halfHeight(halfHeight) { updateBoundingRadius(); }
// virtual void VerletCapsuleShape::setEndPoints(const glm::vec3& startPoint, const glm::vec3& endPoint) { _startPoint->_position = startPoint; _endPoint->_position = endPoint; updateBoundingRadius(); }