| 26 | } |
| 27 | |
| 28 | f32 ray_disc_intersection(const Vector3 &from, const Vector3 &dir, const Vector3 ¢er, 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 | |
| 43 | f32 ray_sphere_intersection(const Vector3 &from, const Vector3 &dir, const Sphere &s) |
| 44 | { |
no test coverage detected