summaryrefslogtreecommitdiffstats
path: root/include/core/Plane.hpp
diff options
context:
space:
mode:
authorKarroffel <therzog@mail.de>2017-05-12 21:53:07 +0200
committerKarroffel <therzog@mail.de>2017-05-12 21:53:07 +0200
commitcf30b0f39ddb2c6acad5d22655c4bca9015d7502 (patch)
tree45a4df6ff16450b334d6c8856a74f4f47f3e9336 /include/core/Plane.hpp
parent3969bcf07857b1a4af391bbddb924388cc7f44bb (diff)
downloadredot-cpp-cf30b0f39ddb2c6acad5d22655c4bca9015d7502.tar.gz
rewrote binding generator in python
Diffstat (limited to 'include/core/Plane.hpp')
-rw-r--r--include/core/Plane.hpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/include/core/Plane.hpp b/include/core/Plane.hpp
new file mode 100644
index 0000000..dbcf448
--- /dev/null
+++ b/include/core/Plane.hpp
@@ -0,0 +1,79 @@
+#ifndef PLANE_H
+#define PLANE_H
+
+#if defined(_WIN32)
+# ifdef _GD_CPP_CORE_API_IMPL
+# define GD_CPP_CORE_API __declspec(dllexport)
+# else
+# define GD_CPP_CORE_API __declspec(dllimport)
+# endif
+#else
+# define GD_CPP_CORE_API
+#endif
+
+#include "Vector3.hpp"
+
+#include <cmath>
+
+
+namespace godot {
+
+
+enum ClockDirection {
+
+ CLOCKWISE,
+ COUNTERCLOCKWISE
+};
+
+class GD_CPP_CORE_API Plane {
+public:
+ Vector3 normal;
+ real_t d;
+
+ void set_normal(const Vector3& p_normal);
+
+ inline Vector3 get_normal() const { return normal; } ///Point is coplanar, CMP_EPSILON for precision
+
+ void normalize();
+
+ Plane normalized() const;
+
+ /* Plane-Point operations */
+
+ inline Vector3 center() const { return normal*d; }
+ Vector3 get_any_point() const;
+ Vector3 get_any_perpendicular_normal() const;
+
+ bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane
+ real_t distance_to(const Vector3 &p_point) const;
+ bool has_point(const Vector3 &p_point,real_t _epsilon=CMP_EPSILON) const;
+
+ /* intersections */
+
+ bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result=0) const;
+ bool intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3* p_intersection) const;
+ bool intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3* p_intersection) const;
+
+ Vector3 project(const Vector3& p_point) const;
+
+ /* misc */
+
+ inline Plane operator-() const { return Plane(-normal,-d); }
+ bool is_almost_like(const Plane& p_plane) const;
+
+ bool operator==(const Plane& p_plane) const;
+ bool operator!=(const Plane& p_plane) const;
+ operator String() const;
+
+ inline Plane() { d=0; }
+ 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) { }
+
+ Plane(const Vector3 &p_normal, real_t p_d);
+ Plane(const Vector3 &p_point, const Vector3& p_normal);
+ Plane(const Vector3 &p_point1, const Vector3 &p_point2,const Vector3 &p_point3,ClockDirection p_dir = CLOCKWISE);
+
+};
+
+}
+
+#endif // PLANE_H