Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc
| Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (mesh_component == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| GeometryComponentFieldContext field_context{*mesh_component, domain}; | GeometryComponentFieldContext field_context{*mesh_component, domain}; | ||||
| const int domain_size = mesh_component->attribute_domain_size(domain); | const int domain_size = mesh_component->attribute_domain_size(domain); | ||||
| if (domain_size == 0) { | if (domain_size == 0) { | ||||
| geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES}); | geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES}); | ||||
| return; | return; | ||||
| } | } | ||||
| fn::FieldEvaluator selection_evaluator{field_context, domain_size}; | fn::FieldEvaluator evaluator{field_context, domain_size}; | ||||
| selection_evaluator.add(selection_field); | evaluator.set_selection(selection_field); | ||||
| selection_evaluator.evaluate(); | /* Evaluating directly into the point cloud doesn't work because we are not using the full | ||||
| const IndexMask selection = selection_evaluator.get_evaluated_as_mask(0); | * "min_array_size" array but compressing the selected elements into the final array with no | ||||
| * gaps. */ | |||||
| evaluator.add(position_field); | |||||
| evaluator.add(radius_field); | |||||
| evaluator.evaluate(); | |||||
| const IndexMask selection = evaluator.get_evaluated_selection_as_mask(); | |||||
| PointCloud *pointcloud = BKE_pointcloud_new_nomain(selection.size()); | PointCloud *pointcloud = BKE_pointcloud_new_nomain(selection.size()); | ||||
| uninitialized_fill_n(pointcloud->radius, pointcloud->totpoint, 0.05f); | uninitialized_fill_n(pointcloud->radius, pointcloud->totpoint, 0.05f); | ||||
| geometry_set.replace_pointcloud(pointcloud); | geometry_set.replace_pointcloud(pointcloud); | ||||
| PointCloudComponent &point_component = | PointCloudComponent &point_component = | ||||
| geometry_set.get_component_for_write<PointCloudComponent>(); | geometry_set.get_component_for_write<PointCloudComponent>(); | ||||
| /* Evaluating directly into the point cloud doesn't work because we are not using the full | |||||
| * "min_array_size" array but compressing the selected elements into the final array with no | |||||
| * gaps. */ | |||||
| fn::FieldEvaluator evaluator{field_context, &selection}; | |||||
| evaluator.add(position_field); | |||||
| evaluator.add(radius_field); | |||||
| evaluator.evaluate(); | |||||
| copy_attribute_to_points(evaluator.get_evaluated<float3>(0), | copy_attribute_to_points(evaluator.get_evaluated<float3>(0), | ||||
| selection, | selection, | ||||
| {(float3 *)pointcloud->co, pointcloud->totpoint}); | {(float3 *)pointcloud->co, pointcloud->totpoint}); | ||||
| copy_attribute_to_points( | copy_attribute_to_points( | ||||
| evaluator.get_evaluated<float>(1), selection, {pointcloud->radius, pointcloud->totpoint}); | evaluator.get_evaluated<float>(1), selection, {pointcloud->radius, pointcloud->totpoint}); | ||||
| Map<AttributeIDRef, AttributeKind> attributes; | Map<AttributeIDRef, AttributeKind> attributes; | ||||
| geometry_set.gather_attributes_for_propagation( | geometry_set.gather_attributes_for_propagation( | ||||
| ▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines | |||||