23 b.add_input<
decl::Vector>(
"Vector").default_value({0.0, 0.0, 1.0});
39 const float3 local_main_axis,
42 mask.foreach_index([&](
const int64_t i) {
45 output_rotations[i] = input_rotations[i];
49 float old_rotation[3][3];
52 mul_v3_m3v3(old_axis, old_rotation, local_main_axis);
66 const float angle = factors[i] * full_angle;
71 float new_rotation_matrix[3][3];
72 mul_m3_m3m3(new_rotation_matrix, rotation, old_rotation);
77 output_rotations[i] = new_rotation;
85 const float3 local_main_axis,
86 const float3 local_pivot_axis,
89 mask.foreach_index([&](
const int64_t i) {
90 if (local_main_axis == local_pivot_axis) {
92 output_rotations[i] = input_rotations[i];
98 output_rotations[i] = input_rotations[i];
102 float old_rotation[3][3];
105 mul_v3_m3v3(old_axis, old_rotation, local_main_axis);
107 mul_v3_m3v3(pivot_axis, old_rotation, local_pivot_axis);
110 if (full_angle >
M_PI) {
112 full_angle -= 2.0f *
M_PI;
114 const float angle = factors[i] * full_angle;
116 float rotation[3][3];
119 float new_rotation_matrix[3][3];
120 mul_m3_m3m3(new_rotation_matrix, rotation, old_rotation);
125 output_rotations[i] = new_rotation;
132 int pivot_axis_mode_;
136 : main_axis_mode_(main_axis_mode), pivot_axis_mode_(pivot_axis_mode)
141 builder.single_input<
float3>(
"Rotation");
142 builder.single_input<
float>(
"Factor");
143 builder.single_input<
float3>(
"Vector");
144 builder.single_output<
float3>(
"Rotation");
156 auto output_rotations =
params.uninitialized_single_output<
float3>(3,
"Rotation");
158 float3 local_main_axis = {0.0f, 0.0f, 0.0f};
159 local_main_axis[main_axis_mode_] = 1;
163 mask, input_rotations, vectors, factors, local_main_axis, output_rotations);
166 float3 local_pivot_axis = {0.0f, 0.0f, 0.0f};
167 local_pivot_axis[pivot_axis_mode_ - 1] = 1;
199 "Align the X axis with the vector"},
204 "Align the Y axis with the vector"},
209 "Align the Z axis with the vector"},
210 {0,
nullptr, 0,
nullptr,
nullptr},
218 "Automatically detect the best rotation axis to rotate towards the vector"},
223 "Rotate around the local X axis"},
228 "Rotate around the local Y axis"},
233 "Rotate around the local Z axis"},
234 {0,
nullptr, 0,
nullptr,
nullptr},
240 "Axis to align to the vector",
250 "Axis to rotate around",
#define NODE_CLASS_CONVERTER
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void eul_to_mat3(float mat[3][3], const float eul[3])
void mat3_to_eul(float eul[3], const float mat[3][3])
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3]) ATTR_WARN_UNUSED_RESULT
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
@ FN_NODE_ALIGN_EULER_TO_VECTOR_AXIS_Z
@ FN_NODE_ALIGN_EULER_TO_VECTOR_AXIS_Y
@ FN_NODE_ALIGN_EULER_TO_VECTOR_AXIS_X
@ FN_NODE_ALIGN_EULER_TO_VECTOR_PIVOT_AXIS_Y
@ FN_NODE_ALIGN_EULER_TO_VECTOR_PIVOT_AXIS_AUTO
@ FN_NODE_ALIGN_EULER_TO_VECTOR_PIVOT_AXIS_X
@ FN_NODE_ALIGN_EULER_TO_VECTOR_PIVOT_AXIS_Z
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
const Signature & signature() const
void set_signature(const Signature *signature)
void construct_and_set_matching_fn(Args &&...args)
ExecutionHints get_execution_hints() const override
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
MF_AlignEulerToVector(int main_axis_mode, int pivot_axis_mode)
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
VecBase< float, 3 > cross_high_precision(const VecBase< float, 3 > &a, const VecBase< float, 3 > &b)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_register()
static void align_rotations_fixed_pivot(const IndexMask &mask, const VArray< float3 > &input_rotations, const VArray< float3 > &vectors, const VArray< float > &factors, const float3 local_main_axis, const float3 local_pivot_axis, MutableSpan< float3 > output_rotations)
static void align_rotations_auto_pivot(const IndexMask &mask, const VArray< float3 > &input_rotations, const VArray< float3 > &vectors, const VArray< float > &factors, const float3 local_main_axis, MutableSpan< float3 > output_rotations)
static void node_declare(NodeDeclarationBuilder &b)
static void node_rna(StructRNA *srna)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
VecBase< float, 3 > float3
void fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
NodeMultiFunctionBuildFunction build_multi_function
const char * deprecation_notice
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare