Blender V5.3
mesh_primitive_cylinder_cone.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cmath>
10#include <numbers>
11
12#include "BKE_attribute.hh"
13#include "BKE_mesh.hh"
14
15#include "BLI_array_utils.hh"
16
20
21namespace blender::geometry {
22
23struct ConeConfig {
26 float height;
31
34 /* The cone tip and a triangle fan filling are topologically identical.
35 * This simplifies the logic in some cases. */
38
39 /* Helpful quantities. */
46
47 /* Helpful vertex indices. */
52
53 /* Helpful edge indices. */
58
59 /* Helpful face indices. */
66
68 float radius_bottom,
69 float depth,
71 int side_segments,
72 int fill_segments,
76 height(0.5f * depth),
81 {
82 this->top_is_point = this->radius_top == 0.0f;
83 this->bottom_is_point = this->radius_bottom == 0.0f;
84 this->top_has_center_vert = this->top_is_point || this->fill_type == ConeFillType::Triangles;
85 this->bottom_has_center_vert = this->bottom_is_point ||
86 this->fill_type == ConeFillType::Triangles;
87
88 this->tot_quad_rings = this->calculate_total_quad_rings();
89 this->tot_edge_rings = this->calculate_total_edge_rings();
90 this->tot_verts = this->calculate_total_verts();
91 this->tot_edges = this->calculate_total_edges();
92 this->tot_corners = this->calculate_total_corners();
93
94 this->first_vert = 0;
95 this->first_ring_verts_start = this->top_has_center_vert ? 1 : first_vert;
96 this->last_vert = this->tot_verts - 1;
97 this->last_ring_verts_start = this->last_vert - this->circle_segments;
98
99 this->first_ring_edges_start = this->top_has_center_vert ? this->circle_segments : 0;
100 this->last_ring_edges_start = this->first_ring_edges_start +
101 this->tot_quad_rings * this->circle_segments * 2;
102 this->last_fan_edges_start = this->tot_edges - this->circle_segments;
103 this->last_edge = this->tot_edges - 1;
104
105 this->top_faces_start = 0;
106 if (!this->top_is_point) {
107 this->top_faces_len = (fill_segments - 1) * circle_segments;
108 this->top_faces_len += this->top_has_center_vert ? circle_segments : 0;
109 this->top_faces_len += this->fill_type == ConeFillType::NGon ? 1 : 0;
110 }
111 else {
112 this->top_faces_len = 0;
113 }
114
115 this->side_faces_start = this->top_faces_len;
116 if (this->top_is_point && this->bottom_is_point) {
117 this->side_faces_len = 0;
118 }
119 else {
120 this->side_faces_len = side_segments * circle_segments;
121 }
122
123 if (!this->bottom_is_point) {
124 this->bottom_faces_len = (fill_segments - 1) * circle_segments;
125 this->bottom_faces_len += this->bottom_has_center_vert ? circle_segments : 0;
126 this->bottom_faces_len += this->fill_type == ConeFillType::NGon ? 1 : 0;
127 }
128 else {
129 this->bottom_faces_len = 0;
130 }
131 this->bottom_faces_start = this->side_faces_start + this->side_faces_len;
132
133 this->tot_faces = this->top_faces_len + this->side_faces_len + this->bottom_faces_len;
134 }
135
136 private:
137 int calculate_total_quad_rings();
138 int calculate_total_edge_rings();
139 int calculate_total_verts();
140 int calculate_total_edges();
141 int calculate_total_corners();
142};
143
144int ConeConfig::calculate_total_quad_rings()
145{
147 return 0;
148 }
149
150 int quad_rings = 0;
151
152 if (!top_is_point) {
153 quad_rings += fill_segments - 1;
154 }
155
156 quad_rings += (!top_is_point && !bottom_is_point) ? side_segments : (side_segments - 1);
157
158 if (!bottom_is_point) {
159 quad_rings += fill_segments - 1;
160 }
161
162 return quad_rings;
163}
164
165int ConeConfig::calculate_total_edge_rings()
166{
168 return 0;
169 }
170
171 int edge_rings = 0;
172
173 if (!top_is_point) {
174 edge_rings += fill_segments;
175 }
176
177 edge_rings += side_segments - 1;
178
179 if (!bottom_is_point) {
180 edge_rings += fill_segments;
181 }
182
183 return edge_rings;
184}
185
186int ConeConfig::calculate_total_verts()
187{
189 return side_segments + 1;
190 }
191
192 int vert_total = 0;
193
195 vert_total++;
196 }
197
198 if (!top_is_point) {
199 vert_total += circle_segments * fill_segments;
200 }
201
202 vert_total += circle_segments * (side_segments - 1);
203
204 if (!bottom_is_point) {
205 vert_total += circle_segments * fill_segments;
206 }
207
209 vert_total++;
210 }
211
212 return vert_total;
213}
214
215int ConeConfig::calculate_total_edges()
216{
218 return side_segments;
219 }
220
221 int edge_total = 0;
223 edge_total += circle_segments;
224 }
225
226 edge_total += circle_segments * (tot_quad_rings * 2 + 1);
227
229 edge_total += circle_segments;
230 }
231
232 return edge_total;
233}
234
235int ConeConfig::calculate_total_corners()
236{
238 return 0;
239 }
240
241 int corner_total = 0;
242
244 corner_total += (circle_segments * 3);
245 }
246 else if (!top_is_point && fill_type == ConeFillType::NGon) {
247 corner_total += circle_segments;
248 }
249
250 corner_total += tot_quad_rings * (circle_segments * 4);
251
253 corner_total += (circle_segments * 3);
254 }
256 corner_total += circle_segments;
257 }
258
259 return corner_total;
260}
261
262static void calculate_cone_verts(const ConeConfig &config, MutableSpan<float3> positions)
263{
264 Array<float2> circle(config.circle_segments);
265 const float angle_delta = 2.0f * (std::numbers::pi / float(config.circle_segments));
266 float angle = 0.0f;
267 for (const int i : IndexRange(config.circle_segments)) {
268 circle[i].x = std::cos(angle);
269 circle[i].y = std::sin(angle);
270 angle += angle_delta;
271 }
272
273 int vert_index = 0;
274
275 /* Top cone tip or triangle fan center. */
276 if (config.top_has_center_vert) {
277 positions[vert_index++] = {0.0f, 0.0f, config.height};
278 }
279
280 /* Top fill including the outer edge of the fill. */
281 if (!config.top_is_point) {
282 const float top_fill_radius_delta = config.radius_top / float(config.fill_segments);
283 for (const int i : IndexRange(config.fill_segments)) {
284 const float top_fill_radius = top_fill_radius_delta * (i + 1);
285 for (const int j : IndexRange(config.circle_segments)) {
286 const float x = circle[j].x * top_fill_radius;
287 const float y = circle[j].y * top_fill_radius;
288 positions[vert_index++] = {x, y, config.height};
289 }
290 }
291 }
292
293 /* Rings along the side. */
294 const float side_radius_delta = (config.radius_bottom - config.radius_top) /
295 float(config.side_segments);
296 const float height_delta = 2.0f * config.height / float(config.side_segments);
297 for (const int i : IndexRange(config.side_segments - 1)) {
298 const float ring_radius = config.radius_top + (side_radius_delta * (i + 1));
299 const float ring_height = config.height - (height_delta * (i + 1));
300 for (const int j : IndexRange(config.circle_segments)) {
301 const float x = circle[j].x * ring_radius;
302 const float y = circle[j].y * ring_radius;
303 positions[vert_index++] = {x, y, ring_height};
304 }
305 }
306
307 /* Bottom fill including the outer edge of the fill. */
308 if (!config.bottom_is_point) {
309 const float bottom_fill_radius_delta = config.radius_bottom / float(config.fill_segments);
310 for (const int i : IndexRange(config.fill_segments)) {
311 const float bottom_fill_radius = config.radius_bottom - (i * bottom_fill_radius_delta);
312 for (const int j : IndexRange(config.circle_segments)) {
313 const float x = circle[j].x * bottom_fill_radius;
314 const float y = circle[j].y * bottom_fill_radius;
315 positions[vert_index++] = {x, y, -config.height};
316 }
317 }
318 }
319
320 /* Bottom cone tip or triangle fan center. */
321 if (config.bottom_has_center_vert) {
322 positions[vert_index++] = {0.0f, 0.0f, -config.height};
323 }
324}
325
326static void calculate_cone_edges(const ConeConfig &config, MutableSpan<int2> edges)
327{
328 int edge_index = 0;
329
330 /* Edges for top cone tip or triangle fan */
331 if (config.top_has_center_vert) {
332 for (const int i : IndexRange(config.circle_segments)) {
333 int2 &edge = edges[edge_index++];
334 edge[0] = config.first_vert;
335 edge[1] = config.first_ring_verts_start + i;
336 }
337 }
338
339 /* Rings and connecting edges between the rings. */
340 for (const int i : IndexRange(config.tot_edge_rings)) {
341 const int this_ring_vert_start = config.first_ring_verts_start + (i * config.circle_segments);
342 const int next_ring_vert_start = this_ring_vert_start + config.circle_segments;
343 /* Edge rings. */
344 for (const int j : IndexRange(config.circle_segments)) {
345 int2 &edge = edges[edge_index++];
346 edge[0] = this_ring_vert_start + j;
347 edge[1] = this_ring_vert_start + ((j + 1) % config.circle_segments);
348 }
349 if (i == config.tot_edge_rings - 1) {
350 /* There is one fewer ring of connecting edges. */
351 break;
352 }
353 /* Connecting edges. */
354 for (const int j : IndexRange(config.circle_segments)) {
355 int2 &edge = edges[edge_index++];
356 edge[0] = this_ring_vert_start + j;
357 edge[1] = next_ring_vert_start + j;
358 }
359 }
360
361 /* Edges for bottom triangle fan or tip. */
362 if (config.bottom_has_center_vert) {
363 for (const int i : IndexRange(config.circle_segments)) {
364 int2 &edge = edges[edge_index++];
365 edge[0] = config.last_ring_verts_start + i;
366 edge[1] = config.last_vert;
367 }
368 }
369}
370
371static void calculate_cone_faces(const ConeConfig &config,
372 MutableSpan<int> corner_verts,
373 MutableSpan<int> corner_edges,
374 MutableSpan<int> face_sizes)
375{
376 int rings_face_start = 0;
377 int rings_loop_start = 0;
378 if (config.top_has_center_vert) {
379 rings_face_start = config.circle_segments;
380 rings_loop_start = config.circle_segments * 3;
381
382 face_sizes.take_front(config.circle_segments).fill(3);
383
384 /* Top cone tip or center triangle fan in the fill. */
385 const int top_center_vert = 0;
386 const int top_fan_edges_start = 0;
387
388 for (const int i : IndexRange(config.circle_segments)) {
389 const int loop_start = i * 3;
390
391 corner_verts[loop_start + 0] = config.first_ring_verts_start + i;
392 corner_edges[loop_start + 0] = config.first_ring_edges_start + i;
393
394 corner_verts[loop_start + 1] = config.first_ring_verts_start +
395 ((i + 1) % config.circle_segments);
396 corner_edges[loop_start + 1] = top_fan_edges_start + ((i + 1) % config.circle_segments);
397
398 corner_verts[loop_start + 2] = top_center_vert;
399 corner_edges[loop_start + 2] = top_fan_edges_start + i;
400 }
401 }
402 else if (config.fill_type == ConeFillType::NGon) {
403 rings_face_start = 1;
404 rings_loop_start = config.circle_segments;
405
406 /* Center n-gon in the fill. */
407 face_sizes.first() = config.circle_segments;
410 }
411
412 /* Quads connect one edge ring to the next one. */
413 const int ring_faces_num = config.tot_quad_rings * config.circle_segments;
414 face_sizes.slice(rings_face_start, ring_faces_num).fill(4);
415 for (const int i : IndexRange(config.tot_quad_rings)) {
416 const int this_ring_loop_start = rings_loop_start + i * config.circle_segments * 4;
417 const int this_ring_vert_start = config.first_ring_verts_start + (i * config.circle_segments);
418 const int next_ring_vert_start = this_ring_vert_start + config.circle_segments;
419
420 const int this_ring_edges_start = config.first_ring_edges_start +
421 (i * 2 * config.circle_segments);
422 const int next_ring_edges_start = this_ring_edges_start + (2 * config.circle_segments);
423 const int ring_connections_start = this_ring_edges_start + config.circle_segments;
424
425 for (const int j : IndexRange(config.circle_segments)) {
426 const int loop_start = this_ring_loop_start + j * 4;
427
428 corner_verts[loop_start + 0] = this_ring_vert_start + j;
429 corner_edges[loop_start + 0] = ring_connections_start + j;
430
431 corner_verts[loop_start + 1] = next_ring_vert_start + j;
432 corner_edges[loop_start + 1] = next_ring_edges_start + j;
433
434 corner_verts[loop_start + 2] = next_ring_vert_start + ((j + 1) % config.circle_segments);
435 corner_edges[loop_start + 2] = ring_connections_start + ((j + 1) % config.circle_segments);
436
437 corner_verts[loop_start + 3] = this_ring_vert_start + ((j + 1) % config.circle_segments);
438 corner_edges[loop_start + 3] = this_ring_edges_start + j;
439 }
440 }
441
442 const int bottom_face_start = rings_face_start + ring_faces_num;
443 const int bottom_loop_start = rings_loop_start + ring_faces_num * 4;
444
445 if (config.bottom_has_center_vert) {
446 face_sizes.slice(bottom_face_start, config.circle_segments).fill(3);
447
448 /* Bottom cone tip or center triangle fan in the fill. */
449 for (const int i : IndexRange(config.circle_segments)) {
450 const int loop_start = bottom_loop_start + i * 3;
451
452 corner_verts[loop_start + 0] = config.last_ring_verts_start + i;
453 corner_edges[loop_start + 0] = config.last_fan_edges_start + i;
454
455 corner_verts[loop_start + 1] = config.last_vert;
456 corner_edges[loop_start + 1] = config.last_fan_edges_start +
457 (i + 1) % config.circle_segments;
458
459 corner_verts[loop_start + 2] = config.last_ring_verts_start +
460 (i + 1) % config.circle_segments;
461 corner_edges[loop_start + 2] = config.last_ring_edges_start + i;
462 }
463 }
464 else if (config.fill_type == ConeFillType::NGon) {
465 /* Center n-gon in the fill. */
466 face_sizes[bottom_face_start] = config.circle_segments;
467 for (const int i : IndexRange(config.circle_segments)) {
468 /* Go backwards to reverse surface normal. */
469 corner_verts[bottom_loop_start + i] = config.last_vert - i;
470 corner_edges[bottom_loop_start + i] = config.last_edge - ((i + 1) % config.circle_segments);
471 }
472 }
473}
474
475static void calculate_selection_outputs(const ConeConfig &config,
476 const ConeAttributeOutputs &attribute_outputs,
478{
479 /* Populate "Top" selection output. */
480 if (attribute_outputs.top_id) {
481 const bool face = !config.top_is_point && config.fill_type != ConeFillType::None;
483 *attribute_outputs.top_id, face ? bke::AttrDomain::Face : bke::AttrDomain::Point);
484
485 if (config.top_is_point) {
486 selection.span[config.first_vert] = true;
487 }
488 else {
489 selection.span.slice(0, face ? config.top_faces_len : config.circle_segments).fill(true);
490 }
491 selection.finish();
492 }
493
494 /* Populate "Bottom" selection output. */
495 if (attribute_outputs.bottom_id) {
496 const bool face = !config.bottom_is_point && config.fill_type != ConeFillType::None;
498 *attribute_outputs.bottom_id, face ? bke::AttrDomain::Face : bke::AttrDomain::Point);
499
500 if (config.bottom_is_point) {
501 selection.span[config.last_vert] = true;
502 }
503 else if (face) {
504 selection.span.slice(config.bottom_faces_start, config.bottom_faces_len).fill(true);
505 }
506 else {
507 selection.span.slice(config.last_ring_verts_start + 1, config.circle_segments).fill(true);
508 }
509 selection.finish();
510 }
511
512 /* Populate "Side" selection output. */
513 if (attribute_outputs.side_id) {
515 *attribute_outputs.side_id, bke::AttrDomain::Face);
516
517 selection.span.slice(config.side_faces_start, config.side_faces_len).fill(true);
518 selection.finish();
519 }
520}
521
530static void calculate_cone_uvs(const ConeConfig &config, Mesh *mesh, const StringRef uv_map_id)
531{
532 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
533
536 MutableSpan<float2> uvs = uv_attribute.span;
537
538 Array<float2> circle(config.circle_segments);
539 float angle = 0.0f;
540 const float angle_delta = 2.0f * std::numbers::pi / float(config.circle_segments);
541 for (const int i : IndexRange(config.circle_segments)) {
542 circle[i].x = std::cos(angle) * 0.225f;
543 circle[i].y = std::sin(angle) * 0.225f;
544 angle += angle_delta;
545 }
546
547 int corner = 0;
548
549 /* Left circle of the UV representing the top fill or top cone tip. */
550 if (config.top_is_point || config.fill_type != ConeFillType::None) {
551 const float2 center_left(0.25f, 0.25f);
552 const float radius_factor_delta = 1.0f / (config.top_is_point ? float(config.side_segments) :
553 float(config.fill_segments));
554 const int left_circle_segment_count = config.top_is_point ? config.side_segments :
555 config.fill_segments;
556
557 if (config.top_has_center_vert) {
558 /* Cone tip itself or triangle fan center of the fill. */
559 for (const int i : IndexRange(config.circle_segments)) {
560 uvs[corner++] = radius_factor_delta * circle[i] + center_left;
561 uvs[corner++] = radius_factor_delta * circle[(i + 1) % config.circle_segments] +
562 center_left;
563 uvs[corner++] = center_left;
564 }
565 }
566 else if (!config.top_is_point && config.fill_type == ConeFillType::NGon) {
567 /* N-gon at the center of the fill. */
568 for (const int i : IndexRange(config.circle_segments)) {
569 uvs[corner++] = radius_factor_delta * circle[i] + center_left;
570 }
571 }
572 /* The rest of the top fill is made out of quad rings. */
573 for (const int i : IndexRange(1, left_circle_segment_count - 1)) {
574 const float inner_radius_factor = i * radius_factor_delta;
575 const float outer_radius_factor = (i + 1) * radius_factor_delta;
576 for (const int j : IndexRange(config.circle_segments)) {
577 uvs[corner++] = inner_radius_factor * circle[j] + center_left;
578 uvs[corner++] = outer_radius_factor * circle[j] + center_left;
579 uvs[corner++] = outer_radius_factor * circle[(j + 1) % config.circle_segments] +
580 center_left;
581 uvs[corner++] = inner_radius_factor * circle[(j + 1) % config.circle_segments] +
582 center_left;
583 }
584 }
585 }
586
587 if (!config.top_is_point && !config.bottom_is_point) {
588 /* Mesh is a truncated cone or cylinder. The sides are unwrapped into a rectangle. */
589 const float bottom = (config.fill_type == ConeFillType::None) ? 0.0f : 0.5f;
590 const float x_delta = 1.0f / float(config.circle_segments);
591 const float y_delta = (1.0f - bottom) / float(config.side_segments);
592
593 for (const int i : IndexRange(config.side_segments)) {
594 for (const int j : IndexRange(config.circle_segments)) {
595 uvs[corner++] = float2(j * x_delta, i * y_delta + bottom);
596 uvs[corner++] = float2(j * x_delta, (i + 1) * y_delta + bottom);
597 uvs[corner++] = float2((j + 1) * x_delta, (i + 1) * y_delta + bottom);
598 uvs[corner++] = float2((j + 1) * x_delta, i * y_delta + bottom);
599 }
600 }
601 }
602
603 /* Right circle of the UV representing the bottom fill or bottom cone tip. */
604 if (config.bottom_is_point || config.fill_type != ConeFillType::None) {
605 const float2 center_right(0.75f, 0.25f);
606 const float radius_factor_delta = 1.0f / (config.bottom_is_point ?
607 float(config.side_segments) :
608 float(config.fill_segments));
609 const int right_circle_segment_count = config.bottom_is_point ? config.side_segments :
610 config.fill_segments;
611
612 /* The bottom circle has to be created outside in to match the loop order. */
613 for (const int i : IndexRange(right_circle_segment_count - 1)) {
614 const float outer_radius_factor = 1.0f - i * radius_factor_delta;
615 const float inner_radius_factor = 1.0f - (i + 1) * radius_factor_delta;
616 for (const int j : IndexRange(config.circle_segments)) {
617 uvs[corner++] = outer_radius_factor * circle[j] + center_right;
618 uvs[corner++] = inner_radius_factor * circle[j] + center_right;
619 uvs[corner++] = inner_radius_factor * circle[(j + 1) % config.circle_segments] +
620 center_right;
621 uvs[corner++] = outer_radius_factor * circle[(j + 1) % config.circle_segments] +
622 center_right;
623 }
624 }
625
626 if (config.bottom_has_center_vert) {
627 /* Cone tip itself or triangle fan center of the fill. */
628 for (const int i : IndexRange(config.circle_segments)) {
629 uvs[corner++] = radius_factor_delta * circle[i] + center_right;
630 uvs[corner++] = center_right;
631 uvs[corner++] = radius_factor_delta * circle[(i + 1) % config.circle_segments] +
632 center_right;
633 }
634 }
635 else if (!config.bottom_is_point && config.fill_type == ConeFillType::NGon) {
636 /* N-gon at the center of the fill. */
637 for (const int i : IndexRange(config.circle_segments)) {
638 /* Go backwards because of reversed face normal. */
639 uvs[corner++] = radius_factor_delta * circle[config.circle_segments - 1 - i] +
640 center_right;
641 }
642 }
643 }
644
645 uv_attribute.finish();
646}
647
649{
650 /* Returns a mesh with a single vertex at the origin. */
651 Mesh *mesh = BKE_mesh_new_nomain(1, 0, 0, 0);
652 mesh->vert_positions_for_write().first() = float3(0);
653 return mesh;
654}
655
661
662Mesh *create_cylinder_or_cone_mesh(const float radius_top,
663 const float radius_bottom,
664 const float depth,
665 const int circle_segments,
666 const int side_segments,
667 const int fill_segments,
668 const ConeFillType fill_type,
669 ConeAttributeOutputs &attribute_outputs)
670{
671 const ConeConfig config(
672 radius_top, radius_bottom, depth, circle_segments, side_segments, fill_segments, fill_type);
673
674 /* Handle the case of a line / single point before everything else to avoid
675 * the need to check for it later. */
676 if (config.top_is_point && config.bottom_is_point) {
677 if (config.height == 0.0f) {
678 return create_vertex_mesh();
679 }
680 const float z_delta = -2.0f * config.height / float(config.side_segments);
681 const float3 start(0.0f, 0.0f, config.height);
682 const float3 delta(0.0f, 0.0f, z_delta);
683 return create_line_mesh(start, delta, config.tot_verts);
684 }
685
687 config.tot_verts, config.tot_edges, config.tot_faces, config.tot_corners);
688
689 MutableSpan<float3> positions = mesh->vert_positions_for_write();
690 MutableSpan<int2> edges = mesh->edges_for_write();
691 MutableSpan<int> face_offsets = mesh->face_offsets_for_write();
692 MutableSpan<int> corner_verts = mesh->corner_verts_for_write();
693 MutableSpan<int> corner_edges = mesh->corner_edges_for_write();
694 bke::mesh_smooth_set(*mesh, false);
695
696 calculate_cone_verts(config, positions);
697 calculate_cone_edges(config, edges);
698 calculate_cone_faces(config, corner_verts, corner_edges, face_offsets.drop_back(1));
700 if (attribute_outputs.uv_map_id) {
701 calculate_cone_uvs(config, mesh, *attribute_outputs.uv_map_id);
702 }
703 calculate_selection_outputs(config, attribute_outputs, mesh->attributes_for_write());
704
705 mesh->tag_loose_verts_none();
706 mesh->tag_loose_edges_none();
707 mesh->tag_overlapping_none();
708 mesh->bounds_set_eager(calculate_bounds_cylinder(config));
709
710 return mesh;
711}
712
713} // namespace blender::geometry
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
constexpr IndexRange()=default
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
Definition BLI_span.hh:579
constexpr MutableSpan drop_back(const int64_t n) const
Definition BLI_span.hh:624
constexpr void fill(const T &value) const
Definition BLI_span.hh:523
constexpr T & first() const
Definition BLI_span.hh:685
constexpr MutableSpan take_front(const int64_t n) const
Definition BLI_span.hh:635
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
void fill_index_range(MutableSpan< T > span, const T start=0)
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
static Bounds< float3 > calculate_bounds_cylinder(const ConeConfig &config)
static void calculate_cone_uvs(const ConeConfig &config, Mesh *mesh, const StringRef uv_map_id)
Mesh * create_cylinder_or_cone_mesh(float radius_top, float radius_bottom, float depth, int circle_segments, int side_segments, int fill_segments, ConeFillType fill_type, ConeAttributeOutputs &attribute_outputs)
static void calculate_cone_faces(const ConeConfig &config, MutableSpan< int > corner_verts, MutableSpan< int > corner_edges, MutableSpan< int > face_sizes)
Bounds< float3 > calculate_bounds_radial_primitive(float radius_top, float radius_bottom, int segments, float height)
Mesh * create_line_mesh(float3 start, float3 delta, int count)
static void calculate_cone_edges(const ConeConfig &config, MutableSpan< int2 > edges)
static void calculate_selection_outputs(const ConeConfig &config, const ConeAttributeOutputs &attribute_outputs, bke::MutableAttributeAccessor attributes)
static void calculate_cone_verts(const ConeConfig &config, MutableSpan< float3 > positions)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
VecBase< float, 3 > float3
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ConeConfig(float radius_top, float radius_bottom, float depth, int circle_segments, int side_segments, int fill_segments, ConeFillType fill_type)