You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
Fix AABB Ray intersection - return inside
* Separates find_intersects from test_intersects for rays, and wraps the former. * Changes parameter name to "r_intersection_point". * Fixes broken old version which returned per axis t. * Returns whether the ray origin is within the AABB. * Returns intersection point when origin outside. * Returns "backtracking" intersection point when inside. * Returns sensible normal when inside. * Returns valid results on borders. * Returns robust results dealing with floating point error. Co-authored-by: Claire Blackshaw <evilkimau@gmail.com>
This commit is contained in:
@@ -71,10 +71,15 @@ struct _NO_DISCARD_ AABB {
|
||||
AABB merge(const AABB &p_with) const;
|
||||
void merge_with(const AABB &p_aabb); ///merge with another AABB
|
||||
AABB intersection(const AABB &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
|
||||
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const;
|
||||
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const;
|
||||
_FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t p_t0, real_t p_t1) const;
|
||||
|
||||
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_intersection_point = nullptr, Vector3 *r_normal = nullptr) const;
|
||||
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir) const {
|
||||
bool inside;
|
||||
return find_intersects_ray(p_from, p_dir, inside);
|
||||
}
|
||||
bool find_intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, bool &r_inside, Vector3 *r_intersection_point = nullptr, Vector3 *r_normal = nullptr) const;
|
||||
|
||||
_FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count) const;
|
||||
_FORCE_INLINE_ bool inside_convex_shape(const Plane *p_planes, int p_plane_count) const;
|
||||
bool intersects_plane(const Plane &p_plane) const;
|
||||
|
||||
Reference in New Issue
Block a user