26 for (
const int i_out :
mask.index_range()) {
35 const int i_dst = index_map[i_src];
37 dst[i_dst] =
src[i_src];
64 attribute_id,
attribute.domain, data_type);
66 if (!result_attribute) {
71 using T = decltype(dummy);
104 attribute_id,
attribute.domain, data_type);
106 if (!result_attribute) {
111 using T = decltype(dummy);
116 result_attribute.
finish();
140 attribute_id,
attribute.domain, data_type);
142 if (!result_attribute) {
147 using T = decltype(dummy);
152 result_attribute.
finish();
159 const int selected_loops_num,
164 indices.reserve(selected_loops_num);
165 for (
const int src_poly_index : selected_poly_indices) {
166 const MPoly &src_poly = mesh_in.
mpoly[src_poly_index];
167 const int src_loop_start = src_poly.
loopstart;
168 const int tot_loop = src_poly.
totloop;
170 indices.append_unchecked(src_loop_start + i);
183 const int i_dst = vertex_map[i_src];
199 const int i_dst = edge_map[i_src];
200 if (
ELEM(i_dst, -1, -2)) {
221 const int i_dst = edge_map[i_src];
230 e_dst.
v1 = vertex_map[e_src.
v1];
231 e_dst.
v2 = vertex_map[e_src.
v2];
242 for (
const int i_dst : masked_poly_indices.
index_range()) {
243 const int i_src = masked_poly_indices[i_dst];
248 const int i_ml_dst = new_loop_starts[i_dst];
250 const MLoop *ml_src = src_mesh.
mloop + i_ml_src;
256 ml_dst[i].
v = ml_src[i].
v;
257 ml_dst[i].
e = edge_map[ml_src[i].
e];
268 for (
const int i_dst : masked_poly_indices.
index_range()) {
269 const int i_src = masked_poly_indices[i_dst];
274 const int i_ml_dst = new_loop_starts[i_dst];
276 const MLoop *ml_src = src_mesh.
mloop + i_ml_src;
282 ml_dst[i].
v = ml_src[i].
v;
283 ml_dst[i].
e = ml_src[i].
e;
295 for (
const int i_dst : masked_poly_indices.
index_range()) {
296 const int i_src = masked_poly_indices[i_dst];
301 const int i_ml_dst = new_loop_starts[i_dst];
303 const MLoop *ml_src = src_mesh.
mloop + i_ml_src;
309 ml_dst[i].
v = vertex_map[ml_src[i].
v];
310 ml_dst[i].
e = edge_map[ml_src[i].e];
324 evaluator.set_selection(selection_field);
325 evaluator.evaluate();
326 const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
340 curves.remove_points(selection);
343 curves.remove_curves(selection);
355 evaluator.set_selection(selection_field);
356 evaluator.evaluate();
357 const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
384 evaluator.set_selection(selection_field);
385 evaluator.evaluate();
386 const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
397 int *r_selected_vertices_num)
401 int selected_verts_num = 0;
403 if (vertex_selection[i]) {
404 r_vertex_map[i] = selected_verts_num;
405 selected_verts_num++;
408 r_vertex_map[i] = -1;
412 *r_selected_vertices_num = selected_verts_num;
418 int *r_selected_edges_num)
422 int selected_edges_num = 0;
427 if (vertex_selection[edge.v1] && vertex_selection[edge.v2]) {
428 r_edge_map[i] = selected_edges_num;
429 selected_edges_num++;
436 *r_selected_edges_num = selected_edges_num;
443 int *r_selected_polys_num,
444 int *r_selected_loops_num)
451 int selected_loops_num = 0;
455 bool all_verts_in_selection =
true;
457 for (
const MLoop &loop : loops_src) {
458 if (!vertex_selection[loop.v]) {
459 all_verts_in_selection =
false;
464 if (all_verts_in_selection) {
467 selected_loops_num += poly_src.
totloop;
471 *r_selected_polys_num = r_selected_poly_indices.
size();
472 *r_selected_loops_num = selected_loops_num;
484 int *r_selected_vertices_num,
485 int *r_selected_edges_num)
489 int selected_edges_num = 0;
490 int selected_verts_num = 0;
493 if (edge_selection[i]) {
494 r_edge_map[i] = selected_edges_num;
495 selected_edges_num++;
496 if (r_vertex_map[edge.v1] == -1) {
497 r_vertex_map[edge.v1] = selected_verts_num;
498 selected_verts_num++;
500 if (r_vertex_map[edge.v2] == -1) {
501 r_vertex_map[edge.v2] = selected_verts_num;
502 selected_verts_num++;
510 *r_selected_vertices_num = selected_verts_num;
511 *r_selected_edges_num = selected_edges_num;
520 int *r_selected_edges_num)
524 int selected_edges_num = 0;
526 if (edge_selection[i]) {
527 r_edge_map[i] = selected_edges_num;
528 selected_edges_num++;
535 *r_selected_edges_num = selected_edges_num;
546 int *r_selected_polys_num,
547 int *r_selected_loops_num)
552 int selected_loops_num = 0;
556 bool all_edges_in_selection =
true;
558 for (
const MLoop &loop : loops_src) {
559 if (!edge_selection[loop.e]) {
560 all_edges_in_selection =
false;
565 if (all_edges_in_selection) {
568 selected_loops_num += poly_src.
totloop;
572 *r_selected_polys_num = r_selected_poly_indices.
size();
573 *r_selected_loops_num = selected_loops_num;
585 int *r_selected_edges_num,
586 int *r_selected_polys_num,
587 int *r_selected_loops_num)
591 mesh, vertex_selection, r_edge_map, r_selected_edges_num);
595 r_selected_poly_indices,
597 r_selected_polys_num,
598 r_selected_loops_num);
611 int *r_selected_vertices_num,
612 int *r_selected_edges_num,
613 int *r_selected_polys_num,
614 int *r_selected_loops_num)
617 vertex_selection, r_vertex_map, r_selected_vertices_num);
620 mesh, vertex_selection, r_edge_map, r_selected_edges_num);
624 r_selected_poly_indices,
626 r_selected_polys_num,
627 r_selected_loops_num);
640 int *r_selected_edges_num,
641 int *r_selected_polys_num,
642 int *r_selected_loops_num)
645 mesh, edge_selection, r_edge_map, r_selected_edges_num);
648 r_selected_poly_indices,
650 r_selected_polys_num,
651 r_selected_loops_num);
664 int *r_selected_vertices_num,
665 int *r_selected_edges_num,
666 int *r_selected_polys_num,
667 int *r_selected_loops_num)
669 r_vertex_map.
fill(-1);
674 r_selected_vertices_num,
675 r_selected_edges_num);
678 r_selected_poly_indices,
680 r_selected_polys_num,
681 r_selected_loops_num);
691 int *r_selected_polys_num,
692 int *r_selected_loops_num)
699 int selected_loops_num = 0;
703 if (poly_selection[i]) {
706 selected_loops_num += poly_src.
totloop;
709 *r_selected_polys_num = r_selected_poly_indices.
size();
710 *r_selected_loops_num = selected_loops_num;
722 int *r_selected_edges_num,
723 int *r_selected_polys_num,
724 int *r_selected_loops_num)
733 int selected_loops_num = 0;
734 int selected_edges_num = 0;
738 if (poly_selection[i]) {
741 selected_loops_num += poly_src.
totloop;
745 for (
const MLoop &loop : loops_src) {
747 if (r_edge_map[loop.e] == -1) {
748 r_edge_map[loop.e] = selected_edges_num;
749 selected_edges_num++;
754 *r_selected_edges_num = selected_edges_num;
755 *r_selected_polys_num = r_selected_poly_indices.
size();
756 *r_selected_loops_num = selected_loops_num;
769 int *r_selected_vertices_num,
770 int *r_selected_edges_num,
771 int *r_selected_polys_num,
772 int *r_selected_loops_num)
776 r_vertex_map.
fill(-1);
782 int selected_loops_num = 0;
783 int selected_verts_num = 0;
784 int selected_edges_num = 0;
788 if (poly_selection[i]) {
791 selected_loops_num += poly_src.
totloop;
795 for (
const MLoop &loop : loops_src) {
797 if (r_vertex_map[loop.v] == -1) {
798 r_vertex_map[loop.v] = selected_verts_num;
799 selected_verts_num++;
801 if (r_edge_map[loop.e] == -1) {
802 r_edge_map[loop.e] = selected_edges_num;
803 selected_edges_num++;
808 *r_selected_vertices_num = selected_verts_num;
809 *r_selected_edges_num = selected_edges_num;
810 *r_selected_polys_num = r_selected_poly_indices.
size();
811 *r_selected_loops_num = selected_loops_num;
826 int selected_polys_num = 0;
827 int selected_loops_num = 0;
838 int selected_verts_num = 0;
841 int selected_edges_num = 0;
850 selected_poly_indices,
855 &selected_loops_num);
862 selected_poly_indices,
867 &selected_loops_num);
874 selected_poly_indices,
879 &selected_loops_num);
896 mesh_in, *mesh_out, vertex_map, edge_map, selected_poly_indices, new_loop_starts);
918 selected_poly_indices,
924 int selected_edges_num = 0;
932 selected_poly_indices,
936 &selected_loops_num);
942 selected_poly_indices,
946 &selected_loops_num);
952 selected_poly_indices,
956 &selected_loops_num);
973 mesh_in, *mesh_out, edge_map, selected_poly_indices, new_loop_starts);
994 selected_poly_indices,
1004 selected_poly_indices,
1006 &selected_polys_num,
1007 &selected_loops_num);
1012 selected_poly_indices,
1014 &selected_polys_num,
1015 &selected_loops_num);
1020 selected_poly_indices,
1022 &selected_polys_num,
1023 &selected_loops_num);
1030 &mesh_in, mesh_in.
totvert, mesh_in.
totedge, 0, selected_loops_num, selected_polys_num);
1051 selected_poly_indices,
1071 evaluator.add(selection_field);
1072 evaluator.evaluate();
1073 const VArray<bool> selection = evaluator.get_evaluated<
bool>(0);
1082 geometry_set, *src_component.
get_for_read(), selection_span, selection_domain, mode);
1097 bool some_valid_domain =
false;
1101 some_valid_domain =
true;
1107 some_valid_domain =
true;
1114 some_valid_domain =
true;
1120 some_valid_domain =
true;
1136 .default_value(
true)
1139 .
description(
N_(
"The parts of the geometry to be deleted"));
1149 uiItemR(layout,
ptr,
"domain", 0,
"", ICON_NONE);
1152 uiItemR(layout,
ptr,
"mode", 0,
"", ICON_NONE);
1191 params.set_output(
"Geometry", std::move(geometry_set));
1205 "NodeGeometryDeleteGeometry",
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
@ GEO_COMPONENT_TYPE_MESH
@ GEO_COMPONENT_TYPE_POINT_CLOUD
struct Mesh * BKE_mesh_new_nomain_from_template(const struct Mesh *me_src, int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
void BKE_mesh_calc_edges_loose(struct Mesh *mesh)
#define GEO_NODE_DELETE_GEOMETRY
#define NODE_STORAGE_FUNCS(StorageT)
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
#define NODE_CLASS_GEOMETRY
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
void nodeRegisterType(struct bNodeType *ntype)
General operations for point clouds.
struct PointCloud * BKE_pointcloud_new_nomain(int totpoint)
#define BLI_assert_unreachable()
static uint8 component(Color32 c, uint i)
GeometryNodeDeleteGeometryMode
@ GEO_NODE_DELETE_GEOMETRY_MODE_EDGE_FACE
@ GEO_NODE_DELETE_GEOMETRY_MODE_ONLY_FACE
@ GEO_NODE_DELETE_GEOMETRY_MODE_ALL
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
int attribute_domain_size(eAttrDomain domain) const
void remove_instances(const blender::IndexMask mask)
int instances_num() const
const Mesh * get_for_read() const
const PointCloud * get_for_read() const
MutableSpan< T > typed() const
ItemIterator items() const
constexpr int64_t size() const
constexpr void fill(const T &value)
constexpr void copy_from(Span< T > values)
constexpr IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool contains(const T &value) const
T get_internal_single() const
Span< T > as_span() const
void append_unchecked(const T &value)
void reserve(const int64_t min_capacity)
GAttributeReader lookup(const AttributeIDRef &attribute_id) const
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
GSpanAttributeWriter lookup_or_add_for_write_only_span(const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type)
StringRefNull description() const
SyclQueue void void * src
ccl_gpu_kernel_postfix int ccl_global int * indices
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
void convert_to_static_type(const CPPType &cpp_type, const Func &func)
static int domain_num(const CurvesGeometry &curves, const eAttrDomain domain)
AttributeAccessor pointcloud_attributes(const PointCloud &pointcloud)
MutableAttributeAccessor pointcloud_attributes_for_write(PointCloud &pointcloud)
AttributeAccessor mesh_attributes(const Mesh &mesh)
eCustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type)
MutableAttributeAccessor mesh_attributes_for_write(Mesh &mesh)
Field< bool > invert_boolean_field(const Field< bool > &field)
static void compute_selected_mesh_data_from_edge_selection_edge_face(const Mesh &mesh, const Span< bool > edge_selection, MutableSpan< int > r_edge_map, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_edges_num, int *r_selected_polys_num, int *r_selected_loops_num)
static void compute_selected_mesh_data_from_vertex_selection(const Mesh &mesh, const Span< bool > vertex_selection, MutableSpan< int > r_vertex_map, MutableSpan< int > r_edge_map, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_vertices_num, int *r_selected_edges_num, int *r_selected_polys_num, int *r_selected_loops_num)
static void node_init(bNodeTree *UNUSED(tree), bNode *node)
static void compute_selected_mesh_data_from_edge_selection(const Mesh &mesh, const Span< bool > edge_selection, MutableSpan< int > r_vertex_map, MutableSpan< int > r_edge_map, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_vertices_num, int *r_selected_edges_num, int *r_selected_polys_num, int *r_selected_loops_num)
static void copy_masked_vertices_to_new_mesh(const Mesh &src_mesh, Mesh &dst_mesh, Span< int > vertex_map)
static void compute_selected_vertices_from_vertex_selection(const Span< bool > vertex_selection, MutableSpan< int > r_vertex_map, int *r_selected_vertices_num)
static void compute_selected_polygons_from_edge_selection(const Mesh &mesh, const Span< bool > edge_selection, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_polys_num, int *r_selected_loops_num)
static void separate_point_cloud_selection(GeometrySet &geometry_set, const Field< bool > &selection_field)
static void separate_mesh_selection(GeometrySet &geometry_set, const Field< bool > &selection_field, const eAttrDomain selection_domain, const GeometryNodeDeleteGeometryMode mode)
static void compute_selected_edges_from_vertex_selection(const Mesh &mesh, const Span< bool > vertex_selection, MutableSpan< int > r_edge_map, int *r_selected_edges_num)
static void compute_selected_mesh_data_from_poly_selection_edge_face(const Mesh &mesh, const Span< bool > poly_selection, MutableSpan< int > r_edge_map, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_edges_num, int *r_selected_polys_num, int *r_selected_loops_num)
static void delete_curves_selection(GeometrySet &geometry_set, const Field< bool > &selection_field, const eAttrDomain selection_domain)
static void copy_face_corner_attributes(const Map< AttributeIDRef, AttributeKind > &attributes, const bke::AttributeAccessor src_attributes, bke::MutableAttributeAccessor dst_attributes, const int selected_loops_num, const Span< int > selected_poly_indices, const Mesh &mesh_in)
static void delete_selected_instances(GeometrySet &geometry_set, const Field< bool > &selection_field)
static void node_declare(NodeDeclarationBuilder &b)
static void copy_data_based_on_map(Span< T > src, MutableSpan< T > dst, Span< int > index_map)
static void do_mesh_separation(GeometrySet &geometry_set, const Mesh &mesh_in, const Span< bool > selection, const eAttrDomain domain, const GeometryNodeDeleteGeometryMode mode)
static void copy_attributes_based_on_map(const Map< AttributeIDRef, AttributeKind > &attributes, const bke::AttributeAccessor src_attributes, bke::MutableAttributeAccessor dst_attributes, const eAttrDomain domain, const Span< int > index_map)
static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void compute_selected_mesh_data_from_vertex_selection_edge_face(const Mesh &mesh, const Span< bool > vertex_selection, MutableSpan< int > r_edge_map, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_edges_num, int *r_selected_polys_num, int *r_selected_loops_num)
static void copy_attributes_based_on_mask(const Map< AttributeIDRef, AttributeKind > &attributes, const bke::AttributeAccessor src_attributes, bke::MutableAttributeAccessor dst_attributes, const eAttrDomain domain, const IndexMask mask)
static void compute_selected_polygons_from_poly_selection(const Mesh &mesh, const Span< bool > poly_selection, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_polys_num, int *r_selected_loops_num)
static void compute_selected_polygons_from_vertex_selection(const Mesh &mesh, const Span< bool > vertex_selection, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_polys_num, int *r_selected_loops_num)
static void node_geo_exec(GeoNodeExecParams params)
static void copy_attributes(const Map< AttributeIDRef, AttributeKind > &attributes, const bke::AttributeAccessor src_attributes, bke::MutableAttributeAccessor dst_attributes, const Span< eAttrDomain > domains)
static void compute_selected_vertices_and_edges_from_edge_selection(const Mesh &mesh, const Span< bool > edge_selection, MutableSpan< int > r_vertex_map, MutableSpan< int > r_edge_map, int *r_selected_vertices_num, int *r_selected_edges_num)
static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh, Mesh &dst_mesh, Span< int > edge_map, Span< int > masked_poly_indices, Span< int > new_loop_starts)
static void copy_data_based_on_mask(Span< T > data, MutableSpan< T > r_data, IndexMask mask)
static void compute_selected_edges_from_edge_selection(const Mesh &mesh, const Span< bool > edge_selection, MutableSpan< int > r_edge_map, int *r_selected_edges_num)
static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh, Mesh &dst_mesh, Span< int > edge_map)
static void compute_selected_mesh_data_from_poly_selection(const Mesh &mesh, const Span< bool > poly_selection, MutableSpan< int > r_vertex_map, MutableSpan< int > r_edge_map, Vector< int > &r_selected_poly_indices, Vector< int > &r_loop_starts, int *r_selected_vertices_num, int *r_selected_edges_num, int *r_selected_polys_num, int *r_selected_loops_num)
void separate_geometry(GeometrySet &geometry_set, eAttrDomain domain, GeometryNodeDeleteGeometryMode mode, const Field< bool > &selection_field, bool &r_is_error)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
void register_node_type_geo_delete_geometry()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
void remove(const GeometryComponentType component_type)
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
bool has_realized_data() const
const GeometryComponent * get_component_for_read(GeometryComponentType component_type) const
void gather_attributes_for_propagation(blender::Span< GeometryComponentType > component_types, GeometryComponentType dst_component_type, bool include_instances, blender::Map< blender::bke::AttributeIDRef, blender::bke::AttributeKind > &r_attributes) const
bool has_instances() const
void modify_geometry_sets(ForeachSubGeometryCallback callback)
void replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
bool has_pointcloud() const
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
NodeDeclareFunction declare