summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
Diffstat (limited to 'core/math')
-rw-r--r--core/math/aabb.cpp (renamed from core/math/rect3.cpp)52
-rw-r--r--core/math/aabb.h (renamed from core/math/rect3.h)54
-rw-r--r--core/math/bsp_tree.cpp6
-rw-r--r--core/math/bsp_tree.h10
-rw-r--r--core/math/camera_matrix.cpp2
-rw-r--r--core/math/camera_matrix.h2
-rw-r--r--core/math/face3.cpp4
-rw-r--r--core/math/face3.h14
-rw-r--r--core/math/geometry.cpp4
-rw-r--r--core/math/octree.h38
-rw-r--r--core/math/quick_hull.cpp2
-rw-r--r--core/math/quick_hull.h2
-rw-r--r--core/math/transform.h14
-rw-r--r--core/math/triangle_mesh.cpp4
-rw-r--r--core/math/triangle_mesh.h4
15 files changed, 106 insertions, 106 deletions
diff --git a/core/math/rect3.cpp b/core/math/aabb.cpp
index 6f01000f61..737a42b337 100644
--- a/core/math/rect3.cpp
+++ b/core/math/aabb.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* rect3.cpp */
+/* aabb.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,25 +27,25 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "rect3.h"
+#include "aabb.h"
#include "print_string.h"
-real_t Rect3::get_area() const {
+real_t AABB::get_area() const {
return size.x * size.y * size.z;
}
-bool Rect3::operator==(const Rect3 &p_rval) const {
+bool AABB::operator==(const AABB &p_rval) const {
return ((position == p_rval.position) && (size == p_rval.size));
}
-bool Rect3::operator!=(const Rect3 &p_rval) const {
+bool AABB::operator!=(const AABB &p_rval) const {
return ((position != p_rval.position) || (size != p_rval.size));
}
-void Rect3::merge_with(const Rect3 &p_aabb) {
+void AABB::merge_with(const AABB &p_aabb) {
Vector3 beg_1, beg_2;
Vector3 end_1, end_2;
@@ -68,7 +68,7 @@ void Rect3::merge_with(const Rect3 &p_aabb) {
size = max - min;
}
-Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
+AABB AABB::intersection(const AABB &p_aabb) const {
Vector3 src_min = position;
Vector3 src_max = position + size;
@@ -78,7 +78,7 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
Vector3 min, max;
if (src_min.x > dst_max.x || src_max.x < dst_min.x)
- return Rect3();
+ return AABB();
else {
min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x;
@@ -86,7 +86,7 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
}
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
- return Rect3();
+ return AABB();
else {
min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y;
@@ -94,17 +94,17 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
}
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
- return Rect3();
+ return AABB();
else {
min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z;
max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z;
}
- return Rect3(min, max - min);
+ return AABB(min, max - min);
}
-bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
+bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
Vector3 c1, c2;
Vector3 end = position + size;
@@ -147,7 +147,7 @@ bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3
return true;
}
-bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const {
+bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const {
real_t min = 0, max = 1;
int axis = 0;
@@ -205,7 +205,7 @@ bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vecto
return true;
}
-bool Rect3::intersects_plane(const Plane &p_plane) const {
+bool AABB::intersects_plane(const Plane &p_plane) const {
Vector3 points[8] = {
Vector3(position.x, position.y, position.z),
@@ -232,7 +232,7 @@ bool Rect3::intersects_plane(const Plane &p_plane) const {
return under && over;
}
-Vector3 Rect3::get_longest_axis() const {
+Vector3 AABB::get_longest_axis() const {
Vector3 axis(1, 0, 0);
real_t max_size = size.x;
@@ -249,7 +249,7 @@ Vector3 Rect3::get_longest_axis() const {
return axis;
}
-int Rect3::get_longest_axis_index() const {
+int AABB::get_longest_axis_index() const {
int axis = 0;
real_t max_size = size.x;
@@ -267,7 +267,7 @@ int Rect3::get_longest_axis_index() const {
return axis;
}
-Vector3 Rect3::get_shortest_axis() const {
+Vector3 AABB::get_shortest_axis() const {
Vector3 axis(1, 0, 0);
real_t max_size = size.x;
@@ -284,7 +284,7 @@ Vector3 Rect3::get_shortest_axis() const {
return axis;
}
-int Rect3::get_shortest_axis_index() const {
+int AABB::get_shortest_axis_index() const {
int axis = 0;
real_t max_size = size.x;
@@ -302,25 +302,25 @@ int Rect3::get_shortest_axis_index() const {
return axis;
}
-Rect3 Rect3::merge(const Rect3 &p_with) const {
+AABB AABB::merge(const AABB &p_with) const {
- Rect3 aabb = *this;
+ AABB aabb = *this;
aabb.merge_with(p_with);
return aabb;
}
-Rect3 Rect3::expand(const Vector3 &p_vector) const {
- Rect3 aabb = *this;
+AABB AABB::expand(const Vector3 &p_vector) const {
+ AABB aabb = *this;
aabb.expand_to(p_vector);
return aabb;
}
-Rect3 Rect3::grow(real_t p_by) const {
+AABB AABB::grow(real_t p_by) const {
- Rect3 aabb = *this;
+ AABB aabb = *this;
aabb.grow_by(p_by);
return aabb;
}
-void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
+void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
ERR_FAIL_INDEX(p_edge, 12);
switch (p_edge) {
@@ -394,7 +394,7 @@ void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
}
}
-Rect3::operator String() const {
+AABB::operator String() const {
return String() + position + " - " + size;
}
diff --git a/core/math/rect3.h b/core/math/aabb.h
index c3a2f5fbfb..c60213496a 100644
--- a/core/math/rect3.h
+++ b/core/math/aabb.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* rect3.h */
+/* aabb.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -39,7 +39,7 @@
* This is implemented by a point (position) and the box size
*/
-class Rect3 {
+class AABB {
public:
Vector3 position;
Vector3 size;
@@ -60,16 +60,16 @@ public:
const Vector3 &get_size() const { return size; }
void set_size(const Vector3 &p_size) { size = p_size; }
- bool operator==(const Rect3 &p_rval) const;
- bool operator!=(const Rect3 &p_rval) const;
+ bool operator==(const AABB &p_rval) const;
+ bool operator!=(const AABB &p_rval) const;
- _FORCE_INLINE_ bool intersects(const Rect3 &p_aabb) const; /// Both AABBs overlap
- _FORCE_INLINE_ bool intersects_inclusive(const Rect3 &p_aabb) const; /// Both AABBs (or their faces) overlap
- _FORCE_INLINE_ bool encloses(const Rect3 &p_aabb) const; /// p_aabb is completely inside this
+ _FORCE_INLINE_ bool intersects(const AABB &p_aabb) const; /// Both AABBs overlap
+ _FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap
+ _FORCE_INLINE_ bool encloses(const AABB &p_aabb) const; /// p_aabb is completely inside this
- Rect3 merge(const Rect3 &p_with) const;
- void merge_with(const Rect3 &p_aabb); ///merge with another AABB
- Rect3 intersection(const Rect3 &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
+ 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 = NULL, Vector3 *r_normal = NULL) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const;
_FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const;
@@ -88,26 +88,26 @@ public:
int get_shortest_axis_index() const;
_FORCE_INLINE_ real_t get_shortest_axis_size() const;
- Rect3 grow(real_t p_by) const;
+ AABB grow(real_t p_by) const;
_FORCE_INLINE_ void grow_by(real_t p_amount);
void get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const;
_FORCE_INLINE_ Vector3 get_endpoint(int p_point) const;
- Rect3 expand(const Vector3 &p_vector) const;
+ AABB expand(const Vector3 &p_vector) const;
_FORCE_INLINE_ void project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const;
_FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */
operator String() const;
- _FORCE_INLINE_ Rect3() {}
- inline Rect3(const Vector3 &p_pos, const Vector3 &p_size)
+ _FORCE_INLINE_ AABB() {}
+ inline AABB(const Vector3 &p_pos, const Vector3 &p_size)
: position(p_pos),
size(p_size) {
}
};
-inline bool Rect3::intersects(const Rect3 &p_aabb) const {
+inline bool AABB::intersects(const AABB &p_aabb) const {
if (position.x >= (p_aabb.position.x + p_aabb.size.x))
return false;
@@ -125,7 +125,7 @@ inline bool Rect3::intersects(const Rect3 &p_aabb) const {
return true;
}
-inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const {
+inline bool AABB::intersects_inclusive(const AABB &p_aabb) const {
if (position.x > (p_aabb.position.x + p_aabb.size.x))
return false;
@@ -143,7 +143,7 @@ inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const {
return true;
}
-inline bool Rect3::encloses(const Rect3 &p_aabb) const {
+inline bool AABB::encloses(const AABB &p_aabb) const {
Vector3 src_min = position;
Vector3 src_max = position + size;
@@ -159,7 +159,7 @@ inline bool Rect3::encloses(const Rect3 &p_aabb) const {
(src_max.z > dst_max.z));
}
-Vector3 Rect3::get_support(const Vector3 &p_normal) const {
+Vector3 AABB::get_support(const Vector3 &p_normal) const {
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -171,7 +171,7 @@ Vector3 Rect3::get_support(const Vector3 &p_normal) const {
ofs;
}
-Vector3 Rect3::get_endpoint(int p_point) const {
+Vector3 AABB::get_endpoint(int p_point) const {
switch (p_point) {
case 0: return Vector3(position.x, position.y, position.z);
@@ -187,7 +187,7 @@ Vector3 Rect3::get_endpoint(int p_point) const {
ERR_FAIL_V(Vector3());
}
-bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
+bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -206,7 +206,7 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co
return true;
}
-bool Rect3::has_point(const Vector3 &p_point) const {
+bool AABB::has_point(const Vector3 &p_point) const {
if (p_point.x < position.x)
return false;
@@ -224,7 +224,7 @@ bool Rect3::has_point(const Vector3 &p_point) const {
return true;
}
-inline void Rect3::expand_to(const Vector3 &p_vector) {
+inline void AABB::expand_to(const Vector3 &p_vector) {
Vector3 begin = position;
Vector3 end = position + size;
@@ -247,7 +247,7 @@ inline void Rect3::expand_to(const Vector3 &p_vector) {
size = end - begin;
}
-void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
+void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5);
Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z);
@@ -258,7 +258,7 @@ void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &
r_max = distance + length;
}
-inline real_t Rect3::get_longest_axis_size() const {
+inline real_t AABB::get_longest_axis_size() const {
real_t max_size = size.x;
@@ -273,7 +273,7 @@ inline real_t Rect3::get_longest_axis_size() const {
return max_size;
}
-inline real_t Rect3::get_shortest_axis_size() const {
+inline real_t AABB::get_shortest_axis_size() const {
real_t max_size = size.x;
@@ -288,7 +288,7 @@ inline real_t Rect3::get_shortest_axis_size() const {
return max_size;
}
-bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
+bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
real_t divx = 1.0 / p_dir.x;
real_t divy = 1.0 / p_dir.y;
@@ -332,7 +332,7 @@ bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, rea
return ((tmin < t1) && (tmax > t0));
}
-void Rect3::grow_by(real_t p_amount) {
+void AABB::grow_by(real_t p_amount) {
position.x -= p_amount;
position.y -= p_amount;
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index be950568cf..bdc040160f 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -31,7 +31,7 @@
#include "error_macros.h"
#include "print_string.h"
-void BSP_Tree::from_aabb(const Rect3 &p_aabb) {
+void BSP_Tree::from_aabb(const AABB &p_aabb) {
planes.clear();
@@ -67,7 +67,7 @@ Vector<Plane> BSP_Tree::get_planes() const {
return planes;
}
-Rect3 BSP_Tree::get_aabb() const {
+AABB BSP_Tree::get_aabb() const {
return aabb;
}
@@ -577,7 +577,7 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) {
error_radius = p_error_radius;
}
-BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius)
+BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius)
: nodes(p_nodes),
planes(p_planes),
aabb(p_aabb),
diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h
index 2e762ba4de..f64a13ce39 100644
--- a/core/math/bsp_tree.h
+++ b/core/math/bsp_tree.h
@@ -30,11 +30,11 @@
#ifndef BSP_TREE_H
#define BSP_TREE_H
+#include "aabb.h"
#include "dvector.h"
#include "face3.h"
#include "method_ptrcall.h"
#include "plane.h"
-#include "rect3.h"
#include "variant.h"
#include "vector.h"
/**
@@ -64,7 +64,7 @@ private:
Vector<Node> nodes;
Vector<Plane> planes;
- Rect3 aabb;
+ AABB aabb;
real_t error_radius;
int _get_points_inside(int p_node, const Vector3 *p_points, int *p_indices, const Vector3 &p_center, const Vector3 &p_half_extents, int p_indices_count) const;
@@ -76,7 +76,7 @@ public:
bool is_empty() const { return nodes.size() == 0; }
Vector<Node> get_nodes() const;
Vector<Plane> get_planes() const;
- Rect3 get_aabb() const;
+ AABB get_aabb() const;
bool point_is_inside(const Vector3 &p_point) const;
int get_points_inside(const Vector3 *p_points, int p_point_count) const;
@@ -85,12 +85,12 @@ public:
operator Variant() const;
- void from_aabb(const Rect3 &p_aabb);
+ void from_aabb(const AABB &p_aabb);
BSP_Tree();
BSP_Tree(const Variant &p_variant);
BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius = 0);
- BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius = 0);
+ BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius = 0);
~BSP_Tree();
};
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 2c587762e8..c5f1d57441 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -596,7 +596,7 @@ void CameraMatrix::make_scale(const Vector3 &p_scale) {
matrix[2][2] = p_scale.z;
}
-void CameraMatrix::scale_translate_to_fit(const Rect3 &p_aabb) {
+void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
Vector3 min = p_aabb.position;
Vector3 max = p_aabb.position + p_aabb.size;
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 3145d73356..15d6b8128e 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -86,7 +86,7 @@ struct CameraMatrix {
operator String() const;
- void scale_translate_to_fit(const Rect3 &p_aabb);
+ void scale_translate_to_fit(const AABB &p_aabb);
void make_scale(const Vector3 &p_scale);
int get_pixels_per_meter(int p_for_pixel_width) const;
operator Transform() const;
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index e1b172e491..070ce77db4 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -189,13 +189,13 @@ ClockDirection Face3::get_clock_dir() const {
return (normal.dot(vertex[0]) >= 0) ? CLOCKWISE : COUNTERCLOCKWISE;
}
-bool Face3::intersects_aabb(const Rect3 &p_aabb) const {
+bool Face3::intersects_aabb(const AABB &p_aabb) const {
/** TEST PLANE **/
if (!p_aabb.intersects_plane(get_plane()))
return false;
-/** TEST FACE AXIS */
+ /** TEST FACE AXIS */
#define TEST_AXIS(m_ax) \
{ \
diff --git a/core/math/face3.h b/core/math/face3.h
index 8e4a25fb7a..561fa31238 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -30,8 +30,8 @@
#ifndef FACE3_H
#define FACE3_H
+#include "aabb.h"
#include "plane.h"
-#include "rect3.h"
#include "transform.h"
#include "vector3.h"
@@ -76,16 +76,16 @@ public:
void get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const;
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
- Rect3 get_aabb() const {
+ AABB get_aabb() const {
- Rect3 aabb(vertex[0], Vector3());
+ AABB aabb(vertex[0], Vector3());
aabb.expand_to(vertex[1]);
aabb.expand_to(vertex[2]);
return aabb;
}
- bool intersects_aabb(const Rect3 &p_aabb) const;
- _FORCE_INLINE_ bool intersects_aabb2(const Rect3 &p_aabb) const;
+ bool intersects_aabb(const AABB &p_aabb) const;
+ _FORCE_INLINE_ bool intersects_aabb2(const AABB &p_aabb) const;
operator String() const;
inline Face3() {}
@@ -96,7 +96,7 @@ public:
}
};
-bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
+bool Face3::intersects_aabb2(const AABB &p_aabb) const {
Vector3 perp = (vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]);
@@ -256,6 +256,6 @@ bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
return true;
}
-//this sucks...
+ //this sucks...
#endif // FACE3_H
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 7c8fb6f17d..39bd34f03c 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -300,7 +300,7 @@ enum _CellFlags {
static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, const Vector3 &voxelsize, const Face3 &p_face) {
- Rect3 aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
+ AABB aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
aabb.position = aabb.position * voxelsize;
aabb.size = aabb.size * voxelsize;
@@ -575,7 +575,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
PoolVector<Face3>::Read facesr = p_array.read();
const Face3 *faces = facesr.ptr();
- Rect3 global_aabb;
+ AABB global_aabb;
for (int i = 0; i < face_count; i++) {
diff --git a/core/math/octree.h b/core/math/octree.h
index 95a67943fd..6acd4c5f75 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -30,10 +30,10 @@
#ifndef OCTREE_H
#define OCTREE_H
+#include "aabb.h"
#include "list.h"
#include "map.h"
#include "print_string.h"
-#include "rect3.h"
#include "variant.h"
#include "vector3.h"
@@ -106,7 +106,7 @@ private:
struct Octant {
// cached for FAST plane check
- Rect3 aabb;
+ AABB aabb;
uint64_t last_pass;
Octant *parent;
@@ -152,8 +152,8 @@ private:
OctreeElementID _id;
Octant *common_parent;
- Rect3 aabb;
- Rect3 container_aabb;
+ AABB aabb;
+ AABB container_aabb;
List<PairData *, AL> pair_list;
@@ -334,7 +334,7 @@ private:
}
void _insert_element(Element *p_element, Octant *p_octant);
- void _ensure_valid_root(const Rect3 &p_aabb);
+ void _ensure_valid_root(const AABB &p_aabb);
bool _remove_element_from_octant(Element *p_element, Octant *p_octant, Octant *p_limit = NULL);
void _remove_element(Element *p_element);
void _pair_element(Element *p_element, Octant *p_octant);
@@ -351,7 +351,7 @@ private:
};
void _cull_convex(Octant *p_octant, _CullConvexData *p_cull);
- void _cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
+ void _cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _cull_segment(Octant *p_octant, const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _cull_point(Octant *p_octant, const Vector3 &p_point, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
@@ -370,8 +370,8 @@ private:
}
public:
- OctreeElementID create(T *p_userdata, const Rect3 &p_aabb = Rect3(), int p_subindex = 0, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
- void move(OctreeElementID p_id, const Rect3 &p_aabb);
+ OctreeElementID create(T *p_userdata, const AABB &p_aabb = AABB(), int p_subindex = 0, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
+ void move(OctreeElementID p_id, const AABB &p_aabb);
void set_pairable(OctreeElementID p_id, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
void erase(OctreeElementID p_id);
@@ -380,7 +380,7 @@ public:
int get_subindex(OctreeElementID p_id) const;
int cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask = 0xFFFFFFFF);
- int cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
+ int cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
int cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
int cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
@@ -479,7 +479,7 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
} else {
/* check againt AABB where child should be */
- Rect3 aabb = p_octant->aabb;
+ AABB aabb = p_octant->aabb;
aabb.size *= 0.5;
if (i & 1)
@@ -535,12 +535,12 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) {
+void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) {
if (!root) {
// octre is empty
- Rect3 base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size);
+ AABB base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size);
while (!base.encloses(p_aabb)) {
@@ -563,7 +563,7 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) {
} else {
- Rect3 base = root->aabb;
+ AABB base = root->aabb;
while (!base.encloses(p_aabb)) {
@@ -793,7 +793,7 @@ void Octree<T, use_pairs, AL>::_remove_element(Element *p_element) {
}
template <class T, bool use_pairs, class AL>
-OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) {
+OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const AABB &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) {
// check for AABB validity
#ifdef DEBUG_ENABLED
@@ -833,7 +833,7 @@ OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_a
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
+void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
#ifdef DEBUG_ENABLED
// check for AABB validity
@@ -859,7 +859,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
if (old_has_surf) {
_remove_element(&e); // removing
e.common_parent = NULL;
- e.aabb = Rect3();
+ e.aabb = AABB();
_optimize();
} else {
_ensure_valid_root(p_aabb); // inserting
@@ -886,7 +886,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
return;
}
- Rect3 combined = e.aabb;
+ AABB combined = e.aabb;
combined.merge_with(p_aabb);
_ensure_valid_root(combined);
@@ -1072,7 +1072,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
+void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
if (*p_result_idx == p_result_max)
return; //pointless
@@ -1313,7 +1313,7 @@ int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_r
}
template <class T, bool use_pairs, class AL>
-int Octree<T, use_pairs, AL>::cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
+int Octree<T, use_pairs, AL>::cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
if (!root)
return 0;
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index e0137b6921..946d9f6b79 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -38,7 +38,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
/* CREATE AABB VOLUME */
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < p_points.size(); i++) {
if (i == 0) {
diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h
index 47ed22615b..f014d0decc 100644
--- a/core/math/quick_hull.h
+++ b/core/math/quick_hull.h
@@ -30,9 +30,9 @@
#ifndef QUICK_HULL_H
#define QUICK_HULL_H
+#include "aabb.h"
#include "geometry.h"
#include "list.h"
-#include "rect3.h"
#include "set.h"
class QuickHull {
diff --git a/core/math/transform.h b/core/math/transform.h
index 566bf482a9..4d91869121 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -30,9 +30,9 @@
#ifndef TRANSFORM_H
#define TRANSFORM_H
+#include "aabb.h"
#include "matrix3.h"
#include "plane.h"
-#include "rect3.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -80,8 +80,8 @@ public:
_FORCE_INLINE_ Plane xform(const Plane &p_plane) const;
_FORCE_INLINE_ Plane xform_inv(const Plane &p_plane) const;
- _FORCE_INLINE_ Rect3 xform(const Rect3 &p_aabb) const;
- _FORCE_INLINE_ Rect3 xform_inv(const Rect3 &p_aabb) const;
+ _FORCE_INLINE_ AABB xform(const AABB &p_aabb) const;
+ _FORCE_INLINE_ AABB xform_inv(const AABB &p_aabb) const;
void operator*=(const Transform &p_transform);
Transform operator*(const Transform &p_transform) const;
@@ -153,14 +153,14 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {
return Plane(normal, d);
}
-_FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
+_FORCE_INLINE_ AABB Transform::xform(const AABB &p_aabb) const {
/* define vertices */
Vector3 x = basis.get_axis(0) * p_aabb.size.x;
Vector3 y = basis.get_axis(1) * p_aabb.size.y;
Vector3 z = basis.get_axis(2) * p_aabb.size.z;
Vector3 pos = xform(p_aabb.position);
//could be even further optimized
- Rect3 new_aabb;
+ AABB new_aabb;
new_aabb.position = pos;
new_aabb.expand_to(pos + x);
new_aabb.expand_to(pos + y);
@@ -172,7 +172,7 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
return new_aabb;
}
-_FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
+_FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
/* define vertices */
Vector3 vertices[8] = {
@@ -186,7 +186,7 @@ _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z)
};
- Rect3 ret;
+ AABB ret;
ret.position = xform_inv(vertices[0]);
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 3b246cb183..5f57c7c26a 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -44,7 +44,7 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in
return -1;
}
- Rect3 aabb;
+ AABB aabb;
aabb = p_bb[p_from]->aabb;
for (int i = 1; i < p_size; i++) {
@@ -166,7 +166,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
valid = true;
}
-Vector3 TriangleMesh::get_area_normal(const Rect3 &p_aabb) const {
+Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const {
uint32_t *stack = (uint32_t *)alloca(sizeof(int) * max_depth);
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index 2bf67fffcb..4bd9fecf37 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -47,7 +47,7 @@ class TriangleMesh : public Reference {
struct BVH {
- Rect3 aabb;
+ AABB aabb;
Vector3 center; //used for sorting
int left;
int right;
@@ -88,7 +88,7 @@ public:
bool is_valid() const;
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const;
bool intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, Vector3 &r_point, Vector3 &r_normal) const;
- Vector3 get_area_normal(const Rect3 &p_aabb) const;
+ Vector3 get_area_normal(const AABB &p_aabb) const;
PoolVector<Face3> get_faces() const;
void create(const PoolVector<Vector3> &p_faces);