Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_scale_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_scale_instances_cc { | namespace blender::nodes::node_geo_scale_instances_cc { | ||||
| static void geo_node_scale_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_("Scale")) | b.add_input<decl::Vector>(N_("Scale")) | ||||
| .subtype(PROP_XYZ) | .subtype(PROP_XYZ) | ||||
| .default_value({1, 1, 1}) | .default_value({1, 1, 1}) | ||||
| .supports_field(); | .supports_field(); | ||||
| b.add_input<decl::Vector>(N_("Center")).subtype(PROP_TRANSLATION).supports_field(); | b.add_input<decl::Vector>(N_("Center")).subtype(PROP_TRANSLATION).supports_field(); | ||||
| Show All 38 Lines | for (const int i_selection : range) { | ||||
| rescale_m4(instance_transform.values, scales[i]); | rescale_m4(instance_transform.values, scales[i]); | ||||
| instance_transform *= float4x4::from_location(-pivot); | instance_transform *= float4x4::from_location(-pivot); | ||||
| instance_transform *= original_transform; | instance_transform *= original_transform; | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| static void geo_node_scale_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>(); | ||||
| scale_instances(params, instances); | scale_instances(params, instances); | ||||
| } | } | ||||
| params.set_output("Instances", std::move(geometry_set)); | params.set_output("Instances", std::move(geometry_set)); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_scale_instances_cc | } // namespace blender::nodes::node_geo_scale_instances_cc | ||||
| void register_node_type_geo_scale_instances() | void register_node_type_geo_scale_instances() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_scale_instances_cc; | namespace file_ns = blender::nodes::node_geo_scale_instances_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_SCALE_INSTANCES, "Scale Instances", NODE_CLASS_GEOMETRY, 0); | geo_node_type_base(&ntype, GEO_NODE_SCALE_INSTANCES, "Scale Instances", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_scale_instances_exec; | ntype.geometry_node_execute = file_ns::node_exec; | ||||
| ntype.declare = file_ns::geo_node_scale_instances_declare; | ntype.declare = file_ns::node_declare; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||