29 b.add_input<
decl::Vector>(
"Center").description(
"Point to rotate around");
35 .description(
"Axis to rotate around");
38 .
description(
"Angle to rotate the input vector by");
43 "The amount of rotation on each axis, around the X, Y, then Z axes in that order");
57 return "node_vector_rotate_axis_angle";
59 return "node_vector_rotate_axis_x";
61 return "node_vector_rotate_axis_y";
63 return "node_vector_rotate_axis_z";
65 return "node_vector_rotate_euler_xyz";
79 if (name !=
nullptr) {
122 static auto fn = mf::build::SI4_SO<float3, float3, float3, float, float3>(
129 static auto fn = mf::build::SI4_SO<float3, float3, float3, float, float3>(
139 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
145 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
154 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
160 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
169 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
175 static auto fn = mf::build::SI3_SO<float3, float3, float, float3>(
183 static auto fn = mf::build::SI3_SO<float3, float3, float3, float3>(
189 static auto fn = mf::build::SI3_SO<float3, float3, float3, float3>(
223 int mode = node_->custom1;
224 bool invert = node_->custom2;
226 NodeItem
vector = get_input_value(
"Vector", NodeItem::Type::Vector3);
227 NodeItem center = get_input_value(
"Center", NodeItem::Type::Vector3) *
228 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f));
232 NodeItem rotation = get_input_value(
"Rotation", NodeItem::Type::Vector3) *
233 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f) * 180.0f /
M_PI);
238 NodeItem
angle = get_input_value(
"Angle", NodeItem::Type::Float) * val(
float(180.0f /
M_PI));
239 NodeItem axis = empty();
242 axis = get_input_value(
"Axis", NodeItem::Type::Vector3) *
243 val(MaterialX::Vector3(1.0f, 1.0f, -1.0f));
246 axis = val(MaterialX::Vector3(1.0f, 0.0f, 0.0f));
249 axis = val(MaterialX::Vector3(0.0f, 1.0f, 0.0f));
252 axis = val(MaterialX::Vector3(0.0f, 0.0f, -1.0f));
272 ntype.
ui_name =
"Vector Rotate";
273 ntype.
ui_description =
"Rotate a vector around a pivot point (center)";
276 ntype.
declare = file_ns::sh_node_vector_rotate_declare;
277 ntype.
draw_buttons = file_ns::node_shader_buts_vector_rotate;
278 ntype.
gpu_fn = file_ns::gpu_shader_vector_rotate;
279 ntype.
updatefunc = file_ns::node_shader_update_vector_rotate;
#define NODE_CLASS_OP_VECTOR
#define SH_NODE_VECTOR_ROTATE
#define BLI_assert_unreachable()
void mul_m3_v3(const float M[3][3], float r[3])
bool invert_m3(float mat[3][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)
@ NODE_VECTOR_ROTATE_TYPE_AXIS
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Z
@ NODE_VECTOR_ROTATE_TYPE_AXIS_X
@ NODE_VECTOR_ROTATE_TYPE_EULER_XYZ
@ NODE_VECTOR_ROTATE_TYPE_AXIS_Y
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void set_matching_fn(const mf::MultiFunction *fn)
void make_available(bNode &node) const
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, StringRef identifier)
void node_register_type(bNodeType &ntype)
void node_set_socket_availability(bNodeTree &ntree, bNodeSocket &sock, bool is_available)
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(uiLayout *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)
VecBase< float, 3 > float3
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void common_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void register_node_type_sh_vector_rotate()
NodeMaterialXFunction materialx_fn
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void(* updatefunc)(bNodeTree *ntree, bNode *node)
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)