43 .description(
"Mesh to extrude elements of");
46 .evaluated_geometry_field()
51 .evaluated_geometry_field();
53 auto &individual =
b.add_input<
decl::Bool>(
"Individual"_ustr)
60 .anonymous_attribute_output()
62 b.add_output<
decl::Bool>(
"Side"_ustr).anonymous_attribute_output();
65 if (
node !=
nullptr) {
110 names_to_remove.
append(name);
113 for (
const StringRef name : names_to_remove) {
133 const int vert_expand,
134 const int edge_expand,
135 const int face_expand,
136 const int loop_expand)
139 if (vert_expand != 0) {
140 const int old_verts_num =
mesh.verts_num;
141 mesh.verts_num += vert_expand;
143 mesh.attribute_storage.wrap().resize(AttrDomain::Point,
mesh.verts_num);
145 if (edge_expand != 0) {
146 if (
mesh.edges_num == 0) {
147 mesh.attributes_for_write().add(
150 const int old_edges_num =
mesh.edges_num;
151 mesh.edges_num += edge_expand;
153 mesh.attribute_storage.wrap().resize(AttrDomain::Edge,
mesh.edges_num);
155 if (face_expand != 0) {
156 const int old_faces_num =
mesh.faces_num;
157 mesh.faces_num += face_expand;
159 mesh.attribute_storage.wrap().resize(AttrDomain::Face,
mesh.faces_num);
161 &
mesh.runtime->face_offsets_sharing_info,
162 old_faces_num == 0 ? 0 : (old_faces_num + 1),
165 mesh.face_offset_indices[0] = 0;
166 mesh.face_offset_indices[
mesh.faces_num] =
mesh.corners_num + loop_expand;
168 if (loop_expand != 0) {
169 if (
mesh.corners_num == 0) {
170 mesh.attributes_for_write().add(
172 mesh.attributes_for_write().add(
175 const int old_loops_num =
mesh.corners_num;
176 mesh.corners_num += loop_expand;
178 mesh.attribute_storage.wrap().resize(AttrDomain::Corner,
mesh.corners_num);
185 case AttrDomain::Point:
186 return mesh.vert_data;
187 case AttrDomain::Edge:
188 return mesh.edge_data;
189 case AttrDomain::Face:
190 return mesh.face_data;
191 case AttrDomain::Corner:
192 return mesh.corner_data;
195 return mesh.vert_data;
211template<
typename SelectionT>
213 const SelectionT &selection,
219 src_groups.
offsets, selection, r_offsets);
223 return {offsets, r_indices};
255 [&](
const int64_t i) { return groups.offsets[i].is_empty(); },
281 names_by_domain[int(iter.
domain)].append(iter.
name);
283 return names_by_domain;
290 bool is_empty =
true;
295 if (iter.
domain != domain) {
338 vertex_group_names.
add(group.
name);
341 if (!vertex_group_names.
is_empty() && !
mesh.deform_verts().is_empty()) {
348 if (!vertex_group_names.
contains(name)) {
363 vertex_group_names.
add(group.
name);
366 if (!vertex_group_names.
is_empty() && !
mesh.deform_verts().is_empty()) {
373 if (!vertex_group_names.
contains(name)) {
387 const int orig_vert_size =
mesh.verts_num;
388 const int orig_edge_size =
mesh.edges_num;
407 {
"position",
".edge_verts"});
412 if (!names_by_domain[
int(AttrDomain::Edge)].is_empty()) {
414 mesh.edges(), orig_vert_size, vert_to_edge_offsets, vert_to_edge_indices);
420 const IndexRange new_vert_range{orig_vert_size, selection.
size()};
421 const IndexRange new_edge_range{orig_edge_size, selection.
size()};
425 [&](
const int index,
const int i_selection) {
426 new_edges[i_selection] =
int2(
index, new_vert_range[i_selection]);
434 if (!names_by_domain[
int(AttrDomain::Edge)].is_empty()) {
438 vert_to_edge_map, selection, new_edge_offsets, new_edge_indices);
439 for (
const StringRef name : names_by_domain[
int(AttrDomain::Edge)]) {
449 [&](
const int index,
const int i) { new_positions[i] = positions[
index] + offsets[
index]; },
459 if (attribute_outputs.
top_id) {
461 attributes, *attribute_outputs.
top_id, AttrDomain::Point, new_vert_range);
463 if (attribute_outputs.
side_id) {
465 attributes, *attribute_outputs.
side_id, AttrDomain::Edge, new_edge_range);
468 const bool no_loose_vert_hint =
mesh.runtime->loose_verts_cache.is_cached() &&
469 mesh.runtime->loose_verts_cache.data().mask.is_empty();
470 const bool no_overlapping_hint =
mesh.no_overlapping_topology();
472 if (no_loose_vert_hint) {
473 mesh.tag_loose_verts_none();
475 if (no_overlapping_hint) {
476 mesh.tag_overlapping_none();
484 const int vert_connected_to_face_1,
485 const int vert_connected_to_face_2,
486 const int vert_across_from_face_1,
487 const int vert_across_from_face_2,
488 const int edge_connected_to_face,
489 const int connecting_edge_1,
490 const int edge_across_from_face,
491 const int connecting_edge_2)
494 bool start_with_connecting_edge =
true;
495 for (
const int i : other_face_edges.
index_range()) {
496 if (other_face_edges[i] == edge_connected_to_face) {
497 start_with_connecting_edge = other_face_verts[i] == vert_connected_to_face_1;
501 if (start_with_connecting_edge) {
502 new_corner_verts[0] = vert_connected_to_face_1;
503 new_corner_edges[0] = connecting_edge_1;
504 new_corner_verts[1] = vert_across_from_face_1;
505 new_corner_edges[1] = edge_across_from_face;
506 new_corner_verts[2] = vert_across_from_face_2;
507 new_corner_edges[2] = connecting_edge_2;
508 new_corner_verts[3] = vert_connected_to_face_2;
509 new_corner_edges[3] = edge_connected_to_face;
512 new_corner_verts[0] = vert_connected_to_face_1;
513 new_corner_edges[0] = edge_connected_to_face;
514 new_corner_verts[1] = vert_connected_to_face_2;
515 new_corner_edges[1] = connecting_edge_2;
516 new_corner_verts[2] = vert_across_from_face_2;
517 new_corner_edges[2] = edge_across_from_face;
518 new_corner_verts[3] = vert_across_from_face_1;
519 new_corner_edges[3] = connecting_edge_1;
529 if (edge_mask.
size() == edges.
size()) {
538 edge_mask.
to_indices<
int>(masked_edge_to_edge);
546 const bool no_loose_vert_hint =
mesh.runtime->loose_verts_cache.is_cached() &&
547 mesh.runtime->loose_verts_cache.data().mask.is_empty();
548 const bool no_loose_edge_hint =
mesh.runtime->loose_edges_cache.is_cached() &&
549 mesh.runtime->loose_edges_cache.data().mask.is_empty();
550 const bool no_overlapping_hint =
mesh.no_overlapping_topology();
552 if (no_loose_vert_hint) {
553 mesh.tag_loose_verts_none();
555 if (no_loose_edge_hint) {
556 mesh.tag_loose_edges_none();
558 if (no_overlapping_hint) {
559 mesh.tag_overlapping_none();
569 const int orig_vert_size =
mesh.verts_num;
572 const int orig_loop_size =
mesh.corners_num;
577 edge_evaluator.
add(offset_field);
592 const int2 edge = orig_edges[i_edge];
593 const float3 offset = edge_offsets[i_edge];
594 mixer.mix_in(edge[0], offset);
595 mixer.mix_in(edge[1], offset);
602 orig_edges, edge_selection, orig_vert_size, memory);
604 const IndexRange new_vert_range{orig_vert_size, new_verts.
size()};
612 const IndexRange new_loop_range{orig_loop_size, new_face_range.
size() * 4};
620 orig_faces,
mesh.corner_edges(),
mesh.edges_num, edge_to_face_offsets, edge_to_face_indices);
627 orig_edges, edge_selection, orig_vert_size, vert_to_edge_offsets, vert_to_edge_indices);
633 new_vert_range.
size(),
634 connect_edge_range.
size() + duplicate_edge_range.
size(),
635 new_face_range.
size(),
636 new_loop_range.
size());
639 attributes, {
"position",
".edge_verts",
".corner_vert",
".corner_edge"});
655 [&](
const int src,
const int dst) { connect_edges[dst] =
int2(src, new_vert_range[dst]); },
661 for (
const int i : duplicate_edges.
index_range()) {
662 const int2 orig_edge = edges[edge_selection[i]];
663 const int i_new_vert_1 = vert_to_new_vert[orig_edge[0]];
664 const int i_new_vert_2 = vert_to_new_vert[orig_edge[1]];
665 duplicate_edges[i] =
int2(new_vert_range[i_new_vert_1], new_vert_range[i_new_vert_2]);
670 const int2 duplicate_edge = duplicate_edges[i];
671 const int new_vert_1 = duplicate_edge[0];
672 const int new_vert_2 = duplicate_edge[1];
673 const int extrude_index_1 = new_vert_1 - orig_vert_size;
674 const int extrude_index_2 = new_vert_2 - orig_vert_size;
676 const int2 orig_edge = edges[orig_edge_index];
677 const Span<int> connected_faces = edge_to_face_map[orig_edge_index];
684 if (connected_faces.
size() == 1) {
686 connected_face_verts = corner_verts.
slice(connected_face);
687 connected_face_edges = corner_edges.
slice(connected_face);
690 connected_face_edges,
691 new_corner_verts.
slice(4 * i, 4),
692 new_corner_edges.
slice(4 * i, 4),
698 connect_edge_range[extrude_index_1],
699 duplicate_edge_range[i],
700 connect_edge_range[extrude_index_2]);
708 attributes, names_by_domain[
int(AttrDomain::Edge)], edge_selection, duplicate_edge_range);
711 if (!names_by_domain[
int(AttrDomain::Edge)].is_empty()) {
715 vert_to_selected_edge_map, new_verts, connect_edge_offsets, connect_edge_indices);
716 for (
const StringRef name : names_by_domain[
int(AttrDomain::Edge)]) {
725 if (!names_by_domain[
int(AttrDomain::Face)].is_empty()) {
729 edge_to_face_map, edge_selection, new_face_offsets, new_face_indices);
730 for (
const StringRef name : names_by_domain[
int(AttrDomain::Face)]) {
739 if (!names_by_domain[
int(AttrDomain::Corner)].is_empty()) {
745 [&](
const int orig_edge_index,
const int i_edge_selection) {
746 const int faces_num = edge_to_face_map[orig_edge_index].
size();
747 vert_group_offsets[2 * i_edge_selection] = faces_num;
748 vert_group_offsets[2 * i_edge_selection + 1] = faces_num;
757 [&](
const int orig_edge_index,
const int i_edge_selection) {
758 const int2 orig_edge = edges[orig_edge_index];
759 const int2 duplicate_edge = duplicate_edges[i_edge_selection];
760 const Span<int> connected_faces = edge_to_face_map[orig_edge_index];
761 const int group_1 = 2 * i_edge_selection;
762 const int group_2 = 2 * i_edge_selection + 1;
764 vert_groups[group_1]);
766 vert_groups[group_2]);
767 for (
const int i_face : connected_faces.
index_range()) {
768 for (
const int corner : faces[connected_faces[i_face]]) {
769 if (corner_verts[corner] == orig_edge[0]) {
770 corners_1[i_face] = corner;
772 else if (corner_verts[corner] == orig_edge[1]) {
773 corners_2[i_face] = corner;
779 for (
const int new_corner :
IndexRange(4 * i_edge_selection, 4)) {
780 const int vert = new_corner_verts[new_corner];
781 new_corner_values[new_corner] =
ELEM(vert, orig_edge[0], duplicate_edge[0]) ? group_1 :
787 const GroupedSpan<int> vert_group_corners_map(vert_groups, vert_group_corners);
788 for (
const StringRef name : names_by_domain[
int(AttrDomain::Corner)]) {
805 [&](
const int src,
const int dst) { new_positions[dst] = positions[src] + offset; },
810 [&](
const int src,
const int dst) {
811 new_positions[dst] = positions[src] + vert_offsets[src];
827 if (attribute_outputs.
top_id) {
829 attributes, *attribute_outputs.
top_id, AttrDomain::Edge, duplicate_edge_range);
831 if (attribute_outputs.
side_id) {
833 attributes, *attribute_outputs.
side_id, AttrDomain::Face, new_face_range);
845 for (
const int i_edge : edge_indices) {
846 const int2 &edge = edges[i_edge];
847 vert_indices.
add(edge[0]);
848 vert_indices.
add(edge[1]);
863 const int orig_vert_size =
mesh.verts_num;
867 const int orig_loop_size = orig_corner_verts.
size();
872 face_evaluator.
add(offset_field);
881 face_selection.
to_bools(face_selection_array);
887 if (!face_position_offsets.
is_single()) {
891 const float3 offset = face_position_offsets[i_face];
892 for (
const int vert : orig_corner_verts.
slice(orig_faces[i_face])) {
893 mixer.mix_in(vert, offset);
903 orig_faces,
mesh.corner_edges(),
mesh.edges_num, edge_to_face_offsets, edge_to_face_indices);
908 orig_faces, face_selection, orig_corner_verts, orig_vert_size, memory);
921 for (
const int i_edge : orig_edges.
index_range()) {
922 const Span<int> faces = edge_to_face_map[i_edge];
924 int i_selected_face = -1;
925 int deselected_face_count = 0;
926 int selected_face_count = 0;
927 for (
const int i_other_face : faces) {
928 if (face_selection_array[i_other_face]) {
929 selected_face_count++;
930 i_selected_face = i_other_face;
933 deselected_face_count++;
937 if (selected_face_count == 1) {
940 boundary_edge_indices.
add_new(i_edge);
941 edge_extruded_face_indices.
append(i_selected_face);
943 else if (selected_face_count > 1) {
945 if (deselected_face_count > 0) {
947 new_inner_edge_indices.
add_new(i_edge);
952 inner_edge_indices.
append(i_edge);
960 const int extruded_vert_size = new_vert_indices.
size();
963 for (
const int i_edge : new_inner_edge_indices) {
964 const int2 &edge = orig_edges[i_edge];
965 new_vert_indices.
add(edge[0]);
966 new_vert_indices.
add(edge[1]);
970 const IndexRange new_vert_range{orig_vert_size, new_vert_indices.
size()};
972 const IndexRange connect_edge_range{orig_edges.
size(), extruded_vert_size};
974 const IndexRange boundary_edge_range = connect_edge_range.
after(boundary_edge_indices.
size());
976 const IndexRange new_inner_edge_range = boundary_edge_range.
after(new_inner_edge_indices.
size());
980 const IndexRange side_loop_range{orig_corner_verts.
size(), side_face_range.
size() * 4};
988 new_vert_range.
size(),
989 connect_edge_range.
size() + boundary_edge_range.
size() + new_inner_edge_range.
size(),
990 side_face_range.
size(),
991 side_loop_range.
size());
994 attributes, {
".corner_vert",
".corner_edge",
".edge_verts"});
1008 if (!new_face_offsets.
is_empty()) {
1015 connect_edges[i] =
int2(new_vert_indices[i], new_vert_range[i]);
1019 for (
const int i : boundary_edges.
index_range()) {
1020 const int2 &orig_edge = edges[boundary_edge_indices[i]];
1021 const int i_new_vert_1 = new_vert_indices.
index_of(orig_edge[0]);
1022 const int i_new_vert_2 = new_vert_indices.
index_of(orig_edge[1]);
1023 boundary_edges[i] =
int2(new_vert_range[i_new_vert_1], new_vert_range[i_new_vert_2]);
1027 for (
const int i : new_inner_edge_indices.
index_range()) {
1028 const int2 &orig_edge = edges[new_inner_edge_indices[i]];
1029 const int i_new_vert_1 = new_vert_indices.
index_of(orig_edge[0]);
1030 const int i_new_vert_2 = new_vert_indices.
index_of(orig_edge[1]);
1031 new_inner_edges[i] =
int2(new_vert_range[i_new_vert_1], new_vert_range[i_new_vert_2]);
1035 for (
const int i : inner_edge_indices) {
1036 int2 &edge = edges[i];
1037 const int i_new_vert_1 = new_vert_indices.
index_of_try(edge[0]);
1038 const int i_new_vert_2 = new_vert_indices.
index_of_try(edge[1]);
1039 if (i_new_vert_1 != -1) {
1040 edge[0] = new_vert_range[i_new_vert_1];
1042 if (i_new_vert_2 != -1) {
1043 edge[1] = new_vert_range[i_new_vert_2];
1049 for (
const int corner : faces[i_face]) {
1050 const int i_new_vert = new_vert_indices.
index_of_try(corner_verts[corner]);
1051 if (i_new_vert != -1) {
1052 corner_verts[corner] = new_vert_range[i_new_vert];
1054 const int i_boundary_edge = boundary_edge_indices.
index_of_try(corner_edges[corner]);
1055 if (i_boundary_edge != -1) {
1056 corner_edges[corner] = boundary_edge_range[i_boundary_edge];
1060 const int i_new_inner_edge = new_inner_edge_indices.
index_of_try(corner_edges[corner]);
1061 if (i_new_inner_edge != -1) {
1062 corner_edges[corner] = new_inner_edge_range[i_new_inner_edge];
1068 for (
const int i : boundary_edge_indices.
index_range()) {
1069 const int2 &boundary_edge = boundary_edges[i];
1070 const int new_vert_1 = boundary_edge[0];
1071 const int new_vert_2 = boundary_edge[1];
1072 const int extrude_index_1 = new_vert_1 - orig_vert_size;
1073 const int extrude_index_2 = new_vert_2 - orig_vert_size;
1075 const IndexRange extrude_face = faces[edge_extruded_face_indices[i]];
1078 corner_edges.
slice(extrude_face),
1079 new_corner_verts.
slice(4 * i, 4),
1080 new_corner_edges.
slice(4 * i, 4),
1083 new_vert_indices[extrude_index_1],
1084 new_vert_indices[extrude_index_2],
1085 boundary_edge_range[i],
1086 connect_edge_range[extrude_index_1],
1087 boundary_edge_indices[i],
1088 connect_edge_range[extrude_index_2]);
1093 mesh, names_by_domain[
int(AttrDomain::Point)], new_vert_indices, new_vert_range);
1097 names_by_domain[
int(AttrDomain::Face)],
1098 edge_extruded_face_indices,
1101 if (!names_by_domain[
int(AttrDomain::Edge)].is_empty()) {
1109 edges, boundary_edge_mask,
mesh.verts_num, vert_to_edge_offsets, vert_to_edge_indices);
1113 vert_to_boundary_edge_map,
1114 new_vert_indices.
as_span().take_front(connect_edge_range.
size()),
1115 connect_edge_offsets,
1116 connect_edge_indices);
1118 for (
const StringRef name : names_by_domain[
int(AttrDomain::Edge)]) {
1137 if (!names_by_domain[
int(AttrDomain::Corner)].is_empty()) {
1140 for (const int i_boundary_edge : range) {
1141 const int2 &boundary_edge = boundary_edges[i_boundary_edge];
1142 const int new_vert_1 = boundary_edge[0];
1143 const int new_vert_2 = boundary_edge[1];
1144 const int orig_vert_1 = new_vert_indices[new_vert_1 - orig_vert_size];
1145 const int orig_vert_2 = new_vert_indices[new_vert_2 - orig_vert_size];
1154 for (const int corner : faces[edge_extruded_face_indices[i_boundary_edge]]) {
1155 if (corner_verts[corner] == new_vert_1) {
1158 if (corner_verts[corner] == new_vert_2) {
1166 for (const int i : IndexRange(4 * i_boundary_edge, 4)) {
1167 if (ELEM(new_corner_verts[i], new_vert_1, orig_vert_1)) {
1168 orig_corners[i] = corner_1;
1170 else if (ELEM(new_corner_verts[i], new_vert_2, orig_vert_2)) {
1171 orig_corners[i] = corner_2;
1177 attributes, names_by_domain[
int(AttrDomain::Corner)], orig_corners, side_loop_range);
1184 if (face_position_offsets.is_single()) {
1185 const float3 offset = face_position_offsets.get_internal_single();
1186 all_selected_verts.foreach_index(
1187 [&](
const int orig_vert) {
1188 const int i_new = new_vert_indices.index_of_try(orig_vert);
1190 positions[orig_vert] += offset;
1193 positions[new_vert_range[i_new]] += offset;
1199 all_selected_verts.foreach_index(
1200 [&](
const int orig_vert) {
1201 const int i_new = new_vert_indices.index_of_try(orig_vert);
1202 const float3 offset = vert_offsets[orig_vert];
1204 positions[orig_vert] += offset;
1207 positions[new_vert_range[i_new]] += offset;
1215 indices->as_span(), new_vert_indices.as_span(), indices->slice(new_vert_range));
1220 new_inner_edge_indices.as_span(),
1221 indices->slice(new_inner_edge_range));
1223 indices->as_span(), boundary_edge_indices.as_span(), indices->slice(boundary_edge_range));
1227 indices->as_span(), edge_extruded_face_indices.as_span(), indices->slice(side_face_range));
1230 if (attribute_outputs.top_id) {
1232 attributes, *attribute_outputs.top_id, AttrDomain::Face, face_selection);
1234 if (attribute_outputs.side_id) {
1236 attributes, *attribute_outputs.side_id, AttrDomain::Face, side_face_range);
1248 const int orig_vert_size =
mesh.verts_num;
1249 const int orig_edge_size =
mesh.edges_num;
1252 const int orig_loop_size = orig_corner_verts.
size();
1272 orig_faces, face_selection, group_per_face_data);
1273 const int extrude_corner_size = group_per_face.
total_size();
1275 const IndexRange new_vert_range{orig_vert_size, extrude_corner_size};
1277 const IndexRange connect_edge_range{orig_edge_size, extrude_corner_size};
1279 const IndexRange duplicate_edge_range = connect_edge_range.
after(extrude_corner_size);
1282 const IndexRange side_loop_range{orig_loop_size, side_face_range.
size() * 4};
1290 new_vert_range.
size(),
1291 connect_edge_range.
size() + duplicate_edge_range.
size(),
1292 side_face_range.
size(),
1293 side_loop_range.
size());
1296 attributes, {
"position",
".edge_verts",
".corner_vert",
".corner_edge"});
1317 Array<int> new_vert_indices(extrude_corner_size);
1318 Array<int> duplicate_edge_indices(extrude_corner_size);
1321 const IndexRange extrude_range = group_per_face[i_selection];
1328 const int i_extrude = extrude_range[i];
1329 new_vert_indices[i_extrude] = face_verts[i];
1330 duplicate_edge_indices[i_extrude] = face_edges[i];
1332 face_verts[i] = new_vert_range[i_extrude];
1333 face_edges[i] = duplicate_edge_range[i_extrude];
1337 const int i_next = (i == face.
size() - 1) ? 0 : i + 1;
1338 const int i_extrude = extrude_range[i];
1339 const int i_extrude_next = extrude_range[i_next];
1341 const int i_duplicate_edge = duplicate_edge_range[i_extrude];
1342 const int new_vert = new_vert_range[i_extrude];
1343 const int new_vert_next = new_vert_range[i_extrude_next];
1345 const int orig_edge = duplicate_edge_indices[i_extrude];
1347 const int orig_vert = new_vert_indices[i_extrude];
1348 const int orig_vert_next = new_vert_indices[i_extrude_next];
1350 duplicate_edges[i_extrude] =
int2(new_vert, new_vert_next);
1354 side_face_verts[0] = new_vert_next;
1355 side_face_edges[0] = i_duplicate_edge;
1356 side_face_verts[1] = new_vert;
1357 side_face_edges[1] = connect_edge_range[i_extrude];
1358 side_face_verts[2] = orig_vert;
1359 side_face_edges[2] = orig_edge;
1360 side_face_verts[3] = orig_vert_next;
1361 side_face_edges[3] = connect_edge_range[i_extrude_next];
1363 connect_edges[i_extrude] =
int2(orig_vert, new_vert);
1370 mesh, names_by_domain[
int(AttrDomain::Point)], new_vert_indices, new_vert_range);
1374 names_by_domain[
int(AttrDomain::Edge)],
1375 duplicate_edge_indices,
1376 duplicate_edge_range);
1379 if (!names_by_domain[
int(AttrDomain::Edge)].is_empty()) {
1384 const IndexRange extrude_range = group_per_face[i_selection];
1387 const int i_prev = (i == 0) ? face.
size() - 1 : i - 1;
1388 const int i_extrude = extrude_range[i];
1389 const int i_extrude_prev = extrude_range[i_prev];
1390 neighbor_edges[i_extrude] =
int2(duplicate_edge_indices[i_extrude],
1391 duplicate_edge_indices[i_extrude_prev]);
1399 neighbor_edges.
as_span().cast<
int>());
1400 for (
const StringRef name : names_by_domain[
int(AttrDomain::Edge)]) {
1409 for (
const StringRef name : names_by_domain[
int(AttrDomain::Face)]) {
1412 group_per_face, face_selection,
attribute.span,
attribute.span.slice(side_face_range));
1417 if (!names_by_domain[
int(AttrDomain::Corner)].is_empty()) {
1422 const IndexRange extrude_range = group_per_face[i_selection];
1425 const IndexRange side_face(extrude_range[i] * 4, 4);
1429 const int corner = face[i];
1431 orig_corners[side_face[0]] = next_corner;
1432 orig_corners[side_face[1]] = corner;
1433 orig_corners[side_face[2]] = corner;
1434 orig_corners[side_face[3]] = next_corner;
1439 attributes, names_by_domain[
int(AttrDomain::Corner)], orig_corners, side_loop_range);
1445 const IndexRange extrude_range = group_per_face[i_selection];
1446 for (
const int i : extrude_range) {
1447 const int src_vert = new_vert_indices[i];
1448 new_positions[i] = positions[src_vert] + face_offset[
index];
1455 indices->as_span(), new_vert_indices.
as_span(), indices->slice(new_vert_range));
1460 duplicate_edge_indices.
as_span(),
1461 indices->slice(duplicate_edge_range));
1465 group_per_face, face_selection, indices->as_span(), indices->
slice(side_face_range));
1468 if (attribute_outputs.
top_id) {
1470 attributes, *attribute_outputs.
top_id, AttrDomain::Face, face_selection);
1472 if (attribute_outputs.
side_id) {
1474 attributes, *attribute_outputs.
side_id, AttrDomain::Face, side_face_range);
1493 {std::move(offset_field), std::move(scale_field)})};
1510 *
mesh, selection, final_offset, attribute_outputs, attribute_filter);
1516 if (extrude_individual) {
1518 *
mesh, selection, final_offset, attribute_outputs, attribute_filter);
1522 *
mesh, selection, final_offset, attribute_outputs, attribute_filter);
1532 params.
set_output(
"Mesh"_ustr, std::move(geometry_set));
1541 {0,
nullptr, 0,
nullptr,
nullptr},
1557 ntype.
ui_name =
"Extrude Mesh";
1559 "Generate new vertices, edges, or faces from selected elements and move them based on an "
1560 "offset while keeping them connected by their boundary";
CustomData interface, see also DNA_customdata_types.h.
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_EXTRUDE_MESH
#define BLT_I18NCONTEXT_ID_NODETREE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
#define BLI_assert_unreachable()
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
void reinitialize(const int64_t new_size)
void fill_assign_indices(const void *value, void *dst, const IndexMask &mask) const
const void * default_value() const
const CPPType & type() const
const CPPType & type() const
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_indices(Span< T > indices, LinearAllocator<> &memory)
constexpr int64_t size() const
constexpr IndexRange()=default
constexpr IndexRange after(int64_t n) const
constexpr IndexRange index_range() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr bool is_empty() const
constexpr IndexRange index_range() const
IndexRange index_range() const
bool contains(const Key &key) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr const T & first() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
T get_internal_single() const
int64_t index_of_try(const Key &key) const
void reserve(const int64_t n)
int64_t index_of(const Key &key) const
IndexRange index_range() const
Span< Key > as_span() const
void add_new(const Key &key)
void append(const T &value)
Set< StringRefNull > all_names() const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
bool contains(StringRef name) const
int domain_size(const AttrDomain domain) const
std::optional< AttrStorageType > storage_type
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
bool remove(const StringRef name)
GSpanAttributeWriter lookup_for_write_span(StringRef name)
void set_selection(Field< bool > selection)
int add(GField field, GVArray *varray_ptr)
IndexMask get_evaluated_selection_as_mask() const
int add_with_destination(GField field, GVMutableArray dst)
const GVArray & get_evaluated(const int field_index) const
void foreach_index_optimized(Fn &&fn, Mode mode=exec_mode::serial) const
IndexMask slice(IndexRange range) const
void to_indices(MutableSpan< T > r_indices) const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
void to_bools(MutableSpan< bool > r_bools) const
static FieldOperationPtr from(std::shared_ptr< const mf::MultiFunction > fn, Vector< GField > inputs)
NodeAttributeFilter get_attribute_filter(const UString output_identifier) const
std::optional< std::string > get_output_anonymous_attribute_id_if_needed(const UString output_identifier, const bool force_create=false)
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)
void gather_to_groups(const OffsetIndices< int > dst_offsets, const IndexMask &src_selection, const Span< T > src, MutableSpan< T > dst)
void gather_group_to_group(const OffsetIndices< int > src_offsets, const OffsetIndices< int > dst_offsets, const IndexMask &selection, const Span< T > src, MutableSpan< T > dst)
void gather(GSpan src, Span< int > map, GMutableSpan dst)
void gather_to_groups(OffsetIndices< int > dst_offsets, const IndexMask &src_selection, GSpan src, GMutableSpan dst)
void mix_groups(GSpan src, OffsetIndices< int > groups, Span< int > all_indices, std::optional< Span< float > > all_weights, GMutableSpan dst)
typename DefaultPropagationMixerStruct< T >::type DefaultPropagationMixer
GroupedSpan< int > build_edge_to_face_map(OffsetIndices< int > faces, Span< int > corner_edges, int edges_num, Array< int > &r_offsets, Array< int > &r_indices)
int face_corner_next(const IndexRange face, const int corner)
GroupedSpan< int > build_vert_to_edge_map(Span< int2 > edges, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
void node_register_type(bNodeType &ntype)
void gather_deform_verts(Span< MDeformVert > src, Span< int > indices, MutableSpan< MDeformVert > dst)
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))
constexpr ParallelGrainSize grain_size(int grain_size)
const MultiFunction & lookup(UString id)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
void debug_randomize_mesh_order(Mesh *mesh)
IndexMask vert_selection_from_face(OffsetIndices< int > faces, const IndexMask &face_mask, Span< int > corner_verts, int verts_num, IndexMaskMemory &memory)
IndexMask vert_selection_from_edge(Span< int2 > edges, const IndexMask &edge_mask, int verts_num, IndexMaskMemory &memory)
void resize_trivial_array(T **data, const ImplicitSharingInfo **sharing_info, int64_t old_size, int64_t new_size)
template void build_reverse_map< int >(const IndexMask &mask, MutableSpan< int > r_map)
static void remove_unsupported_corner_data(Mesh &mesh)
static void node_declare(NodeDeclarationBuilder &b)
static void extrude_individual_mesh_faces(Mesh &mesh, const Field< bool > &selection_field, const Field< float3 > &offset_field, const AttributeOutputs &attribute_outputs, const AttributeFilter &attribute_filter)
static void extrude_mesh_face_regions(Mesh &mesh, const Field< bool > &selection_field, const Field< float3 > &offset_field, const AttributeOutputs &attribute_outputs, const AttributeFilter &attribute_filter)
static void extrude_mesh_edges(Mesh &mesh, const Field< bool > &selection_field, const Field< float3 > &offset_field, const AttributeOutputs &attribute_outputs, const AttributeFilter &attribute_filter)
std::array< Vector< StringRef >, ATTR_DOMAIN_NUM > IDsByDomain
static IDsByDomain get_transfer_attribute_names(const AttributeAccessor attributes, const Set< StringRef > &skip)
static GPointer mixing_default_value(const CPPType &type)
static void gather_attributes(MutableAttributeAccessor attributes, const Span< StringRef > names, const Span< int > indices, const IndexRange new_range)
static VectorSet< int > vert_indices_from_edges(const Mesh &mesh, const Span< int > edge_indices)
static void gather_vert_attributes(Mesh &mesh, const Span< StringRef > names, const Span< int > indices, const IndexRange new_range)
static void remove_unsupported_vert_data(Mesh &mesh)
static bool is_empty_domain(const AttributeAccessor attributes, const Set< StringRef > &skip, const AttrDomain domain)
static void node_register()
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static CustomData & mesh_custom_data_for_domain(Mesh &mesh, const AttrDomain domain)
static void extrude_mesh_vertices(Mesh &mesh, const Field< bool > &selection_field, const Field< float3 > &offset_field, const AttributeOutputs &attribute_outputs, const AttributeFilter &attribute_filter)
static void remove_non_propagated_attributes(MutableAttributeAccessor attributes, const AttributeFilter &attribute_filter)
static void node_rna(StructRNA *srna)
static std::optional< MutableSpan< int > > get_orig_index_layer(Mesh &mesh, const AttrDomain domain)
static void fill_quad_consistent_direction(const Span< int > other_face_verts, const Span< int > other_face_edges, MutableSpan< int > new_corner_verts, MutableSpan< int > new_corner_edges, const int vert_connected_to_face_1, const int vert_connected_to_face_2, const int vert_across_from_face_1, const int vert_across_from_face_2, const int edge_connected_to_face, const int connecting_edge_1, const int edge_across_from_face, const int connecting_edge_2)
static void node_geo_exec(GeoNodeExecParams params)
static void save_selection_as_attribute(MutableAttributeAccessor attributes, const StringRef name, const AttrDomain domain, const IndexMask &selection)
static void mix_groups_or_default(const GSpan src, const GroupedSpan< int > groups, const GPointer default_value, GMutableSpan dst)
static void tag_mesh_added_faces(Mesh &mesh)
static void expand_mesh(Mesh &mesh, const int vert_expand, const int edge_expand, const int face_expand, const int loop_expand)
static GroupedSpan< int > build_vert_to_edge_map(const Span< int2 > edges, const IndexMask &edge_mask, const int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
static GroupedSpan< int > gather_groups(const GroupedSpan< int > src_groups, const SelectionT &selection, Array< int > &r_offsets, Array< int > &r_indices)
static void node_init(bNodeTree *, bNode *node)
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)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
void fill_constant_group_size(int size, int start_offset, MutableSpan< int > offsets)
OffsetIndices< int > gather_selected_offsets(OffsetIndices< int > src_offsets, const IndexMask &selection, int start_offset, MutableSpan< int > dst_offsets)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool CustomData_free_layers(CustomData *data, eCustomDataType type)
void CustomData_realloc(CustomData *data, int old_size, int new_size, eCDAllocType alloctype=CD_CONSTRUCT)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
BMesh const char void * data
void BKE_mesh_runtime_clear_cache(Mesh *mesh)
GeometryNodeExtrudeMeshMode
@ GEO_NODE_EXTRUDE_MESH_VERTICES
@ GEO_NODE_EXTRUDE_MESH_EDGES
@ GEO_NODE_EXTRUDE_MESH_FACES
@ NODE_DEFAULT_INPUT_NORMAL_FIELD
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
void node_free_standard_storage(bNode *node)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
VecBase< float, 3 > float3
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
static MatBase identity()
bool allow_skip(const StringRef name) const
Mesh * get_mesh_for_write()
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
std::optional< std::string > top_id
std::optional< std::string > side_id
OffsetIndices< int > offsets
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
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)