Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc
| Show All 13 Lines | |||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_instance_on_points_cc { | namespace blender::nodes::node_geo_instance_on_points_cc { | ||||
| static void node_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Points")).description(N_("Points to instance on")); | b.add_input<decl::Geometry>(N_("Points")).description(N_("Points to instance on")); | ||||
| b.add_input<decl::Bool>(N_("Selection")).default_value(true).supports_field().hide_value(); | b.add_input<decl::Bool>(N_("Selection")).default_value(true).field_on_auto().hide_value(); | ||||
| b.add_input<decl::Geometry>(N_("Instance")) | b.add_input<decl::Geometry>(N_("Instance")) | ||||
| .description(N_("Geometry that is instanced on the points")); | .description(N_("Geometry that is instanced on the points")); | ||||
| b.add_input<decl::Bool>(N_("Pick Instance")) | b.add_input<decl::Bool>(N_("Pick Instance")) | ||||
| .supports_field() | .field_on_auto() | ||||
| .description(N_("Choose instances from the \"Instance\" input at each point instead of " | .description(N_("Choose instances from the \"Instance\" input at each point instead of " | ||||
| "instancing the entire geometry")); | "instancing the entire geometry")); | ||||
| b.add_input<decl::Int>(N_("Instance Index")) | b.add_input<decl::Int>(N_("Instance Index")) | ||||
| .implicit_field(implicit_field_inputs::id_or_index) | .implicit_field(implicit_field_inputs::id_or_index) | ||||
| .description( | .description( | ||||
| N_("Index of the instance used for each point. This is only used when Pick Instances " | N_("Index of the instance used for each point. This is only used when Pick Instances " | ||||
| "is on. By default the point index is used")); | "is on. By default the point index is used")); | ||||
| b.add_input<decl::Vector>(N_("Rotation")) | b.add_input<decl::Vector>(N_("Rotation")) | ||||
| .subtype(PROP_EULER) | .subtype(PROP_EULER) | ||||
| .supports_field() | .field_on_auto() | ||||
| .description(N_("Rotation of the instances")); | .description(N_("Rotation of the instances")); | ||||
| b.add_input<decl::Vector>(N_("Scale")) | b.add_input<decl::Vector>(N_("Scale")) | ||||
| .default_value({1.0f, 1.0f, 1.0f}) | .default_value({1.0f, 1.0f, 1.0f}) | ||||
| .subtype(PROP_XYZ) | .subtype(PROP_XYZ) | ||||
| .supports_field() | .field_on_auto() | ||||
| .description(N_("Scale of the instances")); | .description(N_("Scale of the instances")); | ||||
| b.add_output<decl::Geometry>(N_("Instances")); | b.add_output<decl::Geometry>(N_("Instances")).propagate_from_auto(); | ||||
| } | } | ||||
| static void add_instances_from_component( | static void add_instances_from_component( | ||||
| bke::Instances &dst_component, | bke::Instances &dst_component, | ||||
| const GeometryComponent &src_component, | const GeometryComponent &src_component, | ||||
| const GeometrySet &instance, | const GeometrySet &instance, | ||||
| const GeoNodeExecParams ¶ms, | const GeoNodeExecParams ¶ms, | ||||
| const Map<AttributeIDRef, AttributeKind> &attributes_to_propagate) | const Map<AttributeIDRef, AttributeKind> &attributes_to_propagate) | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | if (dst_instances == nullptr) { | ||||
| dst_instances = new bke::Instances(); | dst_instances = new bke::Instances(); | ||||
| instances_component.replace(dst_instances); | instances_component.replace(dst_instances); | ||||
| } | } | ||||
| const Array<GeometryComponentType> types{ | const Array<GeometryComponentType> types{ | ||||
| GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE}; | GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE}; | ||||
| Map<AttributeIDRef, AttributeKind> attributes_to_propagate; | Map<AttributeIDRef, AttributeKind> attributes_to_propagate; | ||||
| geometry_set.gather_attributes_for_propagation( | geometry_set.gather_attributes_for_propagation(types, | ||||
| types, GEO_COMPONENT_TYPE_INSTANCES, false, attributes_to_propagate); | GEO_COMPONENT_TYPE_INSTANCES, | ||||
| false, | |||||
| params.get_output_propagation_info("Instances"), | |||||
| attributes_to_propagate); | |||||
| attributes_to_propagate.remove("position"); | attributes_to_propagate.remove("position"); | ||||
| for (const GeometryComponentType type : types) { | for (const GeometryComponentType type : types) { | ||||
| if (geometry_set.has(type)) { | if (geometry_set.has(type)) { | ||||
| add_instances_from_component(*dst_instances, | add_instances_from_component(*dst_instances, | ||||
| *geometry_set.get_component_for_read(type), | *geometry_set.get_component_for_read(type), | ||||
| instance, | instance, | ||||
| params, | params, | ||||
| Show All 31 Lines | |||||