Blender V5.3
displist.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstring>
10#include <numeric>
11
12#include "MEM_guardedalloc.h"
13
14#include "DNA_curve_types.h"
15#include "DNA_mesh_types.h"
16#include "DNA_object_types.h"
17
18#include "BLI_array.hh"
19#include "BLI_delaunay_2d.hh"
20#include "BLI_index_range.hh"
21#include "BLI_listbase.hh"
22#include "BLI_map.hh"
24#include "BLI_math_vector.hh"
25#include "BLI_math_vector_c.hh"
26#include "BLI_memarena.hh"
27#include "BLI_scanfill.hh"
28#include "BLI_span.hh"
29#include "BLI_string.hh"
30#include "BLI_task.hh"
31#include "BLI_utildefines.hh"
32#include "BLI_vector.hh"
33
34#include "BKE_anim_path.h"
35#include "BKE_curve.hh"
37#include "BKE_displist.h"
38#include "BKE_geometry_set.hh"
39#include "BKE_key.hh"
40#include "BKE_lib_id.hh"
41#include "BKE_mesh.hh"
42#include "BKE_modifier.hh"
43#include "BKE_object.hh"
44#include "BKE_object_types.hh"
45#include "BKE_vfont.hh"
46
47#include "DEG_depsgraph.hh"
49
50namespace blender {
51
53{
54 if (dl) {
55 if (dl->verts) {
56 MEM_delete(dl->verts);
57 }
58 if (dl->nors) {
59 MEM_delete(dl->nors);
60 }
61 if (dl->index) {
62 MEM_delete(dl->index);
63 }
64 MEM_delete(dl);
65 }
66}
67
68void BKE_displist_free(ListBaseT<DispList> *lb)
69{
70 while (DispList *dl = static_cast<DispList *>(BLI_pophead(lb))) {
72 }
73}
74
75DispList *BKE_displist_find(ListBaseT<DispList> *lb, int type)
76{
77 for (DispList &dl : *lb) {
78 if (dl.type == type) {
79 return &dl;
80 }
81 }
82
83 return nullptr;
84}
85
87 const DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
88{
89 if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) {
90 return false;
91 }
92
93 if (dl->flag & DL_CYCL_U) {
94 (*p1) = dl->nr * a;
95 (*p2) = (*p1) + dl->nr - 1;
96 (*p3) = (*p1) + dl->nr;
97 (*p4) = (*p2) + dl->nr;
98 (*b) = 0;
99 }
100 else {
101 (*p2) = dl->nr * a;
102 (*p1) = (*p2) + 1;
103 (*p4) = (*p2) + dl->nr;
104 (*p3) = (*p1) + dl->nr;
105 (*b) = 1;
106 }
107
108 if ((dl->flag & DL_CYCL_V) && a == dl->parts - 1) {
109 (*p3) -= dl->nr * dl->parts;
110 (*p4) -= dl->nr * dl->parts;
111 }
112
113 return true;
114}
115
116#ifdef __INTEL_COMPILER
117/* ICC with the optimization -02 causes crashes. */
118# pragma intel optimization_level 1
119#endif
120
121static void curve_to_displist(const Curve *cu,
122 const ListBaseT<Nurb> *nubase,
123 const bool for_render,
124 ListBaseT<DispList> *r_dispbase)
125{
126 const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
127
128 for (Nurb &nu : *nubase) {
129 if (nu.hide != 0 && editmode) {
130 continue;
131 }
132 if (!BKE_nurb_check_valid_u(&nu)) {
133 continue;
134 }
135
136 const int resolution = (for_render && cu->resolu_ren != 0) ? cu->resolu_ren : nu.resolu;
137 const bool is_cyclic = nu.flagu & CU_NURB_CYCLIC;
138
139 if (nu.type == CU_BEZIER) {
140 const BezTriple *bezt_first = &nu.bezt[0];
141 const BezTriple *bezt_last = &nu.bezt[nu.pntsu - 1];
142 int samples_len = 0;
143 for (int i = 1; i < nu.pntsu; i++) {
144 const BezTriple *prevbezt = &nu.bezt[i - 1];
145 const BezTriple *bezt = &nu.bezt[i];
146 if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
147 samples_len++;
148 }
149 else {
150 samples_len += resolution;
151 }
152 }
153 if (is_cyclic) {
154 /* If the curve is cyclic, sample the last edge between the last and first points. */
155 if (bezt_first->h1 == HD_VECT && bezt_last->h2 == HD_VECT) {
156 samples_len++;
157 }
158 else {
159 samples_len += resolution;
160 }
161 }
162 else {
163 /* Otherwise, we only need one additional sample to complete the last edge. */
164 samples_len++;
165 }
166
167 /* Check that there are more than two points so the curve doesn't loop back on itself. This
168 * needs to be separate from `is_cyclic` because cyclic sampling can work with two points
169 * and resolution > 1. */
170 const bool use_cyclic_sample = is_cyclic && (samples_len != 2);
171
172 DispList *dl = MEM_new_zeroed<DispList>(__func__);
173 /* Add one to the length because of #BKE_curve_forward_diff_bezier. */
174 dl->verts = MEM_new_array_uninitialized<float>(3 * size_t(samples_len + 1), __func__);
175 BLI_addtail(r_dispbase, dl);
176 dl->parts = 1;
177 dl->nr = samples_len;
178 dl->col = nu.mat_nr;
179 dl->charidx = nu.charidx;
180
181 dl->type = use_cyclic_sample ? DL_POLY : DL_SEGM;
182
183 float *data = dl->verts;
184 for (int i = 1; i < nu.pntsu; i++) {
185 const BezTriple *prevbezt = &nu.bezt[i - 1];
186 const BezTriple *bezt = &nu.bezt[i];
187
188 if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
189 copy_v3_v3(data, prevbezt->vec[1]);
190 data += 3;
191 }
192 else {
193 for (int j = 0; j < 3; j++) {
194 BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
195 prevbezt->vec[2][j],
196 bezt->vec[0][j],
197 bezt->vec[1][j],
198 data + j,
199 resolution,
200 sizeof(float[3]));
201 }
202 data += 3 * resolution;
203 }
204 }
205 if (is_cyclic) {
206 if (bezt_first->h1 == HD_VECT && bezt_last->h2 == HD_VECT) {
207 copy_v3_v3(data, bezt_last->vec[1]);
208 }
209 else {
210 for (int j = 0; j < 3; j++) {
211 BKE_curve_forward_diff_bezier(bezt_last->vec[1][j],
212 bezt_last->vec[2][j],
213 bezt_first->vec[0][j],
214 bezt_first->vec[1][j],
215 data + j,
216 resolution,
217 sizeof(float[3]));
218 }
219 }
220 }
221 else {
222 copy_v3_v3(data, bezt_last->vec[1]);
223 }
224 }
225 else if (nu.type == CU_NURBS) {
226 const int len = (resolution * SEGMENTSU(&nu));
227 DispList *dl = MEM_new_zeroed<DispList>(__func__);
228 dl->verts = MEM_new_array_uninitialized<float>(3 * size_t(len), __func__);
229 BLI_addtail(r_dispbase, dl);
230 dl->parts = 1;
231 dl->nr = len;
232 dl->col = nu.mat_nr;
233 dl->charidx = nu.charidx;
234 dl->type = is_cyclic ? DL_POLY : DL_SEGM;
235
236 BKE_nurb_makeCurve(&nu, dl->verts, nullptr, nullptr, nullptr, resolution, sizeof(float[3]));
237 }
238 else if (nu.type == CU_POLY) {
239 const int len = nu.pntsu;
240 DispList *dl = MEM_new_zeroed<DispList>(__func__);
241 dl->verts = MEM_new_array_uninitialized<float>(3 * size_t(len), __func__);
242 BLI_addtail(r_dispbase, dl);
243 dl->parts = 1;
244 dl->nr = len;
245 dl->col = nu.mat_nr;
246 dl->charidx = nu.charidx;
247 dl->type = (is_cyclic && (dl->nr != 2)) ? DL_POLY : DL_SEGM;
248
249 float (*coords)[3] = reinterpret_cast<float (*)[3]>(dl->verts);
250 for (int i = 0; i < len; i++) {
251 const BPoint *bp = &nu.bp[i];
252 copy_v3_v3(coords[i], bp->vec);
253 }
254 }
255 }
256}
257
261struct PolyRange {
263 int start;
265 int count;
267 const DispList *dl;
268};
269
274static float isect_vert_calc_z(int vert_index,
275 int edge_index,
277 Span<PolyRange> poly_ranges,
278 Span<double2> input_verts_2d)
279{
280 /* -1 if this intersection vertex only appears on Delaunay edges
281 * (edges created by triangulation) rather than edges deriving from
282 * input polygon edges. Fall back to Z=0. */
283 if (edge_index == -1) [[unlikely]] {
284 return 0.0f;
285 }
286
287 const double2 &vert_co = result.vert[vert_index];
288
289 /* Find a face edge in the original edge info. */
290 for (const uint32_t orig_id : result.edge_orig[edge_index]) {
291 if (orig_id < result.face_edge_offset) {
292 /* Standalone edge - skip. */
293 continue;
294 }
295 /* Decode face index and edge position. */
296 const int face_index = (orig_id / result.face_edge_offset) - 1;
297 const int edge_in_face = orig_id % result.face_edge_offset;
298
299 if (face_index == -1 || face_index >= int(poly_ranges.size())) [[unlikely]] {
300 continue;
301 }
302
303 const PolyRange &poly = poly_ranges[face_index];
304 if (edge_in_face >= poly.count) [[unlikely]] {
305 continue;
306 }
307
308 /* Get the two endpoints of the original edge. */
309 const int v0_local = edge_in_face;
310 const int v1_local = (edge_in_face + 1) % poly.count;
311
312 const int v0_global = poly.start + v0_local;
313 const int v1_global = poly.start + v1_local;
314
315 const double2 &p0 = input_verts_2d[v0_global];
316 const double2 &p1 = input_verts_2d[v1_global];
317
318 /* Project the intersection vertex onto this edge to find parameter t. */
319 const double2 edge_vec = p1 - p0;
320 const double edge_len_sq = math::length_squared(edge_vec);
321
322 double t;
323 if (edge_len_sq < 1e-16) [[unlikely]] {
324 t = 0.5;
325 }
326 else {
327 const double2 to_point = vert_co - p0;
328 t = math::dot(to_point, edge_vec) / edge_len_sq;
329 t = math::clamp(t, 0.0, 1.0);
330 }
331
332 /* Get the Z coordinates of the original edge endpoints. */
333 const float z0 = poly.dl->verts[(3 * v0_local) + 2];
334 const float z1 = poly.dl->verts[(3 * v1_local) + 2];
335
336 /* Interpolate Z. */
337 return z0 + (float(t) * (z1 - z0));
338 }
339
340 /* Fallback: return 0 if no edge found. */
341 return 0.0f;
342}
343
347static void displist_fill_scanfill(const ListBaseT<DispList> *dispbase,
348 ListBaseT<DispList> *to,
349 const float normal_proj[3],
350 const bool flip_normal)
351{
352 if (dispbase == nullptr) {
353 return;
354 }
355 if (BLI_listbase_is_empty(dispbase)) {
356 return;
357 }
358
361
363
364 short colnr = 0;
365 int charidx = 0;
366 bool should_continue = true;
367 while (should_continue) {
368 should_continue = false;
369 bool nextcol = false;
370
371 ScanFillContext sf_ctx;
372 BLI_scanfill_begin_arena(&sf_ctx, sf_arena);
373
374 int totvert = 0;
375 short dl_flag_accum = 0;
376 short dl_rt_accum = 0;
377 for (const DispList &dl : *dispbase) {
378 if (dl.type == DL_POLY) {
379 if (charidx < dl.charidx) {
380 should_continue = true;
381 }
382 else if (charidx == dl.charidx) { /* character with needed index */
383 if (colnr == dl.col) {
384
385 sf_ctx.poly_nr++;
386
387 /* Make verts and edges. */
388 ScanFillVert *sf_vert = nullptr;
389 ScanFillVert *sf_vert_last = nullptr;
390 ScanFillVert *sf_vert_new = nullptr;
391 for (int i = 0; i < dl.nr; i++) {
392 sf_vert_last = sf_vert;
393 sf_vert = BLI_scanfill_vert_add(&sf_ctx, &dl.verts[3 * i]);
394 totvert++;
395 if (sf_vert_last == nullptr) {
396 sf_vert_new = sf_vert;
397 }
398 else {
399 BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
400 }
401 }
402
403 if (sf_vert != nullptr && sf_vert_new != nullptr) {
404 BLI_scanfill_edge_add(&sf_ctx, sf_vert, sf_vert_new);
405 }
406
407 dl_flag_accum |= dl.flag;
408 dl_rt_accum |= dl.rt;
409 }
410 else if (colnr < dl.col) {
411 /* got poly with next material at current char */
412 should_continue = true;
413 nextcol = true;
414 }
415 }
416 }
417 }
418
419 const int triangles_len = BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, normal_proj);
420 if (totvert != 0 && triangles_len != 0) {
421 DispList *dlnew = MEM_new_zeroed<DispList>(__func__);
422 dlnew->type = DL_INDEX3;
423 dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE));
424 dlnew->rt = (dl_rt_accum & CU_SMOOTH);
425 dlnew->col = colnr;
426 dlnew->nr = totvert;
427 dlnew->parts = triangles_len;
428
429 dlnew->index = MEM_new_array_uninitialized<int>(3 * size_t(triangles_len), __func__);
430 dlnew->verts = MEM_new_array_uninitialized<float>(3 * size_t(totvert), __func__);
431
432 /* vert data */
433
434 for (const auto [i, sf_vert] : sf_ctx.fillvertbase.enumerate()) {
435 copy_v3_v3(&dlnew->verts[3 * i], sf_vert.co);
436 sf_vert.tmp.i = i; /* Index number. */
437 }
438
439 /* index data */
440 int *index = dlnew->index;
441 for (const ScanFillFace &sf_tri : sf_ctx.fillfacebase) {
442 index[0] = sf_tri.v1->tmp.i;
443 index[1] = flip_normal ? sf_tri.v3->tmp.i : sf_tri.v2->tmp.i;
444 index[2] = flip_normal ? sf_tri.v2->tmp.i : sf_tri.v3->tmp.i;
445 index += 3;
446 }
447
448 BLI_addhead(to, dlnew);
449 }
450 BLI_scanfill_end_arena(&sf_ctx, sf_arena);
451
452 if (nextcol) {
453 /* stay at current char but fill polys with next material */
454 colnr++;
455 }
456 else {
457 /* switch to next char and start filling from first material */
458 charidx++;
459 colnr = 0;
460 }
461 }
462
463 BLI_memarena_free(sf_arena);
464 /* do not free polys, needed for wireframe display */
465}
466
475
481 const bool flip_normal,
482 const CDT_output_type cdt_output_type)
483{
484 /* Build CDT input, tracking if all Z coordinates are uniform.
485 * Also build vert_to_poly map for O(1) polygon lookup. */
486 Array<double2, 64> verts_2d(group.total_verts);
487 Array<int, 64> vert_to_poly(group.total_verts);
488
489 const float first_z = group.poly_ranges[0].dl->verts[2];
490 bool uniform_z = true;
491
492 Array<int, 8> face_offset_data(group.poly_ranges.size() + 1);
493 for (const int64_t p : group.poly_ranges.index_range()) {
494 face_offset_data[p] = group.poly_ranges[p].count;
495 }
497 face_offset_data);
498 BLI_assert(face_offsets.total_size() == group.total_verts);
499
500 Array<int, 64> face_vert_indices_data(face_offsets.total_size());
501 for (const int64_t p : group.poly_ranges.index_range()) {
502 const PolyRange &poly = group.poly_ranges[p];
503
504 /* Build face indices: sequential vertex indices for this polygon. Hole contours have
505 * reversed winding (done during bevel list generation for correct surface normals).
506 *
507 * Fill indices in reverse order to restore consistent winding
508 * so the CDT winding number calculation produces correct results.
509 * Needed for correct non-zero filling but harmless for odd/even, see: #155733. */
510 MutableSpan<int> indices = face_vert_indices_data.as_mutable_span().slice(face_offsets[p]);
511 if (poly.dl->flag & DL_REVERSED) {
512 std::iota(indices.rbegin(), indices.rend(), poly.start);
513 }
514 else {
515 std::iota(indices.begin(), indices.end(), poly.start);
516 }
517
518 /* Build vertex data. */
519 for (int i = 0; i < poly.count; i++) {
520 const float *v = &poly.dl->verts[3 * i];
521 const int vert_index = poly.start + i;
522 verts_2d[vert_index] = double2(v[0], v[1]);
523 vert_to_poly[vert_index] = int(p);
524 if (uniform_z && v[2] != first_z) {
525 uniform_z = false;
526 }
527 }
528 }
529
531 input.vert = verts_2d;
532 input.face_offsets = face_offsets;
533 input.face_vert_indices = face_vert_indices_data;
534 input.epsilon = 1e-8;
536
538 cdt_output_type);
539
540 if (result.face.is_empty()) [[unlikely]] {
541 return nullptr;
542 }
543
544 /* Build output DispList. */
545 const int out_verts = int(result.vert.size());
546 const int out_tris = int(result.face.size());
547
548 DispList *dlnew = MEM_new_zeroed<DispList>(__func__);
549 dlnew->type = DL_INDEX3;
550 dlnew->flag = (group.dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE));
551 dlnew->rt = (group.dl_rt_accum & CU_SMOOTH);
552 dlnew->col = group.colnr;
553 dlnew->nr = out_verts;
554 dlnew->parts = out_tris;
555 dlnew->verts = MEM_new_array_uninitialized<float>(3 * size_t(out_verts), __func__);
556 dlnew->index = MEM_new_array_uninitialized<int>(3 * size_t(out_tris), __func__);
557
558 /* Build map from intersection vertex to an edge with original edge info.
559 * Only needed when Z coordinates vary and interpolation is required. */
560 Array<int> isect_vert_to_edge;
561 if (!uniform_z) {
562 isect_vert_to_edge.reinitialize(out_verts);
563 isect_vert_to_edge.fill(-1);
564 for (int e = 0; e < int(result.edge.size()); e++) {
565 if (result.edge_orig[e].is_empty()) {
566 continue;
567 }
568 const int v0 = result.edge[e][0];
569 const int v1 = result.edge[e][1];
570 if (result.vert_orig[v0].is_empty()) {
571 isect_vert_to_edge[v0] = e;
572 }
573 if (result.vert_orig[v1].is_empty()) {
574 isect_vert_to_edge[v1] = e;
575 }
576 }
577 }
578
579 /* Map output vertices to 3D. */
580 for (int i = 0; i < out_verts; i++) {
581 float *out = &dlnew->verts[3 * i];
582 if (!result.vert_orig[i].is_empty()) {
583 /* Original vertex - copy from input using direct lookup. */
584 const int orig_index = result.vert_orig[i][0];
585 const PolyRange &poly = group.poly_ranges[vert_to_poly[orig_index]];
586 const int local_index = orig_index - poly.start;
587 copy_v3_v3(out, &poly.dl->verts[3 * local_index]);
588 }
589 else {
590 /* Intersection vertex. */
591 out[0] = float(result.vert[i].x);
592 out[1] = float(result.vert[i].y);
593 out[2] = uniform_z ? first_z :
595 i, isect_vert_to_edge[i], result, group.poly_ranges, input.vert);
596 }
597 }
598
599 /* Build triangle indices. */
600 int *index = dlnew->index;
601 for (const Vector<int> &face : result.face) {
602 BLI_assert(face.size() == 3);
603 index[0] = face[0];
604 index[1] = flip_normal ? face[1] : face[2];
605 index[2] = flip_normal ? face[2] : face[1];
606 index += 3;
607 }
608
609 return dlnew;
610}
611
615static void displist_fill_cdt(const ListBaseT<DispList> *dispbase,
616 ListBaseT<DispList> *to,
617 const bool flip_normal,
618 const CDT_output_type cdt_output_type)
619{
620 if (dispbase == nullptr || BLI_listbase_is_empty(dispbase)) {
621 return;
622 }
623
624 /* Collect groups in a single pass over dispbase.
625 * Polygons are grouped by (charidx, colnr) key. */
627
628 for (const DispList &dl : *dispbase) {
629 if (dl.type != DL_POLY) {
630 continue;
631 }
632 const std::pair<int, short> key(dl.charidx, dl.col);
633 CDTFillGroup &group = group_map.lookup_or_add_default(key);
634 if (group.poly_ranges.is_empty()) {
635 /* First polygon for this key - set colnr. */
636 group.colnr = dl.col;
637 }
638 group.poly_ranges.append({group.total_verts, dl.nr, &dl});
639 group.total_verts += dl.nr;
640 group.dl_flag_accum |= dl.flag;
641 group.dl_rt_accum |= dl.rt;
642 }
643
644 /* Move groups from map to vector for processing. */
646 groups.reserve(group_map.size());
647 for (CDTFillGroup &group : group_map.values()) {
648 groups.append_unchecked(std::move(group));
649 }
650
651 if (groups.is_empty()) [[unlikely]] {
652 return;
653 }
654
655 /* Process groups in parallel. */
656 Array<DispList *, 32> results(groups.size(), nullptr);
657
658 threading::parallel_for(groups.index_range(), 1, [&](const IndexRange range) {
659 for (const int i : range) {
660 results[i] = displist_fill_cdt_process_group(groups[i], flip_normal, cdt_output_type);
661 }
662 });
663
664 /* Add results to output list (serial). */
665 for (DispList *dl : results) {
666 if (dl != nullptr) {
667 BLI_addhead(to, dl);
668 }
669 }
670}
671
672void BKE_displist_fill(const ListBaseT<DispList> *dispbase,
673 ListBaseT<DispList> *to,
674 const float normal_proj[3],
675 const bool flip_normal,
676 const CurveFillSolverType fill_solver,
677 const CurveFillRuleType fill_rule)
678{
679 switch (fill_solver) {
680 case CU_FILL_SOLVER_CDT: {
682 switch (fill_rule) {
684 output_type = CDT_INSIDE_WITH_HOLES_NONZERO;
685 break;
686 }
688 /* Default, already set. */
689 break;
690 }
691 }
692 displist_fill_cdt(dispbase, to, flip_normal, output_type);
693 return;
694 }
696 /* Use the fallback, below. */
697 break;
698 }
699 }
700 /* Fallback for SWEEP_LINE and any unknown values. */
701 displist_fill_scanfill(dispbase, to, normal_proj, flip_normal);
702}
703
704static void bevels_to_filledpoly(const Curve *cu, ListBaseT<DispList> *dispbase)
705{
706 ListBaseT<DispList> front = {nullptr, nullptr};
707 ListBaseT<DispList> back = {nullptr, nullptr};
708
709 for (const DispList &dl : *dispbase) {
710 if (dl.type == DL_SURF) {
711 if ((dl.flag & DL_CYCL_V) && (dl.flag & DL_CYCL_U) == 0) {
712 if ((cu->flag & CU_BACK) && (dl.flag & DL_BACK_CURVE)) {
713 DispList *dlnew = MEM_new_zeroed<DispList>(__func__);
714 BLI_addtail(&front, dlnew);
715 dlnew->verts = MEM_new_array_uninitialized<float>(3 * size_t(dl.parts), __func__);
716 dlnew->nr = dl.parts;
717 dlnew->parts = 1;
718 dlnew->type = DL_POLY;
719 dlnew->flag = DL_BACK_CURVE | (dl.flag & DL_REVERSED);
720 dlnew->col = dl.col;
721 dlnew->charidx = dl.charidx;
722
723 const float *old_verts = dl.verts;
724 float *new_verts = dlnew->verts;
725 for (int i = 0; i < dl.parts; i++) {
726 copy_v3_v3(new_verts, old_verts);
727 new_verts += 3;
728 old_verts += 3 * dl.nr;
729 }
730 }
731 if ((cu->flag & CU_FRONT) && (dl.flag & DL_FRONT_CURVE)) {
732 DispList *dlnew = MEM_new_zeroed<DispList>(__func__);
733 BLI_addtail(&back, dlnew);
734 dlnew->verts = MEM_new_array_uninitialized<float>(3 * size_t(dl.parts), __func__);
735 dlnew->nr = dl.parts;
736 dlnew->parts = 1;
737 dlnew->type = DL_POLY;
738 dlnew->flag = DL_FRONT_CURVE | (dl.flag & DL_REVERSED);
739 dlnew->col = dl.col;
740 dlnew->charidx = dl.charidx;
741
742 const float *old_verts = dl.verts + 3 * (dl.nr - 1);
743 float *new_verts = dlnew->verts;
744 for (int i = 0; i < dl.parts; i++) {
745 copy_v3_v3(new_verts, old_verts);
746 new_verts += 3;
747 old_verts += 3 * dl.nr;
748 }
749 }
750 }
751 }
752 }
753
754 const float z_up[3] = {0.0f, 0.0f, -1.0f};
755 BKE_displist_fill(&front,
756 dispbase,
757 z_up,
758 true,
761 BKE_displist_fill(&back,
762 dispbase,
763 z_up,
764 false,
767
768 BKE_displist_free(&front);
769 BKE_displist_free(&back);
770
771 BKE_displist_fill(dispbase,
772 dispbase,
773 z_up,
774 false,
777}
778
779static void curve_to_filledpoly(const Curve *cu, ListBaseT<DispList> *dispbase)
780{
781 if (!CU_DO_2DFILL(cu)) {
782 return;
783 }
784
785 if (dispbase->first() && (dispbase->first())->type == DL_SURF) {
786 bevels_to_filledpoly(cu, dispbase);
787 }
788 else {
789 const float z_up[3] = {0.0f, 0.0f, -1.0f};
790 BKE_displist_fill(dispbase,
791 dispbase,
792 z_up,
793 false,
796 }
797}
798
799/* taper rules:
800 * - only 1 curve
801 * - first point left, last point right
802 * - based on subdivided points in original curve, not on points in taper curve (still)
803 */
804static float displist_calc_taper(Depsgraph *depsgraph,
805 const Scene *scene,
806 Object *taperobj,
807 float fac)
808{
809 if (taperobj == nullptr || taperobj->type != OB_CURVES_LEGACY) {
810 return 1.0;
811 }
812
813 DispList *dl = taperobj->runtime->curve_cache ? taperobj->runtime->curve_cache->disp.first() :
814 nullptr;
815 if (dl == nullptr) {
816 BKE_displist_make_curveTypes(depsgraph, scene, taperobj, false);
817 dl = taperobj->runtime->curve_cache->disp.first();
818 }
819 if (dl) {
820 float minx, dx, *fp;
821 int a;
822
823 /* horizontal size */
824 minx = dl->verts[0];
825 dx = dl->verts[3 * (dl->nr - 1)] - minx;
826 if (dx > 0.0f) {
827 fp = dl->verts;
828 for (a = 0; a < dl->nr; a++, fp += 3) {
829 if ((fp[0] - minx) / dx >= fac) {
830 /* interpolate with prev */
831 if (a > 0) {
832 float fac1 = (fp[-3] - minx) / dx;
833 float fac2 = (fp[0] - minx) / dx;
834 if (fac1 != fac2) {
835 return fp[1] * (fac1 - fac) / (fac1 - fac2) + fp[-2] * (fac - fac2) / (fac1 - fac2);
836 }
837 }
838 return fp[1];
839 }
840 }
841 return fp[-2]; /* Last y coordinate. */
842 }
843 }
844
845 return 1.0;
846}
847
849 Depsgraph *depsgraph, const Scene *scene, Object *taperobj, int cur, int tot)
850{
851 const float fac = float(cur) / float(tot - 1);
852
853 return displist_calc_taper(depsgraph, scene, taperobj, fac);
854}
855
857 const Object *ob,
858 const bool for_render,
859 const bool editmode)
860{
861 VirtualModifierData virtual_modifier_data;
862 ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtual_modifier_data);
863
864 ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime;
865 if (editmode) {
866 required_mode = ModifierMode(int(required_mode) | eModifierMode_Editmode);
867 }
868
869 ModifierData *pretessellatePoint = nullptr;
870 for (; md; md = md->next) {
872
873 if (!BKE_modifier_is_enabled(scene, md, required_mode)) {
874 continue;
875 }
877 return pretessellatePoint;
878 }
879
880 if (md->type == eModifierType_Smooth) {
881 /* Smooth modifier works with mesh edges explicitly
882 * (so needs tessellation, thus cannot work on control points). */
884 return pretessellatePoint;
885 }
887 pretessellatePoint = md;
888
889 /* this modifiers are moving point of tessellation automatically
890 * (some of them even can't be applied on tessellated curve), set flag
891 * for information button in modifier's header. */
893 }
894 else if (md->mode & eModifierMode_ApplyOnSpline) {
895 pretessellatePoint = md;
896 }
897 }
898
899 return pretessellatePoint;
900}
901
902void BKE_curve_calc_modifiers_pre(Depsgraph *depsgraph,
903 const Scene *scene,
904 Object *ob,
905 ListBaseT<Nurb> *source_nurb,
906 ListBaseT<Nurb> *target_nurb,
907 const bool for_render)
908{
909 const Curve *cu = id_cast<const Curve *>(ob->data);
910
912
913 const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
914 ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime;
915 if (editmode) {
916 required_mode = ModifierMode(int(required_mode) | eModifierMode_Editmode);
917 }
918
919 ModifierApplyFlag apply_flag = ModifierApplyFlag(0);
920 if (editmode) {
921 apply_flag = MOD_APPLY_USECACHE;
922 }
923 if (for_render) {
924 apply_flag = MOD_APPLY_RENDER;
925 }
926
927 float *keyVerts = nullptr;
928 Array<float3> deformedVerts;
929 if (!editmode) {
930 int numElems = 0;
931 keyVerts = BKE_key_evaluate_object(ob, &numElems);
932
933 if (keyVerts) {
934 BLI_assert(BKE_keyblock_curve_element_count(source_nurb) == numElems);
935
936 /* split coords from key data, the latter also includes
937 * tilts, which is passed through in the modifier stack.
938 * this is also the reason curves do not use a virtual
939 * shape key modifier yet. */
940 deformedVerts = BKE_curve_nurbs_key_vert_coords_alloc(source_nurb, keyVerts);
941 }
942 }
943
944 const ModifierEvalContext mectx = {depsgraph, ob, apply_flag};
945 ModifierData *pretessellatePoint = curve_get_tessellate_point(scene, ob, for_render, editmode);
946
947 if (pretessellatePoint) {
948 VirtualModifierData virtual_modifier_data;
949 for (ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtual_modifier_data); md;
950 md = md->next)
951 {
952 const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
953
954 if (!BKE_modifier_is_enabled(scene, md, required_mode)) {
955 continue;
956 }
958 continue;
959 }
960
961 bke::ScopedModifierTimer modifier_timer{*md};
962
963 if (deformedVerts.is_empty()) {
964 deformedVerts = BKE_curve_nurbs_vert_coords_alloc(source_nurb);
965 }
966
967 mti->deform_verts(md, &mectx, nullptr, deformedVerts);
968
969 if (md == pretessellatePoint) {
970 break;
971 }
972 }
973 }
974
975 if (!deformedVerts.is_empty()) {
976 BKE_curve_nurbs_vert_coords_apply(target_nurb, deformedVerts, false);
977 }
978 if (keyVerts) { /* these are not passed through modifier stack */
979 BKE_curve_nurbs_key_vert_tilts_apply(target_nurb, keyVerts);
980 }
981
982 if (keyVerts) {
983 MEM_delete(keyVerts);
984 }
985}
986
992 ModifierData *first_modifier,
993 const Scene *scene,
994 const ModifierMode required_mode,
995 const bool editmode)
996{
997 /* Skip implicit filling and conversion to mesh when using "fast text editing". */
998 if ((curve->flag & CU_FAST) && editmode) {
999 return false;
1000 }
1001
1002 /* Do implicit conversion to mesh with the object bevel mode. */
1003 if (curve->bevel_mode == CU_BEV_MODE_OBJECT && curve->bevobj != nullptr) {
1004 return true;
1005 }
1006
1007 /* 2D curves are sometimes implicitly filled and converted to a mesh. */
1008 if (CU_DO_2DFILL(curve)) {
1009 return true;
1010 }
1011
1012 /* Curve objects with implicit "tube" meshes should convert implicitly to a mesh. */
1013 if (curve->extrude != 0.0f || curve->bevel_radius != 0.0f) {
1014 return true;
1015 }
1016
1017 /* If a non-geometry-nodes modifier is enabled before a nodes modifier,
1018 * force conversion to mesh, since only the nodes modifier supports curve data. */
1019 ModifierData *md = first_modifier;
1020 for (; md; md = md->next) {
1021 if (BKE_modifier_is_enabled(scene, md, required_mode)) {
1022 if (md->type == eModifierType_Nodes) {
1023 break;
1024 }
1025 return true;
1026 }
1027 }
1028
1029 return false;
1030}
1031
1033 const Scene *scene,
1034 Object *ob,
1035 const ListBaseT<DispList> *dispbase,
1036 const bool for_render)
1037{
1038 const Curve *cu = id_cast<const Curve *>(ob->data);
1039 const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
1040 const bool use_cache = !for_render;
1041
1042 ModifierApplyFlag apply_flag = for_render ? MOD_APPLY_RENDER : ModifierApplyFlag(0);
1043 ModifierMode required_mode = for_render ? eModifierMode_Render : eModifierMode_Realtime;
1044 if (editmode) {
1045 required_mode = ModifierMode(int(required_mode) | eModifierMode_Editmode);
1046 }
1047
1048 const ModifierEvalContext mectx_deform = {
1049 depsgraph, ob, editmode ? (apply_flag | MOD_APPLY_USECACHE) : apply_flag};
1050 const ModifierEvalContext mectx_apply = {
1051 depsgraph, ob, use_cache ? (apply_flag | MOD_APPLY_USECACHE) : apply_flag};
1052
1053 ModifierData *pretessellatePoint = curve_get_tessellate_point(scene, ob, for_render, editmode);
1054
1055 VirtualModifierData virtual_modifier_data;
1056 ModifierData *md = pretessellatePoint == nullptr ?
1057 BKE_modifiers_get_virtual_modifierlist(ob, &virtual_modifier_data) :
1058 pretessellatePoint->next;
1059
1060 bke::GeometrySet geometry_set;
1061 if (ob->type == OB_SURF ||
1062 do_curve_implicit_mesh_conversion(cu, md, scene, required_mode, editmode))
1063 {
1065 geometry_set.replace_mesh(mesh);
1066 }
1067 else {
1068 geometry_set.replace_curves(
1070 }
1071
1072 for (; md; md = md->next) {
1074 if (!BKE_modifier_is_enabled(scene, md, required_mode)) {
1075 continue;
1076 }
1077
1078 bke::ScopedModifierTimer modifier_timer{*md};
1079
1080 if (md->type == eModifierType_Nodes) {
1081 mti->modify_geometry_set(md, &mectx_apply, &geometry_set);
1082 continue;
1083 }
1084
1085 if (!geometry_set.has_mesh()) {
1086 geometry_set.replace_mesh(BKE_mesh_new_nomain(0, 0, 0, 0));
1087 }
1088 Mesh *mesh = geometry_set.get_mesh_for_write();
1089
1090 if (mti->type == ModifierTypeType::OnlyDeform) {
1091 mti->deform_verts(md, &mectx_deform, mesh, mesh->vert_positions_for_write());
1092 mesh->tag_positions_changed();
1093 }
1094 else {
1095 Mesh *output_mesh = mti->modify_mesh(md, &mectx_apply, mesh);
1096 if (mesh != output_mesh) {
1097 geometry_set.replace_mesh(output_mesh);
1098 }
1099 }
1100 }
1101
1102 if (geometry_set.has_mesh()) {
1103 Mesh *final_mesh = geometry_set.get_mesh_for_write();
1104 STRNCPY(final_mesh->id.name, cu->id.name);
1105 *(reinterpret_cast<short *>(final_mesh->id.name)) = ID_ME;
1106 }
1107
1108 return geometry_set;
1109}
1110
1112{
1113 int b, p1, p2, p3, p4;
1114
1115 dl->totindex = 0;
1116
1118 4 * size_t(dl->parts + 1) * size_t(dl->nr + 1), __func__);
1119
1120 for (int a = 0; a < dl->parts; a++) {
1121
1122 if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) {
1123 break;
1124 }
1125
1126 for (; b < dl->nr; b++, index += 4) {
1127 index[0] = p1;
1128 index[1] = p2;
1129 index[2] = p4;
1130 index[3] = p3;
1131
1132 dl->totindex++;
1133
1134 p2 = p1;
1135 p1++;
1136 p4 = p3;
1137 p3++;
1138 }
1139 }
1140}
1141
1142static bke::GeometrySet evaluate_surface_object(Depsgraph *depsgraph,
1143 const Scene *scene,
1144 Object *ob,
1145 const bool for_render,
1146 ListBaseT<DispList> *r_dispbase)
1147{
1148 BLI_assert(ob->type == OB_SURF);
1149 const Curve *cu = id_cast<const Curve *>(ob->data);
1150
1151 ListBaseT<Nurb> *deformed_nurbs = &ob->runtime->curve_cache->deformed_nurbs;
1152
1153 if (!for_render && cu->editnurb) {
1155 }
1156 else {
1157 BKE_nurbList_duplicate(deformed_nurbs, &cu->nurb);
1158 }
1159
1160 BKE_curve_calc_modifiers_pre(depsgraph, scene, ob, deformed_nurbs, deformed_nurbs, for_render);
1161
1162 for (const Nurb &nu : *deformed_nurbs) {
1163 if (!(for_render || nu.hide == 0) || !BKE_nurb_check_valid_uv(&nu)) {
1164 continue;
1165 }
1166
1167 const int resolu = (for_render && cu->resolu_ren) ? cu->resolu_ren : nu.resolu;
1168 const int resolv = (for_render && cu->resolv_ren) ? cu->resolv_ren : nu.resolv;
1169
1170 if (nu.pntsv == 1) {
1171 const int len = SEGMENTSU(&nu) * resolu;
1172
1173 DispList *dl = MEM_new_zeroed<DispList>(__func__);
1174 dl->verts = MEM_new_array_uninitialized<float>(3 * size_t(len), __func__);
1175
1176 BLI_addtail(r_dispbase, dl);
1177 dl->parts = 1;
1178 dl->nr = len;
1179 dl->col = nu.mat_nr;
1180 dl->charidx = nu.charidx;
1181 dl->rt = nu.flag;
1182
1183 float *data = dl->verts;
1184 if (nu.flagu & CU_NURB_CYCLIC) {
1185 dl->type = DL_POLY;
1186 }
1187 else {
1188 dl->type = DL_SEGM;
1189 }
1190
1191 BKE_nurb_makeCurve(&nu, data, nullptr, nullptr, nullptr, resolu, sizeof(float[3]));
1192 }
1193 else {
1194 const int len = (nu.pntsu * resolu) * (nu.pntsv * resolv);
1195
1196 DispList *dl = MEM_new_zeroed<DispList>(__func__);
1197 dl->verts = MEM_new_array_uninitialized<float>(3 * size_t(len), __func__);
1198 BLI_addtail(r_dispbase, dl);
1199
1200 dl->col = nu.mat_nr;
1201 dl->charidx = nu.charidx;
1202 dl->rt = nu.flag;
1203
1204 float *data = dl->verts;
1205 dl->type = DL_SURF;
1206
1207 dl->parts = (nu.pntsu * resolu); /* in reverse, because makeNurbfaces works that way */
1208 dl->nr = (nu.pntsv * resolv);
1209 if (nu.flagv & CU_NURB_CYCLIC) {
1210 dl->flag |= DL_CYCL_U; /* reverse too! */
1211 }
1212 if (nu.flagu & CU_NURB_CYCLIC) {
1213 dl->flag |= DL_CYCL_V;
1214 }
1215
1216 BKE_nurb_makeFaces(&nu, data, 0, resolu, resolv);
1217
1218 /* gl array drawing: using indices */
1220 }
1221 }
1222
1223 curve_to_filledpoly(cu, r_dispbase);
1225 depsgraph, scene, ob, r_dispbase, for_render);
1226 if (!geometry_set.has_mesh()) {
1227 geometry_set.replace_mesh(BKE_mesh_new_nomain(0, 0, 0, 0));
1228 }
1229 return geometry_set;
1230}
1231
1232static void rotateBevelPiece(const Curve *cu,
1233 const BevPoint *bevp,
1234 const BevPoint *nbevp,
1235 const DispList *dlb,
1236 const float bev_blend,
1237 const float widfac,
1238 const float radius_factor,
1239 float **r_data)
1240{
1241 float *data = *r_data;
1242 const float *fp = dlb->verts;
1243 for (int b = 0; b < dlb->nr; b++, fp += 3, data += 3) {
1244 if (cu->flag & CU_3D) {
1245 float vec[3], quat[4];
1246
1247 vec[0] = fp[1] + widfac;
1248 vec[1] = fp[2];
1249 vec[2] = 0.0;
1250
1251 if (nbevp == nullptr) {
1252 copy_v3_v3(data, bevp->vec);
1253 copy_qt_qt(quat, bevp->quat);
1254 }
1255 else {
1256 interp_v3_v3v3(data, bevp->vec, nbevp->vec, bev_blend);
1257 interp_qt_qtqt(quat, bevp->quat, nbevp->quat, bev_blend);
1258 }
1259
1260 mul_qt_v3(quat, vec);
1261
1262 data[0] += radius_factor * vec[0];
1263 data[1] += radius_factor * vec[1];
1264 data[2] += radius_factor * vec[2];
1265 }
1266 else {
1267 float sina, cosa;
1268
1269 if (nbevp == nullptr) {
1270 copy_v3_v3(data, bevp->vec);
1271 sina = bevp->sina;
1272 cosa = bevp->cosa;
1273 }
1274 else {
1275 interp_v3_v3v3(data, bevp->vec, nbevp->vec, bev_blend);
1276
1277 /* perhaps we need to interpolate angles instead. but the thing is
1278 * cosa and sina are not actually sine and cosine
1279 */
1280 sina = nbevp->sina * bev_blend + bevp->sina * (1.0f - bev_blend);
1281 cosa = nbevp->cosa * bev_blend + bevp->cosa * (1.0f - bev_blend);
1282 }
1283
1284 data[0] += radius_factor * (widfac + fp[1]) * sina;
1285 data[1] += radius_factor * (widfac + fp[1]) * cosa;
1286 data[2] += radius_factor * fp[2];
1287 }
1288 }
1289
1290 *r_data = data;
1291}
1292
1293static void fillBevelCap(const Nurb *nu,
1294 const DispList *dlb,
1295 const float *prev_fp,
1296 ListBaseT<DispList> *dispbase)
1297{
1298 DispList *dl = MEM_new_zeroed<DispList>(__func__);
1299 dl->verts = MEM_new_array_uninitialized<float>(3 * size_t(dlb->nr), __func__);
1300 memcpy(dl->verts, prev_fp, sizeof(float[3]) * dlb->nr);
1301
1302 dl->type = DL_POLY;
1303
1304 dl->parts = 1;
1305 dl->nr = dlb->nr;
1306 dl->col = nu->mat_nr;
1307 dl->charidx = nu->charidx;
1308 dl->rt = nu->flag;
1309
1310 BLI_addtail(dispbase, dl);
1311}
1312
1314 const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
1315{
1316 float normsum = 0.0f;
1317 float *seglen = bl->seglen;
1318 int *segbevcount = bl->segbevcount;
1319 int bevcount = 0, nr = bl->nr;
1320
1321 float bev_fl = bevfac * (bl->nr - 1);
1322 *r_bev = int(bev_fl);
1323
1324 while (bevcount < nr - 1) {
1325 float normlen = *seglen / spline_length;
1326 if (normsum + normlen > bevfac) {
1327 bev_fl = bevcount + (bevfac - normsum) / normlen * *segbevcount;
1328 *r_bev = int(bev_fl);
1329 *r_blend = bev_fl - *r_bev;
1330 break;
1331 }
1332 normsum += normlen;
1333 bevcount += *segbevcount;
1334 segbevcount++;
1335 seglen++;
1336 }
1337}
1338
1340 const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
1341{
1342 const float len_target = bevfac * spline_length;
1343 BevPoint *bevp = bl->bevpoints;
1344 float len_next = 0.0f, len = 0.0f;
1345 int i = 0, nr = bl->nr;
1346
1347 while (nr--) {
1348 bevp++;
1349 len_next = len + bevp->offset;
1350 if (len_next > len_target) {
1351 break;
1352 }
1353 len = len_next;
1354 i++;
1355 }
1356
1357 *r_bev = i;
1358 *r_blend = (len_target - len) / bevp->offset;
1359}
1360
1362 const BevList *bl, int *r_start, float *r_firstblend, int *r_steps, float *r_lastblend)
1363{
1364 *r_start = 0;
1365 *r_steps = bl->nr;
1366 *r_firstblend = 1.0f;
1367 *r_lastblend = 1.0f;
1368}
1369
1370static void calc_bevfac_mapping(const Curve *cu,
1371 const BevList *bl,
1372 const Nurb *nu,
1373 int *r_start,
1374 float *r_firstblend,
1375 int *r_steps,
1376 float *r_lastblend)
1377{
1378 float tmpf, total_length = 0.0f;
1379 int end = 0, i;
1380
1381 if ((BKE_nurb_check_valid_u(nu) == false) ||
1382 /* not essential, but skips unnecessary calculation */
1383 (min_ff(cu->bevfac1, cu->bevfac2) == 0.0f && max_ff(cu->bevfac1, cu->bevfac2) == 1.0f))
1384 {
1385 calc_bevfac_mapping_default(bl, r_start, r_firstblend, r_steps, r_lastblend);
1386 return;
1387 }
1388
1391 {
1392 for (i = 0; i < SEGMENTSU(nu); i++) {
1393 total_length += bl->seglen[i];
1394 }
1395 }
1396
1397 switch (cu->bevfac1_mapping) {
1398 case CU_BEVFAC_MAP_RESOLU: {
1399 const float start_fl = cu->bevfac1 * (bl->nr - 1);
1400 *r_start = int(start_fl);
1401 *r_firstblend = 1.0f - (start_fl - (*r_start));
1402 break;
1403 }
1404 case CU_BEVFAC_MAP_SEGMENT: {
1405 calc_bevfac_segment_mapping(bl, cu->bevfac1, total_length, r_start, r_firstblend);
1406 *r_firstblend = 1.0f - *r_firstblend;
1407 break;
1408 }
1409 case CU_BEVFAC_MAP_SPLINE: {
1410 calc_bevfac_spline_mapping(bl, cu->bevfac1, total_length, r_start, r_firstblend);
1411 *r_firstblend = 1.0f - *r_firstblend;
1412 break;
1413 }
1414 }
1415
1416 switch (cu->bevfac2_mapping) {
1417 case CU_BEVFAC_MAP_RESOLU: {
1418 const float end_fl = cu->bevfac2 * (bl->nr - 1);
1419 end = int(end_fl);
1420
1421 *r_steps = 2 + end - *r_start;
1422 *r_lastblend = end_fl - end;
1423 break;
1424 }
1425 case CU_BEVFAC_MAP_SEGMENT: {
1426 calc_bevfac_segment_mapping(bl, cu->bevfac2, total_length, &end, r_lastblend);
1427 *r_steps = end - *r_start + 2;
1428 break;
1429 }
1430 case CU_BEVFAC_MAP_SPLINE: {
1431 calc_bevfac_spline_mapping(bl, cu->bevfac2, total_length, &end, r_lastblend);
1432 *r_steps = end - *r_start + 2;
1433 break;
1434 }
1435 }
1436
1437 if (end < *r_start || (end == *r_start && *r_lastblend < 1.0f - *r_firstblend)) {
1438 std::swap(*r_start, end);
1439 tmpf = *r_lastblend;
1440 *r_lastblend = 1.0f - *r_firstblend;
1441 *r_firstblend = 1.0f - tmpf;
1442 *r_steps = end - *r_start + 2;
1443 }
1444
1445 if (*r_start + *r_steps > bl->nr) {
1446 *r_steps = bl->nr - *r_start;
1447 *r_lastblend = 1.0f;
1448 }
1449}
1450
1452 const Scene *scene,
1453 Object *ob,
1454 const bool for_render,
1455 ListBaseT<DispList> *r_dispbase)
1456{
1458 const Curve *cu = id_cast<const Curve *>(ob->data);
1459
1460 ListBaseT<Nurb> *deformed_nurbs = &ob->runtime->curve_cache->deformed_nurbs;
1461
1462 if (ob->type == OB_FONT) {
1463 BKE_vfont_to_curve_nubase(ob, FO_EDIT, deformed_nurbs);
1464 }
1465 else {
1467 }
1468
1469 BKE_curve_calc_modifiers_pre(depsgraph, scene, ob, deformed_nurbs, deformed_nurbs, for_render);
1470
1471 BKE_curve_bevelList_make(ob, deformed_nurbs, for_render);
1472
1473 if ((cu->flag & CU_PATH) ||
1475 {
1477 }
1478
1479 /* If curve has no bevel will return nothing */
1480 ListBaseT<DispList> dlbev = BKE_curve_bevel_make(cu);
1481
1482 /* no bevel or extrude, and no width correction? */
1483 if (dlbev.is_empty() && cu->offset == 1.0f) {
1484 curve_to_displist(cu, deformed_nurbs, for_render, r_dispbase);
1485 }
1486 else {
1487 const float widfac = cu->offset - 1.0f;
1488
1489 const BevList *bl = ob->runtime->curve_cache->bev.first();
1490 const Nurb *nu = deformed_nurbs->first();
1491 for (; bl && nu; bl = bl->next, nu = nu->next) {
1492 float *data;
1493
1494 if (bl->nr == 0) { /* blank bevel lists can happen */
1495 continue;
1496 }
1497
1498 /* exception handling; curve without bevel or extrude, with width correction */
1499 if (dlbev.is_empty()) {
1500 DispList *dl = MEM_new_zeroed<DispList>("makeDispListbev");
1501 dl->verts = MEM_new_array_uninitialized<float>(3 * size_t(bl->nr), "dlverts");
1502 BLI_addtail(r_dispbase, dl);
1503
1504 if (bl->poly != -1) {
1505 dl->type = DL_POLY;
1506 }
1507 else {
1508 dl->type = DL_SEGM;
1510 }
1511 if (bl->reversed) {
1512 dl->flag |= DL_REVERSED;
1513 }
1514
1515 dl->parts = 1;
1516 dl->nr = bl->nr;
1517 dl->col = nu->mat_nr;
1518 dl->charidx = nu->charidx;
1519 dl->rt = nu->flag;
1520
1521 int a = dl->nr;
1522 BevPoint *bevp = bl->bevpoints;
1523 data = dl->verts;
1524 while (a--) {
1525 data[0] = bevp->vec[0] + widfac * bevp->sina;
1526 data[1] = bevp->vec[1] + widfac * bevp->cosa;
1527 data[2] = bevp->vec[2];
1528 bevp++;
1529 data += 3;
1530 }
1531 }
1532 else {
1533 ListBaseT<DispList> bottom_capbase = {nullptr, nullptr};
1534 ListBaseT<DispList> top_capbase = {nullptr, nullptr};
1535 float bottom_no[3] = {0.0f};
1536 float top_no[3] = {0.0f};
1537 float first_blend = 0.0f, last_blend = 0.0f;
1538 int start, steps = 0;
1539
1540 if (nu->flagu & CU_NURB_CYCLIC) {
1541 calc_bevfac_mapping_default(bl, &start, &first_blend, &steps, &last_blend);
1542 }
1543 else {
1544 if (fabsf(cu->bevfac2 - cu->bevfac1) < FLT_EPSILON) {
1545 continue;
1546 }
1547
1548 calc_bevfac_mapping(cu, bl, nu, &start, &first_blend, &steps, &last_blend);
1549 }
1550
1551 for (DispList &dlb : dlbev) {
1552 /* For each part of the bevel use a separate display-block. */
1553 DispList *dl = MEM_new_zeroed<DispList>(__func__);
1554 dl->verts = data = MEM_new_array_uninitialized<float>(3 * size_t(dlb.nr) * size_t(steps),
1555 __func__);
1556 BLI_addtail(r_dispbase, dl);
1557
1558 dl->type = DL_SURF;
1559
1560 dl->flag = dlb.flag & (DL_FRONT_CURVE | DL_BACK_CURVE);
1561 if (dlb.type == DL_POLY) {
1562 dl->flag |= DL_CYCL_U;
1563 }
1564 if ((bl->poly >= 0) && (steps > 2)) {
1565 dl->flag |= DL_CYCL_V;
1566 }
1567 if (bl->reversed) {
1568 dl->flag |= DL_REVERSED;
1569 }
1570
1571 dl->parts = steps;
1572 dl->nr = dlb.nr;
1573 dl->col = nu->mat_nr;
1574 dl->charidx = nu->charidx;
1575 dl->rt = nu->flag;
1576
1577 /* for each point of poly make a bevel piece */
1578 BevPoint *bevp_first = bl->bevpoints;
1579 BevPoint *bevp_last = &bl->bevpoints[bl->nr - 1];
1580 BevPoint *bevp = &bl->bevpoints[start];
1581 for (int i = start, a = 0; a < steps; i++, bevp++, a++) {
1582 float radius_factor = 1.0;
1583 float *cur_data = data;
1584
1585 if (cu->taperobj == nullptr) {
1586 radius_factor = bevp->radius;
1587 }
1588 else {
1589 float taper_factor;
1590 if (cu->flag & CU_MAP_TAPER) {
1591 float len = (steps - 3) + first_blend + last_blend;
1592
1593 if (a == 0) {
1594 taper_factor = 0.0f;
1595 }
1596 else if (a == steps - 1) {
1597 taper_factor = 1.0f;
1598 }
1599 else {
1600 taper_factor = (float(a) - (1.0f - first_blend)) / len;
1601 }
1602 }
1603 else {
1604 float len = bl->nr - 1;
1605 taper_factor = float(i) / len;
1606
1607 if (a == 0) {
1608 taper_factor += (1.0f - first_blend) / len;
1609 }
1610 else if (a == steps - 1) {
1611 taper_factor -= (1.0f - last_blend) / len;
1612 }
1613 }
1614
1615 radius_factor = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_factor);
1616
1618 radius_factor *= bevp->radius;
1619 }
1620 else if (cu->taper_radius_mode == CU_TAPER_RADIUS_ADD) {
1621 radius_factor += bevp->radius;
1622 }
1623 }
1624
1625 /* rotate bevel piece and write in data */
1626 if ((a == 0) && (bevp != bevp_last)) {
1628 cu, bevp, bevp + 1, &dlb, 1.0f - first_blend, widfac, radius_factor, &data);
1629 }
1630 else if ((a == steps - 1) && (bevp != bevp_first)) {
1632 cu, bevp, bevp - 1, &dlb, 1.0f - last_blend, widfac, radius_factor, &data);
1633 }
1634 else {
1635 rotateBevelPiece(cu, bevp, nullptr, &dlb, 0.0f, widfac, radius_factor, &data);
1636 }
1637
1638 if ((cu->flag & CU_FILL_CAPS) && !(nu->flagu & CU_NURB_CYCLIC)) {
1639 if (a == 1) {
1640 /* Can occur when the `bevp->vec` is NAN, see: #141612. */
1641 if (len_squared_v3(bevp->dir) > 0.0f) {
1642 fillBevelCap(nu, &dlb, cur_data - 3 * dlb.nr, &bottom_capbase);
1643 copy_v3_v3(bottom_no, bevp->dir);
1644 }
1645 }
1646 if (a == steps - 1) {
1647 /* Can occur when the `bevp->vec` is NAN, see: #141612. */
1648 if (len_squared_v3(bevp->dir) > 0.0f) {
1649 fillBevelCap(nu, &dlb, cur_data, &top_capbase);
1650 negate_v3_v3(top_no, bevp->dir);
1651 }
1652 }
1653 }
1654 }
1655
1656 /* gl array drawing: using indices */
1658 }
1659
1660 if (bottom_capbase.first()) {
1661 BKE_displist_fill(&bottom_capbase,
1662 r_dispbase,
1663 bottom_no,
1664 false,
1667 BKE_displist_free(&bottom_capbase);
1668 }
1669 if (top_capbase.first()) {
1670 BKE_displist_fill(&top_capbase,
1671 r_dispbase,
1672 top_no,
1673 false,
1676 BKE_displist_free(&top_capbase);
1677 }
1678 }
1679 }
1680 }
1681
1682 BKE_displist_free(&dlbev);
1683
1684 curve_to_filledpoly(cu, r_dispbase);
1685 return curve_calc_modifiers_post(depsgraph, scene, ob, r_dispbase, for_render);
1686}
1687
1688void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
1689 const Scene *scene,
1690 Object *ob,
1691 const bool for_render)
1692{
1694
1696
1697 /* It's important to retrieve this after calling #BKE_object_free_derived_caches,
1698 * which may reset the object data pointer in some cases. */
1699 const Curve &original_curve = *id_cast<const Curve *>(ob->data);
1700
1702 ListBaseT<DispList> *dispbase = &ob->runtime->curve_cache->disp;
1703
1704 if (ob->type == OB_SURF) {
1706 depsgraph, scene, ob, for_render, dispbase);
1707 ob->runtime->geometry_set_eval = new bke::GeometrySet(std::move(geometry));
1708 }
1709 else {
1711 depsgraph, scene, ob, for_render, dispbase);
1712
1713 if (geometry.has_curves()) {
1714 /* Create a copy of the original curve and add necessary pointers to evaluated and edit mode
1715 * data. This is needed for a few reasons:
1716 * - Existing code from before curve evaluation was changed to use #GeometrySet expected to
1717 * have a copy of the original curve data. (Any evaluated data was placed in
1718 * #Object.runtime->curve_cache).
1719 * - The result of modifier evaluation is not a #Curve data-block but a #Curves data-block,
1720 * which can support constructive modifiers and geometry nodes.
1721 * - The dependency graph has handling of edit mode pointers (see #update_edit_mode_pointers)
1722 * but it doesn't seem to work in this case.
1723 *
1724 * Since the plan is to replace this legacy curve object with the curves data-block
1725 * (see #95355), this somewhat hacky inefficient solution is relatively temporary.
1726 */
1727 Curve &cow_curve = *reinterpret_cast<Curve *>(
1728 BKE_id_copy_ex(nullptr, &original_curve.id, nullptr, LIB_ID_COPY_LOCALIZE));
1729 cow_curve.curve_eval = geometry.get_curves();
1730 /* Copy edit mode pointers necessary for drawing to the duplicated curve. */
1731 cow_curve.editnurb = original_curve.editnurb;
1732 cow_curve.editfont = original_curve.editfont;
1733 cow_curve.edit_data_from_original = true;
1734 BKE_object_eval_assign_data(ob, &cow_curve.id, true);
1735 }
1736
1737 ob->runtime->geometry_set_eval = new bke::GeometrySet(std::move(geometry));
1738 }
1739}
1740
1741void BKE_displist_minmax(const ListBaseT<DispList> *dispbase, float min[3], float max[3])
1742{
1743 bool empty = true;
1744
1745 for (const DispList &dl : *dispbase) {
1746 const int tot = dl.type == DL_INDEX3 ? dl.nr : dl.nr * dl.parts;
1747 for (const int i : IndexRange(tot)) {
1748 minmax_v3v3_v3(min, max, &dl.verts[i * 3]);
1749 }
1750 if (tot != 0) {
1751 empty = false;
1752 }
1753 }
1754
1755 if (empty) {
1756 zero_v3(min);
1757 zero_v3(max);
1758 }
1759}
1760
1761} // namespace blender
#define CU_DO_2DFILL(cu)
Definition BKE_curve.hh:96
#define SEGMENTSU(nu)
Definition BKE_curve.hh:84
display list (or rather multi purpose list) stuff.
General operations, lookup, etc. for blender objects.
#define BLI_SCANFILL_ARENA_SIZE
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define ELEM(...)
ccl_device_inline float2 to_point(const float gamma, const float b)
btScalar max
MutableSpan< T > as_mutable_span()
Definition BLI_array.hh:259
void fill(const T &value) const
Definition BLI_array.hh:283
void reinitialize(const int64_t new_size)
Definition BLI_array.hh:430
bool is_empty() const
Definition BLI_array.hh:275
Value & lookup_or_add_default(const Key &key)
Definition BLI_map.hh:639
ValueIterator values() const &
Definition BLI_map.hh:884
int64_t size() const
Definition BLI_map.hh:976
constexpr std::reverse_iterator< T * > rbegin() const
Definition BLI_span.hh:559
constexpr T * end() const
Definition BLI_span.hh:554
constexpr T * begin() const
Definition BLI_span.hh:550
constexpr std::reverse_iterator< T * > rend() const
Definition BLI_span.hh:563
constexpr int64_t size() const
Definition BLI_span.hh:256
int64_t size() const
bool is_empty() const
IndexRange index_range() const
void append_unchecked(const T &value)
void reserve(const int64_t min_capacity)
#define FLT_EPSILON
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
Curves * curve_legacy_to_curves(const Curve &curve_legacy)
T length_squared(const VecBase< T, Size > &a)
T clamp(const T &a, const T &min, const T &max)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
CDT_result< T > delaunay_2d_calc(const CDT_input< T > &input, CDT_output_type output_type)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
BMesh Iterators.
MINLINE float min_ff(float a, float b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE void negate_v3_v3(float r[3], const float a[3])
static void fillBevelCap(const Nurb *nu, const DispList *dlb, const float *prev_fp, ListBaseT< DispList > *dispbase)
Definition displist.cc:1293
__int64 int64_t
Definition BKE_text.h:90
char * STRNCPY(char(&dst)[N], const char *src)
static void curve_to_filledpoly(const Curve *cu, ListBaseT< DispList > *dispbase)
Definition displist.cc:779
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
static void calc_bevfac_mapping(const Curve *cu, const BevList *bl, const Nurb *nu, int *r_start, float *r_firstblend, int *r_steps, float *r_lastblend)
Definition displist.cc:1370
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
const ListBaseT< Nurb > * BKE_curve_nurbs_get_for_read(const Curve *cu)
Definition curve.cc:5001
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
void BKE_displist_fill(const ListBaseT< DispList > *dispbase, ListBaseT< DispList > *to, const float normal_proj[3], bool flip_normal, CurveFillSolverType fill_solver, CurveFillRuleType fill_rule)
Definition displist.cc:672
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
void BKE_displist_free(ListBaseT< DispList > *lb)
Definition displist.cc:68
static void rotateBevelPiece(const Curve *cu, const BevPoint *bevp, const BevPoint *nbevp, const DispList *dlb, const float bev_blend, const float widfac, const float radius_factor, float **r_data)
Definition displist.cc:1232
void BKE_object_eval_assign_data(Object *object, ID *data, bool is_owned)
Definition object.cc:1786
@ CDT_INSIDE_WITH_HOLES
@ CDT_INSIDE_WITH_HOLES_NONZERO
VecBase< double, 2 > double2
@ BLI_SCANFILL_CALC_POLYS
@ BLI_SCANFILL_CALC_HOLES
@ BLI_SCANFILL_CALC_REMOVE_DOUBLES
void BKE_curve_calc_modifiers_pre(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, ListBaseT< Nurb > *source_nurb, ListBaseT< Nurb > *target_nurb, bool for_render)
static bool do_curve_implicit_mesh_conversion(const Curve *curve, ModifierData *first_modifier, const Scene *scene, const ModifierMode required_mode, const bool editmode)
Definition displist.cc:991
DispList * BKE_displist_find(ListBaseT< DispList > *lb, int type)
Definition displist.cc:75
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, const ID *id)
ATTR_WARN_UNUSED_RESULT const BMVert * v
@ LIB_ID_COPY_LOCALIZE
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:259
const ListBaseT< Nurb > * BKE_curve_editNurbs_get_for_read(const Curve *cu)
Definition curve.cc:450
void mul_qt_v3(const float q[4], float r[3])
void BKE_curve_nurbs_key_vert_tilts_apply(ListBaseT< Nurb > *lb, const float *key)
Definition curve.cc:4699
unsigned int uint32_t
Definition BKE_text.h:81
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BKE_object_free_derived_caches(Object *ob)
Definition object.cc:1810
@ eModifierMode_ApplyOnSpline
void copy_qt_qt(float q[4], const float a[4])
@ CU_FILL_SOLVER_SWEEP_LINE
BMesh const char void * data
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
void BKE_nurb_makeCurve(const Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
Definition curve.cc:1493
void BLI_scanfill_begin_arena(ScanFillContext *sf_ctx, struct MemArena *arena)
Definition scanfill.cc:791
@ MOD_APPLY_USECACHE
struct ScanFillVert * BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3])
Definition scanfill.cc:105
void BKE_curve_nurbs_vert_coords_apply(ListBaseT< Nurb > *lb, const Span< float3 > vert_coords, bool constrain_2d)
Definition curve.cc:4635
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
static float displist_calc_taper(Depsgraph *depsgraph, const Scene *scene, Object *taperobj, float fac)
Definition displist.cc:804
static void displist_surf_indices(DispList *dl)
Definition displist.cc:1111
@ DL_BACK_CURVE
@ DL_FRONT_CURVE
void BKE_displist_minmax(const ListBaseT< DispList > *dispbase, float min[3], float max[3])
Definition displist.cc:1741
Mesh * BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBaseT< DispList > *dispbase)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
Array< float3 > BKE_curve_nurbs_key_vert_coords_alloc(const ListBaseT< Nurb > *lb, const float *key)
Definition curve.cc:4670
void BKE_modifiers_clear_errors(Object *ob)
static void calc_bevfac_segment_mapping(const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
Definition displist.cc:1313
MINLINE void zero_v3(float r[3])
bool BKE_displist_surfindex_get(const struct DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
float BKE_displist_calc_taper(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *taperobj, int cur, int tot)
@ CU_BEVFAC_MAP_RESOLU
@ CU_BEVFAC_MAP_SEGMENT
@ CU_BEVFAC_MAP_SPLINE
@ CU_FILL_RULE_EVEN_ODD
@ DAG_EVAL_NEED_CURVE_PATH
struct ScanFillEdge * BLI_scanfill_edge_add(ScanFillContext *sf_ctx, struct ScanFillVert *v1, struct ScanFillVert *v2)
Definition scanfill.cc:127
static void displist_fill_scanfill(const ListBaseT< DispList > *dispbase, ListBaseT< DispList > *to, const float normal_proj[3], const bool flip_normal)
Definition displist.cc:347
Array< float3 > BKE_curve_nurbs_vert_coords_alloc(const ListBaseT< Nurb > *lb)
Definition curve.cc:4592
@ CU_TAPER_RADIUS_MULTIPLY
@ CU_TAPER_RADIUS_ADD
void BKE_nurbList_duplicate(ListBaseT< Nurb > *lb1, const ListBaseT< Nurb > *lb2)
Definition curve.cc:697
bool BKE_nurb_check_valid_u(const Nurb *nu)
Definition curve.cc:4800
void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, struct MemArena *arena)
Definition scanfill.cc:808
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
int BKE_keyblock_curve_element_count(const ListBaseT< Nurb > *nurb)
Definition key.cc:1528
static ModifierData * curve_get_tessellate_point(const Scene *scene, const Object *ob, const bool for_render, const bool editmode)
Definition displist.cc:856
MINLINE float max_ff(float a, float b)
float * BKE_key_evaluate_object(Object *ob, int *r_totelem)
Definition key.cc:1137
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
static bke::GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph, const Scene *scene, Object *ob, const bool for_render, ListBaseT< DispList > *r_dispbase)
Definition displist.cc:1451
bool BKE_nurb_check_valid_uv(const Nurb *nu)
Definition curve.cc:4816
static bke::GeometrySet evaluate_surface_object(Depsgraph *depsgraph, const Scene *scene, Object *ob, const bool for_render, ListBaseT< DispList > *r_dispbase)
Definition displist.cc:1142
static float isect_vert_calc_z(int vert_index, int edge_index, const meshintersect::CDT_result< double > &result, Span< PolyRange > poly_ranges, Span< double2 > input_verts_2d)
Definition displist.cc:274
unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, int flag, const float nor_proj[3])
Definition scanfill.cc:818
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
Definition lib_id.cc:851
void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, bool for_render)
void BKE_curve_bevelList_make(Object *ob, const ListBaseT< Nurb > *nurbs, bool for_render)
Definition curve.cc:2562
static void calc_bevfac_spline_mapping(const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
Definition displist.cc:1339
static void displist_elem_free(DispList *dl)
Definition displist.cc:52
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
Definition curve.cc:1696
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
void BKE_anim_path_calc_data(struct Object *ob)
Definition anim_path.cc:61
static void calc_bevfac_mapping_default(const BevList *bl, int *r_start, float *r_firstblend, int *r_steps, float *r_lastblend)
Definition displist.cc:1361
static void curve_to_displist(const Curve *cu, const ListBaseT< Nurb > *nubase, const bool for_render, ListBaseT< DispList > *r_dispbase)
Definition displist.cc:121
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
bool BKE_vfont_to_curve_nubase(Object *ob, eEditFontMode mode, ListBaseT< Nurb > *r_nubase)
void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
Definition curve.cc:1300
static void displist_fill_cdt(const ListBaseT< DispList > *dispbase, ListBaseT< DispList > *to, const bool flip_normal, const CDT_output_type cdt_output_type)
Definition displist.cc:615
static DispList * displist_fill_cdt_process_group(const CDTFillGroup &group, const bool flip_normal, const CDT_output_type cdt_output_type)
Definition displist.cc:480
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static void bevels_to_filledpoly(const Curve *cu, ListBaseT< DispList > *dispbase)
Definition displist.cc:704
ListBaseT< DispList > BKE_curve_bevel_make(const Curve *curve)
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
static bke::GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph, const Scene *scene, Object *ob, const ListBaseT< DispList > *dispbase, const bool for_render)
Definition displist.cc:1032
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
struct BevList * next
eBezTriple_Handle h2
eBezTriple_Handle h1
Vector< PolyRange > poly_ranges
Definition displist.cc:469
ListBaseT< Nurb > deformed_nurbs
Definition BKE_curve.hh:46
ListBaseT< BevList > bev
Definition BKE_curve.hh:45
ListBaseT< DispList > disp
Definition BKE_curve.hh:44
ListBaseT< Nurb > nurb
eCurveTaperRadiusMode taper_radius_mode
EditNurb * editnurb
eCurveBevfacMapping bevfac2_mapping
struct EditFont * editfont
CurveFillSolverType fill_solver
eCurveBevelMode bevel_mode
struct Object * bevobj
struct Object * taperobj
CurveFillRuleType fill_rule
eCurveBevfacMapping bevfac1_mapping
const struct Curves * curve_eval
char name[258]
Definition DNA_ID.h:433
struct ModifierData * next
void(*) deform_verts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, MutableSpan< float3 > positions)
Mesh *(*) modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
void(*) modify_geometry_set(ModifierData *md, const ModifierEvalContext *ctx, bke::GeometrySet *geometry_set)
eNurbKnotFlag flagu
struct Nurb * next
bke::ObjectRuntime * runtime
const DispList * dl
Definition displist.cc:267
ListBaseT< ScanFillFace > fillfacebase
ListBaseT< ScanFillVert > fillvertbase
struct ScanFillVert * v2
struct ScanFillVert * v1
struct ScanFillVert * v3
union blender::ScanFillVert::@124355022001164321030006076112165043115032300246 tmp
void replace_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)