33 .description(
"Mesh whose elements are converted to points");
36 .evaluated_geometry_field()
39 .evaluated_geometry_field()
45 .evaluated_geometry_field();
69 if (
mesh ==
nullptr) {
73 const int domain_size =
mesh->attributes().domain_size(domain);
74 if (domain_size == 0) {
85 evaluator.
add(position_field);
86 evaluator.
add(radius_field);
96 const bool share_arrays = selection.
size() == domain_size;
97 const bool share_position = share_arrays && positions_eval.
is_span() &&
99 mesh->vert_positions().data();
102 if (share_position) {
107 pointcloud->attributes_for_write().add<
float3>(
"position", AttrDomain::Point,
init);
117 if (
const std::optional<float> radius = radii.
get_if_single()) {
122 "radius", AttrDomain::Point);
133 if (
ELEM(src_name,
"position",
"radius",
".select_edge",
".select_poly")) {
145 const StringRef dst_name = src_name ==
".select_vert" ?
".selection" : src_name;
150 dst_attributes.
add(dst_name, AttrDomain::Point, data_type,
init);
158 dst_attributes.
add(dst_name, AttrDomain::Point, data_type,
init);
162 dst_name, AttrDomain::Point, data_type);
225 params.
set_output(
"Points"_ustr, std::move(geometry_set));
235 "Create a point in the point cloud for each selected vertex"},
240 "Create a point in the point cloud for each selected edge"},
245 "Create a point in the point cloud for each selected face"},
250 "Create a point in the point cloud for each selected face corner"},
251 {0,
nullptr, 0,
nullptr,
nullptr},
270 ntype.
ui_name =
"Mesh to Points";
271 ntype.
ui_description =
"Generate a point cloud from a mesh's vertices";
Generic geometry attributes built on CustomData.
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_MESH_TO_POINTS
General operations for point clouds.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
CommonVArrayInfo common_info() const
const CPPType & type() const
std::optional< T > get_if_single() const
Span< T > get_internal_span() const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader lookup(const StringRef name) const
bool is_builtin(const StringRef name) const
GAttributeReader get() const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, 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 FieldOperationPtr from(std::shared_ptr< const mf::MultiFunction > fn, Vector< GField > inputs)
NodeAttributeFilter get_attribute_filter(const UString output_identifier) const
T extract_input(const UString identifier)
const bNode & node() const
void set_output(const UString identifier, T &&value)
#define storage(slot, qualifiers)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
PointCloud * pointcloud_new_no_attributes(PointCloudType type, int totpoint)
void node_register_type(bNodeType &ntype)
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))
const MultiFunction & lookup(UString id)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
static void node_register()
static void node_init(bNodeTree *, bNode *node)
static void node_rna(StructRNA *srna)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
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)
BMesh const char void * data
@ NODE_DEFAULT_INPUT_POSITION_FIELD
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
PointCloud * BKE_pointcloud_new_nomain(PointCloudType type, int totpoint)
void node_free_standard_storage(bNode *node)
VecBase< float, 3 > float3
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GeometryNodeMeshToPointsMode
@ GEO_NODE_MESH_TO_POINTS_FACES
@ GEO_NODE_MESH_TO_POINTS_EDGES
@ GEO_NODE_MESH_TO_POINTS_CORNERS
@ GEO_NODE_MESH_TO_POINTS_VERTICES
bool allow_skip(const StringRef name) const
const ImplicitSharingInfo * sharing_info
const ImplicitSharingInfo * sharing_info
void keep_only(Span< GeometryComponent::Type > component_types)
void replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const Mesh * get_mesh() const
MutableVArraySpan< T > span
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)