12 b.add_input<
decl::Bool>(
N_(
"Selection")).default_value(
true).hide_value().supports_field();
15 b.add_input<
decl::Bool>(
N_(
"Local Space")).default_value(
true).supports_field();
31 const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
34 const VArray<bool> local_spaces = evaluator.get_evaluated<
bool>(2);
39 for (const int i_selection : range) {
40 const int i = selection[i_selection];
41 const float3 pivot = pivots[i];
42 const float3 euler = rotations[i];
43 float4x4 &instance_transform = instance_transforms[i];
45 float4x4 rotation_matrix;
48 if (local_spaces[i]) {
50 const float3 rotation_axis_x = instance_transform.values[0];
51 const float3 rotation_axis_y = instance_transform.values[1];
52 const float3 rotation_axis_z = instance_transform.values[2];
56 float rotation_x[3][3], rotation_y[3][3], rotation_z[3][3];
57 axis_angle_to_mat3(rotation_x, rotation_axis_x, euler.x);
58 axis_angle_to_mat3(rotation_y, rotation_axis_y, euler.y);
59 axis_angle_to_mat3(rotation_z, rotation_axis_z, euler.z);
63 mul_m3_series(rotation, rotation_z, rotation_y, rotation_x);
64 copy_m4_m3(rotation_matrix.values, rotation);
67 used_pivot = instance_transform * pivot;
71 eul_to_mat4(rotation_matrix.values, euler);
74 sub_v3_v3(instance_transform.values[3], used_pivot);
76 mul_m4_m4_pre(instance_transform.values, rotation_matrix.values);
78 add_v3_v3(instance_transform.values[3], used_pivot);
90 params.set_output(
"Instances", std::move(geometry_set));
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_ROTATE_INSTANCES
void nodeRegisterType(struct bNodeType *ntype)
blender::MutableSpan< blender::float4x4 > instance_transforms()
int instances_num() const
IndexRange index_range() const
static int domain_num(const CurvesGeometry &curves, const eAttrDomain domain)
static void rotate_instances(GeoNodeExecParams ¶ms, InstancesComponent &instances_component)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
MutableSpan< float3 > rotations
void register_node_type_geo_rotate_instances()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
bool has_instances() const
NodeGeometryExecFunction geometry_node_execute
NodeDeclareFunction declare