32 .supported_type(GeometryComponent::Type::Mesh)
33 .description(
"Mesh whose elements are converted to points");
64 if (mesh ==
nullptr) {
65 geometry_set.
keep_only({GeometryComponent::Type::Edit});
68 const int domain_size = mesh->
attributes().domain_size(domain);
69 if (domain_size == 0) {
70 geometry_set.
keep_only({GeometryComponent::Type::Edit});
80 evaluator.
add(position_field);
81 evaluator.
add(radius_field);
87 const bool share_arrays = selection.
size() == domain_size;
88 const bool share_position = share_arrays && positions_eval.
is_span() &&
90 mesh->vert_positions().data();
98 pointcloud->attributes_for_write().add<
float3>(
"position", AttrDomain::Point,
init);
107 "radius", AttrDomain::Point);
113 GeometryComponent::Type::PointCloud,
118 for (
const int i : attributes.
names.index_range()) {
119 if (
ELEM(attributes.
names[
i],
"position",
"radius")) {
133 dst_attributes.
add(attribute_id, AttrDomain::Point, data_type,
init);
137 attribute_id, AttrDomain::Point, data_type);
144 geometry_set.
keep_only({GeometryComponent::Type::PointCloud, GeometryComponent::Type::Edit});
156 static auto max_zero_fn = mf::build::SI1_SO<float, float>(
158 [](
float value) {
return std::max(0.0f, value); },
159 mf::build::exec_presets::AllSpanOrSingle());
204 params.set_output(
"Points", std::move(geometry_set));
214 "Create a point in the point cloud for each selected vertex"},
219 "Create a point in the point cloud for each selected edge"},
224 "Create a point in the point cloud for each selected face"},
229 "Create a point in the point cloud for each selected face corner"},
230 {0,
nullptr, 0,
nullptr,
nullptr},
249 ntype.
ui_name =
"Mesh to Points";
250 ntype.
ui_description =
"Generate a point cloud from a mesh's vertices";
CustomData interface, see also DNA_customdata_types.h.
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_MESH_TO_POINTS
General operations for point clouds.
PointCloud * BKE_pointcloud_new_nomain(int totpoint)
@ NODE_DEFAULT_INPUT_POSITION_FIELD
GeometryNodeMeshToPointsMode
@ GEO_NODE_MESH_TO_POINTS_FACES
@ GEO_NODE_MESH_TO_POINTS_VERTICES
@ GEO_NODE_MESH_TO_POINTS_CORNERS
@ GEO_NODE_MESH_TO_POINTS_EDGES
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
BMesh const char void * data
const void * data() const
GSpan get_internal_span() const
Span< T > get_internal_span() const
GAttributeReader lookup(const StringRef attribute_id) const
bool add(const StringRef attribute_id, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id, AttrDomain domain, AttrType data_type)
void set_selection(Field< bool > selection)
int add(GField field, GVArray *varray_ptr)
IndexMask get_evaluated_selection_as_mask() const
const GVArray & get_evaluated(const int field_index) const
static std::shared_ptr< FieldOperation > from(std::shared_ptr< const mf::MultiFunction > function, Vector< GField > inputs={})
void * MEM_callocN(size_t len, const char *str)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
void node_register_type(bNodeType &ntype)
PointCloud * pointcloud_new_no_attributes(int totpoint)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
static void node_register()
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_init(bNodeTree *, bNode *node)
static void node_rna(StructRNA *srna)
static void node_declare(NodeDeclarationBuilder &b)
static void geometry_set_mesh_to_points(GeometrySet &geometry_set, const Field< float3 > &position_field, const Field< float > &radius_field, const Field< bool > &selection_field, const AttrDomain domain, const AttributeFilter &attribute_filter)
static void node_geo_exec(GeoNodeExecParams params)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
VecBase< float, 3 > float3
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
static void init(bNodeTree *, bNode *node)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
const ImplicitSharingInfo * sharing_info
const ImplicitSharingInfo * sharing_info
Vector< AttributeDomainAndType, 16 > kinds
VectorSet< StringRef, 16 > names
void keep_only(Span< GeometryComponent::Type > component_types)
void replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void gather_attributes_for_propagation(Span< GeometryComponent::Type > component_types, GeometryComponent::Type dst_component_type, bool include_instances, const AttributeFilter &attribute_filter, GatheredAttributes &r_attributes) const
const Mesh * get_mesh() const
MutableVArraySpan< T > span
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)