diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/global_constants.cpp | 2 | ||||
-rw-r--r-- | core/helper/math_fieldwise.cpp | 8 | ||||
-rw-r--r-- | core/io/marshalls.cpp | 12 | ||||
-rw-r--r-- | core/io/resource_format_binary.cpp | 12 | ||||
-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.cpp | 6 | ||||
-rw-r--r-- | core/math/bsp_tree.h | 10 | ||||
-rw-r--r-- | core/math/camera_matrix.cpp | 2 | ||||
-rw-r--r-- | core/math/camera_matrix.h | 2 | ||||
-rw-r--r-- | core/math/face3.cpp | 4 | ||||
-rw-r--r-- | core/math/face3.h | 14 | ||||
-rw-r--r-- | core/math/geometry.cpp | 4 | ||||
-rw-r--r-- | core/math/octree.h | 38 | ||||
-rw-r--r-- | core/math/quick_hull.cpp | 2 | ||||
-rw-r--r-- | core/math/quick_hull.h | 2 | ||||
-rw-r--r-- | core/math/transform.h | 14 | ||||
-rw-r--r-- | core/math/triangle_mesh.cpp | 4 | ||||
-rw-r--r-- | core/math/triangle_mesh.h | 4 | ||||
-rw-r--r-- | core/method_ptrcall.h | 2 | ||||
-rw-r--r-- | core/packed_data_container.cpp | 2 | ||||
-rw-r--r-- | core/type_info.h | 2 | ||||
-rw-r--r-- | core/variant.cpp | 58 | ||||
-rw-r--r-- | core/variant.h | 10 | ||||
-rw-r--r-- | core/variant_call.cpp | 98 | ||||
-rw-r--r-- | core/variant_op.cpp | 60 | ||||
-rw-r--r-- | core/variant_parser.cpp | 10 |
27 files changed, 244 insertions, 244 deletions
diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 7854f342b0..48101c8cf1 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -557,7 +557,7 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM2D", Variant::TRANSFORM2D); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_PLANE", Variant::PLANE); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT); // 10 - BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT3", Variant::RECT3); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_AABB", Variant::AABB); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR", Variant::COLOR); diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp index 228611f8b3..2cd8a4f392 100644 --- a/core/helper/math_fieldwise.cpp +++ b/core/helper/math_fieldwise.cpp @@ -46,8 +46,8 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const switch (p_source.get_type()) { - /* clang-format makes a mess of this macro usage */ - /* clang-format off */ + /* clang-format makes a mess of this macro usage */ + /* clang-format off */ case Variant::VECTOR2: { @@ -106,9 +106,9 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } - case Variant::RECT3: { + case Variant::AABB: { - SETUP_TYPE(Rect3) + SETUP_TYPE(AABB) /**/ TRY_TRANSFER_FIELD("px", position.x) else TRY_TRANSFER_FIELD("py", position.y) diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index d388a622de..1d9d2dd959 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -159,7 +159,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int r_variant = str; } break; - // math types + // math types case Variant::VECTOR2: { @@ -245,10 +245,10 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int (*r_len) += 4 * 4; } break; - case Variant::RECT3: { + case Variant::AABB: { ERR_FAIL_COND_V(len < (int)4 * 6, ERR_INVALID_DATA); - Rect3 val; + AABB val; val.position.x = decode_float(&buf[0]); val.position.y = decode_float(&buf[4]); val.position.z = decode_float(&buf[8]); @@ -967,7 +967,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo _encode_string(p_variant, buf, r_len); } break; - // math types + // math types case Variant::VECTOR2: { @@ -1045,10 +1045,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4 * 4; } break; - case Variant::RECT3: { + case Variant::AABB: { if (buf) { - Rect3 aabb = p_variant; + AABB aabb = p_variant; encode_float(aabb.position.x, &buf[0]); encode_float(aabb.position.y, &buf[4]); encode_float(aabb.position.z, &buf[8]); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 03c3c5f615..8dc396c362 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -52,7 +52,7 @@ enum { VARIANT_VECTOR3 = 12, VARIANT_PLANE = 13, VARIANT_QUAT = 14, - VARIANT_RECT3 = 15, + VARIANT_AABB = 15, VARIANT_MATRIX3 = 16, VARIANT_TRANSFORM = 17, VARIANT_MATRIX32 = 18, @@ -196,9 +196,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { r_v = v; } break; - case VARIANT_RECT3: { + case VARIANT_AABB: { - Rect3 v; + AABB v; v.position.x = f->get_real(); v.position.y = f->get_real(); v.position.z = f->get_real(); @@ -1374,10 +1374,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant &p_property, f->store_real(val.w); } break; - case Variant::RECT3: { + case Variant::AABB: { - f->store_32(VARIANT_RECT3); - Rect3 val = p_property; + f->store_32(VARIANT_AABB); + AABB val = p_property; f->store_real(val.position.x); f->store_real(val.position.y); f->store_real(val.position.z); 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); diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index 2875eb912f..d819dfbc27 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -119,7 +119,7 @@ MAKE_PTRARG_BY_REFERENCE(Vector3); MAKE_PTRARG(Transform2D); MAKE_PTRARG_BY_REFERENCE(Plane); MAKE_PTRARG(Quat); -MAKE_PTRARG_BY_REFERENCE(Rect3); +MAKE_PTRARG_BY_REFERENCE(AABB); MAKE_PTRARG_BY_REFERENCE(Basis); MAKE_PTRARG_BY_REFERENCE(Transform); MAKE_PTRARG_BY_REFERENCE(Color); diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index ad8438e416..3748df12f7 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -234,7 +234,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd case Variant::TRANSFORM2D: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: + case Variant::AABB: case Variant::BASIS: case Variant::TRANSFORM: case Variant::POOL_BYTE_ARRAY: diff --git a/core/type_info.h b/core/type_info.h index 9fb80af0eb..24d96c51e8 100644 --- a/core/type_info.h +++ b/core/type_info.h @@ -82,7 +82,7 @@ MAKE_TYPE_INFO(Vector3, Variant::VECTOR3) MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D) MAKE_TYPE_INFO(Plane, Variant::PLANE) MAKE_TYPE_INFO(Quat, Variant::QUAT) -MAKE_TYPE_INFO(Rect3, Variant::RECT3) +MAKE_TYPE_INFO(AABB, Variant::AABB) MAKE_TYPE_INFO(Basis, Variant::BASIS) MAKE_TYPE_INFO(Transform, Variant::TRANSFORM) MAKE_TYPE_INFO(Color, Variant::COLOR) diff --git a/core/variant.cpp b/core/variant.cpp index f70e4a5218..1dca494492 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -66,7 +66,7 @@ String Variant::get_type_name(Variant::Type p_type) { return "String"; } break; - // math types + // math types case VECTOR2: { @@ -94,9 +94,9 @@ String Variant::get_type_name(Variant::Type p_type) { } break;*/ - case RECT3: { + case AABB: { - return "Rect3"; + return "AABB"; } break; case QUAT: { @@ -722,7 +722,7 @@ bool Variant::is_zero() const { } break; - // math types + // math types case VECTOR2: { @@ -754,9 +754,9 @@ bool Variant::is_zero() const { } break;*/ - case RECT3: { + case AABB: { - return *_data._rect3 == Rect3(); + return *_data._aabb == ::AABB(); } break; case QUAT: { @@ -931,7 +931,7 @@ void Variant::reference(const Variant &p_variant) { memnew_placement(_data._mem, String(*reinterpret_cast<const String *>(p_variant._data._mem))); } break; - // math types + // math types case VECTOR2: { @@ -954,9 +954,9 @@ void Variant::reference(const Variant &p_variant) { memnew_placement(_data._mem, Plane(*reinterpret_cast<const Plane *>(p_variant._data._mem))); } break; - case RECT3: { + case AABB: { - _data._rect3 = memnew(Rect3(*p_variant._data._rect3)); + _data._aabb = memnew(::AABB(*p_variant._data._aabb)); } break; case QUAT: { @@ -1079,9 +1079,9 @@ void Variant::clear() { memdelete(_data._transform2d); } break; - case RECT3: { + case AABB: { - memdelete(_data._rect3); + memdelete(_data._aabb); } break; case BASIS: { @@ -1426,7 +1426,7 @@ Variant::operator String() const { case PLANE: return operator Plane(); //case QUAT: - case RECT3: return operator Rect3(); + case AABB: return operator ::AABB(); case QUAT: return "(" + operator Quat() + ")"; case BASIS: { @@ -1617,12 +1617,12 @@ Variant::operator Plane() const { else return Plane(); } -Variant::operator Rect3() const { +Variant::operator ::AABB() const { - if (type == RECT3) - return *_data._rect3; + if (type == AABB) + return *_data._aabb; else - return Rect3(); + return ::AABB(); } Variant::operator Basis() const { @@ -2188,10 +2188,10 @@ Variant::Variant(const Plane &p_plane) { type = PLANE; memnew_placement(_data._mem, Plane(p_plane)); } -Variant::Variant(const Rect3 &p_aabb) { +Variant::Variant(const ::AABB &p_aabb) { - type = RECT3; - _data._rect3 = memnew(Rect3(p_aabb)); + type = AABB; + _data._aabb = memnew(::AABB(p_aabb)); } Variant::Variant(const Basis &p_matrix) { @@ -2501,7 +2501,7 @@ void Variant::operator=(const Variant &p_variant) { *reinterpret_cast<String *>(_data._mem) = *reinterpret_cast<const String *>(p_variant._data._mem); } break; - // math types + // math types case VECTOR2: { @@ -2524,9 +2524,9 @@ void Variant::operator=(const Variant &p_variant) { *reinterpret_cast<Plane *>(_data._mem) = *reinterpret_cast<const Plane *>(p_variant._data._mem); } break; - case RECT3: { + case AABB: { - *_data._rect3 = *(p_variant._data._rect3); + *_data._aabb = *(p_variant._data._aabb); } break; case QUAT: { @@ -2641,7 +2641,7 @@ uint32_t Variant::hash() const { return reinterpret_cast<const String *>(_data._mem)->hash(); } break; - // math types + // math types case VECTOR2: { @@ -2686,13 +2686,13 @@ uint32_t Variant::hash() const { } break;*/ - case RECT3: { + case AABB: { uint32_t hash = 5831; for (int i = 0; i < 3; i++) { - hash = hash_djb2_one_float(_data._rect3->position[i], hash); - hash = hash_djb2_one_float(_data._rect3->size[i], hash); + hash = hash_djb2_one_float(_data._aabb->position[i], hash); + hash = hash_djb2_one_float(_data._aabb->size[i], hash); } return hash; @@ -2952,9 +2952,9 @@ bool Variant::hash_compare(const Variant &p_variant) const { (hash_compare_scalar(l->d, r->d)); } break; - case RECT3: { - const Rect3 *l = _data._rect3; - const Rect3 *r = p_variant._data._rect3; + case AABB: { + const ::AABB *l = _data._aabb; + const ::AABB *r = p_variant._data._aabb; return (hash_compare_vector3(l->position, r->position) && (hash_compare_vector3(l->size, r->size))); diff --git a/core/variant.h b/core/variant.h index 45066af401..8ba4d576cf 100644 --- a/core/variant.h +++ b/core/variant.h @@ -34,6 +34,7 @@ @author Juan Linietsky <reduzio@gmail.com> */ +#include "aabb.h" #include "array.h" #include "color.h" #include "dictionary.h" @@ -45,7 +46,6 @@ #include "node_path.h" #include "plane.h" #include "quat.h" -#include "rect3.h" #include "ref_ptr.h" #include "rid.h" #include "transform.h" @@ -89,7 +89,7 @@ public: TRANSFORM2D, PLANE, QUAT, // 10 - RECT3, + AABB, BASIS, TRANSFORM, @@ -136,7 +136,7 @@ private: int64_t _int; double _real; Transform2D *_transform2d; - Rect3 *_rect3; + ::AABB *_aabb; Basis *_basis; Transform *_transform; RefPtr *_resource; @@ -184,7 +184,7 @@ public: operator Rect2() const; operator Vector3() const; operator Plane() const; - operator Rect3() const; + operator ::AABB() const; operator Quat() const; operator Basis() const; operator Transform() const; @@ -253,7 +253,7 @@ public: Variant(const Rect2 &p_rect2); Variant(const Vector3 &p_vector3); Variant(const Plane &p_plane); - Variant(const Rect3 &p_aabb); + Variant(const ::AABB &p_aabb); Variant(const Quat &p_quat); Variant(const Basis &p_transform); Variant(const Transform2D &p_transform); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 05f0478003..9e6aaeb911 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -655,26 +655,26 @@ struct _VariantCall { #define VCALL_PTR5R(m_type, m_method) \ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } - VCALL_PTR0R(Rect3, get_area); - VCALL_PTR0R(Rect3, has_no_area); - VCALL_PTR0R(Rect3, has_no_surface); - VCALL_PTR1R(Rect3, intersects); - VCALL_PTR1R(Rect3, encloses); - VCALL_PTR1R(Rect3, merge); - VCALL_PTR1R(Rect3, intersection); - VCALL_PTR1R(Rect3, intersects_plane); - VCALL_PTR2R(Rect3, intersects_segment); - VCALL_PTR1R(Rect3, has_point); - VCALL_PTR1R(Rect3, get_support); - VCALL_PTR0R(Rect3, get_longest_axis); - VCALL_PTR0R(Rect3, get_longest_axis_index); - VCALL_PTR0R(Rect3, get_longest_axis_size); - VCALL_PTR0R(Rect3, get_shortest_axis); - VCALL_PTR0R(Rect3, get_shortest_axis_index); - VCALL_PTR0R(Rect3, get_shortest_axis_size); - VCALL_PTR1R(Rect3, expand); - VCALL_PTR1R(Rect3, grow); - VCALL_PTR1R(Rect3, get_endpoint); + VCALL_PTR0R(AABB, get_area); + VCALL_PTR0R(AABB, has_no_area); + VCALL_PTR0R(AABB, has_no_surface); + VCALL_PTR1R(AABB, intersects); + VCALL_PTR1R(AABB, encloses); + VCALL_PTR1R(AABB, merge); + VCALL_PTR1R(AABB, intersection); + VCALL_PTR1R(AABB, intersects_plane); + VCALL_PTR2R(AABB, intersects_segment); + VCALL_PTR1R(AABB, has_point); + VCALL_PTR1R(AABB, get_support); + VCALL_PTR0R(AABB, get_longest_axis); + VCALL_PTR0R(AABB, get_longest_axis_index); + VCALL_PTR0R(AABB, get_longest_axis_size); + VCALL_PTR0R(AABB, get_shortest_axis); + VCALL_PTR0R(AABB, get_shortest_axis_index); + VCALL_PTR0R(AABB, get_shortest_axis_size); + VCALL_PTR1R(AABB, expand); + VCALL_PTR1R(AABB, grow); + VCALL_PTR1R(AABB, get_endpoint); VCALL_PTR0R(Transform2D, inverse); VCALL_PTR0R(Transform2D, affine_inverse); @@ -755,7 +755,7 @@ struct _VariantCall { case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); return; case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Plane()); return; - case Variant::RECT3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Rect3()); return; + case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); return; default: r_ret = Variant(); } } @@ -766,7 +766,7 @@ struct _VariantCall { case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); return; case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); return; - case Variant::RECT3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect3()); return; + case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); return; default: r_ret = Variant(); } } @@ -878,9 +878,9 @@ struct _VariantCall { r_ret = Color::hex(*p_args[0]); } - static void Rect3_init1(Variant &r_ret, const Variant **p_args) { + static void AABB_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Rect3(*p_args[0], *p_args[1]); + r_ret = ::AABB(*p_args[0], *p_args[1]); } static void Basis_init1(Variant &r_ret, const Variant **p_args) { @@ -1058,8 +1058,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i case TRANSFORM2D: return Transform2D(); case PLANE: return Plane(); case QUAT: return Quat(); - case RECT3: - return Rect3(); // 10 + case AABB: + return ::AABB(); // 10 case BASIS: return Basis(); case TRANSFORM: return Transform(); @@ -1138,8 +1138,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i case VECTOR3: return (Vector3(*p_args[0])); case PLANE: return (Plane(*p_args[0])); case QUAT: return (Quat(*p_args[0])); - case RECT3: - return (Rect3(*p_args[0])); // 10 + case AABB: + return (::AABB(*p_args[0])); // 10 case BASIS: return (Basis(p_args[0]->operator Basis())); case TRANSFORM: return (Transform(p_args[0]->operator Transform())); @@ -1707,26 +1707,26 @@ void register_variant_methods() { //pointerbased - ADDFUNC0R(RECT3, REAL, Rect3, get_area, varray()); - ADDFUNC0R(RECT3, BOOL, Rect3, has_no_area, varray()); - ADDFUNC0R(RECT3, BOOL, Rect3, has_no_surface, varray()); - ADDFUNC1R(RECT3, BOOL, Rect3, intersects, RECT3, "with", varray()); - ADDFUNC1R(RECT3, BOOL, Rect3, encloses, RECT3, "with", varray()); - ADDFUNC1R(RECT3, RECT3, Rect3, merge, RECT3, "with", varray()); - ADDFUNC1R(RECT3, RECT3, Rect3, intersection, RECT3, "with", varray()); - ADDFUNC1R(RECT3, BOOL, Rect3, intersects_plane, PLANE, "plane", varray()); - ADDFUNC2R(RECT3, BOOL, Rect3, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray()); - ADDFUNC1R(RECT3, BOOL, Rect3, has_point, VECTOR3, "point", varray()); - ADDFUNC1R(RECT3, VECTOR3, Rect3, get_support, VECTOR3, "dir", varray()); - ADDFUNC0R(RECT3, VECTOR3, Rect3, get_longest_axis, varray()); - ADDFUNC0R(RECT3, INT, Rect3, get_longest_axis_index, varray()); - ADDFUNC0R(RECT3, REAL, Rect3, get_longest_axis_size, varray()); - ADDFUNC0R(RECT3, VECTOR3, Rect3, get_shortest_axis, varray()); - ADDFUNC0R(RECT3, INT, Rect3, get_shortest_axis_index, varray()); - ADDFUNC0R(RECT3, REAL, Rect3, get_shortest_axis_size, varray()); - ADDFUNC1R(RECT3, RECT3, Rect3, expand, VECTOR3, "to_point", varray()); - ADDFUNC1R(RECT3, RECT3, Rect3, grow, REAL, "by", varray()); - ADDFUNC1R(RECT3, VECTOR3, Rect3, get_endpoint, INT, "idx", varray()); + ADDFUNC0R(AABB, REAL, AABB, get_area, varray()); + ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray()); + ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray()); + ADDFUNC1R(AABB, BOOL, AABB, intersects, AABB, "with", varray()); + ADDFUNC1R(AABB, BOOL, AABB, encloses, AABB, "with", varray()); + ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray()); + ADDFUNC1R(AABB, AABB, AABB, intersection, AABB, "with", varray()); + ADDFUNC1R(AABB, BOOL, AABB, intersects_plane, PLANE, "plane", varray()); + ADDFUNC2R(AABB, BOOL, AABB, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray()); + ADDFUNC1R(AABB, BOOL, AABB, has_point, VECTOR3, "point", varray()); + ADDFUNC1R(AABB, VECTOR3, AABB, get_support, VECTOR3, "dir", varray()); + ADDFUNC0R(AABB, VECTOR3, AABB, get_longest_axis, varray()); + ADDFUNC0R(AABB, INT, AABB, get_longest_axis_index, varray()); + ADDFUNC0R(AABB, REAL, AABB, get_longest_axis_size, varray()); + ADDFUNC0R(AABB, VECTOR3, AABB, get_shortest_axis, varray()); + ADDFUNC0R(AABB, INT, AABB, get_shortest_axis_index, varray()); + ADDFUNC0R(AABB, REAL, AABB, get_shortest_axis_size, varray()); + ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray()); + ADDFUNC1R(AABB, AABB, AABB, grow, REAL, "by", varray()); + ADDFUNC1R(AABB, VECTOR3, AABB, get_endpoint, INT, "idx", varray()); ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray()); ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray()); @@ -1791,7 +1791,7 @@ void register_variant_methods() { _VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL); _VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL); - _VariantCall::add_constructor(_VariantCall::Rect3_init1, Variant::RECT3, "position", Variant::VECTOR3, "size", Variant::VECTOR3); + _VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3); _VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3); _VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 6362090902..c793d70ed8 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -48,7 +48,7 @@ CASE_TYPE(PREFIX, OP, TRANSFORM2D) \ CASE_TYPE(PREFIX, OP, PLANE) \ CASE_TYPE(PREFIX, OP, QUAT) \ - CASE_TYPE(PREFIX, OP, RECT3) \ + CASE_TYPE(PREFIX, OP, AABB) \ CASE_TYPE(PREFIX, OP, BASIS) \ CASE_TYPE(PREFIX, OP, TRANSFORM) \ CASE_TYPE(PREFIX, OP, COLOR) \ @@ -81,7 +81,7 @@ TYPE(PREFIX, OP, TRANSFORM2D), \ TYPE(PREFIX, OP, PLANE), \ TYPE(PREFIX, OP, QUAT), \ - TYPE(PREFIX, OP, RECT3), \ + TYPE(PREFIX, OP, AABB), \ TYPE(PREFIX, OP, BASIS), \ TYPE(PREFIX, OP, TRANSFORM), \ TYPE(PREFIX, OP, COLOR), \ @@ -465,7 +465,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR3, ==, Vector3); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, PLANE, ==, Plane); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, QUAT, ==, Quat); - DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, RECT3, ==, _rect3); + DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, AABB, ==, _aabb); DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, BASIS, ==, _basis); DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, TRANSFORM, ==, _transform); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, COLOR, ==, Color); @@ -555,7 +555,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR3, !=, Vector3); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, PLANE, !=, Plane); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, QUAT, !=, Quat); - DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, RECT3, !=, _rect3); + DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, AABB, !=, _aabb); DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, BASIS, !=, _basis); DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, TRANSFORM, !=, _transform); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, COLOR, !=, Color); @@ -629,7 +629,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_LESS, TRANSFORM2D) CASE_TYPE(math, OP_LESS, PLANE) CASE_TYPE(math, OP_LESS, QUAT) - CASE_TYPE(math, OP_LESS, RECT3) + CASE_TYPE(math, OP_LESS, AABB) CASE_TYPE(math, OP_LESS, BASIS) CASE_TYPE(math, OP_LESS, TRANSFORM) CASE_TYPE(math, OP_LESS, COLOR) @@ -658,7 +658,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM2D) CASE_TYPE(math, OP_LESS_EQUAL, PLANE) CASE_TYPE(math, OP_LESS_EQUAL, QUAT) - CASE_TYPE(math, OP_LESS_EQUAL, RECT3) + CASE_TYPE(math, OP_LESS_EQUAL, AABB) CASE_TYPE(math, OP_LESS_EQUAL, BASIS) CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM) CASE_TYPE(math, OP_LESS_EQUAL, COLOR) @@ -733,7 +733,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_GREATER, TRANSFORM2D) CASE_TYPE(math, OP_GREATER, PLANE) CASE_TYPE(math, OP_GREATER, QUAT) - CASE_TYPE(math, OP_GREATER, RECT3) + CASE_TYPE(math, OP_GREATER, AABB) CASE_TYPE(math, OP_GREATER, BASIS) CASE_TYPE(math, OP_GREATER, TRANSFORM) CASE_TYPE(math, OP_GREATER, COLOR) @@ -762,7 +762,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM2D) CASE_TYPE(math, OP_GREATER_EQUAL, PLANE) CASE_TYPE(math, OP_GREATER_EQUAL, QUAT) - CASE_TYPE(math, OP_GREATER_EQUAL, RECT3) + CASE_TYPE(math, OP_GREATER_EQUAL, AABB) CASE_TYPE(math, OP_GREATER_EQUAL, BASIS) CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM) CASE_TYPE(math, OP_GREATER_EQUAL, COLOR) @@ -818,7 +818,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_ADD, RECT2) CASE_TYPE(math, OP_ADD, TRANSFORM2D) CASE_TYPE(math, OP_ADD, PLANE) - CASE_TYPE(math, OP_ADD, RECT3) + CASE_TYPE(math, OP_ADD, AABB) CASE_TYPE(math, OP_ADD, BASIS) CASE_TYPE(math, OP_ADD, TRANSFORM) CASE_TYPE(math, OP_ADD, NODE_PATH) @@ -842,7 +842,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_SUBTRACT, RECT2) CASE_TYPE(math, OP_SUBTRACT, TRANSFORM2D) CASE_TYPE(math, OP_SUBTRACT, PLANE) - CASE_TYPE(math, OP_SUBTRACT, RECT3) + CASE_TYPE(math, OP_SUBTRACT, AABB) CASE_TYPE(math, OP_SUBTRACT, BASIS) CASE_TYPE(math, OP_SUBTRACT, TRANSFORM) CASE_TYPE(math, OP_SUBTRACT, NODE_PATH) @@ -923,7 +923,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MULTIPLY, STRING) CASE_TYPE(math, OP_MULTIPLY, RECT2) CASE_TYPE(math, OP_MULTIPLY, PLANE) - CASE_TYPE(math, OP_MULTIPLY, RECT3) + CASE_TYPE(math, OP_MULTIPLY, AABB) CASE_TYPE(math, OP_MULTIPLY, NODE_PATH) CASE_TYPE(math, OP_MULTIPLY, _RID) CASE_TYPE(math, OP_MULTIPLY, OBJECT) @@ -964,7 +964,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_DIVIDE, RECT2) CASE_TYPE(math, OP_DIVIDE, TRANSFORM2D) CASE_TYPE(math, OP_DIVIDE, PLANE) - CASE_TYPE(math, OP_DIVIDE, RECT3) + CASE_TYPE(math, OP_DIVIDE, AABB) CASE_TYPE(math, OP_DIVIDE, BASIS) CASE_TYPE(math, OP_DIVIDE, TRANSFORM) CASE_TYPE(math, OP_DIVIDE, NODE_PATH) @@ -995,7 +995,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_POSITIVE, STRING) CASE_TYPE(math, OP_POSITIVE, RECT2) CASE_TYPE(math, OP_POSITIVE, TRANSFORM2D) - CASE_TYPE(math, OP_POSITIVE, RECT3) + CASE_TYPE(math, OP_POSITIVE, AABB) CASE_TYPE(math, OP_POSITIVE, BASIS) CASE_TYPE(math, OP_POSITIVE, TRANSFORM) CASE_TYPE(math, OP_POSITIVE, COLOR) @@ -1029,7 +1029,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_NEGATE, STRING) CASE_TYPE(math, OP_NEGATE, RECT2) CASE_TYPE(math, OP_NEGATE, TRANSFORM2D) - CASE_TYPE(math, OP_NEGATE, RECT3) + CASE_TYPE(math, OP_NEGATE, AABB) CASE_TYPE(math, OP_NEGATE, BASIS) CASE_TYPE(math, OP_NEGATE, TRANSFORM) CASE_TYPE(math, OP_NEGATE, NODE_PATH) @@ -1088,7 +1088,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MODULE, TRANSFORM2D) CASE_TYPE(math, OP_MODULE, PLANE) CASE_TYPE(math, OP_MODULE, QUAT) - CASE_TYPE(math, OP_MODULE, RECT3) + CASE_TYPE(math, OP_MODULE, AABB) CASE_TYPE(math, OP_MODULE, BASIS) CASE_TYPE(math, OP_MODULE, TRANSFORM) CASE_TYPE(math, OP_MODULE, COLOR) @@ -1384,10 +1384,10 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } break; // 10 - case RECT3: { + case AABB: { if (p_value.type == Variant::VECTOR3) { - Rect3 *v = _data._rect3; + ::AABB *v = _data._aabb; //scalar name if (p_index == CoreStringNames::singleton->position) { v->position = *reinterpret_cast<const Vector3 *>(p_value._data._mem); @@ -1609,9 +1609,9 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } } break; // 10 - case RECT3: { + case AABB: { - const Rect3 *v = _data._rect3; + const ::AABB *v = _data._aabb; //scalar name if (p_index == CoreStringNames::singleton->position) { return v->position; @@ -1982,7 +1982,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } break; // 10 - case RECT3: { + case AABB: { if (p_value.type != Variant::VECTOR3) return; @@ -1991,7 +1991,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); - Rect3 *v = _data._rect3; + ::AABB *v = _data._aabb; if (*str == "position") { valid = true; v->position = p_value; @@ -2400,13 +2400,13 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } break; // 10 - case RECT3: { + case AABB: { if (p_index.get_type() == Variant::STRING) { //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); - const Rect3 *v = _data._rect3; + const ::AABB *v = _data._aabb; if (*str == "position") { valid = true; return v->position; @@ -2835,7 +2835,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::REAL, "w")); } break; // 10 - case RECT3: { + case AABB: { p_list->push_back(PropertyInfo(Variant::VECTOR3, "position")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "size")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "end")); @@ -3457,10 +3457,10 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst) r_dst = *reinterpret_cast<const Vector3 *>(a._data._mem) + *reinterpret_cast<const Vector3 *>(b._data._mem) * c; } return; - case RECT3: { - const Rect3 *ra = reinterpret_cast<const Rect3 *>(a._data._mem); - const Rect3 *rb = reinterpret_cast<const Rect3 *>(b._data._mem); - r_dst = Rect3(ra->position + rb->position * c, ra->size + rb->size * c); + case AABB: { + const ::AABB *ra = reinterpret_cast<const ::AABB *>(a._data._mem); + const ::AABB *rb = reinterpret_cast<const ::AABB *>(b._data._mem); + r_dst = ::AABB(ra->position + rb->position * c, ra->size + rb->size * c); } return; case QUAT: { @@ -3591,8 +3591,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & r_dst = reinterpret_cast<const Quat *>(a._data._mem)->slerp(*reinterpret_cast<const Quat *>(b._data._mem), c); } return; - case RECT3: { - r_dst = Rect3(a._data._rect3->position.linear_interpolate(b._data._rect3->position, c), a._data._rect3->size.linear_interpolate(b._data._rect3->size, c)); + case AABB: { + r_dst = ::AABB(a._data._aabb->position.linear_interpolate(b._data._aabb->position, c), a._data._aabb->size.linear_interpolate(b._data._aabb->size, c)); } return; case BASIS: { diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index d60d10cd3a..1552b62c64 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -595,7 +595,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = Quat(args[0], args[1], args[2], args[3]); return OK; - } else if (id == "Rect3" || id == "AABB") { + } else if (id == "AABB") { Vector<float> args; Error err = _parse_construct<float>(p_stream, args, line, r_err_str); @@ -606,7 +606,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, r_err_str = "Expected 6 arguments for constructor"; } - value = Rect3(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5])); + value = AABB(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5])); return OK; } else if (id == "Basis" || id == "Matrix3") { //compatibility @@ -1634,10 +1634,10 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, "Plane( " + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + " )"); } break; - case Variant::RECT3: { + case Variant::AABB: { - Rect3 aabb = p_variant; - p_store_string_func(p_store_string_ud, "Rect3( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )"); + AABB aabb = p_variant; + p_store_string_func(p_store_string_ud, "AABB( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )"); } break; case Variant::QUAT: { |