Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
| Show All 14 Lines | |||||
| */ | */ | ||||
| #include "BLI_task.hh" | #include "BLI_task.hh" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_rotate_instances_cc { | namespace blender::nodes::node_geo_rotate_instances_cc { | ||||
| static void geo_node_rotate_instances_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Instances")).only_instances(); | b.add_input<decl::Geometry>(N_("Instances")).only_instances(); | ||||
| b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | ||||
| b.add_input<decl::Vector>(N_("Rotation")).subtype(PROP_EULER).supports_field(); | b.add_input<decl::Vector>(N_("Rotation")).subtype(PROP_EULER).supports_field(); | ||||
| b.add_input<decl::Vector>(N_("Pivot Point")).subtype(PROP_TRANSLATION).supports_field(); | b.add_input<decl::Vector>(N_("Pivot Point")).subtype(PROP_TRANSLATION).supports_field(); | ||||
| b.add_input<decl::Bool>(N_("Local Space")).default_value(true).supports_field(); | b.add_input<decl::Bool>(N_("Local Space")).default_value(true).supports_field(); | ||||
| b.add_output<decl::Geometry>(N_("Instances")); | b.add_output<decl::Geometry>(N_("Instances")); | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | for (const int i_selection : range) { | ||||
| /* Perform the actual rotation. */ | /* Perform the actual rotation. */ | ||||
| mul_m4_m4_pre(instance_transform.values, rotation_matrix.values); | mul_m4_m4_pre(instance_transform.values, rotation_matrix.values); | ||||
| /* Undo the pivot shifting done before. */ | /* Undo the pivot shifting done before. */ | ||||
| add_v3_v3(instance_transform.values[3], used_pivot); | add_v3_v3(instance_transform.values[3], used_pivot); | ||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| static void geo_node_rotate_instances_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Instances"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Instances"); | ||||
| if (geometry_set.has_instances()) { | if (geometry_set.has_instances()) { | ||||
| InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); | InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); | ||||
| rotate_instances(params, instances); | rotate_instances(params, instances); | ||||
| } | } | ||||
| params.set_output("Instances", std::move(geometry_set)); | params.set_output("Instances", std::move(geometry_set)); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_rotate_instances_cc | } // namespace blender::nodes::node_geo_rotate_instances_cc | ||||
| void register_node_type_geo_rotate_instances() | void register_node_type_geo_rotate_instances() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_rotate_instances_cc; | namespace file_ns = blender::nodes::node_geo_rotate_instances_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base( | ||||
| &ntype, GEO_NODE_ROTATE_INSTANCES, "Rotate Instances", NODE_CLASS_GEOMETRY, 0); | &ntype, GEO_NODE_ROTATE_INSTANCES, "Rotate Instances", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_rotate_instances_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.declare = file_ns::geo_node_rotate_instances_declare; | ntype.declare = file_ns::node_declare; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||