MCPcopy Create free account
hub / github.com/crownengine/crown / ray_disc_intersection

Function ray_disc_intersection

src/core/math/intersection.cpp:28–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28f32 ray_disc_intersection(const Vector3 &from, const Vector3 &dir, const Vector3 &center, f32 radius, const Vector3 &normal)
29{
30 const Plane3 p = plane3::from_point_and_normal(center, normal);
31 const f32 t = ray_plane_intersection(from, dir, p);
32
33 if (t == -1.0f)
34 return -1.0f;
35
36 const Vector3 intersection_point = from + dir * t;
37 if (distance_squared(intersection_point, center) < radius*radius)
38 return t;
39
40 return -1.0f;
41}
42
43f32 ray_sphere_intersection(const Vector3 &from, const Vector3 &dir, const Sphere &s)
44{

Callers 1

load_apiFunction · 0.85

Calls 1

ray_plane_intersectionFunction · 0.85

Tested by

no test coverage detected