Differential D12689 Diff 42665 source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | static void geo_node_point_distribute_points_on_faces_declare(NodeDeclarationBuilder &b) | ||||
| b.add_input<decl::Geometry>("Geometry"); | b.add_input<decl::Geometry>("Geometry"); | ||||
| b.add_input<decl::Float>("Distance Min").min(0.0f).subtype(PROP_DISTANCE); | b.add_input<decl::Float>("Distance Min").min(0.0f).subtype(PROP_DISTANCE); | ||||
| b.add_input<decl::Float>("Density Max").default_value(10.0f).min(0.0f); | b.add_input<decl::Float>("Density Max").default_value(10.0f).min(0.0f); | ||||
| b.add_input<decl::Float>("Density").default_value(10.0f).supports_field(); | b.add_input<decl::Float>("Density").default_value(10.0f).supports_field(); | ||||
| b.add_input<decl::Float>("Density Factor") | b.add_input<decl::Float>("Density Factor") | ||||
| .default_value(1.0f) | .default_value(1.0f) | ||||
| .min(0.0f) | .min(0.0f) | ||||
| .max(1.0f) | .max(1.0f) | ||||
| .subtype(PROP_FACTOR) | |||||
| .supports_field(); | .supports_field(); | ||||
| b.add_input<decl::Int>("Seed"); | b.add_input<decl::Int>("Seed"); | ||||
| b.add_input<decl::Bool>("Selection").default_value(true).hide_value().supports_field(); | b.add_input<decl::Bool>("Selection").default_value(true).hide_value().supports_field(); | ||||
| b.add_output<decl::Geometry>("Points"); | b.add_output<decl::Geometry>("Points"); | ||||
| b.add_output<decl::Vector>("Normal").field_source(); | b.add_output<decl::Vector>("Normal").field_source(); | ||||
| b.add_output<decl::Vector>("Rotation").subtype(PROP_EULER).field_source(); | b.add_output<decl::Vector>("Rotation").subtype(PROP_EULER).field_source(); | ||||
| b.add_output<decl::Int>("Stable ID").field_source(); | b.add_output<decl::Int>("Stable ID").field_source(); | ||||
| ▲ Show 20 Lines • Show All 457 Lines • ▼ Show 20 Lines | static void point_distribution_calculate(GeometrySet &geometry_set, | ||||
| /* Position is set separately. */ | /* Position is set separately. */ | ||||
| attributes.remove("position"); | attributes.remove("position"); | ||||
| propagate_existing_attributes( | propagate_existing_attributes( | ||||
| mesh_component, attributes, point_component, bary_coords, looptri_indices); | mesh_component, attributes, point_component, bary_coords, looptri_indices); | ||||
| compute_attribute_outputs( | compute_attribute_outputs( | ||||
| mesh_component, point_component, bary_coords, looptri_indices, attribute_outputs); | mesh_component, point_component, bary_coords, looptri_indices, attribute_outputs); | ||||
| geometry_set.replace_mesh(nullptr); | |||||
| } | } | ||||
| static void geo_node_point_distribute_points_on_faces_exec(GeoNodeExecParams params) | static void geo_node_point_distribute_points_on_faces_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| const GeometryNodeDistributePointsOnFacesMode method = | const GeometryNodeDistributePointsOnFacesMode method = | ||||
| static_cast<GeometryNodeDistributePointsOnFacesMode>(params.node().custom1); | static_cast<GeometryNodeDistributePointsOnFacesMode>(params.node().custom1); | ||||
| Show All 10 Lines | static void geo_node_point_distribute_points_on_faces_exec(GeoNodeExecParams params) | ||||
| } | } | ||||
| if (params.output_is_required("Stable ID")) { | if (params.output_is_required("Stable ID")) { | ||||
| attribute_outputs.stable_id_id = StrongAnonymousAttributeID("stable id"); | attribute_outputs.stable_id_id = StrongAnonymousAttributeID("stable id"); | ||||
| } | } | ||||
| geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { | ||||
| point_distribution_calculate( | point_distribution_calculate( | ||||
| geometry_set, selection_field, method, seed, attribute_outputs, params); | geometry_set, selection_field, method, seed, attribute_outputs, params); | ||||
| /* Keep instances because the original geometry set may contain instances that are processed as | |||||
| * well. */ | |||||
| geometry_set.keep_only({GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_INSTANCES}); | |||||
| }); | }); | ||||
| params.set_output("Points", std::move(geometry_set)); | params.set_output("Points", std::move(geometry_set)); | ||||
| if (attribute_outputs.normal_id) { | if (attribute_outputs.normal_id) { | ||||
| params.set_output( | params.set_output( | ||||
| "Normal", | "Normal", | ||||
| AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.normal_id))); | AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.normal_id))); | ||||
| Show All 31 Lines | |||||