diff options
153 files changed, 1371 insertions, 1205 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/print_string.cpp b/core/print_string.cpp index 92a04cbf0b..520fb3daec 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -82,7 +82,25 @@ void print_line(String p_string) { PrintHandlerList *l = print_handler_list; while (l) { - l->printfunc(l->userdata, p_string); + l->printfunc(l->userdata, p_string, false); + l = l->next; + } + + _global_unlock(); +} + +void print_error(String p_string) { + + if (!_print_error_enabled) + return; + + OS::get_singleton()->printerr("%s\n", p_string.utf8().get_data()); + + _global_lock(); + PrintHandlerList *l = print_handler_list; + while (l) { + + l->printfunc(l->userdata, p_string, true); l = l->next; } diff --git a/core/print_string.h b/core/print_string.h index 9f8420c31a..6b68380b9d 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -34,7 +34,7 @@ extern void (*_print_func)(String); -typedef void (*PrintHandlerFunc)(void *, const String &p_string); +typedef void (*PrintHandlerFunc)(void *, const String &p_string, bool p_error); struct PrintHandlerList { @@ -56,5 +56,6 @@ void remove_print_handler(PrintHandlerList *p_handler); extern bool _print_line_enabled; extern bool _print_error_enabled; extern void print_line(String p_string); +extern void print_error(String p_string); #endif diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index f77fb116c7..5655a4d5e4 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -832,7 +832,7 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_ mutex->unlock(); } -void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string) { +void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string, bool p_error) { ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this; diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 22137d1350..90d2daf1f8 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -94,7 +94,7 @@ class ScriptDebuggerRemote : public ScriptDebugger { uint64_t msec_count; bool locking; //hack to avoid a deadloop - static void _print_handler(void *p_this, const String &p_string); + static void _print_handler(void *p_this, const String &p_string, bool p_error); PrintHandlerList phl; 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: { diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 258b06f320..31a0d3ccef 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1332,8 +1332,8 @@ <constant name="TYPE_QUAT" value="10"> Variable is of type [Quat]. </constant> - <constant name="TYPE_RECT3" value="11"> - Variable is of type [Rect3]. + <constant name="TYPE_AABB" value="11"> + Variable is of type [AABB]. </constant> <constant name="TYPE_BASIS" value="12"> Variable is of type [Basis]. diff --git a/doc/classes/Rect3.xml b/doc/classes/AABB.xml index 88be5fa419..494dcb8fce 100644 --- a/doc/classes/Rect3.xml +++ b/doc/classes/AABB.xml @@ -1,18 +1,18 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Rect3" category="Built-In Types" version="3.0-alpha"> +<class name="AABB" category="Built-In Types" version="3.0-alpha"> <brief_description> Axis-Aligned Bounding Box. </brief_description> <description> - Rect3 consists of a position, a size, and several utility functions. It is typically used for fast overlap tests. + AABB consists of a position, a size, and several utility functions. It is typically used for fast overlap tests. </description> <tutorials> </tutorials> <demos> </demos> <methods> - <method name="Rect3"> - <return type="Rect3"> + <method name="AABB"> + <return type="AABB"> </return> <argument index="0" name="position" type="Vector3"> </argument> @@ -25,26 +25,26 @@ <method name="encloses"> <return type="bool"> </return> - <argument index="0" name="with" type="Rect3"> + <argument index="0" name="with" type="AABB"> </argument> <description> - Returns [code]true[/code] if this [code]Rect3[/code] completely encloses another one. + Returns [code]true[/code] if this [code]AABB[/code] completely encloses another one. </description> </method> <method name="expand"> - <return type="Rect3"> + <return type="AABB"> </return> <argument index="0" name="to_point" type="Vector3"> </argument> <description> - Returns this [code]Rect3[/code] expanded to include a given point. + Returns this [code]AABB[/code] expanded to include a given point. </description> </method> <method name="get_area"> <return type="float"> </return> <description> - Gets the area of the [code]Rect3[/code]. + Gets the area of the [code]AABB[/code]. </description> </method> <method name="get_endpoint"> @@ -53,49 +53,49 @@ <argument index="0" name="idx" type="int"> </argument> <description> - Gets the position of the 8 endpoints of the [code]Rect3[/code] in space. + Gets the position of the 8 endpoints of the [code]AABB[/code] in space. </description> </method> <method name="get_longest_axis"> <return type="Vector3"> </return> <description> - Returns the normalized longest axis of the [code]Rect3[/code]. + Returns the normalized longest axis of the [code]AABB[/code]. </description> </method> <method name="get_longest_axis_index"> <return type="int"> </return> <description> - Returns the index of the longest axis of the [code]Rect3[/code] (according to [Vector3]::AXIS* enum). + Returns the index of the longest axis of the [code]AABB[/code] (according to [Vector3]::AXIS* enum). </description> </method> <method name="get_longest_axis_size"> <return type="float"> </return> <description> - Returns the scalar length of the longest axis of the [code]Rect3[/code]. + Returns the scalar length of the longest axis of the [code]AABB[/code]. </description> </method> <method name="get_shortest_axis"> <return type="Vector3"> </return> <description> - Returns the normalized shortest axis of the [code]Rect3[/code]. + Returns the normalized shortest axis of the [code]AABB[/code]. </description> </method> <method name="get_shortest_axis_index"> <return type="int"> </return> <description> - Returns the index of the shortest axis of the [code]Rect3[/code] (according to [Vector3]::AXIS* enum). + Returns the index of the shortest axis of the [code]AABB[/code] (according to [Vector3]::AXIS* enum). </description> </method> <method name="get_shortest_axis_size"> <return type="float"> </return> <description> - Returns the scalar length of the shortest axis of the [code]Rect3[/code]. + Returns the scalar length of the shortest axis of the [code]AABB[/code]. </description> </method> <method name="get_support"> @@ -108,26 +108,26 @@ </description> </method> <method name="grow"> - <return type="Rect3"> + <return type="AABB"> </return> <argument index="0" name="by" type="float"> </argument> <description> - Returns a copy of the [code]Rect3[/code] grown a given amount of units towards all the sides. + Returns a copy of the [code]AABB[/code] grown a given amount of units towards all the sides. </description> </method> <method name="has_no_area"> <return type="bool"> </return> <description> - Returns [code]true[/code] if the [code]Rect3[/code] is flat or empty. + Returns [code]true[/code] if the [code]AABB[/code] is flat or empty. </description> </method> <method name="has_no_surface"> <return type="bool"> </return> <description> - Returns [code]true[/code] if the [code]Rect3[/code] is empty. + Returns [code]true[/code] if the [code]AABB[/code] is empty. </description> </method> <method name="has_point"> @@ -136,25 +136,25 @@ <argument index="0" name="point" type="Vector3"> </argument> <description> - Returns [code]true[/code] if the [code]Rect3[/code] contains a point. + Returns [code]true[/code] if the [code]AABB[/code] contains a point. </description> </method> <method name="intersection"> - <return type="Rect3"> + <return type="AABB"> </return> - <argument index="0" name="with" type="Rect3"> + <argument index="0" name="with" type="AABB"> </argument> <description> - Returns the intersection between two [code]Rect3[/code]. An empty Rect3 (size 0,0,0) is returned on failure. + Returns the intersection between two [code]AABB[/code]. An empty AABB (size 0,0,0) is returned on failure. </description> </method> <method name="intersects"> <return type="bool"> </return> - <argument index="0" name="with" type="Rect3"> + <argument index="0" name="with" type="AABB"> </argument> <description> - Returns [code]true[/code] if the [code]Rect3[/code] overlaps with another. + Returns [code]true[/code] if the [code]AABB[/code] overlaps with another. </description> </method> <method name="intersects_plane"> @@ -163,7 +163,7 @@ <argument index="0" name="plane" type="Plane"> </argument> <description> - Returns [code]true[/code] if the [code]Rect3[/code] is on both sides of a plane. + Returns [code]true[/code] if the [code]AABB[/code] is on both sides of a plane. </description> </method> <method name="intersects_segment"> @@ -174,16 +174,16 @@ <argument index="1" name="to" type="Vector3"> </argument> <description> - Returns [code]true[/code] if the [code]Rect3[/code] intersects the line segment between [code]from[/code] and [code]to[/code]. + Returns [code]true[/code] if the [code]AABB[/code] intersects the line segment between [code]from[/code] and [code]to[/code]. </description> </method> <method name="merge"> - <return type="Rect3"> + <return type="AABB"> </return> - <argument index="0" name="with" type="Rect3"> + <argument index="0" name="with" type="AABB"> </argument> <description> - Returns a larger Rect3 that contains this Rect3 and [code]with[/code]. + Returns a larger AABB that contains this AABB and [code]with[/code]. </description> </method> </methods> diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index 10456f805d..6c9b191371 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -66,7 +66,7 @@ </description> </method> <method name="get_custom_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -95,7 +95,7 @@ <method name="set_custom_aabb"> <return type="void"> </return> - <argument index="0" name="aabb" type="Rect3"> + <argument index="0" name="aabb" type="AABB"> </argument> <description> </description> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 79870dd411..03871802b7 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -228,7 +228,14 @@ <argument index="0" name="margin" type="int" enum="Margin"> </argument> <description> - Return the forced neighbour for moving the input focus to. When pressing TAB or directional/joypad directions focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function. + Return the forced neighbour for moving the input focus to. When pressing directional/joypad directions, focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function. + </description> + </method> + <method name="get_focus_next" qualifiers="const"> + <return type="NodePath"> + </return> + <description> + Return the 'focus_next' for moving input focus to. When pressing TAB, focus is moved to the next control in the tree. However, the control to move to can be forced with this function. </description> </method> <method name="get_focus_owner" qualifiers="const"> @@ -238,6 +245,13 @@ Return which control is owning the keyboard focus, or null if no one. </description> </method> + <method name="get_focus_previous" qualifiers="const"> + <return type="NodePath"> + </return> + <description> + Return the 'focus_previous' for moving input focus to. When pressing Shift+TAB focus is moved to the previous control in the tree. However, the control to move to can be forced with this function. + </description> + </method> <method name="get_font" qualifiers="const"> <return type="Font"> </return> @@ -676,7 +690,25 @@ <argument index="1" name="neighbour" type="NodePath"> </argument> <description> - Force a neighbour for moving the input focus to. When pressing TAB or directional/joypad directions focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function. + Force a neighbour for moving the input focus to. When pressing directional/joypad directions, focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function. + </description> + </method> + <method name="set_focus_next"> + <return type="void"> + </return> + <argument index="0" name="next" type="NodePath"> + </argument> + <description> + Force the 'focus_next' for moving input focus to. When pressing TAB, focus is moved to the next control in the tree. However, the control to move to can be forced with this function. + </description> + </method> + <method name="set_focus_previous"> + <return type="void"> + </return> + <argument index="0" name="previous" type="NodePath"> + </argument> + <description> + Force the 'focus_previous' for moving input focus to. When pressing Shift+TAB, focus is moved to the previous control in the tree. However, the control to move to can be forced with this function. </description> </method> <method name="set_global_position"> diff --git a/doc/classes/EditorSpatialGizmo.xml b/doc/classes/EditorSpatialGizmo.xml index e111eec3b9..758024c99b 100644 --- a/doc/classes/EditorSpatialGizmo.xml +++ b/doc/classes/EditorSpatialGizmo.xml @@ -24,7 +24,7 @@ </return> <argument index="0" name="triangles" type="TriangleMesh"> </argument> - <argument index="1" name="bounds" type="Rect3"> + <argument index="1" name="bounds" type="AABB"> </argument> <description> Add collision triangles to the gizmo for picking. A [TriangleMesh] can be generated from a regular [Mesh] too. Call this function during [method redraw]. diff --git a/doc/classes/GIProbeData.xml b/doc/classes/GIProbeData.xml index 3777eba6af..5d118be776 100644 --- a/doc/classes/GIProbeData.xml +++ b/doc/classes/GIProbeData.xml @@ -16,7 +16,7 @@ </description> </method> <method name="get_bounds" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -86,7 +86,7 @@ <method name="set_bounds"> <return type="void"> </return> - <argument index="0" name="bounds" type="Rect3"> + <argument index="0" name="bounds" type="AABB"> </argument> <description> </description> @@ -167,7 +167,7 @@ <members> <member name="bias" type="float" setter="set_bias" getter="get_bias"> </member> - <member name="bounds" type="Rect3" setter="set_bounds" getter="get_bounds"> + <member name="bounds" type="AABB" setter="set_bounds" getter="get_bounds"> </member> <member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size"> </member> diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index 73384c27e4..b6a89d09f4 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -7,7 +7,7 @@ MultiMesh provides low level mesh instancing. If the amount of [Mesh] instances needed goes from hundreds to thousands (and most need to be visible at close proximity) creating such a large amount of [MeshInstance] nodes may affect performance by using too much CPU or video memory. For this case a MultiMesh becomes very useful, as it can draw thousands of instances with little API overhead. As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object). - Since instances may have any behavior, the Rect3 used for visibility must be provided by the user. + Since instances may have any behavior, the AABB used for visibility must be provided by the user. </description> <tutorials> </tutorials> @@ -15,10 +15,10 @@ </demos> <methods> <method name="get_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> - Return the visibility Rect3. + Return the visibility AABB. </description> </method> <method name="get_color_format" qualifiers="const"> diff --git a/doc/classes/Nil.xml b/doc/classes/Nil.xml index 1fccdc0148..a4bd60d53e 100644 --- a/doc/classes/Nil.xml +++ b/doc/classes/Nil.xml @@ -100,7 +100,7 @@ </description> </method> <method name="Nil"> - <argument index="0" name="from" type="Rect3"> + <argument index="0" name="from" type="AABB"> </argument> <description> </description> diff --git a/doc/classes/Particles.xml b/doc/classes/Particles.xml index 4e070f67fd..9a9279b0a7 100644 --- a/doc/classes/Particles.xml +++ b/doc/classes/Particles.xml @@ -13,7 +13,7 @@ </demos> <methods> <method name="capture_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -105,7 +105,7 @@ </description> </method> <method name="get_visibility_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -247,7 +247,7 @@ <method name="set_visibility_aabb"> <return type="void"> </return> - <argument index="0" name="aabb" type="Rect3"> + <argument index="0" name="aabb" type="AABB"> </argument> <description> </description> @@ -300,7 +300,7 @@ <member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale"> Speed scaling ratio. Default value: [code]1[/code]. </member> - <member name="visibility_aabb" type="Rect3" setter="set_visibility_aabb" getter="get_visibility_aabb"> + <member name="visibility_aabb" type="AABB" setter="set_visibility_aabb" getter="get_visibility_aabb"> </member> </members> <constants> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index ecf9e54ee7..60c5e75dec 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -95,10 +95,10 @@ <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="Rect3"> + <argument index="0" name="from" type="AABB"> </argument> <description> - Constructs a new String from the given [Rect3]. + Constructs a new String from the given [AABB]. </description> </method> <method name="String"> diff --git a/doc/classes/VisibilityNotifier.xml b/doc/classes/VisibilityNotifier.xml index 1dfa60a5ac..90f1974697 100644 --- a/doc/classes/VisibilityNotifier.xml +++ b/doc/classes/VisibilityNotifier.xml @@ -12,7 +12,7 @@ </demos> <methods> <method name="get_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> Returns the bounding box of the VisibilityNotifier. @@ -28,7 +28,7 @@ <method name="set_aabb"> <return type="void"> </return> - <argument index="0" name="rect" type="Rect3"> + <argument index="0" name="rect" type="AABB"> </argument> <description> Set the visibility bounding box of the VisibilityNotifier. @@ -36,7 +36,7 @@ </method> </methods> <members> - <member name="aabb" type="Rect3" setter="set_aabb" getter="get_aabb"> + <member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb"> The VisibilityNotifier's bounding box. </member> </members> diff --git a/doc/classes/VisualInstance.xml b/doc/classes/VisualInstance.xml index be2d38bf9f..7108eb13c5 100644 --- a/doc/classes/VisualInstance.xml +++ b/doc/classes/VisualInstance.xml @@ -10,7 +10,7 @@ </demos> <methods> <method name="get_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -22,7 +22,7 @@ </description> </method> <method name="get_transformed_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml index 1030e4ecc0..d716d99e5d 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/VisualServer.xml @@ -1035,7 +1035,7 @@ </description> </method> <method name="mesh_get_custom_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <argument index="0" name="mesh" type="RID"> </argument> @@ -1085,13 +1085,13 @@ </return> <argument index="0" name="mesh" type="RID"> </argument> - <argument index="1" name="aabb" type="Rect3"> + <argument index="1" name="aabb" type="AABB"> </argument> <description> </description> </method> <method name="mesh_surface_get_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <argument index="0" name="mesh" type="RID"> </argument> diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 5d62d2f5a0..42a253bc2d 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1570,6 +1570,7 @@ void RasterizerCanvasGLES3::reset_canvas() { glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); + glDisable(GL_DITHER); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 5071fbba01..004c628252 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2600,7 +2600,7 @@ RID RasterizerStorageGLES3::mesh_create() { return mesh_owner.make_rid(mesh); } -void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<Rect3> &p_bone_aabbs) { +void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { PoolVector<uint8_t> array = p_array; @@ -3240,11 +3240,11 @@ VS::PrimitiveType RasterizerStorageGLES3::mesh_surface_get_primitive_type(RID p_ return mesh->surfaces[p_surface]->primitive; } -Rect3 RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) const { +AABB RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), AABB()); return mesh->surfaces[p_surface]->aabb; } @@ -3279,11 +3279,11 @@ Vector<PoolVector<uint8_t> > RasterizerStorageGLES3::mesh_surface_get_blend_shap return bsarr; } -Vector<Rect3> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { +Vector<AABB> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Vector<Rect3>()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Rect3>()); + ERR_FAIL_COND_V(!mesh, Vector<AABB>()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<AABB>()); return mesh->surfaces[p_surface]->skeleton_bone_aabb; } @@ -3337,7 +3337,7 @@ int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const { return mesh->surfaces.size(); } -void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) { +void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); @@ -3345,37 +3345,37 @@ void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aab mesh->custom_aabb = p_aabb; } -Rect3 RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const { +AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); return mesh->custom_aabb; } -Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { +AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); - if (mesh->custom_aabb != Rect3()) + if (mesh->custom_aabb != AABB()) return mesh->custom_aabb; Skeleton *sk = NULL; if (p_skeleton.is_valid()) sk = skeleton_owner.get(p_skeleton); - Rect3 aabb; + AABB aabb; if (sk && sk->size != 0) { for (int i = 0; i < mesh->surfaces.size(); i++) { - Rect3 laabb; + AABB laabb; if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) { int bs = mesh->surfaces[i]->skeleton_bone_aabb.size(); - const Rect3 *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); + const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); const bool *skused = mesh->surfaces[i]->skeleton_bone_used.ptr(); int sbs = sk->size; @@ -3401,7 +3401,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { mtx.basis[1].y = texture[base_ofs + 1]; mtx.origin.y = texture[base_ofs + 3]; - Rect3 baabb = mtx.xform(skbones[j]); + AABB baabb = mtx.xform(skbones[j]); if (first) { laabb = baabb; first = false; @@ -3434,7 +3434,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { mtx.basis[2].z = texture[base_ofs + 2]; mtx.origin.z = texture[base_ofs + 3]; - Rect3 baabb = mtx.xform(skbones[j]); + AABB baabb = mtx.xform(skbones[j]); if (first) { laabb = baabb; first = false; @@ -4028,10 +4028,10 @@ int RasterizerStorageGLES3::multimesh_get_visible_instances(RID p_multimesh) con return multimesh->visible_instances; } -Rect3 RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const { +AABB RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const { MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); - ERR_FAIL_COND_V(!multimesh, Rect3()); + ERR_FAIL_COND_V(!multimesh, AABB()); const_cast<RasterizerStorageGLES3 *>(this)->update_dirty_multimeshes(); //update pending AABBs @@ -4053,7 +4053,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { if (multimesh->size && multimesh->dirty_aabb) { - Rect3 mesh_aabb; + AABB mesh_aabb; if (multimesh->mesh.is_valid()) { mesh_aabb = mesh_get_aabb(multimesh->mesh, RID()); @@ -4065,7 +4065,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { int count = multimesh->data.size(); float *data = multimesh->data.ptr(); - Rect3 aabb; + AABB aabb; if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) { @@ -4080,7 +4080,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { xform.basis[1][1] = dataptr[5]; xform.origin[1] = dataptr[7]; - Rect3 laabb = xform.xform(mesh_aabb); + AABB laabb = xform.xform(mesh_aabb); if (i == 0) aabb = laabb; else @@ -4106,7 +4106,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { xform.basis.elements[2][2] = dataptr[10]; xform.origin.z = dataptr[11]; - Rect3 laabb = xform.xform(mesh_aabb); + AABB laabb = xform.xform(mesh_aabb); if (i == 0) aabb = laabb; else @@ -4242,10 +4242,10 @@ void RasterizerStorageGLES3::immediate_clear(RID p_immediate) { im->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const { +AABB RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const { Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND_V(!im, Rect3()); + ERR_FAIL_COND_V(!im, AABB()); return im->aabb; } @@ -4694,10 +4694,10 @@ uint64_t RasterizerStorageGLES3::light_get_version(RID p_light) const { return light->version; } -Rect3 RasterizerStorageGLES3::light_get_aabb(RID p_light) const { +AABB RasterizerStorageGLES3::light_get_aabb(RID p_light) const { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, Rect3()); + ERR_FAIL_COND_V(!light, AABB()); switch (light->type) { @@ -4705,22 +4705,22 @@ Rect3 RasterizerStorageGLES3::light_get_aabb(RID p_light) const { float len = light->param[VS::LIGHT_PARAM_RANGE]; float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len; - return Rect3(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); + return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); } break; case VS::LIGHT_OMNI: { float r = light->param[VS::LIGHT_PARAM_RANGE]; - return Rect3(-Vector3(r, r, r), Vector3(r, r, r) * 2); + return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); } break; case VS::LIGHT_DIRECTIONAL: { - return Rect3(); + return AABB(); } break; default: {} } - ERR_FAIL_V(Rect3()); - return Rect3(); + ERR_FAIL_V(AABB()); + return AABB(); } /* PROBE API */ @@ -4842,11 +4842,11 @@ void RasterizerStorageGLES3::reflection_probe_set_cull_mask(RID p_probe, uint32_ reflection_probe->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const { +AABB RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const { const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!reflection_probe, Rect3()); + ERR_FAIL_COND_V(!reflection_probe, AABB()); - Rect3 aabb; + AABB aabb; aabb.position = -reflection_probe->extents; aabb.size = reflection_probe->extents * 2.0; @@ -4903,7 +4903,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { GIProbe *gip = memnew(GIProbe); - gip->bounds = Rect3(Vector3(), Vector3(1, 1, 1)); + gip->bounds = AABB(Vector3(), Vector3(1, 1, 1)); gip->dynamic_range = 1.0; gip->energy = 1.0; gip->propagation = 1.0; @@ -4917,7 +4917,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { return gi_probe_owner.make_rid(gip); } -void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) { +void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) { GIProbe *gip = gi_probe_owner.getornull(p_probe); ERR_FAIL_COND(!gip); @@ -4926,10 +4926,10 @@ void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const Rect3 &p_bou gip->version++; gip->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const { +AABB RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const { const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip, Rect3()); + ERR_FAIL_COND_V(!gip, AABB()); return gip->bounds; } @@ -5338,7 +5338,7 @@ void RasterizerStorageGLES3::_particles_update_histories(Particles *particles) { particles->clear = true; } -void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) { +void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) { Particles *particles = particles_owner.getornull(p_particles); ERR_FAIL_COND(!particles); @@ -5429,15 +5429,15 @@ void RasterizerStorageGLES3::particles_request_process(RID p_particles) { } } -Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { +AABB RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { const Particles *particles = particles_owner.getornull(p_particles); - ERR_FAIL_COND_V(!particles, Rect3()); + ERR_FAIL_COND_V(!particles, AABB()); glBindBuffer(GL_ARRAY_BUFFER, particles->particle_buffers[0]); float *data = (float *)glMapBufferRange(GL_ARRAY_BUFFER, 0, particles->amount * 16 * 6, GL_MAP_READ_BIT); - Rect3 aabb; + AABB aabb; Transform inv = particles->emission_transform.affine_inverse(); @@ -5459,7 +5459,7 @@ Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { float longest_axis = 0; for (int i = 0; i < particles->draw_passes.size(); i++) { if (particles->draw_passes[i].is_valid()) { - Rect3 maabb = mesh_get_aabb(particles->draw_passes[i], RID()); + AABB maabb = mesh_get_aabb(particles->draw_passes[i], RID()); longest_axis = MAX(maabb.get_longest_axis_size(), longest_axis); } } @@ -5469,10 +5469,10 @@ Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { return aabb; } -Rect3 RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const { +AABB RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const { const Particles *particles = particles_owner.getornull(p_particles); - ERR_FAIL_COND_V(!particles, Rect3()); + ERR_FAIL_COND_V(!particles, AABB()); return particles->custom_aabb; } @@ -7027,14 +7027,22 @@ void RasterizerStorageGLES3::initialize() { glBindBuffer(GL_ARRAY_BUFFER, resources.quadie); { const float qv[16] = { - -1, -1, - 0, 0, - -1, 1, - 0, 1, - 1, 1, - 1, 1, - 1, -1, - 1, 0, + -1, + -1, + 0, + 0, + -1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + -1, + 1, + 0, }; glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index bd5aad29c9..8aa8235b42 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -592,7 +592,7 @@ public: GLuint instancing_array_wireframe_id; int index_wireframe_len; - Vector<Rect3> skeleton_bone_aabb; + Vector<AABB> skeleton_bone_aabb; Vector<bool> skeleton_bone_used; //bool packed; @@ -604,7 +604,7 @@ public: Vector<BlendShape> blend_shapes; - Rect3 aabb; + AABB aabb; int array_len; int index_array_len; @@ -659,7 +659,7 @@ public: Vector<Surface *> surfaces; int blend_shape_count; VS::BlendShapeMode blend_shape_mode; - Rect3 custom_aabb; + AABB custom_aabb; mutable uint64_t last_pass; SelfList<MultiMesh>::List multimeshes; @@ -684,7 +684,7 @@ public: virtual RID mesh_create(); - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()); + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount); virtual int mesh_get_blend_shape_count(RID p_mesh) const; @@ -706,17 +706,17 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const; - virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const; + virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const; - virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const; + virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const; virtual void mesh_remove_surface(RID p_mesh, int p_surface); virtual int mesh_get_surface_count(RID p_mesh) const; - virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb); - virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const; + virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb); + virtual AABB mesh_get_custom_aabb(RID p_mesh) const; - virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const; + virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const; virtual void mesh_clear(RID p_mesh); void mesh_render_blend_shapes(Surface *s, float *p_weights); @@ -729,7 +729,7 @@ public: VS::MultimeshTransformFormat transform_format; VS::MultimeshColorFormat color_format; Vector<float> data; - Rect3 aabb; + AABB aabb; SelfList<MultiMesh> update_list; SelfList<MultiMesh> mesh_list; GLuint buffer; @@ -780,7 +780,7 @@ public: virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible); virtual int multimesh_get_visible_instances(RID p_multimesh) const; - virtual Rect3 multimesh_get_aabb(RID p_multimesh) const; + virtual AABB multimesh_get_aabb(RID p_multimesh) const; /* IMMEDIATE API */ @@ -801,7 +801,7 @@ public: List<Chunk> chunks; bool building; int mask; - Rect3 aabb; + AABB aabb; Immediate() { type = GEOMETRY_IMMEDIATE; @@ -830,7 +830,7 @@ public: virtual void immediate_clear(RID p_immediate); virtual void immediate_set_material(RID p_immediate, RID p_material); virtual RID immediate_get_material(RID p_immediate) const; - virtual Rect3 immediate_get_aabb(RID p_immediate) const; + virtual AABB immediate_get_aabb(RID p_immediate) const; /* SKELETON API */ @@ -918,7 +918,7 @@ public: virtual float light_get_param(RID p_light, VS::LightParam p_param); virtual Color light_get_color(RID p_light); - virtual Rect3 light_get_aabb(RID p_light) const; + virtual AABB light_get_aabb(RID p_light) const; virtual uint64_t light_get_version(RID p_light) const; /* PROBE API */ @@ -956,7 +956,7 @@ public: virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable); virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers); - virtual Rect3 reflection_probe_get_aabb(RID p_probe) const; + virtual AABB reflection_probe_get_aabb(RID p_probe) const; virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const; virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const; @@ -969,7 +969,7 @@ public: struct GIProbe : public Instantiable { - Rect3 bounds; + AABB bounds; Transform to_cell; float cell_size; @@ -990,8 +990,8 @@ public: virtual RID gi_probe_create(); - virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds); - virtual Rect3 gi_probe_get_bounds(RID p_probe) const; + virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds); + virtual AABB gi_probe_get_bounds(RID p_probe) const; virtual void gi_probe_set_cell_size(RID p_probe, float p_size); virtual float gi_probe_get_cell_size(RID p_probe) const; @@ -1058,7 +1058,7 @@ public: float explosiveness; float randomness; bool restart_request; - Rect3 custom_aabb; + AABB custom_aabb; bool use_local_coords; RID process_material; @@ -1113,7 +1113,7 @@ public: restart_request = false; - custom_aabb = Rect3(Vector3(-4, -4, -4), Vector3(8, 8, 8)); + custom_aabb = AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8)); draw_order = VS::PARTICLES_DRAW_ORDER_INDEX; particle_buffers[0] = 0; @@ -1155,7 +1155,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles, float p_time); virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio); virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio); - virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb); + virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb); virtual void particles_set_speed_scale(RID p_particles, float p_scale); virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable); virtual void particles_set_process_material(RID p_particles, RID p_material); @@ -1169,8 +1169,8 @@ public: virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh); virtual void particles_request_process(RID p_particles); - virtual Rect3 particles_get_current_aabb(RID p_particles); - virtual Rect3 particles_get_aabb(RID p_particles) const; + virtual AABB particles_get_current_aabb(RID p_particles); + virtual AABB particles_get_aabb(RID p_particles) const; virtual void _particles_update_histories(Particles *particles); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index ad08c59de8..325df8e4f1 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -741,6 +741,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n"; + actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; @@ -828,6 +829,9 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; + actions[VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 54eb695178..b9fd6d6fe7 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -3330,7 +3330,7 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id, int p_last_track) { h.type == Variant::VECTOR2 || h.type == Variant::RECT2 || h.type == Variant::VECTOR3 || - h.type == Variant::RECT3 || + h.type == Variant::AABB || h.type == Variant::QUAT || h.type == Variant::COLOR || h.type == Variant::TRANSFORM) { diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index b4c2ac95cc..cd60455f4f 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -209,7 +209,7 @@ void ConnectDialog::_add_bind() { case Variant::VECTOR3: value = Vector3(); break; case Variant::PLANE: value = Plane(); break; case Variant::QUAT: value = Quat(); break; - case Variant::RECT3: value = Rect3(); break; + case Variant::AABB: value = AABB(); break; case Variant::BASIS: value = Basis(); break; case Variant::TRANSFORM: value = Transform(); break; case Variant::COLOR: value = Color(); break; @@ -295,7 +295,7 @@ ConnectDialog::ConnectDialog() { type_list->add_item("Vector3", Variant::VECTOR3); type_list->add_item("Plane", Variant::PLANE); type_list->add_item("Quat", Variant::QUAT); - type_list->add_item("Rect3", Variant::RECT3); + type_list->add_item("AABB", Variant::AABB); type_list->add_item("Basis", Variant::BASIS); type_list->add_item("Transform", Variant::TRANSFORM); //type_list->add_separator(); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 95b4f7e982..02af304dc6 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -97,6 +97,15 @@ void CreateDialog::popup_create(bool p_dontclear) { search_box->grab_focus(); _update_search(); + + bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines"); + Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color"); + + if (enable_rl) { + search_options->add_constant_override("draw_relationship_lines", 1); + search_options->add_color_override("relationship_line_color", rl_color); + } else + search_options->add_constant_override("draw_relationship_lines", 0); } void CreateDialog::_text_changed(const String &p_newtext) { diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp index 13dbb149d5..45b7613659 100644 --- a/editor/doc/doc_dump.cpp +++ b/editor/doc/doc_dump.cpp @@ -182,7 +182,7 @@ void DocDump::dump(const String &p_file) { case Variant::VECTOR3: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: + case Variant::AABB: case Variant::BASIS: case Variant::COLOR: case Variant::POOL_BYTE_ARRAY: diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index b3a8490fe9..777aedefd2 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4552,6 +4552,11 @@ static Node *_resource_get_edited_scene() { return EditorNode::get_singleton()->get_edited_scene(); } +void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error) { + EditorNode *en = (EditorNode *)p_this; + en->log->add_message(p_string, p_error); +} + EditorNode::EditorNode() { Resource::_get_local_scene_func = _resource_get_edited_scene; @@ -5652,6 +5657,10 @@ EditorNode::EditorNode() { _dim_timer->connect("timeout", this, "_dim_timeout"); add_child(_dim_timer); + print_handler.printfunc = _print_handler; + print_handler.userdata = this; + add_print_handler(&print_handler); + ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F1); ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F2); ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F3); //hack neded for script editor F3 search to work :) Assign like this or don't use F3 @@ -5663,6 +5672,7 @@ EditorNode::EditorNode() { EditorNode::~EditorNode() { + remove_print_handler(&print_handler); memdelete(EditorHelp::get_doc_data()); memdelete(editor_selection); memdelete(editor_plugins_over); diff --git a/editor/editor_node.h b/editor/editor_node.h index 81ff886228..54cb414835 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -30,6 +30,7 @@ #ifndef EDITOR_NODE_H #define EDITOR_NODE_H +#include "core/print_string.h" #include "editor/connections_dialog.h" #include "editor/create_dialog.h" #include "editor/editor_about.h" @@ -610,6 +611,9 @@ private: Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins; + PrintHandlerList print_handler; + static void _print_handler(void *p_this, const String &p_string, bool p_error); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 0bd677ca1b..38e8b301b7 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -102,14 +102,14 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> textures.push_back(Ref<Texture>()); continue; } - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); print_line("aabb: " + aabb); Vector3 ofs = aabb.position + aabb.size * 0.5; aabb.position -= ofs; Transform xform; xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.25); xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.25) * xform.basis; - Rect3 rot_aabb = xform.xform(aabb); + AABB rot_aabb = xform.xform(aabb); print_line("rot_aabb: " + rot_aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) { @@ -455,7 +455,11 @@ void EditorPlugin::make_visible(bool p_visible) { void EditorPlugin::edit(Object *p_object) { if (get_script_instance() && get_script_instance()->has_method("edit")) { - get_script_instance()->call("edit", p_object); + if (p_object->is_class("Resource")) { + get_script_instance()->call("edit", Ref<Resource>(Object::cast_to<Resource>(p_object))); + } else { + get_script_instance()->call("edit", p_object); + } } } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index d8c3b8d3ed..cbc21c9536 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -302,7 +302,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array // get mesh instance and bounding box MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - Rect3 aabb = mi->get_aabb(); + AABB aabb = mi->get_aabb(); // create a new rigid body collision node RigidBody *rigid_body = memnew(RigidBody); diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 24c4813771..0818c8975e 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -389,7 +389,7 @@ void CollisionPolygonEditor::_polygon_draw() { rect = rect.grow(1); - Rect3 r; + AABB r; r.position.x = rect.position.x; r.position.y = rect.position.y; r.position.z = depth; diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 5f73d0b465..dd49bae51d 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -790,13 +790,13 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) { VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; aabb.position -= ofs; Transform xform; xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125); xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis; - Rect3 rot_aabb = xform.xform(aabb); + AABB rot_aabb = xform.xform(aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) return Ref<Texture>(); diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 74618aecc2..60e8858b2d 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -95,7 +95,7 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) { rot_y = 0; _update_rotation(); - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); print_line("aabb: " + aabb); Vector3 ofs = aabb.position + aabb.size * 0.5; float m = aabb.get_longest_axis_size(); diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 10834b74ff..f4a9960087 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -153,15 +153,15 @@ void ParticlesEditor::_generate_aabb() { EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time)); - Rect3 rect; + AABB rect; while (running < time) { uint64_t ticks = OS::get_singleton()->get_ticks_usec(); ep.step("Generating..", int(running), true); OS::get_singleton()->delay_usec(1000); - Rect3 capture = node->capture_aabb(); - if (rect == Rect3()) + AABB capture = node->capture_aabb(); + if (rect == AABB()) rect = capture; else rect.merge_with(capture); @@ -247,7 +247,7 @@ void ParticlesEditor::_generate_emission_points() { PoolVector<Face3>::Read r = geometry.read(); - Rect3 aabb; + AABB aabb; for (int i = 0; i < gcount; i++) { diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 6b945157e8..f670724f47 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -201,7 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() { text_edit->add_keyword_color("Rect2", basetype_color); text_edit->add_keyword_color("Transform2D", basetype_color); text_edit->add_keyword_color("Vector3", basetype_color); - text_edit->add_keyword_color("Rect3", basetype_color); + text_edit->add_keyword_color("AABB", basetype_color); text_edit->add_keyword_color("Basis", basetype_color); text_edit->add_keyword_color("Plane", basetype_color); text_edit->add_keyword_color("Transform", basetype_color); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index ca80908ab5..2c16157b6a 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2011,7 +2011,7 @@ void SpatialEditorViewport::_notification(int p_what) { if (se->aabb.has_no_surface()) { - se->aabb = vi ? vi->get_aabb() : Rect3(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); + se->aabb = vi ? vi->get_aabb() : AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); } Transform t = sp->get_global_transform(); @@ -2756,7 +2756,7 @@ void SpatialEditorViewport::focus_selection() { cursor.pos = center; } -void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, Rect3 *p_preview_bounds, AcceptDialog *p_accept) { +void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) { preview_node = p_preview_node; preview_bounds = p_preview_bounds; accept = p_accept; @@ -2819,14 +2819,14 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const return point + offset; } -Rect3 SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds) { - Rect3 bounds = p_bounds; +AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const AABB p_bounds) { + AABB bounds = p_bounds; for (int i = 0; i < p_parent->get_child_count(); i++) { Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i)); if (child) { MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(child); if (mesh_instance) { - Rect3 mesh_instance_bounds = mesh_instance->get_aabb(); + AABB mesh_instance_bounds = mesh_instance->get_aabb(); mesh_instance_bounds.position += mesh_instance->get_global_transform().origin - p_parent->get_global_transform().origin; bounds.merge_with(mesh_instance_bounds); } @@ -2858,7 +2858,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const { editor->get_scene_root()->add_child(preview_node); } } - *preview_bounds = _calculate_spatial_bounds(preview_node, Rect3()); + *preview_bounds = _calculate_spatial_bounds(preview_node, AABB()); } void SpatialEditorViewport::_remove_preview() { @@ -3534,7 +3534,7 @@ void SpatialEditor::select_gizmo_highlight_axis(int p_axis) { void SpatialEditor::update_transform_gizmo() { List<Node *> &selection = editor_selection->get_selected_node_list(); - Rect3 center; + AABB center; bool first = true; Basis gizmo_basis; @@ -3595,7 +3595,7 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) { void SpatialEditor::_generate_selection_box() { - Rect3 aabb(Vector3(), Vector3(1, 1, 1)); + AABB aabb(Vector3(), Vector3(1, 1, 1)); aabb.grow_by(aabb.get_longest_axis_size() / 20.0); Ref<SurfaceTool> st = memnew(SurfaceTool); @@ -4622,7 +4622,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { // Drag and drop support; preview_node = memnew(Spatial); - preview_bounds = Rect3(); + preview_bounds = AABB(); ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7); ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index c2b698068f..0ef85b72d9 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -108,7 +108,7 @@ private: Size2 prev_size; Spatial *preview_node; - Rect3 *preview_bounds; + AABB *preview_bounds; Vector<String> selected_files; AcceptDialog *accept; @@ -287,7 +287,7 @@ private: Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const; Vector3 _get_instance_position(const Point2 &p_pos) const; - static Rect3 _calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds); + static AABB _calculate_spatial_bounds(const Spatial *p_parent, const AABB p_bounds); void _create_preview(const Vector<String> &files) const; void _remove_preview(); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); @@ -314,7 +314,7 @@ public: void assign_pending_data_pointers( Spatial *p_preview_node, - Rect3 *p_preview_bounds, + AABB *p_preview_bounds, AcceptDialog *p_accept); Viewport *get_viewport_node() { return viewport; } @@ -327,7 +327,7 @@ class SpatialEditorSelectedItem : public Object { GDCLASS(SpatialEditorSelectedItem, Object); public: - Rect3 aabb; + AABB aabb; Transform original; // original location when moving Transform original_local; Transform last_xform; // last transform @@ -435,7 +435,7 @@ private: // Scene drag and drop support Spatial *preview_node; - Rect3 preview_bounds; + AABB preview_bounds; /* struct Selected { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 002ae568ff..5136c96cbf 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -755,7 +755,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: value_editor[3]->set_text(String::num(q.w)); } break; - case Variant::RECT3: { + case Variant::AABB: { field_names.push_back("px"); field_names.push_back("py"); @@ -765,7 +765,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: field_names.push_back("sz"); config_value_editors(6, 3, 16, field_names); - Rect3 aabb = v; + AABB aabb = v; value_editor[0]->set_text(String::num(aabb.position.x)); value_editor[1]->set_text(String::num(aabb.position.y)); value_editor[2]->set_text(String::num(aabb.position.z)); @@ -1585,7 +1585,7 @@ void CustomPropertyEditor::_modified(String p_string) { _emit_changed_whole_or_field(); } break; - case Variant::RECT3: { + case Variant::AABB: { Vector3 pos; Vector3 size; @@ -1605,7 +1605,7 @@ void CustomPropertyEditor::_modified(String p_string) { size.y = value_editor[4]->get_text().to_double(); size.z = value_editor[5]->get_text().to_double(); } - v = Rect3(pos, size); + v = AABB(pos, size); _emit_changed_whole_or_field(); } break; @@ -1727,7 +1727,7 @@ void CustomPropertyEditor::_focus_enter() { case Variant::VECTOR3: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: + case Variant::AABB: case Variant::TRANSFORM2D: case Variant::BASIS: case Variant::TRANSFORM: { @@ -1752,7 +1752,7 @@ void CustomPropertyEditor::_focus_exit() { case Variant::VECTOR3: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: + case Variant::AABB: case Variant::TRANSFORM2D: case Variant::BASIS: case Variant::TRANSFORM: { @@ -2238,7 +2238,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p case Variant::VECTOR3: case Variant::QUAT: case Variant::VECTOR2: - case Variant::RECT3: + case Variant::AABB: case Variant::RECT2: case Variant::TRANSFORM2D: case Variant::BASIS: @@ -3367,13 +3367,13 @@ void PropertyEditor::update_tree() { item->set_icon(0, get_icon("Plane", "EditorIcons")); } break; - case Variant::RECT3: { + case Variant::AABB: { item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); item->set_editable(1, true); - item->set_text(1, "Rect3"); + item->set_text(1, "AABB"); if (show_type_icons) - item->set_icon(0, get_icon("Rect3", "EditorIcons")); + item->set_icon(0, get_icon("AABB", "EditorIcons")); } break; case Variant::QUAT: { @@ -3714,7 +3714,7 @@ void PropertyEditor::_item_edited() { _edit_set(name, item->get_text(1), refresh_all); } } break; - // math types + // math types case Variant::VECTOR3: { @@ -3725,7 +3725,7 @@ void PropertyEditor::_item_edited() { case Variant::QUAT: { } break; - case Variant::RECT3: { + case Variant::AABB: { } break; case Variant::BASIS: { diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 3f8d93d976..3ffc61cb45 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -149,7 +149,7 @@ void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mat md = MAX(0, p_lines[i].length()); } if (md) { - mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); + mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); } } @@ -196,7 +196,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, md = MAX(0, vs[i].length()); } if (md) { - mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); + mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); } } @@ -211,7 +211,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, instances.push_back(ins); } -void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const Rect3 &p_bounds) { +void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const AABB &p_bounds) { collision_mesh = p_tmesh; collision_mesh_bounds = p_bounds; @@ -270,7 +270,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi md = MAX(0, p_handles[i].length()); } if (md) { - mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); + mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); } } @@ -1274,7 +1274,7 @@ void MeshInstanceSpatialGizmo::redraw() { Ref<TriangleMesh> tm = m->generate_triangle_mesh(); if (tm.is_valid()) { - Rect3 aabb; + AABB aabb; add_collision_triangles(tm, aabb); } } @@ -1336,7 +1336,7 @@ void SkeletonSpatialGizmo::redraw() { weights[0] = 1; - Rect3 aabb; + AABB aabb; Color bonecolor = Color(1.0, 0.4, 0.4, 0.3); Color rootcolor = Color(0.4, 1.0, 0.4, 0.1); @@ -1961,7 +1961,7 @@ void CollisionShapeSpatialGizmo::redraw() { Ref<BoxShape> bs = s; Vector<Vector3> lines; - Rect3 aabb; + AABB aabb; aabb.position = -bs->get_extents(); aabb.size = aabb.position * -2; @@ -2191,7 +2191,7 @@ void VisibilityNotifierGizmo::set_handle(int p_idx, Camera *p_camera, const Poin //gt.orthonormalize(); Transform gi = gt.affine_inverse(); - Rect3 aabb = notifier->get_aabb(); + AABB aabb = notifier->get_aabb(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -2234,7 +2234,7 @@ void VisibilityNotifierGizmo::redraw() { clear(); Vector<Vector3> lines; - Rect3 aabb = notifier->get_aabb(); + AABB aabb = notifier->get_aabb(); for (int i = 0; i < 12; i++) { Vector3 a, b; @@ -2293,7 +2293,7 @@ void ParticlesGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_poi bool move = p_idx >= 3; p_idx = p_idx % 3; - Rect3 aabb = particles->get_visibility_aabb(); + AABB aabb = particles->get_visibility_aabb(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -2347,7 +2347,7 @@ void ParticlesGizmo::redraw() { clear(); Vector<Vector3> lines; - Rect3 aabb = particles->get_visibility_aabb(); + AABB aabb = particles->get_visibility_aabb(); for (int i = 0; i < 12; i++) { Vector3 a, b; @@ -2420,7 +2420,7 @@ String ReflectionProbeGizmo::get_handle_name(int p_idx) const { } Variant ReflectionProbeGizmo::get_handle_value(int p_idx) const { - return Rect3(probe->get_extents(), probe->get_origin_offset()); + return AABB(probe->get_extents(), probe->get_origin_offset()); } void ReflectionProbeGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) { @@ -2474,7 +2474,7 @@ void ReflectionProbeGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 void ReflectionProbeGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { - Rect3 restore = p_restore; + AABB restore = p_restore; if (p_cancel) { probe->set_extents(restore.position); @@ -2499,7 +2499,7 @@ void ReflectionProbeGizmo::redraw() { Vector<Vector3> internal_lines; Vector3 extents = probe->get_extents(); - Rect3 aabb; + AABB aabb; aabb.position = -extents; aabb.size = extents * 2; @@ -2641,7 +2641,7 @@ void GIProbeGizmo::redraw() { static const int subdivs[GIProbe::SUBDIV_MAX] = { 64, 128, 256, 512 }; - Rect3 aabb = Rect3(-extents, extents * 2); + AABB aabb = AABB(-extents, extents * 2); int subdiv = subdivs[probe->get_subdiv()]; float cell_size = aabb.get_longest_axis_size() / subdiv; diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index afe64c723c..751bad2b13 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -78,7 +78,7 @@ class EditorSpatialGizmo : public SpatialEditorGizmo { Vector<Vector3> collision_segments; Ref<TriangleMesh> collision_mesh; - Rect3 collision_mesh_bounds; + AABB collision_mesh_bounds; struct Handle { Vector3 pos; @@ -100,7 +100,7 @@ protected: void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false); void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const RID &p_skeleton = RID()); void add_collision_segments(const Vector<Vector3> &p_lines); - void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const Rect3 &p_bounds = Rect3()); + void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const AABB &p_bounds = AABB()); void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1); void add_handles(const Vector<Vector3> &p_handles, bool p_billboard = false, bool p_secondary = false); void add_solid_box(Ref<Material> &p_material, Vector3 size); diff --git a/main/main.cpp b/main/main.cpp index cc6e66d352..3a87742528 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1764,7 +1764,8 @@ bool Main::iteration() { return exit; if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw()) - OS::get_singleton()->delay_usec(16600); //apply some delay to force idle time (results in about 60 FPS max) + //OS::get_singleton()->delay_usec(16600); //apply some delay to force idle time (results in about 60 FPS max) + OS::get_singleton()->delay_usec(1000); //apply some delay to force idle time (results in about 60 FPS max) else { uint32_t frame_delay = Engine::get_singleton()->get_frame_delay(); if (frame_delay) diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp new file mode 100644 index 0000000000..6c89bcdceb --- /dev/null +++ b/modules/gdnative/gdnative/aabb.cpp @@ -0,0 +1,217 @@ +/*************************************************************************/ +/* aabb.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "gdnative/aabb.h" + +#include "core/math/aabb.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) { + const Vector3 *pos = (const Vector3 *)p_pos; + const Vector3 *size = (const Vector3 *)p_size; + AABB *dest = (AABB *)r_dest; + *dest = AABB(*pos, *size); +} + +godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self) { + godot_vector3 raw_ret; + const AABB *self = (const AABB *)p_self; + Vector3 *ret = (Vector3 *)&raw_ret; + *ret = self->position; + return raw_ret; +} + +void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v) { + AABB *self = (AABB *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + self->position = *v; +} + +godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self) { + godot_vector3 raw_ret; + const AABB *self = (const AABB *)p_self; + Vector3 *ret = (Vector3 *)&raw_ret; + *ret = self->size; + return raw_ret; +} + +void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v) { + AABB *self = (AABB *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + self->size = *v; +} + +godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self) { + godot_string ret; + const AABB *self = (const AABB *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_area(); +} + +godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->has_no_area(); +} + +godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->has_no_surface(); +} + +godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with) { + const AABB *self = (const AABB *)p_self; + const AABB *with = (const AABB *)p_with; + return self->intersects(*with); +} + +godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with) { + const AABB *self = (const AABB *)p_self; + const AABB *with = (const AABB *)p_with; + return self->encloses(*with); +} + +godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + const AABB *with = (const AABB *)p_with; + *((AABB *)&dest) = self->merge(*with); + return dest; +} + +godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + const AABB *with = (const AABB *)p_with; + *((AABB *)&dest) = self->intersection(*with); + return dest; +} + +godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane) { + const AABB *self = (const AABB *)p_self; + const Plane *plane = (const Plane *)p_plane; + return self->intersects_plane(*plane); +} + +godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) { + const AABB *self = (const AABB *)p_self; + const Vector3 *from = (const Vector3 *)p_from; + const Vector3 *to = (const Vector3 *)p_to; + return self->intersects_segment(*from, *to); +} + +godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point) { + const AABB *self = (const AABB *)p_self; + const Vector3 *point = (const Vector3 *)p_point; + return self->has_point(*point); +} + +godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir) { + godot_vector3 dest; + const AABB *self = (const AABB *)p_self; + const Vector3 *dir = (const Vector3 *)p_dir; + *((Vector3 *)&dest) = self->get_support(*dir); + return dest; +} + +godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self) { + godot_vector3 dest; + const AABB *self = (const AABB *)p_self; + *((Vector3 *)&dest) = self->get_longest_axis(); + return dest; +} + +godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_longest_axis_index(); +} + +godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_longest_axis_size(); +} + +godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self) { + godot_vector3 dest; + const AABB *self = (const AABB *)p_self; + *((Vector3 *)&dest) = self->get_shortest_axis(); + return dest; +} + +godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_shortest_axis_index(); +} + +godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_shortest_axis_size(); +} + +godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + const Vector3 *to_point = (const Vector3 *)p_to_point; + *((AABB *)&dest) = self->expand(*to_point); + return dest; +} + +godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + + *((AABB *)&dest) = self->grow(p_by); + return dest; +} + +godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx) { + godot_vector3 dest; + const AABB *self = (const AABB *)p_self; + + *((Vector3 *)&dest) = self->get_endpoint(p_idx); + return dest; +} + +godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b) { + const AABB *self = (const AABB *)p_self; + const AABB *b = (const AABB *)p_b; + return *self == *b; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/rect3.cpp b/modules/gdnative/gdnative/rect3.cpp deleted file mode 100644 index 8e088743b4..0000000000 --- a/modules/gdnative/gdnative/rect3.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/*************************************************************************/ -/* rect3.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "gdnative/rect3.h" - -#include "core/math/rect3.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) { - const Vector3 *pos = (const Vector3 *)p_pos; - const Vector3 *size = (const Vector3 *)p_size; - Rect3 *dest = (Rect3 *)r_dest; - *dest = Rect3(*pos, *size); -} - -godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self) { - godot_vector3 raw_ret; - const Rect3 *self = (const Rect3 *)p_self; - Vector3 *ret = (Vector3 *)&raw_ret; - *ret = self->position; - return raw_ret; -} - -void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v) { - Rect3 *self = (Rect3 *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->position = *v; -} - -godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self) { - godot_vector3 raw_ret; - const Rect3 *self = (const Rect3 *)p_self; - Vector3 *ret = (Vector3 *)&raw_ret; - *ret = self->size; - return raw_ret; -} - -void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v) { - Rect3 *self = (Rect3 *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->size = *v; -} - -godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self) { - godot_string ret; - const Rect3 *self = (const Rect3 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_area(); -} - -godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->has_no_area(); -} - -godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->has_no_surface(); -} - -godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - return self->intersects(*with); -} - -godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - return self->encloses(*with); -} - -godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - *((Rect3 *)&dest) = self->merge(*with); - return dest; -} - -godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - *((Rect3 *)&dest) = self->intersection(*with); - return dest; -} - -godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane) { - const Rect3 *self = (const Rect3 *)p_self; - const Plane *plane = (const Plane *)p_plane; - return self->intersects_plane(*plane); -} - -godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) { - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *from = (const Vector3 *)p_from; - const Vector3 *to = (const Vector3 *)p_to; - return self->intersects_segment(*from, *to); -} - -godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point) { - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->has_point(*point); -} - -godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *dir = (const Vector3 *)p_dir; - *((Vector3 *)&dest) = self->get_support(*dir); - return dest; -} - -godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - *((Vector3 *)&dest) = self->get_longest_axis(); - return dest; -} - -godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_longest_axis_index(); -} - -godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_longest_axis_size(); -} - -godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - *((Vector3 *)&dest) = self->get_shortest_axis(); - return dest; -} - -godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_shortest_axis_index(); -} - -godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_shortest_axis_size(); -} - -godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *to_point = (const Vector3 *)p_to_point; - *((Rect3 *)&dest) = self->expand(*to_point); - return dest; -} - -godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - - *((Rect3 *)&dest) = self->grow(p_by); - return dest; -} - -godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - - *((Vector3 *)&dest) = self->get_endpoint(p_idx); - return dest; -} - -godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *b = (const Rect3 *)p_b; - return *self == *b; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp index 96b2ec8a7a..b07fcffcb6 100644 --- a/modules/gdnative/gdnative/transform.cpp +++ b/modules/gdnative/gdnative/transform.cpp @@ -198,20 +198,20 @@ godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_s return raw_dest; } -godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v) { - godot_rect3 raw_dest; - Rect3 *dest = (Rect3 *)&raw_dest; +godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v) { + godot_aabb raw_dest; + AABB *dest = (AABB *)&raw_dest; const Transform *self = (const Transform *)p_self; - const Rect3 *v = (const Rect3 *)p_v; + const AABB *v = (const AABB *)p_v; *dest = self->xform(*v); return raw_dest; } -godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v) { - godot_rect3 raw_dest; - Rect3 *dest = (Rect3 *)&raw_dest; +godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v) { + godot_aabb raw_dest; + AABB *dest = (AABB *)&raw_dest; const Transform *self = (const Transform *)p_self; - const Rect3 *v = (const Rect3 *)p_v; + const AABB *v = (const AABB *)p_v; *dest = self->xform_inv(*v); return raw_dest; } diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index 0c31bc643c..6483d19d74 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -118,10 +118,10 @@ void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_qua memnew_placement_custom(dest, Variant, Variant(*quat)); } -void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3) { +void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb) { Variant *dest = (Variant *)r_dest; - Rect3 *rect3 = (Rect3 *)p_rect3; - memnew_placement_custom(dest, Variant, Variant(*rect3)); + AABB *aabb = (AABB *)p_aabb; + memnew_placement_custom(dest, Variant, Variant(*aabb)); } void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) { @@ -304,10 +304,10 @@ godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self) { return raw_dest; } -godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self) { - godot_rect3 raw_dest; +godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self) { + godot_aabb raw_dest; const Variant *self = (const Variant *)p_self; - Rect3 *dest = (Rect3 *)&raw_dest; + AABB *dest = (AABB *)&raw_dest; *dest = *self; return raw_dest; } diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 770fb429c7..877c65dfb9 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -3221,209 +3221,209 @@ ] }, { - "name": "godot_rect3_new", + "name": "godot_aabb_new", "return_type": "void", "arguments": [ - ["godot_rect3 *", "r_dest"], + ["godot_aabb *", "r_dest"], ["const godot_vector3 *", "p_pos"], ["const godot_vector3 *", "p_size"] ] }, { - "name": "godot_rect3_get_position", + "name": "godot_aabb_get_position", "return_type": "godot_vector3", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_set_position", + "name": "godot_aabb_set_position", "return_type": "void", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_vector3 *", "p_v"] ] }, { - "name": "godot_rect3_get_size", + "name": "godot_aabb_get_size", "return_type": "godot_vector3", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_set_size", + "name": "godot_aabb_set_size", "return_type": "void", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_vector3 *", "p_v"] ] }, { - "name": "godot_rect3_as_string", + "name": "godot_aabb_as_string", "return_type": "godot_string", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_get_area", + "name": "godot_aabb_get_area", "return_type": "godot_real", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_has_no_area", + "name": "godot_aabb_has_no_area", "return_type": "godot_bool", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_has_no_surface", + "name": "godot_aabb_has_no_surface", "return_type": "godot_bool", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_intersects", + "name": "godot_aabb_intersects", "return_type": "godot_bool", "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_with"] + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_with"] ] }, { - "name": "godot_rect3_encloses", + "name": "godot_aabb_encloses", "return_type": "godot_bool", "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_with"] + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_with"] ] }, { - "name": "godot_rect3_merge", - "return_type": "godot_rect3", + "name": "godot_aabb_merge", + "return_type": "godot_aabb", "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_with"] + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_with"] ] }, { - "name": "godot_rect3_intersection", - "return_type": "godot_rect3", + "name": "godot_aabb_intersection", + "return_type": "godot_aabb", "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_with"] + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_with"] ] }, { - "name": "godot_rect3_intersects_plane", + "name": "godot_aabb_intersects_plane", "return_type": "godot_bool", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_plane *", "p_plane"] ] }, { - "name": "godot_rect3_intersects_segment", + "name": "godot_aabb_intersects_segment", "return_type": "godot_bool", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_vector3 *", "p_from"], ["const godot_vector3 *", "p_to"] ] }, { - "name": "godot_rect3_has_point", + "name": "godot_aabb_has_point", "return_type": "godot_bool", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_vector3 *", "p_point"] ] }, { - "name": "godot_rect3_get_support", + "name": "godot_aabb_get_support", "return_type": "godot_vector3", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_vector3 *", "p_dir"] ] }, { - "name": "godot_rect3_get_longest_axis", + "name": "godot_aabb_get_longest_axis", "return_type": "godot_vector3", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_get_longest_axis_index", + "name": "godot_aabb_get_longest_axis_index", "return_type": "godot_int", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_get_longest_axis_size", + "name": "godot_aabb_get_longest_axis_size", "return_type": "godot_real", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_get_shortest_axis", + "name": "godot_aabb_get_shortest_axis", "return_type": "godot_vector3", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_get_shortest_axis_index", + "name": "godot_aabb_get_shortest_axis_index", "return_type": "godot_int", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_get_shortest_axis_size", + "name": "godot_aabb_get_shortest_axis_size", "return_type": "godot_real", "arguments": [ - ["const godot_rect3 *", "p_self"] + ["const godot_aabb *", "p_self"] ] }, { - "name": "godot_rect3_expand", - "return_type": "godot_rect3", + "name": "godot_aabb_expand", + "return_type": "godot_aabb", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_vector3 *", "p_to_point"] ] }, { - "name": "godot_rect3_grow", - "return_type": "godot_rect3", + "name": "godot_aabb_grow", + "return_type": "godot_aabb", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_real", "p_by"] ] }, { - "name": "godot_rect3_get_endpoint", + "name": "godot_aabb_get_endpoint", "return_type": "godot_vector3", "arguments": [ - ["const godot_rect3 *", "p_self"], + ["const godot_aabb *", "p_self"], ["const godot_int", "p_idx"] ] }, { - "name": "godot_rect3_operator_equal", + "name": "godot_aabb_operator_equal", "return_type": "godot_bool", "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_b"] + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_b"] ] }, { @@ -3632,19 +3632,19 @@ ] }, { - "name": "godot_transform_xform_rect3", - "return_type": "godot_rect3", + "name": "godot_transform_xform_aabb", + "return_type": "godot_aabb", "arguments": [ ["const godot_transform *", "p_self"], - ["const godot_rect3 *", "p_v"] + ["const godot_aabb *", "p_v"] ] }, { - "name": "godot_transform_xform_inv_rect3", - "return_type": "godot_rect3", + "name": "godot_transform_xform_inv_aabb", + "return_type": "godot_aabb", "arguments": [ ["const godot_transform *", "p_self"], - ["const godot_rect3 *", "p_v"] + ["const godot_aabb *", "p_v"] ] }, { @@ -3930,11 +3930,11 @@ ] }, { - "name": "godot_variant_new_rect3", + "name": "godot_variant_new_aabb", "return_type": "void", "arguments": [ ["godot_variant *", "r_dest"], - ["const godot_rect3 *", "p_rect3"] + ["const godot_aabb *", "p_aabb"] ] }, { @@ -4135,8 +4135,8 @@ ] }, { - "name": "godot_variant_as_rect3", - "return_type": "godot_rect3", + "name": "godot_variant_as_aabb", + "return_type": "godot_aabb", "arguments": [ ["const godot_variant *", "p_self"] ] diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h new file mode 100644 index 0000000000..34339fa242 --- /dev/null +++ b/modules/gdnative/include/gdnative/aabb.h @@ -0,0 +1,117 @@ +/*************************************************************************/ +/* aabb.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_AABB_H +#define GODOT_AABB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#define GODOT_AABB_SIZE 24 + +#ifndef GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_AABB_SIZE]; +} godot_aabb; +#endif + +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + +#include <gdnative/gdnative.h> +#include <gdnative/plane.h> +#include <gdnative/vector3.h> + +#ifdef __cplusplus +extern "C" { +#endif + +void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); + +godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self); +void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v); + +godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self); +void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v); + +godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self); + +godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self); + +godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self); + +godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self); + +godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with); + +godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with); + +godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with); + +godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with); + +godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane); + +godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to); + +godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point); + +godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir); + +godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self); + +godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self); + +godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self); + +godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self); + +godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self); + +godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self); + +godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point); + +godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by); + +godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx); + +godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_AABB_H diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index a479eced16..38a42ab658 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -169,9 +169,9 @@ typedef void godot_object; #include <gdnative/quat.h> -/////// Rect3 +/////// AABB -#include <gdnative/rect3.h> +#include <gdnative/aabb.h> /////// Basis diff --git a/modules/gdnative/include/gdnative/rect3.h b/modules/gdnative/include/gdnative/rect3.h deleted file mode 100644 index f603a9268a..0000000000 --- a/modules/gdnative/include/gdnative/rect3.h +++ /dev/null @@ -1,117 +0,0 @@ -/*************************************************************************/ -/* rect3.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef GODOT_RECT3_H -#define GODOT_RECT3_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -#define GODOT_RECT3_SIZE 24 - -#ifndef GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_RECT3_SIZE]; -} godot_rect3; -#endif - -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - -#include <gdnative/gdnative.h> -#include <gdnative/plane.h> -#include <gdnative/vector3.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); - -godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self); -void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v); - -godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self); -void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v); - -godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane); - -godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to); - -godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point); - -godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir); - -godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self); - -godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self); - -godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self); - -godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self); - -godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point); - -godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by); - -godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx); - -godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_RECT3_H diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h index 29510313c9..cca3eb2672 100644 --- a/modules/gdnative/include/gdnative/string.h +++ b/modules/gdnative/include/gdnative/string.h @@ -51,6 +51,7 @@ typedef struct { } #endif +#include <gdnative/array.h> #include <gdnative/gdnative.h> #include <gdnative/variant.h> diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h index 8f50b01fb5..3b5c189bdf 100644 --- a/modules/gdnative/include/gdnative/transform.h +++ b/modules/gdnative/include/gdnative/transform.h @@ -98,9 +98,9 @@ godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self, godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v); -godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v); +godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v); -godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v); +godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index 3d744ef1f2..06cafcfa63 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -62,7 +62,7 @@ typedef enum godot_variant_type { GODOT_VARIANT_TYPE_TRANSFORM2D, GODOT_VARIANT_TYPE_PLANE, GODOT_VARIANT_TYPE_QUAT, // 10 - GODOT_VARIANT_TYPE_RECT3, + GODOT_VARIANT_TYPE_AABB, GODOT_VARIANT_TYPE_BASIS, GODOT_VARIANT_TYPE_TRANSFORM, @@ -104,6 +104,7 @@ typedef struct godot_variant_call_error { } #endif +#include <gdnative/aabb.h> #include <gdnative/array.h> #include <gdnative/basis.h> #include <gdnative/color.h> @@ -113,7 +114,6 @@ typedef struct godot_variant_call_error { #include <gdnative/pool_arrays.h> #include <gdnative/quat.h> #include <gdnative/rect2.h> -#include <gdnative/rect3.h> #include <gdnative/rid.h> #include <gdnative/string.h> #include <gdnative/transform.h> @@ -145,7 +145,7 @@ void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d); void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane); void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat); -void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3); +void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb); void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis); void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans); void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color); @@ -173,7 +173,7 @@ godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self); godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self); godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self); godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self); -godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self); +godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self); godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self); godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self); godot_color GDAPI godot_variant_as_color(const godot_variant *p_self); diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 29b0a6719c..8af643df50 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -371,7 +371,7 @@ void unregister_gdnative_types() { print_line(String("poolarray:\t") + itos(sizeof(PoolByteArray))); print_line(String("quat:\t") + itos(sizeof(Quat))); print_line(String("rect2:\t") + itos(sizeof(Rect2))); - print_line(String("rect3:\t") + itos(sizeof(Rect3))); + print_line(String("aabb:\t") + itos(sizeof(AABB))); print_line(String("rid:\t") + itos(sizeof(RID))); print_line(String("string:\t") + itos(sizeof(String))); print_line(String("transform:\t") + itos(sizeof(Transform))); diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index 467dbf3e56..c6066ceefb 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -642,7 +642,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ } //str+="\n"; - OS::get_singleton()->printerr("%s\n", str.utf8().get_data()); + print_error(str); r_ret = Variant(); } break; diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index 174bb02967..e3a0af8ee6 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -148,7 +148,7 @@ static const _bit _type_list[] = { { Variant::RECT2, "Rect2" }, { Variant::TRANSFORM2D, "Transform2D" }, { Variant::VECTOR3, "Vector3" }, - { Variant::RECT3, "Rect3" }, + { Variant::AABB, "AABB" }, { Variant::PLANE, "Plane" }, { Variant::QUAT, "Quat" }, { Variant::BASIS, "Basis" }, @@ -253,9 +253,9 @@ bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const case TK_BUILT_IN_FUNC: case TK_OP_IN: - //case TK_OP_NOT: - //case TK_OP_OR: - //case TK_OP_AND: + //case TK_OP_NOT: + //case TK_OP_OR: + //case TK_OP_AND: case TK_PR_CLASS: case TK_PR_CONST: @@ -1125,7 +1125,7 @@ void GDScriptTokenizerText::advance(int p_amount) { _advance(); } -////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////// #define BYTECODE_VERSION 12 diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index bceb2b7db7..491adb31ee 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1137,7 +1137,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { for (int i = 0; i < 12; i++) { - Rect3 base(Vector3(0, 0, 0), Vector3(1, 1, 1)); + AABB base(Vector3(0, 0, 0), Vector3(1, 1, 1)); Vector3 a, b; base.get_edge(i, a, b); lines.push_back(a); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 161e130a07..dfa5e720ae 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -346,7 +346,7 @@ static String variant_type_to_managed_name(const String &p_var_type_name) { Variant::TRANSFORM2D, Variant::PLANE, Variant::QUAT, - Variant::RECT3, + Variant::AABB, Variant::BASIS, Variant::TRANSFORM, Variant::COLOR, diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index a293cc2c50..59a2b73dbc 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -1721,7 +1721,7 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; break; case Variant::PLANE: - case Variant::RECT3: + case Variant::AABB: case Variant::COLOR: r_iarg.default_argument = "new Color(1, 1, 1, 1)"; r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; @@ -1793,7 +1793,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() { INSERT_STRUCT_TYPE(Basis, "real_t*") INSERT_STRUCT_TYPE(Quat, "real_t*") INSERT_STRUCT_TYPE(Transform, "real_t*") - INSERT_STRUCT_TYPE(Rect3, "real_t*") + INSERT_STRUCT_TYPE(AABB, "real_t*") INSERT_STRUCT_TYPE(Color, "real_t*") INSERT_STRUCT_TYPE(Plane, "real_t*") diff --git a/modules/mono/glue/cs_files/Rect3.cs b/modules/mono/glue/cs_files/AABB.cs index 617d33e7fd..6ee3bbe53a 100644 --- a/modules/mono/glue/cs_files/Rect3.cs +++ b/modules/mono/glue/cs_files/AABB.cs @@ -1,15 +1,15 @@ using System; -// file: core/math/rect3.h +// file: core/math/aabb.h // commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 -// file: core/math/rect3.cpp +// file: core/math/aabb.cpp // commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0 // file: core/variant_call.cpp // commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685 namespace Godot { - public struct Rect3 : IEquatable<Rect3> + public struct AABB : IEquatable<AABB> { private Vector3 position; private Vector3 size; @@ -38,7 +38,7 @@ namespace Godot } } - public bool encloses(Rect3 with) + public bool encloses(AABB with) { Vector3 src_min = position; Vector3 src_max = position + size; @@ -53,7 +53,7 @@ namespace Godot (src_max.z > dst_max.z)); } - public Rect3 expand(Vector3 to_point) + public AABB expand(Vector3 to_point) { Vector3 begin = position; Vector3 end = position + size; @@ -72,7 +72,7 @@ namespace Godot if (to_point.z > end.z) end.z = to_point.z; - return new Rect3(begin, end - begin); + return new AABB(begin, end - begin); } public float get_area() @@ -222,9 +222,9 @@ namespace Godot (dir.z > 0f) ? -half_extents.z : half_extents.z); } - public Rect3 grow(float by) + public AABB grow(float by) { - Rect3 res = this; + AABB res = this; res.position.x -= by; res.position.y -= by; @@ -264,7 +264,7 @@ namespace Godot return true; } - public Rect3 intersection(Rect3 with) + public AABB intersection(AABB with) { Vector3 src_min = position; Vector3 src_max = position + size; @@ -275,7 +275,7 @@ namespace Godot if (src_min.x > dst_max.x || src_max.x < dst_min.x) { - return new Rect3(); + return new AABB(); } else { @@ -285,7 +285,7 @@ namespace Godot if (src_min.y > dst_max.y || src_max.y < dst_min.y) { - return new Rect3(); + return new AABB(); } else { @@ -295,7 +295,7 @@ namespace Godot if (src_min.z > dst_max.z || src_max.z < dst_min.z) { - return new Rect3(); + return new AABB(); } else { @@ -303,10 +303,10 @@ namespace Godot max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z; } - return new Rect3(min, max - min); + return new AABB(min, max - min); } - public bool intersects(Rect3 with) + public bool intersects(AABB with) { if (position.x >= (with.position.x + with.size.x)) return false; @@ -398,7 +398,7 @@ namespace Godot return true; } - public Rect3 merge(Rect3 with) + public AABB merge(AABB with) { Vector3 beg_1 = position; Vector3 beg_2 = with.position; @@ -417,36 +417,36 @@ namespace Godot (end_1.z > end_2.z) ? end_1.z : end_2.z ); - return new Rect3(min, max - min); + return new AABB(min, max - min); } - public Rect3(Vector3 position, Vector3 size) + public AABB(Vector3 position, Vector3 size) { this.position = position; this.size = size; } - public static bool operator ==(Rect3 left, Rect3 right) + public static bool operator ==(AABB left, AABB right) { return left.Equals(right); } - public static bool operator !=(Rect3 left, Rect3 right) + public static bool operator !=(AABB left, AABB right) { return !left.Equals(right); } public override bool Equals(object obj) { - if (obj is Rect3) + if (obj is AABB) { - return Equals((Rect3)obj); + return Equals((AABB)obj); } return false; } - public bool Equals(Rect3 other) + public bool Equals(AABB other) { return position == other.position && size == other.size; } diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp index 1643f8cfc5..1bee1115a6 100644 --- a/modules/mono/mono_gd/gd_mono_field.cpp +++ b/modules/mono/mono_gd/gd_mono_field.cpp @@ -129,8 +129,8 @@ void GDMonoField::set_value(MonoObject *p_object, const Variant &p_value) { if (tclass == CACHED_CLASS(Transform)) SET_FROM_STRUCT_AND_BREAK(Transform); - if (tclass == CACHED_CLASS(Rect3)) - SET_FROM_STRUCT_AND_BREAK(Rect3); + if (tclass == CACHED_CLASS(AABB)) + SET_FROM_STRUCT_AND_BREAK(AABB); if (tclass == CACHED_CLASS(Color)) SET_FROM_STRUCT_AND_BREAK(Color); @@ -229,7 +229,7 @@ void GDMonoField::set_value(MonoObject *p_object, const Variant &p_value) { case Variant::TRANSFORM2D: SET_FROM_STRUCT_AND_BREAK(Transform2D); case Variant::PLANE: SET_FROM_STRUCT_AND_BREAK(Plane); case Variant::QUAT: SET_FROM_STRUCT_AND_BREAK(Quat); - case Variant::RECT3: SET_FROM_STRUCT_AND_BREAK(Rect3); + case Variant::AABB: SET_FROM_STRUCT_AND_BREAK(AABB); case Variant::BASIS: SET_FROM_STRUCT_AND_BREAK(Basis); case Variant::TRANSFORM: SET_FROM_STRUCT_AND_BREAK(Transform); case Variant::COLOR: SET_FROM_STRUCT_AND_BREAK(Color); diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 01392447f3..9c415951bb 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -104,8 +104,8 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) { if (tclass == CACHED_CLASS(Transform)) return Variant::TRANSFORM; - if (tclass == CACHED_CLASS(Rect3)) - return Variant::RECT3; + if (tclass == CACHED_CLASS(AABB)) + return Variant::AABB; if (tclass == CACHED_CLASS(Color)) return Variant::COLOR; @@ -297,8 +297,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty if (tclass == CACHED_CLASS(Transform)) RETURN_BOXED_STRUCT(Transform, p_var); - if (tclass == CACHED_CLASS(Rect3)) - RETURN_BOXED_STRUCT(Rect3, p_var); + if (tclass == CACHED_CLASS(AABB)) + RETURN_BOXED_STRUCT(AABB, p_var); if (tclass == CACHED_CLASS(Color)) RETURN_BOXED_STRUCT(Color, p_var); @@ -394,8 +394,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty RETURN_BOXED_STRUCT(Plane, p_var); case Variant::QUAT: RETURN_BOXED_STRUCT(Quat, p_var); - case Variant::RECT3: - RETURN_BOXED_STRUCT(Rect3, p_var); + case Variant::AABB: + RETURN_BOXED_STRUCT(AABB, p_var); case Variant::BASIS: RETURN_BOXED_STRUCT(Basis, p_var); case Variant::TRANSFORM: @@ -518,8 +518,8 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) { if (tclass == CACHED_CLASS(Transform)) RETURN_UNBOXED_STRUCT(Transform, p_obj); - if (tclass == CACHED_CLASS(Rect3)) - RETURN_UNBOXED_STRUCT(Rect3, p_obj); + if (tclass == CACHED_CLASS(AABB)) + RETURN_UNBOXED_STRUCT(AABB, p_obj); if (tclass == CACHED_CLASS(Color)) RETURN_UNBOXED_STRUCT(Color, p_obj); diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h index 9f403b787f..443e947fb5 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.h +++ b/modules/mono/mono_gd/gd_mono_marshal.h @@ -197,10 +197,10 @@ Dictionary mono_object_to_Dictionary(MonoObject *p_dict); Basis(m_in[0], m_in[1], m_in[2], m_in[3], m_in[4], m_in[5], m_in[6], m_in[7], m_in[8]), \ Vector3(m_in[9], m_in[10], m_in[11])); -// Rect3 +// AABB -#define MARSHALLED_OUT_Rect3(m_in, m_out) real_t m_out[6] = { m_in.position.x, m_in.position.y, m_in.position.z, m_in.size.x, m_in.size.y, m_in.size.z }; -#define MARSHALLED_IN_Rect3(m_in, m_out) Rect3 m_out(Vector3(m_in[0], m_in[1], m_in[2]), Vector3(m_in[3], m_in[4], m_in[5])); +#define MARSHALLED_OUT_AABB(m_in, m_out) real_t m_out[6] = { m_in.position.x, m_in.position.y, m_in.position.z, m_in.size.x, m_in.size.y, m_in.size.z }; +#define MARSHALLED_IN_AABB(m_in, m_out) AABB m_out(Vector3(m_in[0], m_in[1], m_in[2]), Vector3(m_in[3], m_in[4], m_in[5])); // Color @@ -214,6 +214,6 @@ Dictionary mono_object_to_Dictionary(MonoObject *p_dict); #endif -} // GDMonoMarshal +} // namespace GDMonoMarshal #endif // GDMONOMARSHAL_H diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 53e45002c4..1cccd0ad9d 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -80,7 +80,7 @@ void MonoCache::clear_members() { class_Basis = NULL; class_Quat = NULL; class_Transform = NULL; - class_Rect3 = NULL; + class_AABB = NULL; class_Color = NULL; class_Plane = NULL; class_NodePath = NULL; @@ -147,7 +147,7 @@ void update_godot_api_cache() { CACHE_CLASS_AND_CHECK(Basis, GODOT_API_CLASS(Basis)); CACHE_CLASS_AND_CHECK(Quat, GODOT_API_CLASS(Quat)); CACHE_CLASS_AND_CHECK(Transform, GODOT_API_CLASS(Transform)); - CACHE_CLASS_AND_CHECK(Rect3, GODOT_API_CLASS(Rect3)); + CACHE_CLASS_AND_CHECK(AABB, GODOT_API_CLASS(AABB)); CACHE_CLASS_AND_CHECK(Color, GODOT_API_CLASS(Color)); CACHE_CLASS_AND_CHECK(Plane, GODOT_API_CLASS(Plane)); CACHE_CLASS_AND_CHECK(NodePath, GODOT_API_CLASS(NodePath)); @@ -364,4 +364,4 @@ String get_exception_name_and_message(MonoObject *p_ex) { return res; } -} +} // namespace GDMonoUtils diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index ebb5d28e4d..c38f8c5af5 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -82,7 +82,7 @@ struct MonoCache { GDMonoClass *class_Basis; GDMonoClass *class_Quat; GDMonoClass *class_Transform; - GDMonoClass *class_Rect3; + GDMonoClass *class_AABB; GDMonoClass *class_Color; GDMonoClass *class_Plane; GDMonoClass *class_NodePath; @@ -166,7 +166,7 @@ MonoDomain *create_domain(const String &p_friendly_name); String get_exception_name_and_message(MonoObject *p_ex); -} // GDMonoUtils +} // namespace GDMonoUtils #define NATIVE_GDMONOCLASS_NAME(m_class) (GDMonoMarshal::mono_string_to_godot((MonoString *)m_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(NULL))) diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 7c9d306831..8f7fe58bee 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -1109,7 +1109,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in String str = *p_inputs[0]; //str+="\n"; - OS::get_singleton()->printerr("%s\n", str.utf8().get_data()); + print_error(str); } break; case VisualScriptBuiltinFunc::TEXT_PRINTRAW: { diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 86cf5b27e6..83b8d8da2d 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -349,7 +349,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { case Variant::TRANSFORM2D: color = Color::html("#c4ec69"); break; case Variant::PLANE: color = Color::html("#f77070"); break; case Variant::QUAT: color = Color::html("#ec69a3"); break; - case Variant::RECT3: color = Color::html("#ee7991"); break; + case Variant::AABB: color = Color::html("#ee7991"); break; case Variant::BASIS: color = Color::html("#e3ec69"); break; case Variant::TRANSFORM: color = Color::html("#f6a86e"); break; @@ -386,7 +386,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { case Variant::TRANSFORM2D: color = Color::html("#96ce1a"); break; case Variant::PLANE: color = Color::html("#f77070"); break; case Variant::QUAT: color = Color::html("#ec69a3"); break; - case Variant::RECT3: color = Color::html("#ee7991"); break; + case Variant::AABB: color = Color::html("#ee7991"); break; case Variant::BASIS: color = Color::html("#b2bb19"); break; case Variant::TRANSFORM: color = Color::html("#f49047"); break; diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index c146ac08c2..aee5d89150 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -77,7 +77,7 @@ void Particles2D::set_randomness_ratio(float p_ratio) { void Particles2D::set_visibility_rect(const Rect2 &p_aabb) { visibility_rect = p_aabb; - Rect3 aabb; + AABB aabb; aabb.position.x = p_aabb.position.x; aabb.position.y = p_aabb.position.y; aabb.size.x = p_aabb.size.x; @@ -223,7 +223,7 @@ String Particles2D::get_configuration_warning() const { Rect2 Particles2D::capture_rect() const { - Rect3 aabb = VS::get_singleton()->particles_get_current_aabb(particles); + AABB aabb = VS::get_singleton()->particles_get_current_aabb(particles); Rect2 r; r.position.x = aabb.position.x; r.position.y = aabb.position.y; @@ -378,7 +378,7 @@ void Particles2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta"); ADD_GROUP("Drawing", ""); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_rect"), "set_visibility_rect", "get_visibility_rect"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "visibility_rect"), "set_visibility_rect", "get_visibility_rect"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime"), "set_draw_order", "get_draw_order"); ADD_GROUP("Process Material", "process_"); diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index 382cbb8f38..a6d812efec 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -117,7 +117,7 @@ Vector<Point2> CollisionPolygon::get_polygon() const { return polygon; } -Rect3 CollisionPolygon::get_item_rect() const { +AABB CollisionPolygon::get_item_rect() const { return aabb; } @@ -176,7 +176,7 @@ void CollisionPolygon::_bind_methods() { CollisionPolygon::CollisionPolygon() { - aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2)); + aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); depth = 1.0; set_notify_local_transform(true); parent = NULL; diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h index dbed1d7154..14d8c3aba6 100644 --- a/scene/3d/collision_polygon.h +++ b/scene/3d/collision_polygon.h @@ -40,7 +40,7 @@ class CollisionPolygon : public Spatial { protected: float depth; - Rect3 aabb; + AABB aabb; Vector<Point2> polygon; uint32_t owner_id; @@ -64,7 +64,7 @@ public: void set_disabled(bool p_disabled); bool is_disabled() const; - virtual Rect3 get_item_rect() const; + virtual AABB get_item_rect() const; String get_configuration_warning() const; diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index bc70feaffb..05d5d52d28 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -31,12 +31,12 @@ #include "mesh_instance.h" -void GIProbeData::set_bounds(const Rect3 &p_bounds) { +void GIProbeData::set_bounds(const AABB &p_bounds) { VS::get_singleton()->gi_probe_set_bounds(probe, p_bounds); } -Rect3 GIProbeData::get_bounds() const { +AABB GIProbeData::get_bounds() const { return VS::get_singleton()->gi_probe_get_bounds(probe); } @@ -180,7 +180,7 @@ void GIProbeData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_compress", "compress"), &GIProbeData::set_compress); ClassDB::bind_method(D_METHOD("is_compressed"), &GIProbeData::is_compressed); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_cell_size", "get_cell_size"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "to_cell_xform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_to_cell_xform", "get_to_cell_xform"); @@ -542,7 +542,7 @@ static _FORCE_INLINE_ Vector2 get_uv(const Vector3 &p_pos, const Vector3 *p_vtx, return p_uv[0] * u + p_uv[1] * v + p_uv[2] * w; } -void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker) { +void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const AABB &p_aabb, Baker *p_baker) { if (p_level == p_baker->cell_subdiv - 1) { //plot the face by guessing it's albedo and emission value @@ -702,7 +702,7 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons int half = (1 << (p_baker->cell_subdiv - 1)) >> (p_level + 1); for (int i = 0; i < 8; i++) { - Rect3 aabb = p_aabb; + AABB aabb = p_aabb; aabb.size *= 0.5; int nx = p_x; @@ -726,7 +726,7 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons continue; { - Rect3 test_aabb = aabb; + AABB test_aabb = aabb; //test_aabb.grow_by(test_aabb.get_longest_axis_size()*0.05); //grow a bit to avoid numerical error in real-time Vector3 qsize = test_aabb.size * 0.5; //quarter size, for fast aabb test @@ -1083,11 +1083,11 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform(); - if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) { + if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) { Baker::PlotMesh pm; pm.local_xform = xf; pm.mesh = mesh; @@ -1113,11 +1113,11 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { if (!mesh.is_valid()) continue; - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf); - if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) { + if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) { Baker::PlotMesh pm; pm.local_xform = xf; pm.mesh = mesh; @@ -1151,7 +1151,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { baker.bake_cells.resize(1); //find out the actual real bounds, power of 2, which gets the highest subdivision - baker.po2_bounds = Rect3(-extents, extents * 2.0); + baker.po2_bounds = AABB(-extents, extents * 2.0); int longest_axis = baker.po2_bounds.get_longest_axis_index(); baker.axis_cell_size[longest_axis] = (1 << (baker.cell_subdiv - 1)); baker.leaf_voxel_count = 0; @@ -1286,7 +1286,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { Ref<GIProbeData> probe_data; probe_data.instance(); - probe_data->set_bounds(Rect3(-extents, extents * 2.0)); + probe_data->set_bounds(AABB(-extents, extents * 2.0)); probe_data->set_cell_size(baker.po2_bounds.size[longest_axis] / baker.axis_cell_size[longest_axis]); probe_data->set_dynamic_data(data); probe_data->set_dynamic_range(dynamic_range); @@ -1306,7 +1306,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { } } -void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) { +void GIProbe::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) { if (p_level == p_baker->cell_subdiv - 1) { @@ -1328,7 +1328,7 @@ void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<Multi if (p_baker->bake_cells[p_idx].childs[i] == Baker::CHILD_EMPTY) continue; - Rect3 aabb = p_aabb; + AABB aabb = p_aabb; aabb.size *= 0.5; if (i & 1) @@ -1440,9 +1440,9 @@ void GIProbe::_debug_bake() { bake(NULL, true); } -Rect3 GIProbe::get_aabb() const { +AABB GIProbe::get_aabb() const { - return Rect3(-extents, extents * 2); + return AABB(-extents, extents * 2); } PoolVector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const { diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index 8f13960b67..324ff8e917 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -43,8 +43,8 @@ protected: static void _bind_methods(); public: - void set_bounds(const Rect3 &p_bounds); - Rect3 get_bounds() const; + void set_bounds(const AABB &p_bounds); + AABB get_bounds() const; void set_cell_size(float p_size); float get_cell_size() const; @@ -146,7 +146,7 @@ private: MaterialCache _get_material_cache(Ref<Material> p_material); int leaf_voxel_count; - Rect3 po2_bounds; + AABB po2_bounds; int axis_cell_size[3]; struct PlotMesh { @@ -180,12 +180,12 @@ private: Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add); Baker::MaterialCache _get_material_cache(Ref<Material> p_material, Baker *p_baker); - void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker); + void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const AABB &p_aabb, Baker *p_baker); void _plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material); void _find_meshes(Node *p_at_node, Baker *p_baker); void _fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Baker *p_baker); - void _debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker); + void _debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker); void _create_debug_mesh(Baker *p_baker); void _debug_bake(); @@ -230,7 +230,7 @@ public: void bake(Node *p_from_node = NULL, bool p_create_visual_debug = false); - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; GIProbe(); diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp index 11f7efe066..092ed8f0b2 100644 --- a/scene/3d/immediate_geometry.cpp +++ b/scene/3d/immediate_geometry.cpp @@ -85,7 +85,7 @@ void ImmediateGeometry::clear() { cached_textures.clear(); } -Rect3 ImmediateGeometry::get_aabb() const { +AABB ImmediateGeometry::get_aabb() const { return aabb; } diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h index 93ef726c6d..1ff4e05e82 100644 --- a/scene/3d/immediate_geometry.h +++ b/scene/3d/immediate_geometry.h @@ -42,7 +42,7 @@ class ImmediateGeometry : public GeometryInstance { // in VisualServer from becoming invalid if the texture is no longer used List<Ref<Texture> > cached_textures; bool empty; - Rect3 aabb; + AABB aabb; protected: static void _bind_methods(); @@ -62,7 +62,7 @@ public: void add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv = true); - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; ImmediateGeometry(); diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 389d87cd90..324411c5cc 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -117,24 +117,24 @@ bool Light::get_shadow_reverse_cull_face() const { return reverse_cull; } -Rect3 Light::get_aabb() const { +AABB Light::get_aabb() const { if (type == VisualServer::LIGHT_DIRECTIONAL) { - return Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2)); + return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); } else if (type == VisualServer::LIGHT_OMNI) { - return Rect3(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]); + return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]); } else if (type == VisualServer::LIGHT_SPOT) { float len = param[PARAM_RANGE]; float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len; - return Rect3(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); + return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); } - return Rect3(); + return AABB(); } PoolVector<Face3> Light::get_faces(uint32_t p_usage_flags) const { diff --git a/scene/3d/light.h b/scene/3d/light.h index 2f3ac8a5e7..37c17cbbe3 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -113,7 +113,7 @@ public: void set_shadow_reverse_cull_face(bool p_enable); bool get_shadow_reverse_cull_face() const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; Light(); diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index c8215971c4..1e52ccc6e0 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -165,12 +165,12 @@ NodePath MeshInstance::get_skeleton_path() { return skeleton_path; } -Rect3 MeshInstance::get_aabb() const { +AABB MeshInstance::get_aabb() const { if (!mesh.is_null()) return mesh->get_aabb(); - return Rect3(); + return AABB(); } PoolVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const { diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h index 8e8c12a592..970a10aaf3 100644 --- a/scene/3d/mesh_instance.h +++ b/scene/3d/mesh_instance.h @@ -85,7 +85,7 @@ public: void create_debug_tangents(); - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; MeshInstance(); diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp index f90489f1f0..ce7b97be7f 100644 --- a/scene/3d/multimesh_instance.cpp +++ b/scene/3d/multimesh_instance.cpp @@ -55,10 +55,10 @@ PoolVector<Face3> MultiMeshInstance::get_faces(uint32_t p_usage_flags) const { return PoolVector<Face3>(); } -Rect3 MultiMeshInstance::get_aabb() const { +AABB MultiMeshInstance::get_aabb() const { if (multimesh.is_null()) - return Rect3(); + return AABB(); else return multimesh->get_aabb(); } diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h index cd0e7b463c..9b2b1ff9a7 100644 --- a/scene/3d/multimesh_instance.h +++ b/scene/3d/multimesh_instance.h @@ -52,7 +52,7 @@ public: void set_multimesh(const Ref<MultiMesh> &p_multimesh); Ref<MultiMesh> get_multimesh() const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; MultiMeshInstance(); ~MultiMeshInstance(); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 6ac6e52367..915a10328b 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -31,9 +31,9 @@ #include "scene/resources/surface_tool.h" #include "servers/visual_server.h" -Rect3 Particles::get_aabb() const { +AABB Particles::get_aabb() const { - return Rect3(); + return AABB(); } PoolVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const { @@ -82,7 +82,7 @@ void Particles::set_randomness_ratio(float p_ratio) { randomness_ratio = p_ratio; VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); } -void Particles::set_visibility_aabb(const Rect3 &p_aabb) { +void Particles::set_visibility_aabb(const AABB &p_aabb) { visibility_aabb = p_aabb; VS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb); @@ -140,7 +140,7 @@ float Particles::get_randomness_ratio() const { return randomness_ratio; } -Rect3 Particles::get_visibility_aabb() const { +AABB Particles::get_visibility_aabb() const { return visibility_aabb; } @@ -252,7 +252,7 @@ void Particles::restart() { VisualServer::get_singleton()->particles_restart(particles); } -Rect3 Particles::capture_aabb() const { +AABB Particles::capture_aabb() const { return VS::get_singleton()->particles_get_current_aabb(particles); } @@ -335,7 +335,7 @@ void Particles::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta"); ADD_GROUP("Drawing", ""); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime,View Depth"), "set_draw_order", "get_draw_order"); ADD_GROUP("Process Material", ""); @@ -367,7 +367,7 @@ Particles::Particles() { set_pre_process_time(0); set_explosiveness_ratio(0); set_randomness_ratio(0); - set_visibility_aabb(Rect3(Vector3(-4, -4, -4), Vector3(8, 8, 8))); + set_visibility_aabb(AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8))); set_use_local_coordinates(true); set_draw_passes(1); set_draw_order(DRAW_ORDER_INDEX); diff --git a/scene/3d/particles.h b/scene/3d/particles.h index e3109f470f..30080360bb 100644 --- a/scene/3d/particles.h +++ b/scene/3d/particles.h @@ -65,7 +65,7 @@ private: float explosiveness_ratio; float randomness_ratio; float speed_scale; - Rect3 visibility_aabb; + AABB visibility_aabb; bool local_coords; int fixed_fps; bool fractional_delta; @@ -82,7 +82,7 @@ protected: virtual void _validate_property(PropertyInfo &property) const; public: - Rect3 get_aabb() const; + AABB get_aabb() const; PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; void set_emitting(bool p_emitting); @@ -92,7 +92,7 @@ public: void set_pre_process_time(float p_time); void set_explosiveness_ratio(float p_ratio); void set_randomness_ratio(float p_ratio); - void set_visibility_aabb(const Rect3 &p_aabb); + void set_visibility_aabb(const AABB &p_aabb); void set_use_local_coordinates(bool p_enable); void set_process_material(const Ref<Material> &p_material); void set_speed_scale(float p_scale); @@ -104,7 +104,7 @@ public: float get_pre_process_time() const; float get_explosiveness_ratio() const; float get_randomness_ratio() const; - Rect3 get_visibility_aabb() const; + AABB get_visibility_aabb() const; bool get_use_local_coordinates() const; Ref<Material> get_process_material() const; float get_speed_scale() const; @@ -128,7 +128,7 @@ public: void restart(); - Rect3 capture_aabb() const; + AABB capture_aabb() const; Particles(); ~Particles(); }; diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp index 6c14f7dbc9..4fde29aab9 100644 --- a/scene/3d/portal.cpp +++ b/scene/3d/portal.cpp @@ -98,7 +98,7 @@ void Portal::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::REAL, "connect_range", PROPERTY_HINT_RANGE, "0.1,4096,0.01")); } -Rect3 Portal::get_aabb() const { +AABB Portal::get_aabb() const { return aabb; } diff --git a/scene/3d/portal.h b/scene/3d/portal.h index 6de3df8553..4ea208a718 100644 --- a/scene/3d/portal.h +++ b/scene/3d/portal.h @@ -53,7 +53,7 @@ class Portal : public VisualInstance { Color disabled_color; float connect_range; - Rect3 aabb; + AABB aabb; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -63,7 +63,7 @@ protected: static void _bind_methods(); public: - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; void set_enabled(bool p_enabled); diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 46b105cd21..0e575ec152 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -178,9 +178,9 @@ ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const { return update_mode; } -Rect3 ReflectionProbe::get_aabb() const { +AABB ReflectionProbe::get_aabb() const { - Rect3 aabb; + AABB aabb; aabb.position = -origin_offset; aabb.size = origin_offset + extents; return aabb; diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h index 7c328a8f16..26f17fdcf9 100644 --- a/scene/3d/reflection_probe.h +++ b/scene/3d/reflection_probe.h @@ -101,7 +101,7 @@ public: void set_update_mode(UpdateMode p_mode); UpdateMode get_update_mode() const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; ReflectionProbe(); diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp index 439b6bfdf8..47a7b8bfb9 100644 --- a/scene/3d/room_instance.cpp +++ b/scene/3d/room_instance.cpp @@ -66,12 +66,12 @@ void Room::_notification(int p_what) { } } -Rect3 Room::get_aabb() const { +AABB Room::get_aabb() const { if (room.is_null()) - return Rect3(); + return AABB(); - return Rect3(); + return AABB(); } PoolVector<Face3> Room::get_faces(uint32_t p_usage_flags) const { diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h index b9a64b6670..3069ea2eba 100644 --- a/scene/3d/room_instance.h +++ b/scene/3d/room_instance.h @@ -71,7 +71,7 @@ public: NOTIFICATION_AREA_CHANGED = 60 }; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; void set_room(const Ref<RoomBounds> &p_room); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 49a3205f21..18ebc22c8b 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -188,7 +188,7 @@ void SpriteBase3D::_queue_update() { call_deferred(SceneStringNames::get_singleton()->_im_update); } -Rect3 SpriteBase3D::get_aabb() const { +AABB SpriteBase3D::get_aabb() const { return aabb; } @@ -407,7 +407,7 @@ void Sprite3D::_draw() { } } - Rect3 aabb; + AABB aabb; for (int i = 0; i < 4; i++) { VS::get_singleton()->immediate_normal(immediate, normal); @@ -698,7 +698,7 @@ void AnimatedSprite3D::_draw() { } } - Rect3 aabb; + AABB aabb; for (int i = 0; i < 4; i++) { VS::get_singleton()->immediate_normal(immediate, normal); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 1165392cb2..d18553a504 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -71,7 +71,7 @@ private: Vector3::Axis axis; float pixel_size; - Rect3 aabb; + AABB aabb; RID immediate; @@ -87,7 +87,7 @@ protected: void _notification(int p_what); static void _bind_methods(); virtual void _draw() = 0; - _FORCE_INLINE_ void set_aabb(const Rect3 &p_aabb) { aabb = p_aabb; } + _FORCE_INLINE_ void set_aabb(const AABB &p_aabb) { aabb = p_aabb; } _FORCE_INLINE_ RID &get_immediate() { return immediate; } void _queue_update(); @@ -130,7 +130,7 @@ public: virtual Rect2 get_item_rect() const = 0; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; SpriteBase3D(); diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp index e60b32a92a..47144c4b78 100644 --- a/scene/3d/visibility_notifier.cpp +++ b/scene/3d/visibility_notifier.cpp @@ -60,7 +60,7 @@ void VisibilityNotifier::_exit_camera(Camera *p_camera) { } } -void VisibilityNotifier::set_aabb(const Rect3 &p_aabb) { +void VisibilityNotifier::set_aabb(const AABB &p_aabb) { if (aabb == p_aabb) return; @@ -74,7 +74,7 @@ void VisibilityNotifier::set_aabb(const Rect3 &p_aabb) { update_gizmo(); } -Rect3 VisibilityNotifier::get_aabb() const { +AABB VisibilityNotifier::get_aabb() const { return aabb; } @@ -108,7 +108,7 @@ void VisibilityNotifier::_bind_methods() { ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier::get_aabb); ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier::is_on_screen); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "aabb"), "set_aabb", "get_aabb"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb"); ADD_SIGNAL(MethodInfo("camera_entered", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"))); ADD_SIGNAL(MethodInfo("camera_exited", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"))); @@ -118,7 +118,7 @@ void VisibilityNotifier::_bind_methods() { VisibilityNotifier::VisibilityNotifier() { - aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2)); + aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); set_notify_transform(true); } diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h index 0b83e0534e..fc06cf5aec 100644 --- a/scene/3d/visibility_notifier.h +++ b/scene/3d/visibility_notifier.h @@ -39,7 +39,7 @@ class VisibilityNotifier : public Spatial { Set<Camera *> cameras; - Rect3 aabb; + AABB aabb; protected: virtual void _screen_enter() {} @@ -53,8 +53,8 @@ protected: void _exit_camera(Camera *p_camera); public: - void set_aabb(const Rect3 &p_aabb); - Rect3 get_aabb() const; + void set_aabb(const AABB &p_aabb); + AABB get_aabb() const; bool is_on_screen() const; VisibilityNotifier(); diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index fa35d982eb..b92e7ead04 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -33,7 +33,7 @@ #include "servers/visual_server.h" #include "skeleton.h" -Rect3 VisualInstance::get_transformed_aabb() const { +AABB VisualInstance::get_transformed_aabb() const { return get_global_transform().xform(get_aabb()); } diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h index c405236d2c..5827f1e1fb 100644 --- a/scene/3d/visual_instance.h +++ b/scene/3d/visual_instance.h @@ -62,10 +62,10 @@ public: }; RID get_instance() const; - virtual Rect3 get_aabb() const = 0; + virtual AABB get_aabb() const = 0; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const = 0; - virtual Rect3 get_transformed_aabb() const; // helper + virtual AABB get_transformed_aabb() const; // helper void set_base(const RID &p_base); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index e0508cf147..40d06dc756 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -416,10 +416,10 @@ Variant Tween::_run_equation(InterpolateData &p_data) { result = r; } break; - case Variant::RECT3: { - Rect3 i = initial_val; - Rect3 d = delta_val; - Rect3 r; + case Variant::AABB: { + AABB i = initial_val; + AABB d = delta_val; + AABB r; APPLY_EQUATION(position.x); APPLY_EQUATION(position.y); @@ -956,10 +956,10 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final case Variant::QUAT: delta_val = final_val.operator Quat() - initial_val.operator Quat(); break; - case Variant::RECT3: { - Rect3 i = initial_val; - Rect3 f = final_val; - delta_val = Rect3(f.position - i.position, f.size - i.size); + case Variant::AABB: { + AABB i = initial_val; + AABB f = final_val; + delta_val = AABB(f.position - i.position, f.size - i.size); } break; case Variant::TRANSFORM: { Transform i = initial_val; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index e73ada9f31..3976a2ad48 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1847,6 +1847,25 @@ Control *Control::find_next_valid_focus() const { while (true) { + // If the focus property is manually overwritten, attempt to use it. + + if (!data.focus_next.is_empty()) { + Node *n = get_node(data.focus_next); + if (n) { + from = Object::cast_to<Control>(n); + + if (!from) { + + ERR_EXPLAIN("Next focus node is not a control: " + n->get_name()); + ERR_FAIL_V(NULL); + } + } else { + return NULL; + } + if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE) + return from; + } + // find next child Control *next_child = NULL; @@ -1926,6 +1945,25 @@ Control *Control::find_prev_valid_focus() const { while (true) { + // If the focus property is manually overwritten, attempt to use it. + + if (!data.focus_prev.is_empty()) { + Node *n = get_node(data.focus_prev); + if (n) { + from = Object::cast_to<Control>(n); + + if (!from) { + + ERR_EXPLAIN("Prev focus node is not a control: " + n->get_name()); + ERR_FAIL_V(NULL); + } + } else { + return NULL; + } + if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE) + return from; + } + // find prev child Control *prev_child = NULL; @@ -2157,6 +2195,26 @@ NodePath Control::get_focus_neighbour(Margin p_margin) const { return data.focus_neighbour[p_margin]; } +void Control::set_focus_next(const NodePath &p_next) { + + data.focus_next = p_next; +} + +NodePath Control::get_focus_next() const { + + return data.focus_next; +} + +void Control::set_focus_previous(const NodePath &p_prev) { + + data.focus_prev = p_prev; +} + +NodePath Control::get_focus_previous() const { + + return data.focus_prev; +} + #define MAX_NEIGHBOUR_SEARCH_COUNT 512 Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { @@ -2172,7 +2230,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { if (!c) { - ERR_EXPLAIN("Next focus node is not a control: " + n->get_name()); + ERR_EXPLAIN("Neighbour focus node is not a control: " + n->get_name()); ERR_FAIL_V(NULL); } } else { @@ -2677,6 +2735,12 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_focus_neighbour", "margin", "neighbour"), &Control::set_focus_neighbour); ClassDB::bind_method(D_METHOD("get_focus_neighbour", "margin"), &Control::get_focus_neighbour); + ClassDB::bind_method(D_METHOD("set_focus_next", "next"), &Control::set_focus_next); + ClassDB::bind_method(D_METHOD("get_focus_next"), &Control::get_focus_next); + + ClassDB::bind_method(D_METHOD("set_focus_previous", "previous"), &Control::set_focus_previous); + ClassDB::bind_method(D_METHOD("get_focus_previous"), &Control::get_focus_previous); + ClassDB::bind_method(D_METHOD("force_drag", "data", "preview"), &Control::force_drag); ClassDB::bind_method(D_METHOD("set_mouse_filter", "filter"), &Control::set_mouse_filter); @@ -2737,6 +2801,8 @@ void Control::_bind_methods() { ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_top"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_TOP); ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_right"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_RIGHT); ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_bottom"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_BOTTOM); + ADD_PROPERTYNZ(PropertyInfo(Variant::NODE_PATH, "focus_next"), "set_focus_next", "get_focus_next"); + ADD_PROPERTYNZ(PropertyInfo(Variant::NODE_PATH, "focus_previous"), "set_focus_previous", "get_focus_previous"); ADD_GROUP("Mouse", "mouse_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_filter", PROPERTY_HINT_ENUM, "Stop,Pass,Ignore"), "set_mouse_filter", "get_mouse_filter"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 4d0e3934ad..94c484ca50 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -191,6 +191,8 @@ private: ObjectID modal_prev_focus_owner; NodePath focus_neighbour[4]; + NodePath focus_next; + NodePath focus_prev; HashMap<StringName, Ref<Texture>, StringNameHasher> icon_override; HashMap<StringName, Ref<Shader>, StringNameHasher> shader_override; @@ -374,6 +376,11 @@ public: void set_focus_neighbour(Margin p_margin, const NodePath &p_neighbour); NodePath get_focus_neighbour(Margin p_margin) const; + void set_focus_next(const NodePath &p_next); + NodePath get_focus_next() const; + void set_focus_previous(const NodePath &p_prev); + NodePath get_focus_previous() const; + Control *get_focus_owner() const; void set_mouse_filter(MouseFilter p_filter); diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 21e4a85cd1..8192074c17 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1125,14 +1125,14 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a return a.cubic_slerp(b, pa, pb, p_c); } break; - case Variant::RECT3: { + case Variant::AABB: { - Rect3 a = p_a; - Rect3 b = p_b; - Rect3 pa = p_pre_a; - Rect3 pb = p_post_b; + AABB a = p_a; + AABB b = p_b; + AABB pa = p_pre_a; + AABB pb = p_post_b; - return Rect3( + return AABB( a.position.cubic_interpolate(b.position, pa.position, pb.position, p_c), a.size.cubic_interpolate(b.size, pa.size, pb.size, p_c)); } break; diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp index bbc85ce0f6..4b9843f3f5 100644 --- a/scene/resources/box_shape.cpp +++ b/scene/resources/box_shape.cpp @@ -33,7 +33,7 @@ Vector<Vector3> BoxShape::_gen_debug_mesh_lines() { Vector<Vector3> lines; - Rect3 aabb; + AABB aabb; aabb.position = -get_extents(); aabb.size = aabb.position * -2; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 3e86daf3a7..06b147ba41 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -594,9 +594,9 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { } ERR_FAIL_COND_V(!d.has("aabb"), false); - Rect3 aabb = d["aabb"]; + AABB aabb = d["aabb"]; - Vector<Rect3> bone_aabb; + Vector<AABB> bone_aabb; if (d.has("skeleton_aabb")) { Array baabb = d["skeleton_aabb"]; bone_aabb.resize(baabb.size()); @@ -676,7 +676,7 @@ bool ArrayMesh::_get(const StringName &p_name, Variant &r_ret) const { d["format"] = VS::get_singleton()->mesh_surface_get_format(mesh, idx); d["aabb"] = VS::get_singleton()->mesh_surface_get_aabb(mesh, idx); - Vector<Rect3> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh, idx); + Vector<AABB> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh, idx); Array arr; for (int i = 0; i < skel_aabb.size(); i++) { arr[i] = skel_aabb[i]; @@ -725,13 +725,13 @@ void ArrayMesh::_get_property_list(List<PropertyInfo> *p_list) const { } } - p_list->push_back(PropertyInfo(Variant::RECT3, "custom_aabb/custom_aabb")); + p_list->push_back(PropertyInfo(Variant::AABB, "custom_aabb/custom_aabb")); } void ArrayMesh::_recompute_aabb() { // regenerate AABB - aabb = Rect3(); + aabb = AABB(); for (int i = 0; i < surfaces.size(); i++) { @@ -742,7 +742,7 @@ void ArrayMesh::_recompute_aabb() { } } -void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<Rect3> &p_bone_aabbs) { +void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { Surface s; s.aabb = p_aabb; @@ -772,7 +772,7 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array & const Vector3 *vtx = r.ptr(); // check AABB - Rect3 aabb; + AABB aabb; for (int i = 0; i < len; i++) { if (i == 0) @@ -926,7 +926,7 @@ void ArrayMesh::surface_update_region(int p_surface, int p_offset, const PoolVec VS::get_singleton()->mesh_surface_update_region(mesh, p_surface, p_offset, p_data); } -void ArrayMesh::surface_set_custom_aabb(int p_idx, const Rect3 &p_aabb) { +void ArrayMesh::surface_set_custom_aabb(int p_idx, const AABB &p_aabb) { ERR_FAIL_INDEX(p_idx, surfaces.size()); surfaces[p_idx].aabb = p_aabb; @@ -942,7 +942,7 @@ Ref<Material> ArrayMesh::surface_get_material(int p_idx) const { void ArrayMesh::add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data) { VisualServer::get_singleton()->mesh_add_surface_from_mesh_data(mesh, p_mesh_data); - Rect3 aabb; + AABB aabb; for (int i = 0; i < p_mesh_data.vertices.size(); i++) { if (i == 0) @@ -970,18 +970,18 @@ RID ArrayMesh::get_rid() const { return mesh; } -Rect3 ArrayMesh::get_aabb() const { +AABB ArrayMesh::get_aabb() const { return aabb; } -void ArrayMesh::set_custom_aabb(const Rect3 &p_custom) { +void ArrayMesh::set_custom_aabb(const AABB &p_custom) { custom_aabb = p_custom; VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb); } -Rect3 ArrayMesh::get_custom_aabb() const { +AABB ArrayMesh::get_custom_aabb() const { return custom_aabb; } diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index 75927079c7..b85a6a84af 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -136,7 +136,7 @@ public: Ref<Mesh> create_outline(float p_margin) const; - virtual Rect3 get_aabb() const = 0; + virtual AABB get_aabb() const = 0; Mesh(); }; @@ -149,16 +149,16 @@ class ArrayMesh : public Mesh { private: struct Surface { String name; - Rect3 aabb; + AABB aabb; Ref<Material> material; bool is_2d; }; Vector<Surface> surfaces; RID mesh; - Rect3 aabb; + AABB aabb; BlendShapeMode blend_shape_mode; Vector<StringName> blend_shapes; - Rect3 custom_aabb; + AABB custom_aabb; void _recompute_aabb(); @@ -173,7 +173,7 @@ protected: public: void add_surface_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_flags = ARRAY_COMPRESS_DEFAULT); - void add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()); + void add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); Array surface_get_arrays(int p_surface) const; Array surface_get_blend_shape_arrays(int p_surface) const; @@ -191,7 +191,7 @@ public: int get_surface_count() const; void surface_remove(int p_idx); - void surface_set_custom_aabb(int p_idx, const Rect3 &p_aabb); //only recognized by driver + void surface_set_custom_aabb(int p_idx, const AABB &p_aabb); //only recognized by driver int surface_get_array_len(int p_idx) const; int surface_get_array_index_len(int p_idx) const; @@ -207,10 +207,10 @@ public: void add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data); - void set_custom_aabb(const Rect3 &p_custom); - Rect3 get_custom_aabb() const; + void set_custom_aabb(const AABB &p_custom); + AABB get_custom_aabb() const; - Rect3 get_aabb() const; + AABB get_aabb() const; virtual RID get_rid() const; void center_geometry(); diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp index 15f1e15542..ee6efa6e85 100644 --- a/scene/resources/multimesh.cpp +++ b/scene/resources/multimesh.cpp @@ -155,7 +155,7 @@ Color MultiMesh::get_instance_color(int p_instance) const { return VisualServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance); } -Rect3 MultiMesh::get_aabb() const { +AABB MultiMesh::get_aabb() const { return VisualServer::get_singleton()->multimesh_get_aabb(multimesh); } diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h index 7ca66b0b46..0a5310f641 100644 --- a/scene/resources/multimesh.h +++ b/scene/resources/multimesh.h @@ -84,7 +84,7 @@ public: void set_instance_color(int p_instance, const Color &p_color); Color get_instance_color(int p_instance) const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual RID get_rid() const; diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 8e3899315c..3b80db291c 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -42,7 +42,7 @@ void PrimitiveMesh::_update() const { PoolVector<Vector3> points = arr[VS::ARRAY_VERTEX]; - aabb = Rect3(); + aabb = AABB(); int pc = points.size(); ERR_FAIL_COND(pc == 0); @@ -141,7 +141,7 @@ StringName PrimitiveMesh::get_blend_shape_name(int p_index) const { return StringName(); } -Rect3 PrimitiveMesh::get_aabb() const { +AABB PrimitiveMesh::get_aabb() const { if (pending_request) { _update(); } diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h index f0c8935261..b38c247827 100644 --- a/scene/resources/primitive_meshes.h +++ b/scene/resources/primitive_meshes.h @@ -47,7 +47,7 @@ class PrimitiveMesh : public Mesh { private: RID mesh; - mutable Rect3 aabb; + mutable AABB aabb; Ref<Material> material; @@ -73,7 +73,7 @@ public: virtual Ref<Material> surface_get_material(int p_idx) const; virtual int get_blend_shape_count() const; virtual StringName get_blend_shape_name(int p_index) const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual RID get_rid() const; void set_material(const Ref<Material> &p_material); diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index f0304bfaa5..fe23fbf6b3 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -33,7 +33,7 @@ #include "project_settings.h" #include "version.h" -//version 2: changed names for basis, rect3, poolvectors, etc. +//version 2: changed names for basis, aabb, poolvectors, etc. #define FORMAT_VERSION 2 #include "os/dir_access.h" diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp index af159975ca..86b32a5cdd 100644 --- a/scene/resources/world.cpp +++ b/scene/resources/world.cpp @@ -41,7 +41,7 @@ struct SpatialIndexer { struct NotifierData { - Rect3 aabb; + AABB aabb; OctreeElementID id; }; @@ -63,7 +63,7 @@ struct SpatialIndexer { uint64_t pass; uint64_t last_frame; - void _notifier_add(VisibilityNotifier *p_notifier, const Rect3 &p_rect) { + void _notifier_add(VisibilityNotifier *p_notifier, const AABB &p_rect) { ERR_FAIL_COND(notifiers.has(p_notifier)); notifiers[p_notifier].aabb = p_rect; @@ -71,7 +71,7 @@ struct SpatialIndexer { changed = true; } - void _notifier_update(VisibilityNotifier *p_notifier, const Rect3 &p_rect) { + void _notifier_update(VisibilityNotifier *p_notifier, const AABB &p_rect) { Map<VisibilityNotifier *, NotifierData>::Element *E = notifiers.find(p_notifier); ERR_FAIL_COND(!E); @@ -229,14 +229,14 @@ void World::_remove_camera(Camera *p_camera) { #endif } -void World::_register_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect) { +void World::_register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) { #ifndef _3D_DISABLED indexer->_notifier_add(p_notifier, p_rect); #endif } -void World::_update_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect) { +void World::_update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) { #ifndef _3D_DISABLED indexer->_notifier_update(p_notifier, p_rect); diff --git a/scene/resources/world.h b/scene/resources/world.h index 767d1b5b6e..e0f1de1fd0 100644 --- a/scene/resources/world.h +++ b/scene/resources/world.h @@ -60,8 +60,8 @@ protected: void _update_camera(Camera *p_camera); void _remove_camera(Camera *p_camera); - void _register_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect); - void _update_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect); + void _register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect); + void _update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect); void _remove_notifier(VisibilityNotifier *p_notifier); friend class Viewport; void _update(uint64_t p_frame); diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp index c6565ac2e9..e4eae09c61 100644 --- a/servers/physics/broad_phase_basic.cpp +++ b/servers/physics/broad_phase_basic.cpp @@ -46,7 +46,7 @@ BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subi return current; } -void BroadPhaseBasic::move(ID p_id, const Rect3 &p_aabb) { +void BroadPhaseBasic::move(ID p_id, const AABB &p_aabb) { Map<ID, Element>::Element *E = element_map.find(p_id); ERR_FAIL_COND(!E); @@ -109,7 +109,7 @@ int BroadPhaseBasic::cull_point(const Vector3 &p_point, CollisionObjectSW **p_re for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) { - const Rect3 aabb = E->get().aabb; + const AABB aabb = E->get().aabb; if (aabb.has_point(p_point)) { p_results[rc] = E->get().owner; @@ -129,7 +129,7 @@ int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, Co for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) { - const Rect3 aabb = E->get().aabb; + const AABB aabb = E->get().aabb; if (aabb.intersects_segment(p_from, p_to)) { p_results[rc] = E->get().owner; @@ -142,13 +142,13 @@ int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, Co return rc; } -int BroadPhaseBasic::cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhaseBasic::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { int rc = 0; for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) { - const Rect3 aabb = E->get().aabb; + const AABB aabb = E->get().aabb; if (aabb.intersects(p_aabb)) { p_results[rc] = E->get().owner; diff --git a/servers/physics/broad_phase_basic.h b/servers/physics/broad_phase_basic.h index 5c124c1792..ee683ed840 100644 --- a/servers/physics/broad_phase_basic.h +++ b/servers/physics/broad_phase_basic.h @@ -39,7 +39,7 @@ class BroadPhaseBasic : public BroadPhaseSW { CollisionObjectSW *owner; bool _static; - Rect3 aabb; + AABB aabb; int subindex; }; @@ -83,7 +83,7 @@ class BroadPhaseBasic : public BroadPhaseSW { public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0); - virtual void move(ID p_id, const Rect3 &p_aabb); + virtual void move(ID p_id, const AABB &p_aabb); virtual void set_static(ID p_id, bool p_static); virtual void remove(ID p_id); @@ -93,7 +93,7 @@ public: virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); + virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata); diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp index e7111d9580..3b18a270f0 100644 --- a/servers/physics/broad_phase_octree.cpp +++ b/servers/physics/broad_phase_octree.cpp @@ -32,11 +32,11 @@ BroadPhaseSW::ID BroadPhaseOctree::create(CollisionObjectSW *p_object, int p_subindex) { - ID oid = octree.create(p_object, Rect3(), p_subindex, false, 1 << p_object->get_type(), 0); + ID oid = octree.create(p_object, AABB(), p_subindex, false, 1 << p_object->get_type(), 0); return oid; } -void BroadPhaseOctree::move(ID p_id, const Rect3 &p_aabb) { +void BroadPhaseOctree::move(ID p_id, const AABB &p_aabb) { octree.move(p_id, p_aabb); } @@ -76,7 +76,7 @@ int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, C return octree.cull_segment(p_from, p_to, p_results, p_max_results, p_result_indices); } -int BroadPhaseOctree::cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { return octree.cull_aabb(p_aabb, p_results, p_max_results, p_result_indices); } diff --git a/servers/physics/broad_phase_octree.h b/servers/physics/broad_phase_octree.h index d28f2da13f..f894d6ca5a 100644 --- a/servers/physics/broad_phase_octree.h +++ b/servers/physics/broad_phase_octree.h @@ -48,7 +48,7 @@ class BroadPhaseOctree : public BroadPhaseSW { public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0); - virtual void move(ID p_id, const Rect3 &p_aabb); + virtual void move(ID p_id, const AABB &p_aabb); virtual void set_static(ID p_id, bool p_static); virtual void remove(ID p_id); @@ -58,7 +58,7 @@ public: virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); + virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata); diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h index 2b5ed629fe..5ad3f9a261 100644 --- a/servers/physics/broad_phase_sw.h +++ b/servers/physics/broad_phase_sw.h @@ -30,8 +30,8 @@ #ifndef BROAD_PHASE_SW_H #define BROAD_PHASE_SW_H +#include "aabb.h" #include "math_funcs.h" -#include "rect3.h" class CollisionObjectSW; @@ -49,7 +49,7 @@ public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object_, int p_subindex = 0) = 0; - virtual void move(ID p_id, const Rect3 &p_aabb) = 0; + virtual void move(ID p_id, const AABB &p_aabb) = 0; virtual void set_static(ID p_id, bool p_static) = 0; virtual void remove(ID p_id) = 0; @@ -59,7 +59,7 @@ public: virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; - virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; + virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata) = 0; virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) = 0; diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp index 3af8b542fa..126f8141ff 100644 --- a/servers/physics/collision_object_sw.cpp +++ b/servers/physics/collision_object_sw.cpp @@ -149,7 +149,7 @@ void CollisionObjectSW::_update_shapes() { } //not quite correct, should compute the next matrix.. - Rect3 shape_aabb = s.shape->get_aabb(); + AABB shape_aabb = s.shape->get_aabb(); Transform xform = transform * s.xform; shape_aabb = xform.xform(shape_aabb); s.aabb_cache = shape_aabb; @@ -176,10 +176,10 @@ void CollisionObjectSW::_update_shapes_with_motion(const Vector3 &p_motion) { } //not quite correct, should compute the next matrix.. - Rect3 shape_aabb = s.shape->get_aabb(); + AABB shape_aabb = s.shape->get_aabb(); Transform xform = transform * s.xform; shape_aabb = xform.xform(shape_aabb); - shape_aabb = shape_aabb.merge(Rect3(shape_aabb.position + p_motion, shape_aabb.size)); //use motion + shape_aabb = shape_aabb.merge(AABB(shape_aabb.position + p_motion, shape_aabb.size)); //use motion s.aabb_cache = shape_aabb; space->get_broadphase()->move(s.bpid, shape_aabb); diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index 67a8a44944..254947060b 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -61,7 +61,7 @@ private: Transform xform; Transform xform_inv; BroadPhaseSW::ID bpid; - Rect3 aabb_cache; //for rayqueries + AABB aabb_cache; //for rayqueries real_t area_cache; ShapeSW *shape; bool disabled; @@ -123,7 +123,7 @@ public: _FORCE_INLINE_ ShapeSW *get_shape(int p_index) const { return shapes[p_index].shape; } _FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; } _FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; } - _FORCE_INLINE_ const Rect3 &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } + _FORCE_INLINE_ const AABB &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } _FORCE_INLINE_ const real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; } _FORCE_INLINE_ Transform get_transform() const { return transform; } diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp index 7bef208237..a9431dc6d8 100644 --- a/servers/physics/collision_solver_sw.cpp +++ b/servers/physics/collision_solver_sw.cpp @@ -152,7 +152,7 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A, const Transform //quickly compute a local AABB - Rect3 local_aabb; + AABB local_aabb; for (int i = 0; i < 3; i++) { Vector3 axis(p_transform_B.basis.get_axis(i)); @@ -291,7 +291,7 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A, const Tra return collided; } -bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const Rect3 &p_concave_hint, Vector3 *r_sep_axis) { +bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) { if (p_shape_A->is_concave()) return false; @@ -328,14 +328,14 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform //quickly compute a local AABB - bool use_cc_hint = p_concave_hint != Rect3(); - Rect3 cc_hint_aabb; + bool use_cc_hint = p_concave_hint != AABB(); + AABB cc_hint_aabb; if (use_cc_hint) { cc_hint_aabb = p_concave_hint; cc_hint_aabb.position -= p_transform_B.origin; } - Rect3 local_aabb; + AABB local_aabb; for (int i = 0; i < 3; i++) { Vector3 axis(p_transform_B.basis.get_axis(i)); diff --git a/servers/physics/collision_solver_sw.h b/servers/physics/collision_solver_sw.h index 1e38b1b54e..a40b665ff0 100644 --- a/servers/physics/collision_solver_sw.h +++ b/servers/physics/collision_solver_sw.h @@ -46,7 +46,7 @@ private: public: static bool solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0); - static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const Rect3 &p_concave_hint, Vector3 *r_sep_axis = NULL); + static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = NULL); }; #endif // COLLISION_SOLVER__SW_H diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index 6dafaac115..b204ff7a33 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -37,7 +37,7 @@ #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002 #define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998 -void ShapeSW::configure(const Rect3 &p_aabb) { +void ShapeSW::configure(const AABB &p_aabb) { aabb = p_aabb; configured = true; for (Map<ShapeOwnerSW *, int>::Element *E = owners.front(); E; E = E->next()) { @@ -141,7 +141,7 @@ Vector3 PlaneShapeSW::get_moment_of_inertia(real_t p_mass) const { void PlaneShapeSW::_setup(const Plane &p_plane) { plane = p_plane; - configure(Rect3(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2))); + configure(AABB(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2))); } void PlaneShapeSW::set_data(const Variant &p_data) { @@ -223,7 +223,7 @@ Vector3 RayShapeSW::get_moment_of_inertia(real_t p_mass) const { void RayShapeSW::_setup(real_t p_length) { length = p_length; - configure(Rect3(Vector3(0, 0, 0), Vector3(0.1, 0.1, length))); + configure(AABB(Vector3(0, 0, 0), Vector3(0.1, 0.1, length))); } void RayShapeSW::set_data(const Variant &p_data) { @@ -299,7 +299,7 @@ Vector3 SphereShapeSW::get_moment_of_inertia(real_t p_mass) const { void SphereShapeSW::_setup(real_t p_radius) { radius = p_radius; - configure(Rect3(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0))); + configure(AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0))); } void SphereShapeSW::set_data(const Variant &p_data) { @@ -430,7 +430,7 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup bool BoxShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { - Rect3 aabb(-half_extents, half_extents * 2.0); + AABB aabb(-half_extents, half_extents * 2.0); return aabb.intersects_segment(p_begin, p_end, &r_result, &r_normal); } @@ -504,7 +504,7 @@ void BoxShapeSW::_setup(const Vector3 &p_half_extents) { half_extents = p_half_extents.abs(); - configure(Rect3(-half_extents, half_extents * 2)); + configure(AABB(-half_extents, half_extents * 2)); } void BoxShapeSW::set_data(const Variant &p_data) { @@ -684,7 +684,7 @@ void CapsuleShapeSW::_setup(real_t p_height, real_t p_radius) { height = p_height; radius = p_radius; - configure(Rect3(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0))); + configure(AABB(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0))); } void CapsuleShapeSW::set_data(const Variant &p_data) { @@ -957,7 +957,7 @@ void ConvexPolygonShapeSW::_setup(const Vector<Vector3> &p_vertices) { if (err != OK) ERR_PRINT("Failed to build QuickHull"); - Rect3 _aabb; + AABB _aabb; for (int i = 0; i < mesh.vertices.size(); i++) { @@ -1102,7 +1102,7 @@ Vector3 FaceShapeSW::get_moment_of_inertia(real_t p_mass) const { FaceShapeSW::FaceShapeSW() { - configure(Rect3()); + configure(AABB()); } PoolVector<Vector3> ConcavePolygonShapeSW::get_faces() const { @@ -1300,13 +1300,13 @@ void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const { } } -void ConcavePolygonShapeSW::cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const { +void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const { // make matrix local to concave if (faces.size() == 0) return; - Rect3 local_aabb = p_local_aabb; + AABB local_aabb = p_local_aabb; // unlock data PoolVector<Face>::Read fr = faces.read(); @@ -1341,7 +1341,7 @@ Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(real_t p_mass) const { struct _VolumeSW_BVH_Element { - Rect3 aabb; + AABB aabb; Vector3 center; int face_index; }; @@ -1372,7 +1372,7 @@ struct _VolumeSW_BVH_CompareZ { struct _VolumeSW_BVH { - Rect3 aabb; + AABB aabb; _VolumeSW_BVH *left; _VolumeSW_BVH *right; @@ -1396,7 +1396,7 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz bvh->face_index = -1; } - Rect3 aabb; + AABB aabb; for (int i = 0; i < p_size; i++) { if (i == 0) @@ -1467,7 +1467,7 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { int src_face_count = p_faces.size(); if (src_face_count == 0) { - configure(Rect3()); + configure(AABB()); return; } ERR_FAIL_COND(src_face_count % 3); @@ -1491,7 +1491,7 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { PoolVector<Vector3>::Write vw = vertices.write(); Vector3 *verticesw = vw.ptr(); - Rect3 _aabb; + AABB _aabb; for (int i = 0; i < src_face_count; i++) { @@ -1588,7 +1588,7 @@ Vector3 HeightMapShapeSW::get_closest_point_to(const Vector3 &p_point) const { return Vector3(); } -void HeightMapShapeSW::cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const { +void HeightMapShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const { } Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const { @@ -1611,7 +1611,7 @@ void HeightMapShapeSW::_setup(PoolVector<real_t> p_heights, int p_width, int p_d PoolVector<real_t>::Read r = heights.read(); - Rect3 aabb; + AABB aabb; for (int i = 0; i < depth; i++) { diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h index 151b84c054..48832affc9 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics/shape_sw.h @@ -58,14 +58,14 @@ public: class ShapeSW : public RID_Data { RID self; - Rect3 aabb; + AABB aabb; bool configured; real_t custom_bias; Map<ShapeOwnerSW *, int> owners; protected: - void configure(const Rect3 &p_aabb); + void configure(const AABB &p_aabb); public: enum { @@ -79,7 +79,7 @@ public: virtual PhysicsServer::ShapeType get_type() const = 0; - _FORCE_INLINE_ Rect3 get_aabb() const { return aabb; } + _FORCE_INLINE_ AABB get_aabb() const { return aabb; } _FORCE_INLINE_ bool is_configured() const { return configured; } virtual bool is_concave() const { return false; } @@ -114,7 +114,7 @@ public: typedef void (*Callback)(void *p_userdata, ShapeSW *p_convex); virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; } - virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const = 0; + virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const = 0; ConcaveShapeSW() {} }; @@ -299,7 +299,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { struct BVH { - Rect3 aabb; + AABB aabb; int left; int right; @@ -310,7 +310,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { struct _CullParams { - Rect3 aabb; + AABB aabb; Callback callback; void *userdata; const Face *faces; @@ -353,7 +353,7 @@ public: virtual bool intersect_point(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; - virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const; + virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const; @@ -389,7 +389,7 @@ public: virtual bool intersect_point(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; - virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const; + virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const; @@ -462,7 +462,7 @@ struct MotionShapeSW : public ShapeSW { virtual void set_data(const Variant &p_data) {} virtual Variant get_data() const { return Variant(); } - MotionShapeSW() { configure(Rect3()); } + MotionShapeSW() { configure(AABB()); } }; struct _ShapeTestConvexBSPSW { diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 7fac56f3d7..a6426b7ee0 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -176,7 +176,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, 0); - Rect3 aabb = p_xform.xform(shape->get_aabb()); + AABB aabb = p_xform.xform(shape->get_aabb()); int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); @@ -224,8 +224,8 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, false); - Rect3 aabb = p_xform.xform(shape->get_aabb()); - aabb = aabb.merge(Rect3(aabb.position + p_motion, aabb.size)); //motion + AABB aabb = p_xform.xform(shape->get_aabb()); + aabb = aabb.merge(AABB(aabb.position + p_motion, aabb.size)); //motion aabb = aabb.grow(p_margin); /* @@ -341,7 +341,7 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, 0); - Rect3 aabb = p_shape_xform.xform(shape->get_aabb()); + AABB aabb = p_shape_xform.xform(shape->get_aabb()); aabb = aabb.grow(p_margin); int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); @@ -417,7 +417,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_ ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, 0); - Rect3 aabb = p_shape_xform.xform(shape->get_aabb()); + AABB aabb = p_shape_xform.xform(shape->get_aabb()); aabb = aabb.grow(p_margin); int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); @@ -514,7 +514,7 @@ PhysicsDirectSpaceStateSW::PhysicsDirectSpaceStateSW() { //////////////////////////////////////////////////////////////////////////////////////////////////////////// -int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const Rect3 &p_aabb) { +int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) { int amount = broadphase->cull_aabb(p_aabb, intersection_query_results, INTERSECTION_QUERY_MAX, intersection_query_subindex_results); @@ -561,7 +561,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve r_result->collider_id = 0; r_result->collider_shape = 0; } - Rect3 body_aabb; + AABB body_aabb; for (int i = 0; i < p_body->get_shape_count(); i++) { @@ -648,7 +648,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve { // STEP 2 ATTEMPT MOTION - Rect3 motion_aabb = body_aabb; + AABB motion_aabb = body_aabb; motion_aabb.position += p_motion; motion_aabb = motion_aabb.merge(body_aabb); diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index 270e4ef1bd..fd7e6d16a9 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -122,7 +122,7 @@ private: friend class PhysicsDirectSpaceStateSW; - int _cull_aabb_for_body(BodySW *p_body, const Rect3 &p_aabb); + int _cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb); public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 333fe1e72a..21d059c48e 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -234,7 +234,7 @@ public: virtual RID mesh_create() = 0; - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()) = 0; + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) = 0; virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount) = 0; virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0; @@ -256,17 +256,17 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0; - virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; + virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0; - virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; + virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0; virtual int mesh_get_surface_count(RID p_mesh) const = 0; - virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) = 0; - virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const = 0; + virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0; + virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0; - virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0; + virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0; virtual void mesh_clear(RID p_mesh) = 0; /* MULTIMESH API */ @@ -290,7 +290,7 @@ public: virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0; virtual int multimesh_get_visible_instances(RID p_multimesh) const = 0; - virtual Rect3 multimesh_get_aabb(RID p_multimesh) const = 0; + virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0; /* IMMEDIATE API */ @@ -306,7 +306,7 @@ public: virtual void immediate_clear(RID p_immediate) = 0; virtual void immediate_set_material(RID p_immediate, RID p_material) = 0; virtual RID immediate_get_material(RID p_immediate) const = 0; - virtual Rect3 immediate_get_aabb(RID p_immediate) const = 0; + virtual AABB immediate_get_aabb(RID p_immediate) const = 0; /* SKELETON API */ @@ -350,7 +350,7 @@ public: virtual bool light_has_shadow(RID p_light) const = 0; virtual VS::LightType light_get_type(RID p_light) const = 0; - virtual Rect3 light_get_aabb(RID p_light) const = 0; + virtual AABB light_get_aabb(RID p_light) const = 0; virtual float light_get_param(RID p_light, VS::LightParam p_param) = 0; virtual Color light_get_color(RID p_light) = 0; virtual uint64_t light_get_version(RID p_light) const = 0; @@ -372,7 +372,7 @@ public: virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0; virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0; - virtual Rect3 reflection_probe_get_aabb(RID p_probe) const = 0; + virtual AABB reflection_probe_get_aabb(RID p_probe) const = 0; virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0; virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const = 0; virtual Vector3 reflection_probe_get_extents(RID p_probe) const = 0; @@ -390,8 +390,8 @@ public: virtual RID gi_probe_create() = 0; - virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) = 0; - virtual Rect3 gi_probe_get_bounds(RID p_probe) const = 0; + virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) = 0; + virtual AABB gi_probe_get_bounds(RID p_probe) const = 0; virtual void gi_probe_set_cell_size(RID p_probe, float p_range) = 0; virtual float gi_probe_get_cell_size(RID p_probe) const = 0; @@ -446,7 +446,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0; virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0; virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0; - virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) = 0; + virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0; virtual void particles_set_speed_scale(RID p_particles, float p_scale) = 0; virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0; virtual void particles_set_process_material(RID p_particles, RID p_material) = 0; @@ -460,8 +460,8 @@ public: virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0; virtual void particles_request_process(RID p_particles) = 0; - virtual Rect3 particles_get_current_aabb(RID p_particles) = 0; - virtual Rect3 particles_get_aabb(RID p_particles) const = 0; + virtual AABB particles_get_current_aabb(RID p_particles) = 0; + virtual AABB particles_get_aabb(RID p_particles) const = 0; virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0; @@ -882,7 +882,7 @@ public: case Item::Command::TYPE_MESH: { const Item::CommandMesh *mesh = static_cast<const Item::CommandMesh *>(c); - Rect3 aabb = RasterizerStorage::base_singleton->mesh_get_aabb(mesh->mesh, mesh->skeleton); + AABB aabb = RasterizerStorage::base_singleton->mesh_get_aabb(mesh->mesh, mesh->skeleton); r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); @@ -890,7 +890,7 @@ public: case Item::Command::TYPE_MULTIMESH: { const Item::CommandMultiMesh *multimesh = static_cast<const Item::CommandMultiMesh *>(c); - Rect3 aabb = RasterizerStorage::base_singleton->multimesh_get_aabb(multimesh->multimesh); + AABB aabb = RasterizerStorage::base_singleton->multimesh_get_aabb(multimesh->multimesh); r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); @@ -899,7 +899,7 @@ public: const Item::CommandParticles *particles_cmd = static_cast<const Item::CommandParticles *>(c); if (particles_cmd->particles.is_valid()) { - Rect3 aabb = RasterizerStorage::base_singleton->particles_get_aabb(particles_cmd->particles); + AABB aabb = RasterizerStorage::base_singleton->particles_get_aabb(particles_cmd->particles); r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); } diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 67375e81b6..08a0cfa269 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -77,8 +77,8 @@ class VisualServerRaster : public VisualServer { static void _changes_changed() {} public: -//if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed() -//#define DEBUG_CHANGES + //if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed() + //#define DEBUG_CHANGES #ifdef DEBUG_CHANGES _FORCE_INLINE_ static void redraw_request() { @@ -96,7 +96,7 @@ public: #define DISPLAY_CHANGED \ changes++; #endif -// print_line(String("CHANGED: ") + __FUNCTION__); + // print_line(String("CHANGED: ") + __FUNCTION__); #define BIND0R(m_r, m_name) \ m_r m_name() { return BINDBASE->m_name(); } @@ -203,7 +203,7 @@ public: BIND0R(RID, mesh_create) - BIND10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &) + BIND10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const AABB &, const Vector<PoolVector<uint8_t> > &, const Vector<AABB> &) BIND2(mesh_set_blend_shape_count, RID, int) BIND1RC(int, mesh_get_blend_shape_count, RID) @@ -225,15 +225,15 @@ public: BIND2RC(uint32_t, mesh_surface_get_format, RID, int) BIND2RC(PrimitiveType, mesh_surface_get_primitive_type, RID, int) - BIND2RC(Rect3, mesh_surface_get_aabb, RID, int) + BIND2RC(AABB, mesh_surface_get_aabb, RID, int) BIND2RC(Vector<PoolVector<uint8_t> >, mesh_surface_get_blend_shapes, RID, int) - BIND2RC(Vector<Rect3>, mesh_surface_get_skeleton_aabb, RID, int) + BIND2RC(Vector<AABB>, mesh_surface_get_skeleton_aabb, RID, int) BIND2(mesh_remove_surface, RID, int) BIND1RC(int, mesh_get_surface_count, RID) - BIND2(mesh_set_custom_aabb, RID, const Rect3 &) - BIND1RC(Rect3, mesh_get_custom_aabb, RID) + BIND2(mesh_set_custom_aabb, RID, const AABB &) + BIND1RC(AABB, mesh_get_custom_aabb, RID) BIND1(mesh_clear, RID) @@ -250,7 +250,7 @@ public: BIND3(multimesh_instance_set_color, RID, int, const Color &) BIND1RC(RID, multimesh_get_mesh, RID) - BIND1RC(Rect3, multimesh_get_aabb, RID) + BIND1RC(AABB, multimesh_get_aabb, RID) BIND2RC(Transform, multimesh_instance_get_transform, RID, int) BIND2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int) @@ -327,8 +327,8 @@ public: BIND0R(RID, gi_probe_create) - BIND2(gi_probe_set_bounds, RID, const Rect3 &) - BIND1RC(Rect3, gi_probe_get_bounds, RID) + BIND2(gi_probe_set_bounds, RID, const AABB &) + BIND1RC(AABB, gi_probe_get_bounds, RID) BIND2(gi_probe_set_cell_size, RID, float) BIND1RC(float, gi_probe_get_cell_size, RID) @@ -371,7 +371,7 @@ public: BIND2(particles_set_pre_process_time, RID, float) BIND2(particles_set_explosiveness_ratio, RID, float) BIND2(particles_set_randomness_ratio, RID, float) - BIND2(particles_set_custom_aabb, RID, const Rect3 &) + BIND2(particles_set_custom_aabb, RID, const AABB &) BIND2(particles_set_speed_scale, RID, float) BIND2(particles_set_use_local_coordinates, RID, bool) BIND2(particles_set_process_material, RID, RID) @@ -384,7 +384,7 @@ public: BIND2(particles_set_draw_passes, RID, int) BIND3(particles_set_draw_pass_mesh, RID, int, RID) - BIND1R(Rect3, particles_get_current_aabb, RID) + BIND1R(AABB, particles_get_current_aabb, RID) BIND2(particles_set_emission_transform, RID, const Transform &) #undef BINDBASE @@ -449,7 +449,7 @@ public: BIND2R(int, viewport_get_render_info, RID, ViewportRenderInfo) BIND2(viewport_set_debug_draw, RID, ViewportDebugDraw) -/* ENVIRONMENT API */ + /* ENVIRONMENT API */ #undef BINDBASE //from now on, calls forwarded to this singleton @@ -479,7 +479,7 @@ public: BIND6(environment_set_fog_depth, RID, bool, float, float, bool, float) BIND5(environment_set_fog_height, RID, bool, float, float, float) -/* SCENARIO API */ + /* SCENARIO API */ #undef BINDBASE #define BINDBASE VSG::scene @@ -510,7 +510,7 @@ public: BIND2(instance_set_extra_visibility_margin, RID, real_t) // don't use these in a game! - BIND2RC(Vector<ObjectID>, instances_cull_aabb, const Rect3 &, RID) + BIND2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID) BIND3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID) BIND2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index e49baf0763..3e46705ff8 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -614,7 +614,7 @@ void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) { void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) { } -Vector<ObjectID> VisualServerScene::instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario) const { +Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const { Vector<ObjectID> instances; Scenario *scenario = scenario_owner.get(p_scenario); @@ -772,7 +772,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) { p_instance->mirror = p_instance->transform.basis.determinant() < 0.0; - Rect3 new_aabb; + AABB new_aabb; new_aabb = p_instance->transform.xform(p_instance->aabb); @@ -817,7 +817,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) { void VisualServerScene::_update_instance_aabb(Instance *p_instance) { - Rect3 new_aabb; + AABB new_aabb; ERR_FAIL_COND(p_instance->base_type != VS::INSTANCE_NONE && !p_instance->base.is_valid()); @@ -1279,7 +1279,7 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view camera->zfar, camera->vaspect - ); + ); ortho = true; } break; case Camera::PERSPECTIVE: { @@ -1291,7 +1291,7 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view camera->zfar, camera->vaspect - ); + ); ortho = false; } break; @@ -1863,7 +1863,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { probe->dynamic.enabled = true; Transform cell_to_xform = VSG::storage->gi_probe_get_to_cell_xform(p_instance->base); - Rect3 bounds = VSG::storage->gi_probe_get_bounds(p_instance->base); + AABB bounds = VSG::storage->gi_probe_get_bounds(p_instance->base); float cell_size = VSG::storage->gi_probe_get_cell_size(p_instance->base); probe->dynamic.light_to_cell_xform = cell_to_xform * p_instance->transform.affine_inverse(); diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index d30a2108a5..2738fa058d 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -195,8 +195,8 @@ public: SelfList<Instance> update_item; - Rect3 aabb; - Rect3 transformed_aabb; + AABB aabb; + AABB transformed_aabb; float extra_margin; uint32_t object_ID; @@ -466,7 +466,7 @@ public: virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin); // don't use these in a game! - virtual Vector<ObjectID> instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario = RID()) const; + virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const; virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const; diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 1dddef7bd4..509b77cf9c 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -63,7 +63,7 @@ class VisualServerWrapMT : public VisualServer { int pool_max_size; -//#define DEBUG_SYNC + //#define DEBUG_SYNC #ifdef DEBUG_SYNC #define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__)); @@ -136,7 +136,7 @@ public: FUNCRID(mesh) - FUNC10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &) + FUNC10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const AABB &, const Vector<PoolVector<uint8_t> > &, const Vector<AABB> &) FUNC2(mesh_set_blend_shape_count, RID, int) FUNC1RC(int, mesh_get_blend_shape_count, RID) @@ -158,15 +158,15 @@ public: FUNC2RC(uint32_t, mesh_surface_get_format, RID, int) FUNC2RC(PrimitiveType, mesh_surface_get_primitive_type, RID, int) - FUNC2RC(Rect3, mesh_surface_get_aabb, RID, int) + FUNC2RC(AABB, mesh_surface_get_aabb, RID, int) FUNC2RC(Vector<PoolVector<uint8_t> >, mesh_surface_get_blend_shapes, RID, int) - FUNC2RC(Vector<Rect3>, mesh_surface_get_skeleton_aabb, RID, int) + FUNC2RC(Vector<AABB>, mesh_surface_get_skeleton_aabb, RID, int) FUNC2(mesh_remove_surface, RID, int) FUNC1RC(int, mesh_get_surface_count, RID) - FUNC2(mesh_set_custom_aabb, RID, const Rect3 &) - FUNC1RC(Rect3, mesh_get_custom_aabb, RID) + FUNC2(mesh_set_custom_aabb, RID, const AABB &) + FUNC1RC(AABB, mesh_get_custom_aabb, RID) FUNC1(mesh_clear, RID) @@ -183,7 +183,7 @@ public: FUNC3(multimesh_instance_set_color, RID, int, const Color &) FUNC1RC(RID, multimesh_get_mesh, RID) - FUNC1RC(Rect3, multimesh_get_aabb, RID) + FUNC1RC(AABB, multimesh_get_aabb, RID) FUNC2RC(Transform, multimesh_instance_get_transform, RID, int) FUNC2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int) @@ -260,8 +260,8 @@ public: FUNCRID(gi_probe) - FUNC2(gi_probe_set_bounds, RID, const Rect3 &) - FUNC1RC(Rect3, gi_probe_get_bounds, RID) + FUNC2(gi_probe_set_bounds, RID, const AABB &) + FUNC1RC(AABB, gi_probe_get_bounds, RID) FUNC2(gi_probe_set_cell_size, RID, float) FUNC1RC(float, gi_probe_get_cell_size, RID) @@ -304,7 +304,7 @@ public: FUNC2(particles_set_pre_process_time, RID, float) FUNC2(particles_set_explosiveness_ratio, RID, float) FUNC2(particles_set_randomness_ratio, RID, float) - FUNC2(particles_set_custom_aabb, RID, const Rect3 &) + FUNC2(particles_set_custom_aabb, RID, const AABB &) FUNC2(particles_set_speed_scale, RID, float) FUNC2(particles_set_use_local_coordinates, RID, bool) FUNC2(particles_set_process_material, RID, RID) @@ -318,7 +318,7 @@ public: FUNC3(particles_set_draw_pass_mesh, RID, int, RID) FUNC2(particles_set_emission_transform, RID, const Transform &) - FUNC1R(Rect3, particles_get_current_aabb, RID) + FUNC1R(AABB, particles_get_current_aabb, RID) /* CAMERA API */ @@ -431,7 +431,7 @@ public: FUNC2(instance_set_extra_visibility_margin, RID, real_t) // don't use these in a game! - FUNC2RC(Vector<ObjectID>, instances_cull_aabb, const Rect3 &, RID) + FUNC2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID) FUNC3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID) FUNC2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 039bbedbcc..10f350d667 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -308,7 +308,7 @@ RID VisualServer::get_white_texture() { #define SMALL_VEC2 Vector2(0.00001, 0.00001) #define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001) -Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb) { +Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> r_bone_aabb) { PoolVector<uint8_t>::Write vw = r_vertex_array.write(); @@ -373,7 +373,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } - r_aabb = Rect3(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0)); + r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0)); } else { PoolVector<Vector3> array = p_arrays[ai]; @@ -383,7 +383,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ const Vector3 *src = read.ptr(); // setting vertices means regenerating the AABB - Rect3 aabb; + AABB aabb; if (p_format & ARRAY_COMPRESS_VERTEX) { @@ -395,7 +395,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect3(src[i], SMALL_VEC3); + aabb = AABB(src[i], SMALL_VEC3); } else { aabb.expand_to(src[i]); @@ -411,7 +411,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect3(src[i], SMALL_VEC3); + aabb = AABB(src[i], SMALL_VEC3); } else { aabb.expand_to(src[i]); @@ -728,7 +728,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ PoolVector<int>::Read rb = bones.read(); PoolVector<float>::Read rw = weights.read(); - Rect3 *bptr = r_bone_aabb.ptr(); + AABB *bptr = r_bone_aabb.ptr(); for (int i = 0; i < vs; i++) { @@ -743,7 +743,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (bptr->size.x < 0) { //first - bptr[idx] = Rect3(v, SMALL_VEC3); + bptr[idx] = AABB(v, SMALL_VEC3); any_valid = true; } else { bptr[idx].expand_to(v); @@ -975,8 +975,8 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim PoolVector<uint8_t> index_array; index_array.resize(index_array_size); - Rect3 aabb; - Vector<Rect3> bone_aabb; + AABB aabb; + Vector<AABB> bone_aabb; Error err = _surface_set_data(p_arrays, format, offsets, total_elem_size, vertex_array, array_len, index_array, index_array_len, aabb, bone_aabb); @@ -993,7 +993,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim vertex_array_shape.resize(array_size); PoolVector<uint8_t> noindex; - Rect3 laabb; + AABB laabb; Error err = _surface_set_data(p_blend_shapes[i], format & ~ARRAY_FORMAT_INDEX, offsets, total_elem_size, vertex_array_shape, array_len, noindex, 0, laabb, bone_aabb); aabb.merge_with(laabb); if (err) { @@ -1470,7 +1470,7 @@ Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surfac Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const { - Vector<Rect3> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface); + Vector<AABB> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface); Array arr; for (int i = 0; i < vec.size(); i++) { arr[i] = vec[i]; diff --git a/servers/visual_server.h b/servers/visual_server.h index a36ba4a50a..4e43d0bd17 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -60,7 +60,7 @@ protected: RID white_texture; RID test_material; - Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb); + Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> r_bone_aabb); static VisualServer *(*create_func)(); static void _bind_methods(); @@ -247,7 +247,7 @@ public: virtual RID mesh_create() = 0; virtual void mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_compress_format = ARRAY_COMPRESS_DEFAULT); - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()) = 0; + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) = 0; virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount) = 0; virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0; @@ -277,16 +277,16 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0; virtual PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0; - virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; + virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0; - virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; + virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; Array _mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const; virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0; virtual int mesh_get_surface_count(RID p_mesh) const = 0; - virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) = 0; - virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const = 0; + virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0; + virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0; virtual void mesh_clear(RID p_mesh) = 0; @@ -314,7 +314,7 @@ public: virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0; virtual RID multimesh_get_mesh(RID p_multimesh) const = 0; - virtual Rect3 multimesh_get_aabb(RID p_multimesh) const = 0; + virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0; virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0; virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0; @@ -449,8 +449,8 @@ public: virtual RID gi_probe_create() = 0; - virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) = 0; - virtual Rect3 gi_probe_get_bounds(RID p_probe) const = 0; + virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) = 0; + virtual AABB gi_probe_get_bounds(RID p_probe) const = 0; virtual void gi_probe_set_cell_size(RID p_probe, float p_range) = 0; virtual float gi_probe_get_cell_size(RID p_probe) const = 0; @@ -493,7 +493,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0; virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0; virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0; - virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) = 0; + virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0; virtual void particles_set_speed_scale(RID p_particles, float p_scale) = 0; virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0; virtual void particles_set_process_material(RID p_particles, RID p_material) = 0; @@ -512,7 +512,7 @@ public: virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0; virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0; - virtual Rect3 particles_get_current_aabb(RID p_particles) = 0; + virtual AABB particles_get_current_aabb(RID p_particles) = 0; virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0; //this is only used for 2D, in 3D it's automatic @@ -758,7 +758,7 @@ public: virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) = 0; // don't use these in a game! - virtual Vector<ObjectID> instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario = RID()) const = 0; + virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const = 0; virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0; |