summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/variant/plane.hpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-07 22:25:54 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-10-07 22:25:54 +0200
commitdb8679443fb6fcd5f9a97abf3e25c9e64f256607 (patch)
tree3adaf7df7db0ce66302490f3e5e9cbf263645929 /include/godot_cpp/variant/plane.hpp
parent0eba81ef79b96922a0e1637f812e4e1df4d29a4c (diff)
parent65eeb94f75d00cf523da114de3587f930cdec13f (diff)
downloadredot-cpp-db8679443fb6fcd5f9a97abf3e25c9e64f256607.tar.gz
Merge pull request #885 from aaronfranke/core-data-structs
Update core data structures to match the engine
Diffstat (limited to 'include/godot_cpp/variant/plane.hpp')
-rw-r--r--include/godot_cpp/variant/plane.hpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/include/godot_cpp/variant/plane.hpp b/include/godot_cpp/variant/plane.hpp
index 3a13ed2..8d5f69f 100644
--- a/include/godot_cpp/variant/plane.hpp
+++ b/include/godot_cpp/variant/plane.hpp
@@ -32,29 +32,30 @@
#define GODOT_PLANE_HPP
#include <godot_cpp/classes/global_constants.hpp>
-#include <godot_cpp/core/math.hpp>
#include <godot_cpp/variant/vector3.hpp>
namespace godot {
+class Variant;
+
struct _NO_DISCARD_ Plane {
Vector3 normal;
real_t d = 0;
void set_normal(const Vector3 &p_normal);
- inline Vector3 get_normal() const { return normal; }; /// Point is coplanar, CMP_EPSILON for precision
+ _FORCE_INLINE_ Vector3 get_normal() const { return normal; };
void normalize();
Plane normalized() const;
/* Plane-Point operations */
- inline Vector3 center() const { return normal * d; }
+ _FORCE_INLINE_ Vector3 center() const { return normal * d; }
Vector3 get_any_perpendicular_normal() const;
- inline bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane
- inline real_t distance_to(const Vector3 &p_point) const;
- inline bool has_point(const Vector3 &p_point, real_t _epsilon = CMP_EPSILON) const;
+ _FORCE_INLINE_ bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane
+ _FORCE_INLINE_ real_t distance_to(const Vector3 &p_point) const;
+ _FORCE_INLINE_ bool has_point(const Vector3 &p_point, real_t p_tolerance = CMP_EPSILON) const;
/* intersections */
@@ -62,7 +63,12 @@ struct _NO_DISCARD_ Plane {
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const;
bool intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const;
- inline Vector3 project(const Vector3 &p_point) const {
+ // For Variant bindings.
+ Variant intersect_3_bind(const Plane &p_plane1, const Plane &p_plane2) const;
+ Variant intersects_ray_bind(const Vector3 &p_from, const Vector3 &p_dir) const;
+ Variant intersects_segment_bind(const Vector3 &p_begin, const Vector3 &p_end) const;
+
+ _FORCE_INLINE_ Vector3 project(const Vector3 &p_point) const {
return p_point - normal * distance_to(p_point);
}
@@ -72,18 +78,18 @@ struct _NO_DISCARD_ Plane {
bool is_equal_approx(const Plane &p_plane) const;
bool is_equal_approx_any_side(const Plane &p_plane) const;
- inline bool operator==(const Plane &p_plane) const;
- inline bool operator!=(const Plane &p_plane) const;
+ _FORCE_INLINE_ bool operator==(const Plane &p_plane) const;
+ _FORCE_INLINE_ bool operator!=(const Plane &p_plane) const;
operator String() const;
- inline Plane() {}
- inline Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) :
+ _FORCE_INLINE_ Plane() {}
+ _FORCE_INLINE_ Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) :
normal(p_a, p_b, p_c),
d(p_d) {}
- inline Plane(const Vector3 &p_normal, real_t p_d);
- inline Plane(const Vector3 &p_point, const Vector3 &p_normal);
- inline Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir = CLOCKWISE);
+ _FORCE_INLINE_ Plane(const Vector3 &p_normal, real_t p_d = 0.0);
+ _FORCE_INLINE_ Plane(const Vector3 &p_normal, const Vector3 &p_point);
+ _FORCE_INLINE_ Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir = CLOCKWISE);
};
bool Plane::is_point_over(const Vector3 &p_point) const {
@@ -94,10 +100,10 @@ real_t Plane::distance_to(const Vector3 &p_point) const {
return (normal.dot(p_point) - d);
}
-bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const {
+bool Plane::has_point(const Vector3 &p_point, real_t p_tolerance) const {
real_t dist = normal.dot(p_point) - d;
dist = Math::abs(dist);
- return (dist <= _epsilon);
+ return (dist <= p_tolerance);
}
Plane::Plane(const Vector3 &p_normal, real_t p_d) :
@@ -105,7 +111,7 @@ Plane::Plane(const Vector3 &p_normal, real_t p_d) :
d(p_d) {
}
-Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) :
+Plane::Plane(const Vector3 &p_normal, const Vector3 &p_point) :
normal(p_normal),
d(p_normal.dot(p_point)) {
}
@@ -128,6 +134,7 @@ bool Plane::operator==(const Plane &p_plane) const {
bool Plane::operator!=(const Plane &p_plane) const {
return normal != p_plane.normal || d != p_plane.d;
}
+
} // namespace godot
#endif // GODOT_PLANE_HPP