21 b.use_custom_socket_order();
22 b.allow_any_socket_order();
23 b.add_default_layout();
48 const float3 local_main_axis,
55 output_rotations[
i] = old_rotation;
73 const float angle = factors[
i] * full_angle;
84 const float3 local_main_axis,
85 const float3 local_pivot_axis,
90 if (local_main_axis == local_pivot_axis) {
92 output_rotations[
i] = old_rotation;
98 output_rotations[
i] = old_rotation;
106 if (full_angle >
M_PI) {
108 full_angle -= 2.0f *
M_PI;
110 const float angle = factors[
i] * full_angle;
124 : main_axis_mode_(main_axis_mode), pivot_axis_mode_(pivot_axis_mode)
126 static const mf::Signature
signature = []() {
128 mf::SignatureBuilder builder{
"Align Rotation to Vector",
signature};
130 builder.single_input<
float>(
"Factor");
131 builder.single_input<
float3>(
"Vector");
147 float3 local_main_axis = {0.0f, 0.0f, 0.0f};
148 local_main_axis[main_axis_mode_.as_int()] = 1.0f;
152 mask, input_rotations, vectors, factors, local_main_axis, output_rotations);
155 float3 local_pivot_axis = {0.0f, 0.0f, 0.0f};
156 local_pivot_axis[pivot_axis_mode_ - 1] = 1;
185 {int(
math::Axis::X),
"X", ICON_NONE,
"X",
"Align the X axis with the vector"},
186 {int(
math::Axis::Y),
"Y", ICON_NONE,
"Y",
"Align the Y axis with the vector"},
187 {int(
math::Axis::Z),
"Z", ICON_NONE,
"Z",
"Align the Z axis with the vector"},
188 {0,
nullptr, 0,
nullptr,
nullptr},
194 "Axis to align to the vector",
203 "Automatically detect the best rotation axis to rotate towards the vector"},
208 "Rotate around the local X axis"},
213 "Rotate around the local Y axis"},
218 "Rotate around the local Z axis"},
219 {0,
nullptr, 0,
nullptr,
nullptr},
225 "Axis to rotate around",
235 ntype.
ui_name =
"Align Rotation to Vector";
236 ntype.
ui_description =
"Orient a rotation along the given direction";
#define NODE_CLASS_CONVERTER
#define FN_NODE_ALIGN_ROTATION_TO_VECTOR
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
NodeAlignEulerToVectorPivotAxis
@ 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
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
const Signature & signature() const
void set_signature(const Signature *signature)
static constexpr Axis from_int(const int axis_int)
void construct_and_set_matching_fn(Args &&...args)
void call(const IndexMask &mask, mf::Params params, mf::Context) const final
ExecutionHints get_execution_hints() const final
AlignRotationToVectorFunction(const math::Axis main_axis_mode, const NodeAlignEulerToVectorPivotAxis pivot_axis_mode)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void node_register_type(bNodeType &ntype)
QuaternionBase< float > Quaternion
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
VecBase< float, 3 > cross_high_precision(const VecBase< float, 3 > &a, const VecBase< float, 3 > &b)
AxisAngleBase< float, AngleRadianBase< float > > AxisAngle
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
static void node_init(bNodeTree *, bNode *node)
static void align_rotations_auto_pivot(const IndexMask &mask, const VArray< math::Quaternion > &input_rotations, const VArray< float3 > &vectors, const VArray< float > &factors, const float3 local_main_axis, MutableSpan< math::Quaternion > output_rotations)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_register()
static void align_rotations_fixed_pivot(const IndexMask &mask, const VArray< math::Quaternion > &input_rotations, const VArray< float3 > &vectors, const VArray< float > &factors, const float3 local_main_axis, const float3 local_pivot_axis, MutableSpan< math::Quaternion > output_rotations)
static void node_rna(StructRNA *srna)
static void node_declare(NodeDeclarationBuilder &b)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
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, std::string idname, const std::optional< int16_t > legacy_type)
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void use_property_decorate_set(bool is_sep)
void use_property_split_set(bool value)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)