Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_translate_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_translate_instances_cc { | namespace blender::nodes::node_geo_translate_instances_cc { | ||||
| static void geo_node_translate_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_("Translation")).subtype(PROP_TRANSLATION).supports_field(); | b.add_input<decl::Vector>(N_("Translation")).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 All 23 Lines | for (const int i_selection : range) { | ||||
| } | } | ||||
| else { | else { | ||||
| add_v3_v3(instance_transforms[i].values[3], translations[i]); | add_v3_v3(instance_transforms[i].values[3], translations[i]); | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| static void geo_node_translate_instances_exec(GeoNodeExecParams params) | static void node_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>(); | ||||
| translate_instances(params, instances); | translate_instances(params, instances); | ||||
| } | } | ||||
| params.set_output("Instances", std::move(geometry_set)); | params.set_output("Instances", std::move(geometry_set)); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_translate_instances_cc | } // namespace blender::nodes::node_geo_translate_instances_cc | ||||
| void register_node_type_geo_translate_instances() | void register_node_type_geo_translate_instances() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_translate_instances_cc; | namespace file_ns = blender::nodes::node_geo_translate_instances_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base( | ||||
| &ntype, GEO_NODE_TRANSLATE_INSTANCES, "Translate Instances", NODE_CLASS_GEOMETRY, 0); | &ntype, GEO_NODE_TRANSLATE_INSTANCES, "Translate Instances", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_translate_instances_exec; | ntype.geometry_node_execute = file_ns::node_exec; | ||||
| ntype.declare = file_ns::geo_node_translate_instances_declare; | ntype.declare = file_ns::node_declare; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||