22 _center = src._center;
23 _radius = src._radius;
34 const Vector3 delta = point - _center;
42 const float b = m.
dot(rayDirection);
43 const float c = m.
dot(m) - _radius * _radius;
45 if (c > 0.0f && b > 0.0f) {
49 const float discr = b * b - c;
54 const float t = std::abs(-b - std::sqrt(discr));
56 *point = ray.
origin() + rayDirection * t;
63 const Vector3 delta = sphere._center - _center;
64 const float totalRadius = sphere._radius + _radius;
BoundingSphere clone() const
const Vector3 & center() const
bool intersectsRay(const Ray &ray, Vector3 *point=nullptr) const
bool containsPoint(const Vector3 &point) const
bool intersectsBoundingSphere(const BoundingSphere &sphere) const
BoundingSphere & copy(const BoundingSphere &src)
Infinite ray defined by origin and direction for raycasting and picking.
const Vector3 & origin() const
const Vector3 & direction() const
3D vector for positions, directions, and normals with multi-backend SIMD acceleration.
Vector3 normalized() const
float dot(const Vector3 &other) const
float lengthSquared() const