Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
RaySphere.h File Reference

Go to the source code of this file.

Functions

JPH_NAMESPACE_BEGIN JPH_INLINE float RaySphere (Vec3Arg inRayOrigin, Vec3Arg inRayDirection, Vec3Arg inSphereCenter, float inSphereRadius)
 
JPH_INLINE int RaySphere (Vec3Arg inRayOrigin, Vec3Arg inRayDirection, Vec3Arg inSphereCenter, float inSphereRadius, float &outMinFraction, float &outMaxFraction)
 

Function Documentation

◆ RaySphere() [1/2]

JPH_NAMESPACE_BEGIN JPH_INLINE float RaySphere ( Vec3Arg  inRayOrigin,
Vec3Arg  inRayDirection,
Vec3Arg  inSphereCenter,
float  inSphereRadius 
)

Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection against a sphere,

Returns
FLT_MAX if there is no intersection, otherwise the fraction along the ray.
Parameters
inRayOriginRay origin. If the ray starts inside the sphere, the returned fraction will be 0.
inRayDirectionRay direction. Does not need to be normalized.
inSphereCenterPosition of the center of the sphere
inSphereRadiusRadius of the sphere

◆ RaySphere() [2/2]

JPH_INLINE int RaySphere ( Vec3Arg  inRayOrigin,
Vec3Arg  inRayDirection,
Vec3Arg  inSphereCenter,
float  inSphereRadius,
float &  outMinFraction,
float &  outMaxFraction 
)

Tests a ray starting at inRayOrigin and extending infinitely in inRayDirection against a sphere. Outputs entry and exit points (outMinFraction and outMaxFraction) along the ray (which could be negative if the hit point is before the start of the ray).

Parameters
inRayOriginRay origin. If the ray starts inside the sphere, the returned fraction will be 0.
inRayDirectionRay direction. Does not need to be normalized.
inSphereCenterPosition of the center of the sphere.
inSphereRadiusRadius of the sphere.
outMinFractionReturned lowest intersection fraction
outMaxFractionReturned highest intersection fraction
Returns
The amount of intersections with the sphere. If 1 intersection is returned outMinFraction will be equal to outMaxFraction