Commit: e543c9ad323e1073fff648513f71f5b5d2a01132 Author: Jacques Lucke Date: Fri Feb 14 11:40:02 2020 +0100 Branches: functions https://developer.blender.org/rBe543c9ad323e1073fff648513f71f5b5d2a01132
add global sin and cos functions =================================================================== M source/blender/functions/intern/multi_functions/global_functions.cc M source/blender/functions/intern/multi_functions/global_functions.h M source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc =================================================================== diff --git a/source/blender/functions/intern/multi_functions/global_functions.cc b/source/blender/functions/intern/multi_functions/global_functions.cc index 31d2f667a34..a8b304020cd 100644 --- a/source/blender/functions/intern/multi_functions/global_functions.cc +++ b/source/blender/functions/intern/multi_functions/global_functions.cc @@ -7,6 +7,8 @@ const MultiFunction *MF_GLOBAL_add_floats_2 = nullptr; const MultiFunction *MF_GLOBAL_multiply_floats_2 = nullptr; const MultiFunction *MF_GLOBAL_subtract_floats = nullptr; const MultiFunction *MF_GLOBAL_safe_division_floats = nullptr; +const MultiFunction *MF_GLOBAL_sin_float = nullptr; +const MultiFunction *MF_GLOBAL_cos_float = nullptr; void init_global_functions() { @@ -20,6 +22,11 @@ void init_global_functions() "safe divide 2 floats", [](float a, float b) { return (b != 0.0f) ? a / b : 0.0f; }, BLI_RAND_PER_LINE_UINT32); + + MF_GLOBAL_sin_float = new MF_Custom_In1_Out1<float, float>( + "sin float", [](float a) { return std::sin(a); }, BLI_RAND_PER_LINE_UINT32); + MF_GLOBAL_cos_float = new MF_Custom_In1_Out1<float, float>( + "cos float", [](float a) { return std::cos(a); }, BLI_RAND_PER_LINE_UINT32); } void free_global_functions() @@ -28,6 +35,8 @@ void free_global_functions() delete MF_GLOBAL_multiply_floats_2; delete MF_GLOBAL_subtract_floats; delete MF_GLOBAL_safe_division_floats; + delete MF_GLOBAL_sin_float; + delete MF_GLOBAL_cos_float; } } // namespace FN diff --git a/source/blender/functions/intern/multi_functions/global_functions.h b/source/blender/functions/intern/multi_functions/global_functions.h index 6a77ec16621..a36894085d1 100644 --- a/source/blender/functions/intern/multi_functions/global_functions.h +++ b/source/blender/functions/intern/multi_functions/global_functions.h @@ -11,5 +11,7 @@ extern const MultiFunction *MF_GLOBAL_add_floats_2; extern const MultiFunction *MF_GLOBAL_multiply_floats_2; extern const MultiFunction *MF_GLOBAL_subtract_floats; extern const MultiFunction *MF_GLOBAL_safe_division_floats; +extern const MultiFunction *MF_GLOBAL_sin_float; +extern const MultiFunction *MF_GLOBAL_cos_float; } // namespace FN diff --git a/source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc index 0fc10e0a52b..b46babc4e11 100644 --- a/source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc +++ b/source/blender/functions/intern/node_tree_multi_function_network/mappings_nodes.cc @@ -170,6 +170,11 @@ static void build_math_fn_in1_out1(FNodeMFBuilder &builder, {"use_list"}, builder.fnode().name(), func, operation_hash); } +static void build_math_fn_in1_out1(FNodeMFBuilder &builder, const MultiFunction &base_fn) +{ + builder.set_vectorized_matching_fn({"use_list"}, base_fn); +} + template<typename InT1, typename InT2, typename OutT, typename FuncT> static void build_math_fn_in2_out1(FNodeMFBuilder &builder, FuncT element_func, @@ -270,14 +275,12 @@ static void INSERT_abs_float(FNodeMFBuilder &builder) static void INSERT_sine_float(FNodeMFBuilder &builder) { - build_math_fn_in1_out1<float, float>( - builder, [](float a) -> float { return std::sin(a); }, BLI_RAND_PER_LINE_UINT32); + build_math_fn_in1_out1(builder, *MF_GLOBAL_sin_float); } static void INSERT_cosine_float(FNodeMFBuilder &builder) { - build_math_fn_in1_out1<float, float>( - builder, [](float a) -> float { return std::cos(a); }, BLI_RAND_PER_LINE_UINT32); + build_math_fn_in1_out1(builder, *MF_GLOBAL_cos_float); } static void INSERT_ceil_float(FNodeMFBuilder &builder) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs