From e5766752d04794c2693dedad75baeb8c7d68f4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 12 Jan 2022 12:43:40 +0100 Subject: Revert "BLI: Refactor vector types & functions to use templates" Reverted because the commit removes a lot of commits. This reverts commit a2c1c368af48644fa8995ecbe7138cc0d7900c30. --- source/blender/nodes/NOD_math_functions.hh | 75 +++++++++++++--------- source/blender/nodes/NOD_socket_declarations.hh | 2 +- .../blender/nodes/composite/node_composite_tree.cc | 17 ----- .../nodes/composite/nodes/node_composite_image.cc | 28 ++++---- .../blender/nodes/function/node_function_util.hh | 2 +- .../nodes/node_fn_align_euler_to_vector.cc | 8 +-- .../nodes/function/nodes/node_fn_compare.cc | 24 +++---- .../blender/nodes/geometry/node_geometry_util.hh | 4 +- .../node_geo_legacy_align_rotation_to_vector.cc | 8 +-- .../legacy/node_geo_legacy_attribute_proximity.cc | 2 +- .../legacy/node_geo_legacy_attribute_transfer.cc | 2 +- .../legacy/node_geo_legacy_curve_to_points.cc | 4 +- .../legacy/node_geo_legacy_point_distribute.cc | 4 +- .../legacy/node_geo_legacy_points_to_volume.cc | 2 +- .../nodes/legacy/node_geo_legacy_raycast.cc | 2 +- .../nodes/geometry/nodes/node_geo_curve_fill.cc | 2 +- .../nodes/geometry/nodes/node_geo_curve_fillet.cc | 21 +++--- .../nodes/node_geo_curve_primitive_circle.cc | 18 +++--- .../nodes/node_geo_curve_primitive_line.cc | 2 +- .../node_geo_curve_primitive_quadratic_bezier.cc | 6 +- .../nodes/geometry/nodes/node_geo_curve_sample.cc | 4 +- .../nodes/node_geo_curve_spline_parameter.cc | 2 +- .../geometry/nodes/node_geo_curve_to_points.cc | 4 +- .../nodes/geometry/nodes/node_geo_image_texture.cc | 2 +- .../geometry/nodes/node_geo_mesh_primitive_cube.cc | 6 +- .../geometry/nodes/node_geo_mesh_primitive_line.cc | 6 +- .../nodes/node_geo_mesh_primitive_uv_sphere.cc | 2 +- .../geometry/nodes/node_geo_points_to_volume.cc | 2 +- .../nodes/geometry/nodes/node_geo_proximity.cc | 2 +- .../nodes/geometry/nodes/node_geo_raycast.cc | 2 +- .../geometry/nodes/node_geo_set_curve_handles.cc | 2 +- .../geometry/nodes/node_geo_transfer_attribute.cc | 2 +- .../nodes/geometry/nodes/node_geo_transform.cc | 4 +- source/blender/nodes/intern/node_socket.cc | 2 +- source/blender/nodes/shader/node_shader_util.hh | 2 +- .../nodes/shader/nodes/node_shader_map_range.cc | 10 +-- .../nodes/shader/nodes/node_shader_tex_brick.cc | 3 +- .../nodes/shader/nodes/node_shader_tex_gradient.cc | 4 +- .../nodes/shader/nodes/node_shader_tex_noise.cc | 4 +- .../nodes/shader/nodes/node_shader_tex_voronoi.cc | 36 +++++------ 40 files changed, 164 insertions(+), 170 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/NOD_math_functions.hh b/source/blender/nodes/NOD_math_functions.hh index 6ea89beee2e..a0a2e6f81f8 100644 --- a/source/blender/nodes/NOD_math_functions.hh +++ b/source/blender/nodes/NOD_math_functions.hh @@ -18,9 +18,9 @@ #include "DNA_node_types.h" +#include "BLI_float3.hh" #include "BLI_math_base_safe.h" #include "BLI_math_rotation.h" -#include "BLI_math_vec_types.hh" #include "BLI_string_ref.hh" namespace blender::nodes { @@ -240,8 +240,6 @@ template inline bool try_dispatch_float_math_fl3_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback) { - using namespace blender::math; - const FloatMathOperationInfo *info = get_float3_math_operation_info(operation); if (info == nullptr) { return false; @@ -261,21 +259,40 @@ inline bool try_dispatch_float_math_fl3_fl3_to_fl3(const NodeVectorMathOperation case NODE_VECTOR_MATH_MULTIPLY: return dispatch([](float3 a, float3 b) { return a * b; }); case NODE_VECTOR_MATH_DIVIDE: - return dispatch([](float3 a, float3 b) { return safe_divide(a, b); }); + return dispatch([](float3 a, float3 b) { + return float3(safe_divide(a.x, b.x), safe_divide(a.y, b.y), safe_divide(a.z, b.z)); + }); case NODE_VECTOR_MATH_CROSS_PRODUCT: - return dispatch([](float3 a, float3 b) { return cross_high_precision(a, b); }); + return dispatch([](float3 a, float3 b) { return float3::cross_high_precision(a, b); }); case NODE_VECTOR_MATH_PROJECT: - return dispatch([](float3 a, float3 b) { return project(a, b); }); + return dispatch([](float3 a, float3 b) { + float length_squared = b.length_squared(); + return (length_squared != 0.0) ? (float3::dot(a, b) / length_squared) * b : float3(0.0f); + }); case NODE_VECTOR_MATH_REFLECT: - return dispatch([](float3 a, float3 b) { return reflect(a, normalize(b)); }); + return dispatch([](float3 a, float3 b) { + b.normalize(); + return a.reflected(b); + }); case NODE_VECTOR_MATH_SNAP: - return dispatch([](float3 a, float3 b) { return floor(safe_divide(a, b)) * b; }); + return dispatch([](float3 a, float3 b) { + return float3(floor(safe_divide(a.x, b.x)), + floor(safe_divide(a.y, b.y)), + floor(safe_divide(a.z, b.z))) * + b; + }); case NODE_VECTOR_MATH_MODULO: - return dispatch([](float3 a, float3 b) { return mod(a, b); }); + return dispatch([](float3 a, float3 b) { + return float3(safe_modf(a.x, b.x), safe_modf(a.y, b.y), safe_modf(a.z, b.z)); + }); case NODE_VECTOR_MATH_MINIMUM: - return dispatch([](float3 a, float3 b) { return min(a, b); }); + return dispatch([](float3 a, float3 b) { + return float3(min_ff(a.x, b.x), min_ff(a.y, b.y), min_ff(a.z, b.z)); + }); case NODE_VECTOR_MATH_MAXIMUM: - return dispatch([](float3 a, float3 b) { return max(a, b); }); + return dispatch([](float3 a, float3 b) { + return float3(max_ff(a.x, b.x), max_ff(a.y, b.y), max_ff(a.z, b.z)); + }); default: return false; } @@ -289,8 +306,6 @@ template inline bool try_dispatch_float_math_fl3_fl3_to_fl(const NodeVectorMathOperation operation, Callback &&callback) { - using namespace blender::math; - const FloatMathOperationInfo *info = get_float3_math_operation_info(operation); if (info == nullptr) { return false; @@ -304,9 +319,9 @@ inline bool try_dispatch_float_math_fl3_fl3_to_fl(const NodeVectorMathOperation switch (operation) { case NODE_VECTOR_MATH_DOT_PRODUCT: - return dispatch([](float3 a, float3 b) { return dot(a, b); }); + return dispatch([](float3 a, float3 b) { return float3::dot(a, b); }); case NODE_VECTOR_MATH_DISTANCE: - return dispatch([](float3 a, float3 b) { return distance(a, b); }); + return dispatch([](float3 a, float3 b) { return float3::distance(a, b); }); default: return false; } @@ -320,8 +335,6 @@ template inline bool try_dispatch_float_math_fl3_fl3_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback) { - using namespace blender::math; - const FloatMathOperationInfo *info = get_float3_math_operation_info(operation); if (info == nullptr) { return false; @@ -341,7 +354,7 @@ inline bool try_dispatch_float_math_fl3_fl3_fl3_to_fl3(const NodeVectorMathOpera return float3(wrapf(a.x, b.x, c.x), wrapf(a.y, b.y, c.y), wrapf(a.z, b.z, c.z)); }); case NODE_VECTOR_MATH_FACEFORWARD: - return dispatch([](float3 a, float3 b, float3 c) { return faceforward(a, b, c); }); + return dispatch([](float3 a, float3 b, float3 c) { return float3::faceforward(a, b, c); }); default: return false; } @@ -355,8 +368,6 @@ template inline bool try_dispatch_float_math_fl3_fl3_fl_to_fl3(const NodeVectorMathOperation operation, Callback &&callback) { - using namespace blender::math; - const FloatMathOperationInfo *info = get_float3_math_operation_info(operation); if (info == nullptr) { return false; @@ -370,7 +381,8 @@ inline bool try_dispatch_float_math_fl3_fl3_fl_to_fl3(const NodeVectorMathOperat switch (operation) { case NODE_VECTOR_MATH_REFRACT: - return dispatch([](float3 a, float3 b, float c) { return refract(a, normalize(b), c); }); + return dispatch( + [](float3 a, float3 b, float c) { return float3::refract(a, b.normalized(), c); }); default: return false; } @@ -384,8 +396,6 @@ template inline bool try_dispatch_float_math_fl3_to_fl(const NodeVectorMathOperation operation, Callback &&callback) { - using namespace blender::math; - const FloatMathOperationInfo *info = get_float3_math_operation_info(operation); if (info == nullptr) { return false; @@ -399,7 +409,7 @@ inline bool try_dispatch_float_math_fl3_to_fl(const NodeVectorMathOperation oper switch (operation) { case NODE_VECTOR_MATH_LENGTH: - return dispatch([](float3 in) { return length(in); }); + return dispatch([](float3 in) { return in.length(); }); default: return false; } @@ -440,8 +450,6 @@ template inline bool try_dispatch_float_math_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback) { - using namespace blender::math; - const FloatMathOperationInfo *info = get_float3_math_operation_info(operation); if (info == nullptr) { return false; @@ -455,15 +463,20 @@ inline bool try_dispatch_float_math_fl3_to_fl3(const NodeVectorMathOperation ope switch (operation) { case NODE_VECTOR_MATH_NORMALIZE: - return dispatch([](float3 in) { return normalize(in); }); /* Should be safe. */ + return dispatch([](float3 in) { + float3 out = in; + out.normalize(); + return out; + }); /* Should be safe. */ case NODE_VECTOR_MATH_FLOOR: - return dispatch([](float3 in) { return floor(in); }); + return dispatch([](float3 in) { return float3(floor(in.x), floor(in.y), floor(in.z)); }); case NODE_VECTOR_MATH_CEIL: - return dispatch([](float3 in) { return ceil(in); }); + return dispatch([](float3 in) { return float3(ceil(in.x), ceil(in.y), ceil(in.z)); }); case NODE_VECTOR_MATH_FRACTION: - return dispatch([](float3 in) { return fract(in); }); + return dispatch( + [](float3 in) { return in - float3(floor(in.x), floor(in.y), floor(in.z)); }); case NODE_VECTOR_MATH_ABSOLUTE: - return dispatch([](float3 in) { return abs(in); }); + return dispatch([](float3 in) { return float3::abs(in); }); case NODE_VECTOR_MATH_SINE: return dispatch([](float3 in) { return float3(sinf(in.x), sinf(in.y), sinf(in.z)); }); case NODE_VECTOR_MATH_COSINE: diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh index a1972c66ca2..c0580a2c919 100644 --- a/source/blender/nodes/NOD_socket_declarations.hh +++ b/source/blender/nodes/NOD_socket_declarations.hh @@ -21,7 +21,7 @@ #include "RNA_types.h" #include "BLI_color.hh" -#include "BLI_math_vec_types.hh" +#include "BLI_float3.hh" namespace blender::nodes::decl { diff --git a/source/blender/nodes/composite/node_composite_tree.cc b/source/blender/nodes/composite/node_composite_tree.cc index 08dbd4ad6f0..c54382cc1ad 100644 --- a/source/blender/nodes/composite/node_composite_tree.cc +++ b/source/blender/nodes/composite/node_composite_tree.cc @@ -249,23 +249,6 @@ void ntreeCompositUpdateRLayers(bNodeTree *ntree) } } -void ntreeCompositRegisterPass(bNodeTree *ntree, - Scene *scene, - ViewLayer *view_layer, - const char *name, - eNodeSocketDatatype type) -{ - if (ntree == nullptr) { - return; - } - - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - if (node->type == CMP_NODE_R_LAYERS) { - node_cmp_rlayers_register_pass(ntree, node, scene, view_layer, name, type); - } - } -} - void ntreeCompositTagRender(Scene *scene) { /* XXX Think using G_MAIN here is valid, since you want to update current file's scene nodes, diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc index 6f4f9d7e597..f2b9fbc2215 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.cc +++ b/source/blender/nodes/composite/nodes/node_composite_image.cc @@ -269,7 +269,12 @@ void node_cmp_rlayers_register_pass(bNodeTree *ntree, } } -static void cmp_node_rlayer_create_outputs_cb(void *UNUSED(userdata), +struct CreateOutputUserData { + bNodeTree &ntree; + bNode &node; +}; + +static void cmp_node_rlayer_create_outputs_cb(void *userdata, Scene *scene, ViewLayer *view_layer, const char *name, @@ -277,18 +282,8 @@ static void cmp_node_rlayer_create_outputs_cb(void *UNUSED(userdata), const char *UNUSED(chanid), eNodeSocketDatatype type) { - /* Register the pass in all scenes that have a render layer node for this layer. - * Since multiple scenes can be used in the compositor, the code must loop over all scenes - * and check whether their nodetree has a node that needs to be updated. */ - /* NOTE: using G_MAIN seems valid here, - * unless we want to register that for every other temp Main we could generate??? */ - ntreeCompositRegisterPass(scene->nodetree, scene, view_layer, name, type); - - for (Scene *sce = (Scene *)G_MAIN->scenes.first; sce; sce = (Scene *)sce->id.next) { - if (sce->nodetree && sce != scene) { - ntreeCompositRegisterPass(sce->nodetree, scene, view_layer, name, type); - } - } + CreateOutputUserData &data = *(CreateOutputUserData *)userdata; + node_cmp_rlayers_register_pass(&data.ntree, &data.node, scene, view_layer, name, type); } static void cmp_node_rlayer_create_outputs(bNodeTree *ntree, @@ -308,14 +303,17 @@ static void cmp_node_rlayer_create_outputs(bNodeTree *ntree, data->prev_index = -1; node->storage = data; + CreateOutputUserData userdata = {*ntree, *node}; + RenderEngine *engine = RE_engine_create(engine_type); RE_engine_update_render_passes( - engine, scene, view_layer, cmp_node_rlayer_create_outputs_cb, nullptr); + engine, scene, view_layer, cmp_node_rlayer_create_outputs_cb, &userdata); RE_engine_free(engine); if ((scene->r.mode & R_EDGE_FRS) && (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS)) { - ntreeCompositRegisterPass(ntree, scene, view_layer, RE_PASSNAME_FREESTYLE, SOCK_RGBA); + node_cmp_rlayers_register_pass( + ntree, node, scene, view_layer, RE_PASSNAME_FREESTYLE, SOCK_RGBA); } MEM_freeN(data); diff --git a/source/blender/nodes/function/node_function_util.hh b/source/blender/nodes/function/node_function_util.hh index 69c617b4f01..acde9c4b55b 100644 --- a/source/blender/nodes/function/node_function_util.hh +++ b/source/blender/nodes/function/node_function_util.hh @@ -18,7 +18,7 @@ #include -#include "BLI_math_vec_types.hh" +#include "BLI_float3.hh" #include "BLI_utildefines.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc b/source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc index bcc035e6ede..f4ce8d2f35a 100644 --- a/source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc +++ b/source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc @@ -69,14 +69,14 @@ static void align_rotations_auto_pivot(IndexMask mask, float3 old_axis; mul_v3_m3v3(old_axis, old_rotation, local_main_axis); - const float3 new_axis = math::normalize(vector); - float3 rotation_axis = math::cross_high_precision(old_axis, new_axis); + const float3 new_axis = vector.normalized(); + float3 rotation_axis = float3::cross_high_precision(old_axis, new_axis); if (is_zero_v3(rotation_axis)) { /* The vectors are linearly dependent, so we fall back to another axis. */ - rotation_axis = math::cross_high_precision(old_axis, float3(1, 0, 0)); + rotation_axis = float3::cross_high_precision(old_axis, float3(1, 0, 0)); if (is_zero_v3(rotation_axis)) { /* This is now guaranteed to not be zero. */ - rotation_axis = math::cross_high_precision(old_axis, float3(0, 1, 0)); + rotation_axis = float3::cross_high_precision(old_axis, float3(0, 1, 0)); } } diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc index 7c09bace756..3bb46511eeb 100644 --- a/source/blender/nodes/function/nodes/node_fn_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_compare.cc @@ -265,7 +265,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_DOT_PRODUCT: { static fn::CustomMF_SI_SI_SI_SO fn{ "Less Than - Dot Product", - [](float3 a, float3 b, float comp) { return math::dot(a, b) < comp; }}; + [](float3 a, float3 b, float comp) { return float3::dot(a, b) < comp; }}; return &fn; } case NODE_COMPARE_MODE_DIRECTION: { @@ -283,7 +283,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_LENGTH: { static fn::CustomMF_SI_SI_SO fn{ "Less Than - Length", - [](float3 a, float3 b) { return math::length(a) < math::length(b); }}; + [](float3 a, float3 b) { return a.length() < b.length(); }}; return &fn; } } @@ -299,7 +299,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_DOT_PRODUCT: { static fn::CustomMF_SI_SI_SI_SO fn{ "Less Equal - Dot Product", - [](float3 a, float3 b, float comp) { return math::dot(a, b) <= comp; }}; + [](float3 a, float3 b, float comp) { return float3::dot(a, b) <= comp; }}; return &fn; } case NODE_COMPARE_MODE_DIRECTION: { @@ -317,7 +317,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_LENGTH: { static fn::CustomMF_SI_SI_SO fn{ "Less Equal - Length", - [](float3 a, float3 b) { return math::length(a) <= math::length(b); }}; + [](float3 a, float3 b) { return a.length() <= b.length(); }}; return &fn; } } @@ -333,7 +333,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_DOT_PRODUCT: { static fn::CustomMF_SI_SI_SI_SO fn{ "Greater Than - Dot Product", - [](float3 a, float3 b, float comp) { return math::dot(a, b) > comp; }}; + [](float3 a, float3 b, float comp) { return float3::dot(a, b) > comp; }}; return &fn; } case NODE_COMPARE_MODE_DIRECTION: { @@ -351,7 +351,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_LENGTH: { static fn::CustomMF_SI_SI_SO fn{ "Greater Than - Length", - [](float3 a, float3 b) { return math::length(a) > math::length(b); }}; + [](float3 a, float3 b) { return a.length() > b.length(); }}; return &fn; } } @@ -367,7 +367,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_DOT_PRODUCT: { static fn::CustomMF_SI_SI_SI_SO fn{ "Greater Equal - Dot Product", - [](float3 a, float3 b, float comp) { return math::dot(a, b) >= comp; }}; + [](float3 a, float3 b, float comp) { return float3::dot(a, b) >= comp; }}; return &fn; } case NODE_COMPARE_MODE_DIRECTION: { @@ -385,7 +385,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_LENGTH: { static fn::CustomMF_SI_SI_SO fn{ "Greater Equal - Length", - [](float3 a, float3 b) { return math::length(a) >= math::length(b); }}; + [](float3 a, float3 b) { return a.length() >= b.length(); }}; return &fn; } } @@ -402,7 +402,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_DOT_PRODUCT: { static fn::CustomMF_SI_SI_SI_SI_SO fn{ "Equal - Dot Product", [](float3 a, float3 b, float comp, float epsilon) { - return abs(math::dot(a, b) - comp) <= epsilon; + return abs(float3::dot(a, b) - comp) <= epsilon; }}; return &fn; } @@ -424,7 +424,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_LENGTH: { static fn::CustomMF_SI_SI_SI_SO fn{ "Equal - Length", [](float3 a, float3 b, float epsilon) { - return abs(math::length(a) - math::length(b)) <= epsilon; + return abs(a.length() - b.length()) <= epsilon; }}; return &fn; } @@ -442,7 +442,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_DOT_PRODUCT: { static fn::CustomMF_SI_SI_SI_SI_SO fn{ "Not Equal - Dot Product", [](float3 a, float3 b, float comp, float epsilon) { - return abs(math::dot(a, b) - comp) >= epsilon; + return abs(float3::dot(a, b) - comp) >= epsilon; }}; return &fn; } @@ -464,7 +464,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_COMPARE_MODE_LENGTH: { static fn::CustomMF_SI_SI_SI_SO fn{ "Not Equal - Length", [](float3 a, float3 b, float epsilon) { - return abs(math::length(a) - math::length(b)) > epsilon; + return abs(a.length() - b.length()) > epsilon; }}; return &fn; } diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh index e063be62987..1c2a8f521c0 100644 --- a/source/blender/nodes/geometry/node_geometry_util.hh +++ b/source/blender/nodes/geometry/node_geometry_util.hh @@ -18,7 +18,7 @@ #include -#include "BLI_math_vec_types.hh" +#include "BLI_float3.hh" #include "BLI_utildefines.h" #include "MEM_guardedalloc.h" @@ -83,7 +83,7 @@ Mesh *create_cylinder_or_cone_mesh(float radius_top, int circle_segments, int side_segments, int fill_segments, - const GeometryNodeMeshCircleFillType fill_type, + GeometryNodeMeshCircleFillType fill_type, ConeAttributeOutputs &attribute_outputs); Mesh *create_cuboid_mesh(float3 size, int verts_x, int verts_y, int verts_z); diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc index 1d064586238..36ad4605a4b 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc @@ -90,14 +90,14 @@ static void align_rotations_auto_pivot(const VArray &vectors, float3 old_axis; mul_v3_m3v3(old_axis, old_rotation, local_main_axis); - const float3 new_axis = math::normalize(vector); - float3 rotation_axis = math::cross_high_precision(old_axis, new_axis); + const float3 new_axis = vector.normalized(); + float3 rotation_axis = float3::cross_high_precision(old_axis, new_axis); if (is_zero_v3(rotation_axis)) { /* The vectors are linearly dependent, so we fall back to another axis. */ - rotation_axis = math::cross_high_precision(old_axis, float3(1, 0, 0)); + rotation_axis = float3::cross_high_precision(old_axis, float3(1, 0, 0)); if (is_zero_v3(rotation_axis)) { /* This is now guaranteed to not be zero. */ - rotation_axis = math::cross_high_precision(old_axis, float3(0, 1, 0)); + rotation_axis = float3::cross_high_precision(old_axis, float3(0, 1, 0)); } } diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_proximity.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_proximity.cc index 20f500b1bd8..74dac73f255 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_proximity.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_proximity.cc @@ -81,7 +81,7 @@ static void calculate_mesh_proximity(const VArray &positions, for (int i : range) { /* Use the distance to the last found point as upper bound to speedup the bvh lookup. */ - nearest.dist_sq = math::distance_squared(float3(nearest.co), positions[i]); + nearest.dist_sq = float3::distance_squared(nearest.co, positions[i]); BLI_bvhtree_find_nearest( bvh_data.tree, positions[i], &nearest, bvh_data.nearest_callback, &bvh_data); diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc index a85a7c56cb9..b0210f2eb94 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc @@ -229,7 +229,7 @@ static void get_closest_mesh_corners(const Mesh &mesh, const MLoop &loop = mesh.mloop[loop_index]; const int vertex_index = loop.v; const MVert &mvert = mesh.mvert[vertex_index]; - const float distance_sq = math::distance_squared(position, float3(mvert.co)); + const float distance_sq = float3::distance_squared(position, mvert.co); if (distance_sq < min_distance_sq) { min_distance_sq = distance_sq; closest_loop_index = loop_index; diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_to_points.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_to_points.cc index 1e6b7f92a77..8555d7cc8a3 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_to_points.cc @@ -241,13 +241,13 @@ static void copy_uniform_sample_point_attributes(Span splines, spline.sample_with_index_factors( spline.evaluated_tangents(), uniform_samples, data.tangents.slice(offset, size)); for (float3 &tangent : data.tangents) { - tangent = math::normalize(tangent); + tangent.normalize(); } spline.sample_with_index_factors( spline.evaluated_normals(), uniform_samples, data.normals.slice(offset, size)); for (float3 &normals : data.normals) { - normals = math::normalize(normals); + normals.normalize(); } } }); diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc index c712e82ca18..29eff373d15 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc @@ -321,7 +321,7 @@ BLI_NOINLINE static void interpolate_existing_attributes( continue; } - for (const int UNUSED(i_set_instance) : set_group.transforms.index_range()) { + for ([[maybe_unused]] const int i_set_instance : set_group.transforms.index_range()) { const int offset = instance_start_offsets[i_instance]; Span bary_coords = bary_coords_array[i_instance]; Span looptri_indices = looptri_indices_array[i_instance]; @@ -516,7 +516,7 @@ static void distribute_points_poisson_disk(Span set_group const VArray density_factors = component.attribute_get_for_read( density_attribute_name, ATTR_DOMAIN_CORNER, use_one_default ? 1.0f : 0.0f); - for (const int UNUSED(i_set_instance) : set_group.transforms.index_range()) { + for ([[maybe_unused]] const int i_set_instance : set_group.transforms.index_range()) { Vector &positions = positions_all[i_instance]; Vector &bary_coords = bary_coords_all[i_instance]; Vector &looptri_indices = looptri_indices_all[i_instance]; diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_points_to_volume.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_points_to_volume.cc index f54ffc53a6e..7b1bbed8ae4 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_points_to_volume.cc @@ -161,7 +161,7 @@ static float compute_voxel_size(const GeoNodeExecParams ¶ms, } /* The voxel size adapts to the final size of the volume. */ - const float diagonal = math::distance(min, max); + const float diagonal = float3::distance(min, max); const float extended_diagonal = diagonal + 2.0f * radius; const float voxel_size = extended_diagonal / voxel_amount; return voxel_size; diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_raycast.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_raycast.cc index cfae88e0625..dd03092a594 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_raycast.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_raycast.cc @@ -107,7 +107,7 @@ static void raycast_to_mesh(const Mesh &mesh, for (const int i : ray_origins.index_range()) { const float ray_length = ray_lengths[i]; const float3 ray_origin = ray_origins[i]; - const float3 ray_direction = math::normalize(ray_directions[i]); + const float3 ray_direction = ray_directions[i].normalized(); BVHTreeRayHit hit; hit.index = -1; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc index 929d9046f98..7e09721273a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc @@ -16,7 +16,7 @@ #include "BLI_array.hh" #include "BLI_delaunay_2d.h" -#include "BLI_math_vec_types.hh" +#include "BLI_double2.hh" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc index 68b609f8045..1a44fce86a6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc @@ -122,9 +122,9 @@ static Array calculate_directions(const Span positions) Array directions(size); for (const int i : IndexRange(size - 1)) { - directions[i] = math::normalize(positions[i + 1] - positions[i]); + directions[i] = (positions[i + 1] - positions[i]).normalized(); } - directions[size - 1] = math::normalize(positions[0] - positions[size - 1]); + directions[size - 1] = (positions[0] - positions[size - 1]).normalized(); return directions; } @@ -135,9 +135,9 @@ static Array calculate_axes(const Span directions) const int size = directions.size(); Array axes(size); - axes[0] = math::normalize(math::cross(-directions[size - 1], directions[0])); + axes[0] = float3::cross(-directions[size - 1], directions[0]).normalized(); for (const int i : IndexRange(1, size - 1)) { - axes[i] = math::normalize(math::cross(-directions[i - 1], directions[i])); + axes[i] = float3::cross(-directions[i - 1], directions[i]).normalized(); } return axes; @@ -248,8 +248,8 @@ static void limit_radii(FilletData &fd, const bool cyclic) if (cyclic) { /* Calculate lengths between adjacent control points. */ - const float len_prev = math::distance(positions[0], positions[size - 1]); - const float len_next = math::distance(positions[0], positions[1]); + const float len_prev = float3::distance(positions[0], positions[size - 1]); + const float len_next = float3::distance(positions[0], positions[1]); /* Calculate tangent lengths of fillets in control points. */ const float tan_len = radii[0] * tan(angles[0] / 2.0f); @@ -271,16 +271,16 @@ static void limit_radii(FilletData &fd, const bool cyclic) } /* Initialize max_radii to largest possible radii. */ - float prev_dist = math::distance(positions[1], positions[0]); + float prev_dist = float3::distance(positions[1], positions[0]); for (const int i : IndexRange(1, size - 2)) { - const float temp_dist = math::distance(positions[i], positions[i + 1]); + const float temp_dist = float3::distance(positions[i], positions[i + 1]); max_radii[i] = std::min(prev_dist, temp_dist) / tan(angles[i] / 2.0f); prev_dist = temp_dist; } /* Max radii calculations for each index. */ for (const int i : IndexRange(start, fillet_count - 1)) { - const float len_next = math::distance(positions[i], positions[i + 1]); + const float len_next = float3::distance(positions[i], positions[i + 1]); const float tan_len = radii[i] * tan(angles[i] / 2.0f); const float tan_len_next = radii[i + 1] * tan(angles[i + 1] / 2.0f); @@ -415,8 +415,7 @@ static void update_bezier_positions(const FilletData &fd, const float3 center = get_center(dst_spline.positions()[i_dst] - positions[i_src], fd, i_src); /* Calculate the vector of the radius formed by the first vertex. */ float3 radius_vec = dst_spline.positions()[i_dst] - center; - float radius; - radius_vec = math::normalize_and_get_length(radius_vec, radius); + const float radius = radius_vec.normalize_and_get_length(); dst_spline.handle_types_right().slice(1, count - 2).fill(BezierSpline::HandleType::Align); dst_spline.handle_types_left().slice(1, count - 2).fill(BezierSpline::HandleType::Align); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index 7b5d1a1dc80..a7fb493c7d7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -101,8 +101,8 @@ static void node_update(bNodeTree *ntree, bNode *node) static bool colinear_f3_f3_f3(const float3 p1, const float3 p2, const float3 p3) { - const float3 a = math::normalize(p2 - p1); - const float3 b = math::normalize(p3 - p1); + const float3 a = (p2 - p1).normalized(); + const float3 b = (p3 - p1).normalized(); return (ELEM(a, b, b * -1.0f)); } @@ -122,18 +122,18 @@ static std::unique_ptr create_point_circle_curve( float3 center; /* Midpoints of `P1->P2` and `P2->P3`. */ - const float3 q1 = math::interpolate(p1, p2, 0.5f); - const float3 q2 = math::interpolate(p2, p3, 0.5f); + const float3 q1 = float3::interpolate(p1, p2, 0.5f); + const float3 q2 = float3::interpolate(p2, p3, 0.5f); /* Normal Vectors of `P1->P2` and `P2->P3` */ - const float3 v1 = math::normalize(p2 - p1); - const float3 v2 = math::normalize(p3 - p2); + const float3 v1 = (p2 - p1).normalized(); + const float3 v2 = (p3 - p2).normalized(); /* Normal of plane of main 2 segments P1->P2 and `P2->P3`. */ - const float3 v3 = math::normalize(math::cross(v1, v2)); + const float3 v3 = float3::cross(v1, v2).normalized(); /* Normal of plane of first perpendicular bisector and `P1->P2`. */ - const float3 v4 = math::normalize(math::cross(v3, v1)); + const float3 v4 = float3::cross(v3, v1).normalized(); /* Determine Center-point from the intersection of 3 planes. */ float plane_1[4], plane_2[4], plane_3[4]; @@ -148,7 +148,7 @@ static std::unique_ptr create_point_circle_curve( } /* Get the radius from the center-point to p1. */ - const float r = math::distance(p1, center); + const float r = float3::distance(p1, center); const float theta_step = ((2 * M_PI) / (float)resolution); for (const int i : IndexRange(resolution)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc index d35fa0a2fdc..ff9218b1ac2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc @@ -100,7 +100,7 @@ static std::unique_ptr create_direction_line_curve(const float3 start spline->resize(2); MutableSpan positions = spline->positions(); positions[0] = start; - positions[1] = math::normalize(direction) * length + start; + positions[1] = direction.normalized() * length + start; spline->radii().fill(1.0f); spline->tilts().fill(0.0f); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc index 885d92a111b..084d27e9d24 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc @@ -58,9 +58,9 @@ static std::unique_ptr create_quadratic_bezier_curve(const float3 p1, const float step = 1.0f / resolution; for (const int i : IndexRange(resolution + 1)) { const float factor = step * i; - const float3 q1 = math::interpolate(p1, p2, factor); - const float3 q2 = math::interpolate(p2, p3, factor); - positions[i] = math::interpolate(q1, q2, factor); + const float3 q1 = float3::interpolate(p1, p2, factor); + const float3 q2 = float3::interpolate(p2, p3, factor); + positions[i] = float3::interpolate(q1, q2, factor); } curve->add_spline(std::move(spline)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc index 56fbc50f033..038f7625825 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc @@ -185,7 +185,7 @@ class SampleCurveFunction : public fn::MultiFunction { for (const int i : mask) { const Spline::LookupResult &lookup = lookups[i]; const Span evaluated_tangents = splines[spline_indices[i]]->evaluated_tangents(); - sampled_tangents[i] = math::normalize(sample_with_lookup(lookup, evaluated_tangents)); + sampled_tangents[i] = sample_with_lookup(lookup, evaluated_tangents).normalized(); } } @@ -193,7 +193,7 @@ class SampleCurveFunction : public fn::MultiFunction { for (const int i : mask) { const Spline::LookupResult &lookup = lookups[i]; const Span evaluated_normals = splines[spline_indices[i]]->evaluated_normals(); - sampled_normals[i] = math::normalize(sample_with_lookup(lookup, evaluated_normals)); + sampled_normals[i] = sample_with_lookup(lookup, evaluated_normals).normalized(); } } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc index 257a5b8df00..40dde645756 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc @@ -96,7 +96,7 @@ static void calculate_nurbs_lengths(const NURBSpline &spline, MutableSpan float length = 0.0f; for (const int i : IndexRange(positions.size() - 1)) { lengths[i] = length; - length += math::distance(positions[i], positions[i + 1]); + length += float3::distance(positions[i], positions[i + 1]); } lengths.last() = length; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 19efd4b7508..a8553b636a4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -285,7 +285,7 @@ static void copy_uniform_sample_point_attributes(const Span splines, spline.sample_with_index_factors( spline.evaluated_tangents(), uniform_samples, data.tangents.slice(offset, size)); for (float3 &tangent : data.tangents) { - tangent = math::normalize(tangent); + tangent.normalize(); } } @@ -293,7 +293,7 @@ static void copy_uniform_sample_point_attributes(const Span splines, spline.sample_with_index_factors( spline.evaluated_normals(), uniform_samples, data.normals.slice(offset, size)); for (float3 &normals : data.normals) { - normals = math::normalize(normals); + normals.normalize(); } } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc index 624a8b6b0f6..28a8fb80294 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc @@ -21,7 +21,7 @@ #include "BKE_image.h" -#include "BLI_math_vec_types.hh" +#include "BLI_float4.hh" #include "BLI_threads.h" #include "BLI_timeit.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc index e90a9eb393b..5b67258a947 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc @@ -155,7 +155,7 @@ static void calculate_polys(const CuboidConfig &config, /* Calculate polys for Bottom faces. */ int vert_1_start = 0; - for (const int UNUSED(y) : IndexRange(config.edges_y)) { + for ([[maybe_unused]] const int y : IndexRange(config.edges_y)) { for (const int x : IndexRange(config.edges_x)) { const int vert_1 = vert_1_start + x; const int vert_2 = vert_1_start + config.verts_x + x; @@ -173,7 +173,7 @@ static void calculate_polys(const CuboidConfig &config, vert_1_start = 0; int vert_2_start = config.verts_x * config.verts_y; - for (const int UNUSED(z) : IndexRange(config.edges_z)) { + for ([[maybe_unused]] const int z : IndexRange(config.edges_z)) { for (const int x : IndexRange(config.edges_x)) { define_quad(polys, loops, @@ -196,7 +196,7 @@ static void calculate_polys(const CuboidConfig &config, (config.verts_x - 2) * (config.verts_y - 2)); vert_2_start = vert_1_start + config.verts_x; - for (const int UNUSED(y) : IndexRange(config.edges_y)) { + for ([[maybe_unused]] const int y : IndexRange(config.edges_y)) { for (const int x : IndexRange(config.edges_x)) { define_quad(polys, loops, diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index 8a2b054ece0..5116e78fdda 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -155,8 +155,8 @@ static void node_geo_exec(GeoNodeExecParams params) if (count_mode == GEO_NODE_MESH_LINE_COUNT_RESOLUTION) { /* Don't allow asymptotic count increase for low resolution values. */ const float resolution = std::max(params.extract_input("Resolution"), 0.0001f); - const int count = math::length(total_delta) / resolution + 1; - const float3 delta = math::normalize(total_delta) * resolution; + const int count = total_delta.length() / resolution + 1; + const float3 delta = total_delta.normalized() * resolution; mesh = create_line_mesh(start, delta, count); } else if (count_mode == GEO_NODE_MESH_LINE_COUNT_TOTAL) { @@ -204,7 +204,7 @@ Mesh *create_line_mesh(const float3 start, const float3 delta, const int count) MutableSpan edges{mesh->medge, mesh->totedge}; short normal[3]; - normal_float_to_short_v3(normal, math::normalize(delta)); + normal_float_to_short_v3(normal, delta.normalized()); for (const int i : verts.index_range()) { copy_v3_v3(verts[i].co, start + delta * i); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index 373e6bfdd18..41178d5c4e6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -178,7 +178,7 @@ static void calculate_sphere_faces(MutableSpan loops, int ring_vert_index_start = 1; int ring_edge_index_start = segments; - for (const int UNUSED(ring) : IndexRange(1, rings - 2)) { + for ([[maybe_unused]] const int ring : IndexRange(1, rings - 2)) { const int next_ring_vert_index_start = ring_vert_index_start + segments; const int next_ring_edge_index_start = ring_edge_index_start + segments * 2; const int ring_vertical_edge_index_start = ring_edge_index_start + segments; diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index c165bcf8e35..dda4543d5e1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -166,7 +166,7 @@ static float compute_voxel_size(const GeoNodeExecParams ¶ms, } /* The voxel size adapts to the final size of the volume. */ - const float diagonal = math::distance(min, max); + const float diagonal = float3::distance(min, max); const float extended_diagonal = diagonal + 2.0f * radius; const float voxel_size = extended_diagonal / voxel_amount; return voxel_size; diff --git a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc index 772638ef240..e0117c4726d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc @@ -85,7 +85,7 @@ static bool calculate_mesh_proximity(const VArray &positions, for (int i : range) { const int index = mask[i]; /* Use the distance to the last found point as upper bound to speedup the bvh lookup. */ - nearest.dist_sq = math::distance_squared(float3(nearest.co), positions[index]); + nearest.dist_sq = float3::distance_squared(nearest.co, positions[index]); BLI_bvhtree_find_nearest( bvh_data.tree, positions[index], &nearest, bvh_data.nearest_callback, &bvh_data); diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index c38503f688c..2c35ca0afc9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -163,7 +163,7 @@ static void raycast_to_mesh(IndexMask mask, for (const int i : mask) { const float ray_length = ray_lengths[i]; const float3 ray_origin = ray_origins[i]; - const float3 ray_direction = math::normalize(ray_directions[i]); + const float3 ray_direction = ray_directions[i].normalized(); BVHTreeRayHit hit; hit.index = -1; diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc index feab0a6743f..82d09bbc208 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc @@ -106,7 +106,7 @@ static void set_position_in_component(const GeometryNodeCurveHandleMode mode, } } else { - for (int UNUSED(i) : spline->positions().index_range()) { + for ([[maybe_unused]] int i : spline->positions().index_range()) { if (current_mask < selection.size() && selection[current_mask] == current_point) { current_mask++; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc index 6867051ecfe..331460296a6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc @@ -296,7 +296,7 @@ static void get_closest_mesh_corners(const Mesh &mesh, const MLoop &loop = mesh.mloop[loop_index]; const int vertex_index = loop.v; const MVert &mvert = mesh.mvert[vertex_index]; - const float distance_sq = math::distance_squared(position, float3(mvert.co)); + const float distance_sq = float3::distance_squared(position, mvert.co); if (distance_sq < min_distance_sq) { min_distance_sq = distance_sq; closest_loop_index = loop_index; diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform.cc b/source/blender/nodes/geometry/nodes/node_geo_transform.cc index 6187a2eacf9..7f866ea6f4a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transform.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transform.cc @@ -37,7 +37,7 @@ namespace blender::nodes { static bool use_translate(const float3 rotation, const float3 scale) { - if (compare_ff(math::length_squared(rotation), 0.0f, 1e-9f) != 1) { + if (compare_ff(rotation.length_squared(), 0.0f, 1e-9f) != 1) { return false; } if (compare_ff(scale.x, 1.0f, 1e-9f) != 1 || compare_ff(scale.y, 1.0f, 1e-9f) != 1 || @@ -49,7 +49,7 @@ static bool use_translate(const float3 rotation, const float3 scale) static void translate_mesh(Mesh &mesh, const float3 translation) { - if (!math::is_zero(translation)) { + if (!translation.is_zero()) { BKE_mesh_translate(&mesh, translation, false); } } diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index ed72580ccf1..6a6b6e3d3cc 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -26,8 +26,8 @@ #include "DNA_node_types.h" #include "BLI_color.hh" +#include "BLI_float3.hh" #include "BLI_listbase.h" -#include "BLI_math_vec_types.hh" #include "BLI_string.h" #include "BLI_utildefines.h" diff --git a/source/blender/nodes/shader/node_shader_util.hh b/source/blender/nodes/shader/node_shader_util.hh index 5a5b4f613f3..9d4d57d01dd 100644 --- a/source/blender/nodes/shader/node_shader_util.hh +++ b/source/blender/nodes/shader/node_shader_util.hh @@ -29,9 +29,9 @@ #include "BLI_blenlib.h" #include "BLI_color.hh" +#include "BLI_float3.hh" #include "BLI_math.h" #include "BLI_math_base_safe.h" -#include "BLI_math_vec_types.hh" #include "BLI_rand.h" #include "BLI_threads.h" #include "BLI_utildefines.h" diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index bc7ca661a77..3276a1bfd72 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -272,7 +272,7 @@ class MapRangeVectorFunction : public blender::fn::MultiFunction { blender::MutableSpan results = params.uninitialized_single_output(5, "Vector"); for (int64_t i : mask) { - float3 factor = math::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]); + float3 factor = float3::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]); results[i] = factor * (to_max[i] - to_min[i]) + to_min[i]; } @@ -315,8 +315,8 @@ class MapRangeSteppedVectorFunction : public blender::fn::MultiFunction { blender::MutableSpan results = params.uninitialized_single_output(6, "Vector"); for (int64_t i : mask) { - float3 factor = math::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]); - factor = math::safe_divide(math::floor(factor * (steps[i] + 1.0f)), steps[i]); + float3 factor = float3::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]); + factor = float3::safe_divide(float3::floor(factor * (steps[i] + 1.0f)), steps[i]); results[i] = factor * (to_max[i] - to_min[i]) + to_min[i]; } @@ -355,7 +355,7 @@ class MapRangeSmoothstepVectorFunction : public blender::fn::MultiFunction { blender::MutableSpan results = params.uninitialized_single_output(5, "Vector"); for (int64_t i : mask) { - float3 factor = math::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]); + float3 factor = float3::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]); clamp_v3(factor, 0.0f, 1.0f); factor = (float3(3.0f) - 2.0f * factor) * (factor * factor); results[i] = factor * (to_max[i] - to_min[i]) + to_min[i]; @@ -390,7 +390,7 @@ class MapRangeSmootherstepVectorFunction : public blender::fn::MultiFunction { blender::MutableSpan results = params.uninitialized_single_output(5, "Vector"); for (int64_t i : mask) { - float3 factor = math::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]); + float3 factor = float3::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]); clamp_v3(factor, 0.0f, 1.0f); factor = factor * factor * factor * (factor * (factor * 6.0f - 15.0f) + 10.0f); results[i] = factor * (to_max[i] - to_min[i]) + to_min[i]; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc index 81a69ef18da..61b1613c11a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc @@ -19,7 +19,8 @@ #include "node_shader_util.hh" -#include "BLI_math_vec_types.hh" +#include "BLI_float2.hh" +#include "BLI_float4.hh" #include "UI_interface.h" #include "UI_resources.h" diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc index 53be5bc09d9..85e0f262ca7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc @@ -130,7 +130,7 @@ class GradientFunction : public fn::MultiFunction { /* Bias a little bit for the case where input is a unit length vector, * to get exactly zero instead of a small random value depending * on float precision. */ - const float r = std::max(0.999999f - math::length(vector[i]), 0.0f); + const float r = std::max(0.999999f - vector[i].length(), 0.0f); fac[i] = r * r; } break; @@ -140,7 +140,7 @@ class GradientFunction : public fn::MultiFunction { /* Bias a little bit for the case where input is a unit length vector, * to get exactly zero instead of a small random value depending * on float precision. */ - fac[i] = std::max(0.999999f - math::length(vector[i]), 0.0f); + fac[i] = std::max(0.999999f - vector[i].length(), 0.0f); } break; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc index 1c703313edf..0e549859a39 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -176,14 +176,14 @@ class NoiseFunction : public fn::MultiFunction { const VArray &vector = params.readonly_single_input(0, "Vector"); if (compute_factor) { for (int64_t i : mask) { - const float2 position = float2(vector[i] * scale[i]); + const float2 position = vector[i] * scale[i]; r_factor[i] = noise::perlin_fractal_distorted( position, detail[i], roughness[i], distortion[i]); } } if (compute_color) { for (int64_t i : mask) { - const float2 position = float2(vector[i] * scale[i]); + const float2 position = vector[i] * scale[i]; const float3 c = noise::perlin_float3_fractal_distorted( position, detail[i], roughness[i], distortion[i]); r_color[i] = ColorGeometry4f(c[0], c[1], c[2], 1.0f); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc index 209f96449cd..2b5c1ddfe21 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc @@ -313,7 +313,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - pos = math::safe_divide(pos, scale[i]); + pos = float2::safe_divide(pos, scale[i]); r_position[i] = float3(pos.x, pos.y, 0.0f); } } @@ -345,7 +345,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - pos = math::safe_divide(pos, scale[i]); + pos = float2::safe_divide(pos, scale[i]); r_position[i] = float3(pos.x, pos.y, 0.0f); } } @@ -380,7 +380,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - pos = math::safe_divide(pos, scale[i]); + pos = float2::safe_divide(pos, scale[i]); r_position[i] = float3(pos.x, pos.y, 0.0f); } } @@ -416,7 +416,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - r_position[i] = math::safe_divide(r_position[i], scale[i]); + r_position[i] = float3::safe_divide(r_position[i], scale[i]); } } break; @@ -446,7 +446,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - r_position[i] = math::safe_divide(r_position[i], scale[i]); + r_position[i] = float3::safe_divide(r_position[i], scale[i]); } } break; @@ -479,7 +479,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - r_position[i] = math::safe_divide(r_position[i], scale[i]); + r_position[i] = float3::safe_divide(r_position[i], scale[i]); } } break; @@ -519,7 +519,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position || calc_w) { - pos = math::safe_divide(pos, scale[i]); + pos = float4::safe_divide(pos, scale[i]); if (calc_position) { r_position[i] = float3(pos.x, pos.y, pos.z); } @@ -560,7 +560,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position || calc_w) { - pos = math::safe_divide(pos, scale[i]); + pos = float4::safe_divide(pos, scale[i]); if (calc_position) { r_position[i] = float3(pos.x, pos.y, pos.z); } @@ -604,7 +604,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position || calc_w) { - pos = math::safe_divide(pos, scale[i]); + pos = float4::safe_divide(pos, scale[i]); if (calc_position) { r_position[i] = float3(pos.x, pos.y, pos.z); } @@ -837,7 +837,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - pos = math::safe_divide(pos, scale[i]); + pos = float2::safe_divide(pos, scale[i]); r_position[i] = float3(pos.x, pos.y, 0.0f); } } @@ -868,7 +868,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - pos = math::safe_divide(pos, scale[i]); + pos = float2::safe_divide(pos, scale[i]); r_position[i] = float3(pos.x, pos.y, 0.0f); } } @@ -902,7 +902,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - pos = math::safe_divide(pos, scale[i]); + pos = float2::safe_divide(pos, scale[i]); r_position[i] = float3(pos.x, pos.y, 0.0f); } } @@ -937,7 +937,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - r_position[i] = math::safe_divide(r_position[i], scale[i]); + r_position[i] = float3::safe_divide(r_position[i], scale[i]); } } break; @@ -966,7 +966,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - r_position[i] = math::safe_divide(r_position[i], scale[i]); + r_position[i] = float3::safe_divide(r_position[i], scale[i]); } } break; @@ -999,7 +999,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position) { - r_position[i] = math::safe_divide(r_position[i], scale[i]); + r_position[i] = float3::safe_divide(r_position[i], scale[i]); } } } @@ -1040,7 +1040,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position || calc_w) { - pos = math::safe_divide(pos, scale[i]); + pos = float4::safe_divide(pos, scale[i]); if (calc_position) { r_position[i] = float3(pos.x, pos.y, pos.z); } @@ -1080,7 +1080,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position || calc_w) { - pos = math::safe_divide(pos, scale[i]); + pos = float4::safe_divide(pos, scale[i]); if (calc_position) { r_position[i] = float3(pos.x, pos.y, pos.z); } @@ -1123,7 +1123,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { r_color[i] = ColorGeometry4f(col[0], col[1], col[2], 1.0f); } if (calc_position || calc_w) { - pos = math::safe_divide(pos, scale[i]); + pos = float4::safe_divide(pos, scale[i]); if (calc_position) { r_position[i] = float3(pos.x, pos.y, pos.z); } -- cgit v1.2.3