diff options
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/bvh_split.inc | 4 | ||||
-rw-r--r-- | core/math/bvh_structs.inc | 4 | ||||
-rw-r--r-- | core/math/bvh_tree.h | 2 | ||||
-rw-r--r-- | core/math/convex_hull.h | 6 | ||||
-rw-r--r-- | core/math/math_fieldwise.cpp | 47 | ||||
-rw-r--r-- | core/math/vector2i.h | 2 | ||||
-rw-r--r-- | core/math/vector3i.h | 2 | ||||
-rw-r--r-- | core/math/vector4.h | 2 | ||||
-rw-r--r-- | core/math/vector4i.h | 2 |
9 files changed, 64 insertions, 7 deletions
diff --git a/core/math/bvh_split.inc b/core/math/bvh_split.inc index ff07166d4a..180bbfb511 100644 --- a/core/math/bvh_split.inc +++ b/core/math/bvh_split.inc @@ -13,7 +13,7 @@ void _split_inform_references(uint32_t p_node_id) { void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, uint16_t *group_b, const BVHABB_CLASS *temp_bounds, const BVHABB_CLASS full_bound) { // special case for low leaf sizes .. should static compile out - if (MAX_ITEMS < 4) { + if constexpr (MAX_ITEMS < 4) { uint32_t ind = group_a[0]; // add to b @@ -34,7 +34,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u order[POINT::AXIS_COUNT - 1] = size.max_axis_index(); static_assert(POINT::AXIS_COUNT <= 3, "BVH POINT::AXIS_COUNT has unexpected size"); - if (POINT::AXIS_COUNT == 3) { + if constexpr (POINT::AXIS_COUNT == 3) { order[1] = 3 - (order[0] + order[2]); } diff --git a/core/math/bvh_structs.inc b/core/math/bvh_structs.inc index 58c8f0479a..06f6e5d05d 100644 --- a/core/math/bvh_structs.inc +++ b/core/math/bvh_structs.inc @@ -100,7 +100,11 @@ public: num_items++; return id; } +#ifdef DEV_ENABLED return -1; +#else + ERR_FAIL_V_MSG(0, "BVH request_item error."); +#endif } }; diff --git a/core/math/bvh_tree.h b/core/math/bvh_tree.h index cdb2bb4413..8291394b31 100644 --- a/core/math/bvh_tree.h +++ b/core/math/bvh_tree.h @@ -235,7 +235,7 @@ private: // no need to keep back references for children at the moment - uint32_t sibling_id; // always a node id, as tnode is never a leaf + uint32_t sibling_id = 0; // always a node id, as tnode is never a leaf bool sibling_present = false; // if there are more children, or this is the root node, don't try and delete diff --git a/core/math/convex_hull.h b/core/math/convex_hull.h index bd86fe0eba..cc41a794bd 100644 --- a/core/math/convex_hull.h +++ b/core/math/convex_hull.h @@ -28,6 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#ifndef CONVEX_HULL_H +#define CONVEX_HULL_H + /* Copyright (c) 2011 Ole Kniemeyer, MAXON, www.maxon.net This software is provided 'as-is', without any express or implied warranty. @@ -40,9 +43,6 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef CONVEX_HULL_H -#define CONVEX_HULL_H - #include "core/math/geometry_3d.h" #include "core/math/vector3.h" #include "core/templates/local_vector.h" diff --git a/core/math/math_fieldwise.cpp b/core/math/math_fieldwise.cpp index 208f89f449..726a2aeb97 100644 --- a/core/math/math_fieldwise.cpp +++ b/core/math/math_fieldwise.cpp @@ -56,6 +56,15 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } + case Variant::VECTOR2I: { + SETUP_TYPE(Vector2i) + + /**/ TRY_TRANSFER_FIELD("x", x) + else TRY_TRANSFER_FIELD("y", y) + + return target; + } + case Variant::RECT2: { SETUP_TYPE(Rect2) @@ -67,6 +76,17 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } + case Variant::RECT2I: { + SETUP_TYPE(Rect2i) + + /**/ TRY_TRANSFER_FIELD("x", position.x) + else TRY_TRANSFER_FIELD("y", position.y) + else TRY_TRANSFER_FIELD("w", size.x) + else TRY_TRANSFER_FIELD("h", size.y) + + return target; + } + case Variant::VECTOR3: { SETUP_TYPE(Vector3) @@ -76,6 +96,7 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } + case Variant::VECTOR3I: { SETUP_TYPE(Vector3i) @@ -85,6 +106,7 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } + case Variant::VECTOR4: { SETUP_TYPE(Vector4) @@ -95,6 +117,7 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } + case Variant::VECTOR4I: { SETUP_TYPE(Vector4i) @@ -106,7 +129,6 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } - case Variant::PLANE: { SETUP_TYPE(Plane) @@ -190,6 +212,29 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } + case Variant::PROJECTION: { + SETUP_TYPE(Projection) + + /**/ TRY_TRANSFER_FIELD("xx", matrix[0].x) + else TRY_TRANSFER_FIELD("xy", matrix[0].y) + else TRY_TRANSFER_FIELD("xz", matrix[0].z) + else TRY_TRANSFER_FIELD("xw", matrix[0].w) + else TRY_TRANSFER_FIELD("yx", matrix[1].x) + else TRY_TRANSFER_FIELD("yy", matrix[1].y) + else TRY_TRANSFER_FIELD("yz", matrix[1].z) + else TRY_TRANSFER_FIELD("yw", matrix[1].w) + else TRY_TRANSFER_FIELD("zx", matrix[2].x) + else TRY_TRANSFER_FIELD("zy", matrix[2].y) + else TRY_TRANSFER_FIELD("zz", matrix[2].z) + else TRY_TRANSFER_FIELD("zw", matrix[2].w) + else TRY_TRANSFER_FIELD("xo", matrix[3].x) + else TRY_TRANSFER_FIELD("yo", matrix[3].y) + else TRY_TRANSFER_FIELD("zo", matrix[3].z) + else TRY_TRANSFER_FIELD("wo", matrix[3].w) + + return target; + } + default: { ERR_FAIL_V(p_target); } diff --git a/core/math/vector2i.h b/core/math/vector2i.h index 0245900a3b..e131bdea94 100644 --- a/core/math/vector2i.h +++ b/core/math/vector2i.h @@ -38,6 +38,8 @@ class String; struct Vector2; struct _NO_DISCARD_ Vector2i { + static const int AXIS_COUNT = 2; + enum Axis { AXIS_X, AXIS_Y, diff --git a/core/math/vector3i.h b/core/math/vector3i.h index 5a62ff044b..710fd96376 100644 --- a/core/math/vector3i.h +++ b/core/math/vector3i.h @@ -38,6 +38,8 @@ class String; struct Vector3; struct _NO_DISCARD_ Vector3i { + static const int AXIS_COUNT = 3; + enum Axis { AXIS_X, AXIS_Y, diff --git a/core/math/vector4.h b/core/math/vector4.h index b3ddff3f22..426c473e13 100644 --- a/core/math/vector4.h +++ b/core/math/vector4.h @@ -37,6 +37,8 @@ #include "core/string/ustring.h" struct _NO_DISCARD_ Vector4 { + static const int AXIS_COUNT = 4; + enum Axis { AXIS_X, AXIS_Y, diff --git a/core/math/vector4i.h b/core/math/vector4i.h index 86ac8fd581..a32414bb18 100644 --- a/core/math/vector4i.h +++ b/core/math/vector4i.h @@ -38,6 +38,8 @@ class String; struct Vector4; struct _NO_DISCARD_ Vector4i { + static const int AXIS_COUNT = 4; + enum Axis { AXIS_X, AXIS_Y, |