Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/NOD_math_functions.hh75
-rw-r--r--source/blender/nodes/NOD_socket_declarations.hh2
-rw-r--r--source/blender/nodes/composite/node_composite_tree.cc17
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.cc28
-rw-r--r--source/blender/nodes/function/node_function_util.hh2
-rw-r--r--source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc8
-rw-r--r--source/blender/nodes/function/nodes/node_fn_compare.cc24
-rw-r--r--source/blender/nodes/geometry/node_geometry_util.hh4
-rw-r--r--source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc8
-rw-r--r--source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_proximity.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_transfer.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_curve_to_points.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_distribute.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_points_to_volume.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_raycast.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc21
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc18
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc6
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_image_texture.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc6
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc6
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_proximity.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_raycast.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_transform.cc4
-rw-r--r--source/blender/nodes/intern/node_socket.cc2
-rw-r--r--source/blender/nodes/shader/node_shader_util.hh2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_map_range.cc10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_brick.cc3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_noise.cc4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc36
40 files changed, 170 insertions, 164 deletions
diff --git a/source/blender/nodes/NOD_math_functions.hh b/source/blender/nodes/NOD_math_functions.hh
index a0a2e6f81f8..6ea89beee2e 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,6 +240,8 @@ template<typename Callback>
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;
@@ -259,40 +261,21 @@ 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 float3(safe_divide(a.x, b.x), safe_divide(a.y, b.y), safe_divide(a.z, b.z));
- });
+ return dispatch([](float3 a, float3 b) { return safe_divide(a, b); });
case NODE_VECTOR_MATH_CROSS_PRODUCT:
- return dispatch([](float3 a, float3 b) { return float3::cross_high_precision(a, b); });
+ return dispatch([](float3 a, float3 b) { return cross_high_precision(a, b); });
case NODE_VECTOR_MATH_PROJECT:
- 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);
- });
+ return dispatch([](float3 a, float3 b) { return project(a, b); });
case NODE_VECTOR_MATH_REFLECT:
- return dispatch([](float3 a, float3 b) {
- b.normalize();
- return a.reflected(b);
- });
+ return dispatch([](float3 a, float3 b) { return reflect(a, normalize(b)); });
case NODE_VECTOR_MATH_SNAP:
- 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;
- });
+ return dispatch([](float3 a, float3 b) { return floor(safe_divide(a, b)) * b; });
case NODE_VECTOR_MATH_MODULO:
- 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));
- });
+ return dispatch([](float3 a, float3 b) { return mod(a, b); });
case NODE_VECTOR_MATH_MINIMUM:
- 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));
- });
+ return dispatch([](float3 a, float3 b) { return min(a, b); });
case NODE_VECTOR_MATH_MAXIMUM:
- 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));
- });
+ return dispatch([](float3 a, float3 b) { return max(a, b); });
default:
return false;
}
@@ -306,6 +289,8 @@ template<typename Callback>
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;
@@ -319,9 +304,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 float3::dot(a, b); });
+ return dispatch([](float3 a, float3 b) { return dot(a, b); });
case NODE_VECTOR_MATH_DISTANCE:
- return dispatch([](float3 a, float3 b) { return float3::distance(a, b); });
+ return dispatch([](float3 a, float3 b) { return distance(a, b); });
default:
return false;
}
@@ -335,6 +320,8 @@ template<typename Callback>
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;
@@ -354,7 +341,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 float3::faceforward(a, b, c); });
+ return dispatch([](float3 a, float3 b, float3 c) { return faceforward(a, b, c); });
default:
return false;
}
@@ -368,6 +355,8 @@ template<typename Callback>
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;
@@ -381,8 +370,7 @@ 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 float3::refract(a, b.normalized(), c); });
+ return dispatch([](float3 a, float3 b, float c) { return refract(a, normalize(b), c); });
default:
return false;
}
@@ -396,6 +384,8 @@ template<typename Callback>
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;
@@ -409,7 +399,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 in.length(); });
+ return dispatch([](float3 in) { return length(in); });
default:
return false;
}
@@ -450,6 +440,8 @@ template<typename Callback>
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;
@@ -463,20 +455,15 @@ inline bool try_dispatch_float_math_fl3_to_fl3(const NodeVectorMathOperation ope
switch (operation) {
case NODE_VECTOR_MATH_NORMALIZE:
- return dispatch([](float3 in) {
- float3 out = in;
- out.normalize();
- return out;
- }); /* Should be safe. */
+ return dispatch([](float3 in) { return normalize(in); }); /* Should be safe. */
case NODE_VECTOR_MATH_FLOOR:
- return dispatch([](float3 in) { return float3(floor(in.x), floor(in.y), floor(in.z)); });
+ return dispatch([](float3 in) { return floor(in); });
case NODE_VECTOR_MATH_CEIL:
- return dispatch([](float3 in) { return float3(ceil(in.x), ceil(in.y), ceil(in.z)); });
+ return dispatch([](float3 in) { return ceil(in); });
case NODE_VECTOR_MATH_FRACTION:
- return dispatch(
- [](float3 in) { return in - float3(floor(in.x), floor(in.y), floor(in.z)); });
+ return dispatch([](float3 in) { return fract(in); });
case NODE_VECTOR_MATH_ABSOLUTE:
- return dispatch([](float3 in) { return float3::abs(in); });
+ return dispatch([](float3 in) { return 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 c0580a2c919..a1972c66ca2 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_float3.hh"
+#include "BLI_math_vec_types.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 c54382cc1ad..08dbd4ad6f0 100644
--- a/source/blender/nodes/composite/node_composite_tree.cc
+++ b/source/blender/nodes/composite/node_composite_tree.cc
@@ -249,6 +249,23 @@ 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 f2b9fbc2215..6f4f9d7e597 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_image.cc
@@ -269,12 +269,7 @@ void node_cmp_rlayers_register_pass(bNodeTree *ntree,
}
}
-struct CreateOutputUserData {
- bNodeTree &ntree;
- bNode &node;
-};
-
-static void cmp_node_rlayer_create_outputs_cb(void *userdata,
+static void cmp_node_rlayer_create_outputs_cb(void *UNUSED(userdata),
Scene *scene,
ViewLayer *view_layer,
const char *name,
@@ -282,8 +277,18 @@ static void cmp_node_rlayer_create_outputs_cb(void *userdata,
const char *UNUSED(chanid),
eNodeSocketDatatype type)
{
- CreateOutputUserData &data = *(CreateOutputUserData *)userdata;
- node_cmp_rlayers_register_pass(&data.ntree, &data.node, scene, view_layer, name, 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);
+ }
+ }
}
static void cmp_node_rlayer_create_outputs(bNodeTree *ntree,
@@ -303,17 +308,14 @@ 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, &userdata);
+ engine, scene, view_layer, cmp_node_rlayer_create_outputs_cb, nullptr);
RE_engine_free(engine);
if ((scene->r.mode & R_EDGE_FRS) &&
(view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS)) {
- node_cmp_rlayers_register_pass(
- ntree, node, scene, view_layer, RE_PASSNAME_FREESTYLE, SOCK_RGBA);
+ ntreeCompositRegisterPass(ntree, 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 acde9c4b55b..69c617b4f01 100644
--- a/source/blender/nodes/function/node_function_util.hh
+++ b/source/blender/nodes/function/node_function_util.hh
@@ -18,7 +18,7 @@
#include <string.h>
-#include "BLI_float3.hh"
+#include "BLI_math_vec_types.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 f4ce8d2f35a..bcc035e6ede 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 = vector.normalized();
- float3 rotation_axis = float3::cross_high_precision(old_axis, new_axis);
+ const float3 new_axis = math::normalize(vector);
+ float3 rotation_axis = math::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 = float3::cross_high_precision(old_axis, float3(1, 0, 0));
+ rotation_axis = math::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 = float3::cross_high_precision(old_axis, float3(0, 1, 0));
+ rotation_axis = math::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 3bb46511eeb..7c09bace756 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<float3, float3, float, bool> fn{
"Less Than - Dot Product",
- [](float3 a, float3 b, float comp) { return float3::dot(a, b) < comp; }};
+ [](float3 a, float3 b, float comp) { return math::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<float3, float3, bool> fn{
"Less Than - Length",
- [](float3 a, float3 b) { return a.length() < b.length(); }};
+ [](float3 a, float3 b) { return math::length(a) < math::length(b); }};
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<float3, float3, float, bool> fn{
"Less Equal - Dot Product",
- [](float3 a, float3 b, float comp) { return float3::dot(a, b) <= comp; }};
+ [](float3 a, float3 b, float comp) { return math::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<float3, float3, bool> fn{
"Less Equal - Length",
- [](float3 a, float3 b) { return a.length() <= b.length(); }};
+ [](float3 a, float3 b) { return math::length(a) <= math::length(b); }};
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<float3, float3, float, bool> fn{
"Greater Than - Dot Product",
- [](float3 a, float3 b, float comp) { return float3::dot(a, b) > comp; }};
+ [](float3 a, float3 b, float comp) { return math::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<float3, float3, bool> fn{
"Greater Than - Length",
- [](float3 a, float3 b) { return a.length() > b.length(); }};
+ [](float3 a, float3 b) { return math::length(a) > math::length(b); }};
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<float3, float3, float, bool> fn{
"Greater Equal - Dot Product",
- [](float3 a, float3 b, float comp) { return float3::dot(a, b) >= comp; }};
+ [](float3 a, float3 b, float comp) { return math::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<float3, float3, bool> fn{
"Greater Equal - Length",
- [](float3 a, float3 b) { return a.length() >= b.length(); }};
+ [](float3 a, float3 b) { return math::length(a) >= math::length(b); }};
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<float3, float3, float, float, bool> fn{
"Equal - Dot Product", [](float3 a, float3 b, float comp, float epsilon) {
- return abs(float3::dot(a, b) - comp) <= epsilon;
+ return abs(math::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<float3, float3, float, bool> fn{
"Equal - Length", [](float3 a, float3 b, float epsilon) {
- return abs(a.length() - b.length()) <= epsilon;
+ return abs(math::length(a) - math::length(b)) <= 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<float3, float3, float, float, bool> fn{
"Not Equal - Dot Product", [](float3 a, float3 b, float comp, float epsilon) {
- return abs(float3::dot(a, b) - comp) >= epsilon;
+ return abs(math::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<float3, float3, float, bool> fn{
"Not Equal - Length", [](float3 a, float3 b, float epsilon) {
- return abs(a.length() - b.length()) > epsilon;
+ return abs(math::length(a) - math::length(b)) > epsilon;
}};
return &fn;
}
diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh
index 1c2a8f521c0..e063be62987 100644
--- a/source/blender/nodes/geometry/node_geometry_util.hh
+++ b/source/blender/nodes/geometry/node_geometry_util.hh
@@ -18,7 +18,7 @@
#include <string.h>
-#include "BLI_float3.hh"
+#include "BLI_math_vec_types.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,
- GeometryNodeMeshCircleFillType fill_type,
+ const 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 36ad4605a4b..1d064586238 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<float3> &vectors,
float3 old_axis;
mul_v3_m3v3(old_axis, old_rotation, local_main_axis);
- const float3 new_axis = vector.normalized();
- float3 rotation_axis = float3::cross_high_precision(old_axis, new_axis);
+ const float3 new_axis = math::normalize(vector);
+ float3 rotation_axis = math::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 = float3::cross_high_precision(old_axis, float3(1, 0, 0));
+ rotation_axis = math::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 = float3::cross_high_precision(old_axis, float3(0, 1, 0));
+ rotation_axis = math::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 74dac73f255..20f500b1bd8 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<float3> &positions,
for (int i : range) {
/* Use the distance to the last found point as upper bound to speedup the bvh lookup. */
- nearest.dist_sq = float3::distance_squared(nearest.co, positions[i]);
+ nearest.dist_sq = math::distance_squared(float3(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 b0210f2eb94..a85a7c56cb9 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 = float3::distance_squared(position, mvert.co);
+ const float distance_sq = math::distance_squared(position, float3(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 8555d7cc8a3..1e6b7f92a77 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<SplinePtr> splines,
spline.sample_with_index_factors<float3>(
spline.evaluated_tangents(), uniform_samples, data.tangents.slice(offset, size));
for (float3 &tangent : data.tangents) {
- tangent.normalize();
+ tangent = math::normalize(tangent);
}
spline.sample_with_index_factors<float3>(
spline.evaluated_normals(), uniform_samples, data.normals.slice(offset, size));
for (float3 &normals : data.normals) {
- normals.normalize();
+ normals = math::normalize(normals);
}
}
});
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 29eff373d15..c712e82ca18 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 ([[maybe_unused]] const int i_set_instance : set_group.transforms.index_range()) {
+ for (const int UNUSED(i_set_instance) : set_group.transforms.index_range()) {
const int offset = instance_start_offsets[i_instance];
Span<float3> bary_coords = bary_coords_array[i_instance];
Span<int> looptri_indices = looptri_indices_array[i_instance];
@@ -516,7 +516,7 @@ static void distribute_points_poisson_disk(Span<GeometryInstanceGroup> set_group
const VArray<float> density_factors = component.attribute_get_for_read<float>(
density_attribute_name, ATTR_DOMAIN_CORNER, use_one_default ? 1.0f : 0.0f);
- for ([[maybe_unused]] const int i_set_instance : set_group.transforms.index_range()) {
+ for (const int UNUSED(i_set_instance) : set_group.transforms.index_range()) {
Vector<float3> &positions = positions_all[i_instance];
Vector<float3> &bary_coords = bary_coords_all[i_instance];
Vector<int> &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 7b1bbed8ae4..f54ffc53a6e 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 &params,
}
/* The voxel size adapts to the final size of the volume. */
- const float diagonal = float3::distance(min, max);
+ const float diagonal = math::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 dd03092a594..cfae88e0625 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 = ray_directions[i].normalized();
+ const float3 ray_direction = math::normalize(ray_directions[i]);
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 7e09721273a..929d9046f98 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_double2.hh"
+#include "BLI_math_vec_types.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 1a44fce86a6..68b609f8045 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<float3> calculate_directions(const Span<float3> positions)
Array<float3> directions(size);
for (const int i : IndexRange(size - 1)) {
- directions[i] = (positions[i + 1] - positions[i]).normalized();
+ directions[i] = math::normalize(positions[i + 1] - positions[i]);
}
- directions[size - 1] = (positions[0] - positions[size - 1]).normalized();
+ directions[size - 1] = math::normalize(positions[0] - positions[size - 1]);
return directions;
}
@@ -135,9 +135,9 @@ static Array<float3> calculate_axes(const Span<float3> directions)
const int size = directions.size();
Array<float3> axes(size);
- axes[0] = float3::cross(-directions[size - 1], directions[0]).normalized();
+ axes[0] = math::normalize(math::cross(-directions[size - 1], directions[0]));
for (const int i : IndexRange(1, size - 1)) {
- axes[i] = float3::cross(-directions[i - 1], directions[i]).normalized();
+ axes[i] = math::normalize(math::cross(-directions[i - 1], directions[i]));
}
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 = float3::distance(positions[0], positions[size - 1]);
- const float len_next = float3::distance(positions[0], positions[1]);
+ const float len_prev = math::distance(positions[0], positions[size - 1]);
+ const float len_next = math::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 = float3::distance(positions[1], positions[0]);
+ float prev_dist = math::distance(positions[1], positions[0]);
for (const int i : IndexRange(1, size - 2)) {
- const float temp_dist = float3::distance(positions[i], positions[i + 1]);
+ const float temp_dist = math::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 = float3::distance(positions[i], positions[i + 1]);
+ const float len_next = math::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,7 +415,8 @@ 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;
- const float radius = radius_vec.normalize_and_get_length();
+ float radius;
+ radius_vec = math::normalize_and_get_length(radius_vec, radius);
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 a7fb493c7d7..7b5d1a1dc80 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 = (p2 - p1).normalized();
- const float3 b = (p3 - p1).normalized();
+ const float3 a = math::normalize(p2 - p1);
+ const float3 b = math::normalize(p3 - p1);
return (ELEM(a, b, b * -1.0f));
}
@@ -122,18 +122,18 @@ static std::unique_ptr<CurveEval> create_point_circle_curve(
float3 center;
/* Midpoints of `P1->P2` and `P2->P3`. */
- const float3 q1 = float3::interpolate(p1, p2, 0.5f);
- const float3 q2 = float3::interpolate(p2, p3, 0.5f);
+ const float3 q1 = math::interpolate(p1, p2, 0.5f);
+ const float3 q2 = math::interpolate(p2, p3, 0.5f);
/* Normal Vectors of `P1->P2` and `P2->P3` */
- const float3 v1 = (p2 - p1).normalized();
- const float3 v2 = (p3 - p2).normalized();
+ const float3 v1 = math::normalize(p2 - p1);
+ const float3 v2 = math::normalize(p3 - p2);
/* Normal of plane of main 2 segments P1->P2 and `P2->P3`. */
- const float3 v3 = float3::cross(v1, v2).normalized();
+ const float3 v3 = math::normalize(math::cross(v1, v2));
/* Normal of plane of first perpendicular bisector and `P1->P2`. */
- const float3 v4 = float3::cross(v3, v1).normalized();
+ const float3 v4 = math::normalize(math::cross(v3, v1));
/* 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<CurveEval> create_point_circle_curve(
}
/* Get the radius from the center-point to p1. */
- const float r = float3::distance(p1, center);
+ const float r = math::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 ff9218b1ac2..d35fa0a2fdc 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<CurveEval> create_direction_line_curve(const float3 start
spline->resize(2);
MutableSpan<float3> positions = spline->positions();
positions[0] = start;
- positions[1] = direction.normalized() * length + start;
+ positions[1] = math::normalize(direction) * 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 084d27e9d24..885d92a111b 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<CurveEval> 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 = float3::interpolate(p1, p2, factor);
- const float3 q2 = float3::interpolate(p2, p3, factor);
- positions[i] = float3::interpolate(q1, q2, factor);
+ const float3 q1 = math::interpolate(p1, p2, factor);
+ const float3 q2 = math::interpolate(p2, p3, factor);
+ positions[i] = math::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 038f7625825..56fbc50f033 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<float3> evaluated_tangents = splines[spline_indices[i]]->evaluated_tangents();
- sampled_tangents[i] = sample_with_lookup(lookup, evaluated_tangents).normalized();
+ sampled_tangents[i] = math::normalize(sample_with_lookup(lookup, evaluated_tangents));
}
}
@@ -193,7 +193,7 @@ class SampleCurveFunction : public fn::MultiFunction {
for (const int i : mask) {
const Spline::LookupResult &lookup = lookups[i];
const Span<float3> evaluated_normals = splines[spline_indices[i]]->evaluated_normals();
- sampled_normals[i] = sample_with_lookup(lookup, evaluated_normals).normalized();
+ sampled_normals[i] = math::normalize(sample_with_lookup(lookup, evaluated_normals));
}
}
}
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 40dde645756..257a5b8df00 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>
float length = 0.0f;
for (const int i : IndexRange(positions.size() - 1)) {
lengths[i] = length;
- length += float3::distance(positions[i], positions[i + 1]);
+ length += math::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 a8553b636a4..19efd4b7508 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<SplinePtr> splines,
spline.sample_with_index_factors<float3>(
spline.evaluated_tangents(), uniform_samples, data.tangents.slice(offset, size));
for (float3 &tangent : data.tangents) {
- tangent.normalize();
+ tangent = math::normalize(tangent);
}
}
@@ -293,7 +293,7 @@ static void copy_uniform_sample_point_attributes(const Span<SplinePtr> splines,
spline.sample_with_index_factors<float3>(
spline.evaluated_normals(), uniform_samples, data.normals.slice(offset, size));
for (float3 &normals : data.normals) {
- normals.normalize();
+ normals = math::normalize(normals);
}
}
}
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 28a8fb80294..624a8b6b0f6 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_float4.hh"
+#include "BLI_math_vec_types.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 5b67258a947..e90a9eb393b 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 ([[maybe_unused]] const int y : IndexRange(config.edges_y)) {
+ for (const int UNUSED(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 ([[maybe_unused]] const int z : IndexRange(config.edges_z)) {
+ for (const int UNUSED(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 ([[maybe_unused]] const int y : IndexRange(config.edges_y)) {
+ for (const int UNUSED(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 5116e78fdda..8a2b054ece0 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<float>("Resolution"), 0.0001f);
- const int count = total_delta.length() / resolution + 1;
- const float3 delta = total_delta.normalized() * resolution;
+ const int count = math::length(total_delta) / resolution + 1;
+ const float3 delta = math::normalize(total_delta) * 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<MEdge> edges{mesh->medge, mesh->totedge};
short normal[3];
- normal_float_to_short_v3(normal, delta.normalized());
+ normal_float_to_short_v3(normal, math::normalize(delta));
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 41178d5c4e6..373e6bfdd18 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<MLoop> loops,
int ring_vert_index_start = 1;
int ring_edge_index_start = segments;
- for ([[maybe_unused]] const int ring : IndexRange(1, rings - 2)) {
+ for (const int UNUSED(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 dda4543d5e1..c165bcf8e35 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 &params,
}
/* The voxel size adapts to the final size of the volume. */
- const float diagonal = float3::distance(min, max);
+ const float diagonal = math::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 e0117c4726d..772638ef240 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<float3> &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 = float3::distance_squared(nearest.co, positions[index]);
+ nearest.dist_sq = math::distance_squared(float3(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 2c35ca0afc9..c38503f688c 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 = ray_directions[i].normalized();
+ const float3 ray_direction = math::normalize(ray_directions[i]);
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 82d09bbc208..feab0a6743f 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 ([[maybe_unused]] int i : spline->positions().index_range()) {
+ for (int UNUSED(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 331460296a6..6867051ecfe 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 = float3::distance_squared(position, mvert.co);
+ const float distance_sq = math::distance_squared(position, float3(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 7f866ea6f4a..6187a2eacf9 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(rotation.length_squared(), 0.0f, 1e-9f) != 1) {
+ if (compare_ff(math::length_squared(rotation), 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 (!translation.is_zero()) {
+ if (!math::is_zero(translation)) {
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 6a6b6e3d3cc..ed72580ccf1 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 9d4d57d01dd..5a5b4f613f3 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 3276a1bfd72..bc7ca661a77 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<float3> results = params.uninitialized_single_output<float3>(5, "Vector");
for (int64_t i : mask) {
- float3 factor = float3::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]);
+ float3 factor = math::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<float3> results = params.uninitialized_single_output<float3>(6, "Vector");
for (int64_t i : mask) {
- 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]);
+ 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]);
results[i] = factor * (to_max[i] - to_min[i]) + to_min[i];
}
@@ -355,7 +355,7 @@ class MapRangeSmoothstepVectorFunction : public blender::fn::MultiFunction {
blender::MutableSpan<float3> results = params.uninitialized_single_output<float3>(5, "Vector");
for (int64_t i : mask) {
- float3 factor = float3::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]);
+ float3 factor = math::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<float3> results = params.uninitialized_single_output<float3>(5, "Vector");
for (int64_t i : mask) {
- float3 factor = float3::safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]);
+ float3 factor = math::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 61b1613c11a..81a69ef18da 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc
@@ -19,8 +19,7 @@
#include "node_shader_util.hh"
-#include "BLI_float2.hh"
-#include "BLI_float4.hh"
+#include "BLI_math_vec_types.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 85e0f262ca7..53be5bc09d9 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 - vector[i].length(), 0.0f);
+ const float r = std::max(0.999999f - math::length(vector[i]), 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 - vector[i].length(), 0.0f);
+ fac[i] = std::max(0.999999f - math::length(vector[i]), 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 0e549859a39..1c703313edf 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<float3> &vector = params.readonly_single_input<float3>(0, "Vector");
if (compute_factor) {
for (int64_t i : mask) {
- const float2 position = vector[i] * scale[i];
+ const float2 position = float2(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 = vector[i] * scale[i];
+ const float2 position = float2(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 2b5c1ddfe21..209f96449cd 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 = float2::safe_divide(pos, scale[i]);
+ pos = math::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 = float2::safe_divide(pos, scale[i]);
+ pos = math::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 = float2::safe_divide(pos, scale[i]);
+ pos = math::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] = float3::safe_divide(r_position[i], scale[i]);
+ r_position[i] = math::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] = float3::safe_divide(r_position[i], scale[i]);
+ r_position[i] = math::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] = float3::safe_divide(r_position[i], scale[i]);
+ r_position[i] = math::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 = float4::safe_divide(pos, scale[i]);
+ pos = math::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 = float4::safe_divide(pos, scale[i]);
+ pos = math::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 = float4::safe_divide(pos, scale[i]);
+ pos = math::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 = float2::safe_divide(pos, scale[i]);
+ pos = math::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 = float2::safe_divide(pos, scale[i]);
+ pos = math::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 = float2::safe_divide(pos, scale[i]);
+ pos = math::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] = float3::safe_divide(r_position[i], scale[i]);
+ r_position[i] = math::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] = float3::safe_divide(r_position[i], scale[i]);
+ r_position[i] = math::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] = float3::safe_divide(r_position[i], scale[i]);
+ r_position[i] = math::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 = float4::safe_divide(pos, scale[i]);
+ pos = math::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 = float4::safe_divide(pos, scale[i]);
+ pos = math::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 = float4::safe_divide(pos, scale[i]);
+ pos = math::safe_divide(pos, scale[i]);
if (calc_position) {
r_position[i] = float3(pos.x, pos.y, pos.z);
}