This is an old revision of the document!
The Raycasting namespace provides functions for testing ray intersections with various shapes.
Raycasting is a technique used in real-time physics simulations and games to detect collisions between objects. It involves projecting a ray from an origin point in a certain direction, and checking if it intersects with any objects in its path.
Raycasting can be used for a variety of purposes, such as detecting line-of-sight, finding the distance between two objects, and determining the surface normal of a collision. In games, it's often used to simulate realistic lighting and shadows, as well as to detect collisions between a player and the environment or other game objects.
For example, in a first-person shooter game, raycasting can be used to determine whether a bullet fired by the player hits an enemy or not. Similarly, in a racing game, it can be used to detect collisions between a player's car and other objects on the track.
Overall, raycasting is a powerful technique for simulating physics in real-time applications and games, and it has a wide range of practical uses.
Tests if a ray intersects a sphere.
Parameters:
a
: Sphere
- The sphere to test.ray
: Ray
- The ray to test.Returns:
float
- The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.Tests if a ray intersects an axis-aligned bounding box (AABB).
Parameters:
aabb
: AABB
- The AABB to test.ray
: Ray
- The ray to test.Returns:
float
- The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.Tests if a ray intersects an oriented bounding box (OBB).
Parameters:
obb
: OrientedBox
- The OBB to test.ray
: Ray
- The ray to test.Returns:
float
- The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.Tests if a ray intersects a plane.
Parameters:
plane
: Plane
- The plane to test.ray
: Ray
- The ray to test.Returns:
float
- The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.Tests if a ray intersects a triangle.
Parameters:
triangle
: Triangle
- The triangle to test.ray
: Ray
- The ray to test.Returns:
float
- The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.Tests if a ray intersects a mesh.
Parameters:
mesh
: Mesh
- The mesh to test.ray
: Ray
- The ray to test.Returns:
float
- The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.Tests if a ray intersects an entity.
Parameters:
entity
: Entity
- The entity to test.ray
: Ray
- The ray to test.Returns:
float
- The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.Tests if a line intersects a sphere.
Parameters:
sphere
: Sphere
- The sphere to test.line
: Line
- The line to test.Returns:
bool
- true
if the line intersects the sphere, false
otherwise.Tests if a line intersects an axis-aligned bounding box (AABB).
Parameters:
aabb
: AABB
- The AABB to test.line
: Line
- The line to test.Returns:
bool
- true
if the line intersects the AABB, false
otherwise.Tests if a line intersects an oriented bounding box (OBB).
Parameters:
obb
: OrientedBox
- The OBB to test.line
: Line
- The line to test.Returns:
bool
- true
if the line intersects the OBB, false
otherwise.Tests if a line intersects a plane.
Parameters:
plane
: Plane
- The plane to test.line
: Line
- The line to test.Returns:
bool
- true
if the line intersects the plane, false
otherwise.Tests if a line intersects a triangle.
Parameters:
triangle
: Triangle
- The triangle to test.line
: Line
- The line to test.Returns:
bool
- true
if the line intersects the triangle, false
otherwise.Tests if a line intersects a mesh.
Parameters:
mesh
: Mesh
- The mesh to test.line
: Line
- The line to test.Returns:
bool
- true
if the line intersects the mesh, false
otherwise.Tests if a line intersects an entity.
Parameters:
entity
: Entity
- The entity to test.line
: Line
- The line to test.Returns:
bool
- true
if the line intersects the entity, false
otherwise.Calculates the barycentric coordinates of a point in relation to a triangle.
Parameters:
p
: Point
- The point for which to calculate barycentric coordinates.t
: Triangle
- The triangle to use for the calculation.Returns:
Vector3
- The barycentric coordinates of the point in relation to the triangle.