30 b.use_custom_socket_order();
31 b.allow_any_socket_order();
32 b.add_default_layout();
34 b.add_output<
decl::Vector>(
"Vector"_ustr).align_with_previous();
35 b.add_input<
decl::Vector>(
"Center"_ustr).description(
"Point to rotate around");
39 .default_value({0.0f, 0.0f, 1.0f})
41 .description(
"Axis to rotate around");
44 .
description(
"Angle to rotate the input vector by");
49 "The amount of rotation on each axis, around the X, Y, then Z axes in that order");
62 return "node_vector_rotate_axis_angle";
64 return "node_vector_rotate_axis_x";
66 return "node_vector_rotate_axis_y";
68 return "node_vector_rotate_axis_z";
70 return "node_vector_rotate_euler_xyz";
84 if (name !=
nullptr) {
122 const int mode =
node.custom1;
127 static auto fn = mf::build::SI4_SO<float3, float3, float3, float, float3>(
134 static auto fn = mf::build::SI4_SO<float3, float3, float3, float, float3>(
144 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
150 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
159 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
165 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
174 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
180 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
188 static auto fn = mf::build::SI3_SO<float3, float3, float3, float3>(
194 static auto fn = mf::build::SI3_SO<float3, float3, float3, float3>(
228 int mode = node_->custom1;
229 bool invert = node_->custom2;
231 NodeItem vector = get_input_value(
"Vector", NodeItem::Type::Vector3);
232 NodeItem center = get_input_value(
"Center", NodeItem::Type::Vector3) *
233 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f));
234 vector = vector - center;
237 NodeItem rotation = get_input_value(
"Rotation", NodeItem::Type::Vector3) *
238 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f) * 180.0f /
M_PI);
240 return vector.rotate(
invert ? -rotation : rotation,
invert) + center;
243 NodeItem
angle = get_input_value(
"Angle", NodeItem::Type::Float) * val(
float(180.0f /
M_PI));
244 NodeItem axis = empty();
247 axis = get_input_value(
"Axis", NodeItem::Type::Vector3) *
248 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f));
251 axis = val(MaterialX::Vector3(1.0f, 0.0f, 0.0f));
254 axis = val(MaterialX::Vector3(0.0f, 1.0f, 0.0f));
257 axis = val(MaterialX::Vector3(0.0f, 0.0f, -1.0f));
277 ntype.
ui_name =
"Vector Rotate";
278 ntype.
ui_description =
"Rotate a vector around a pivot point (center)";
281 ntype.
declare = file_ns::sh_node_vector_rotate_declare;
282 ntype.
draw_buttons = file_ns::node_shader_buts_vector_rotate;
283 ntype.
gpu_fn = file_ns::gpu_shader_vector_rotate;
284 ntype.
updatefunc = file_ns::node_shader_update_vector_rotate;
#define NODE_CLASS_OP_VECTOR
#define SH_NODE_VECTOR_ROTATE
#define BLI_assert_unreachable()
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
void set_matching_fn(const mf::MultiFunction *fn)
void make_available(bNode &node) const
float2x2 invert(float2x2 mat)
void node_register_type(bNodeType &ntype)
void node_set_socket_availability(bNodeTree &ntree, bNodeSocket &sock, bool is_available)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
static float3 sh_node_vector_rotate_around_axis(const float3 &vector, const float3 ¢er, const float3 &axis, const float angle)
static void sh_node_vector_rotate_declare(NodeDeclarationBuilder &b)
static void node_shader_buts_vector_rotate(ui::Layout &layout, bContext *, PointerRNA *ptr)
static const mf::MultiFunction * get_multi_function(const bNode &node)
static void sh_node_vector_rotate_build_multi_function(NodeMultiFunctionBuilder &builder)
static float3 sh_node_vector_rotate_euler(const float3 &vector, const float3 ¢er, const float3 &rotation, const bool invert)
static const char * gpu_shader_get_name(int mode)
static int gpu_shader_vector_rotate(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_update_vector_rotate(bNodeTree *ntree, bNode *node)
@ ITEM_R_SPLIT_EMPTY_NAME
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void mul_m3_v3(const float M[3][3], float r[3])
void eul_to_mat3(float mat[3][3], const float eul[3])
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
GPUNodeLink * GPU_constant(const float *num)
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Y
@ NODE_VECTOR_ROTATE_TYPE_EULER_XYZ
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Z
@ NODE_VECTOR_ROTATE_TYPE_AXIS
@ NODE_VECTOR_ROTATE_TYPE_AXIS_X
bool invert_m3(float mat[3][3])
VecBase< float, 3 > float3
void register_node_type_sh_vector_rotate()
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
NodeMaterialXFunction materialx_fn
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
void(*) updatefunc(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)