Blender  V2.93
displist.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <math.h>
25 #include <stdio.h>
26 #include <string.h>
27 
28 #include "MEM_guardedalloc.h"
29 
30 #include "DNA_curve_types.h"
31 #include "DNA_mesh_types.h"
32 #include "DNA_object_types.h"
33 #include "DNA_scene_types.h"
34 #include "DNA_vfont_types.h"
35 
36 #include "BLI_bitmap.h"
37 #include "BLI_linklist.h"
38 #include "BLI_listbase.h"
39 #include "BLI_math.h"
40 #include "BLI_memarena.h"
41 #include "BLI_scanfill.h"
42 #include "BLI_string.h"
43 #include "BLI_utildefines.h"
44 
45 #include "BKE_anim_path.h"
46 #include "BKE_curve.h"
47 #include "BKE_displist.h"
48 #include "BKE_font.h"
49 #include "BKE_key.h"
50 #include "BKE_lattice.h"
51 #include "BKE_lib_id.h"
52 #include "BKE_mball.h"
53 #include "BKE_mball_tessellate.h"
54 #include "BKE_mesh.h"
55 #include "BKE_modifier.h"
56 #include "BKE_object.h"
57 
58 #include "BLI_sys_types.h" // for intptr_t support
59 
60 #include "DEG_depsgraph.h"
61 #include "DEG_depsgraph_query.h"
62 
63 static void boundbox_displist_object(Object *ob);
64 
66 {
67  if (dl) {
68  if (dl->verts) {
69  MEM_freeN(dl->verts);
70  }
71  if (dl->nors) {
72  MEM_freeN(dl->nors);
73  }
74  if (dl->index) {
75  MEM_freeN(dl->index);
76  }
77  MEM_freeN(dl);
78  }
79 }
80 
82 {
83  DispList *dl;
84 
85  while ((dl = BLI_pophead(lb))) {
87  }
88 }
89 
91 {
92  LISTBASE_FOREACH (DispList *, dl, lb) {
93  if (dl->type == type) {
94  return dl;
95  }
96  }
97 
98  DispList *dl = MEM_callocN(sizeof(DispList), "find_disp");
99  dl->type = type;
100  BLI_addtail(lb, dl);
101 
102  return dl;
103 }
104 
106 {
107  LISTBASE_FOREACH (DispList *, dl, lb) {
108  if (dl->type == type) {
109  return dl;
110  }
111  }
112 
113  return NULL;
114 }
115 
117 {
118  LISTBASE_FOREACH (const DispList *, dl, lb) {
119  if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) {
120  return true;
121  }
122  }
123 
124  return false;
125 }
126 
127 void BKE_displist_copy(ListBase *lbn, const ListBase *lb)
128 {
129  BKE_displist_free(lbn);
130 
131  LISTBASE_FOREACH (const DispList *, dl, lb) {
132  DispList *dln = MEM_dupallocN(dl);
133  BLI_addtail(lbn, dln);
134  dln->verts = MEM_dupallocN(dl->verts);
135  dln->nors = MEM_dupallocN(dl->nors);
136  dln->index = MEM_dupallocN(dl->index);
137  }
138 }
139 
141 {
142  float *vdata, *ndata, nor[3];
143  float *v1, *v2, *v3, *v4;
144  float *n1, *n2, *n3, *n4;
145  int a, b, p1, p2, p3, p4;
146 
147  LISTBASE_FOREACH (DispList *, dl, lb) {
148  if (dl->type == DL_INDEX3) {
149  if (dl->nors == NULL) {
150  dl->nors = MEM_callocN(sizeof(float[3]), "dlnors");
151 
152  if (dl->flag & DL_BACK_CURVE) {
153  dl->nors[2] = -1.0f;
154  }
155  else {
156  dl->nors[2] = 1.0f;
157  }
158  }
159  }
160  else if (dl->type == DL_SURF) {
161  if (dl->nors == NULL) {
162  dl->nors = MEM_callocN(sizeof(float[3]) * dl->nr * dl->parts, "dlnors");
163 
164  vdata = dl->verts;
165  ndata = dl->nors;
166 
167  for (a = 0; a < dl->parts; a++) {
168 
169  if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) {
170  break;
171  }
172 
173  v1 = vdata + 3 * p1;
174  n1 = ndata + 3 * p1;
175  v2 = vdata + 3 * p2;
176  n2 = ndata + 3 * p2;
177  v3 = vdata + 3 * p3;
178  n3 = ndata + 3 * p3;
179  v4 = vdata + 3 * p4;
180  n4 = ndata + 3 * p4;
181 
182  for (; b < dl->nr; b++) {
183  normal_quad_v3(nor, v1, v3, v4, v2);
184 
185  add_v3_v3(n1, nor);
186  add_v3_v3(n2, nor);
187  add_v3_v3(n3, nor);
188  add_v3_v3(n4, nor);
189 
190  v2 = v1;
191  v1 += 3;
192  v4 = v3;
193  v3 += 3;
194  n2 = n1;
195  n1 += 3;
196  n4 = n3;
197  n3 += 3;
198  }
199  }
200  a = dl->parts * dl->nr;
201  v1 = ndata;
202  while (a--) {
203  normalize_v3(v1);
204  v1 += 3;
205  }
206  }
207  }
208  }
209 }
210 
211 void BKE_displist_count(const ListBase *lb, int *totvert, int *totface, int *tottri)
212 {
213  LISTBASE_FOREACH (const DispList *, dl, lb) {
214  int vert_tot = 0;
215  int face_tot = 0;
216  int tri_tot = 0;
217  bool cyclic_u = dl->flag & DL_CYCL_U;
218  bool cyclic_v = dl->flag & DL_CYCL_V;
219 
220  switch (dl->type) {
221  case DL_SURF: {
222  int segments_u = dl->nr - (cyclic_u == false);
223  int segments_v = dl->parts - (cyclic_v == false);
224  vert_tot = dl->nr * dl->parts;
225  face_tot = segments_u * segments_v;
226  tri_tot = face_tot * 2;
227  break;
228  }
229  case DL_INDEX3: {
230  vert_tot = dl->nr;
231  face_tot = dl->parts;
232  tri_tot = face_tot;
233  break;
234  }
235  case DL_INDEX4: {
236  vert_tot = dl->nr;
237  face_tot = dl->parts;
238  tri_tot = face_tot * 2;
239  break;
240  }
241  case DL_POLY:
242  case DL_SEGM: {
243  vert_tot = dl->nr * dl->parts;
244  break;
245  }
246  }
247 
248  *totvert += vert_tot;
249  *totface += face_tot;
250  *tottri += tri_tot;
251  }
252 }
253 
255  const DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
256 {
257  if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) {
258  return false;
259  }
260 
261  if (dl->flag & DL_CYCL_U) {
262  (*p1) = dl->nr * a;
263  (*p2) = (*p1) + dl->nr - 1;
264  (*p3) = (*p1) + dl->nr;
265  (*p4) = (*p2) + dl->nr;
266  (*b) = 0;
267  }
268  else {
269  (*p2) = dl->nr * a;
270  (*p1) = (*p2) + 1;
271  (*p4) = (*p2) + dl->nr;
272  (*p3) = (*p1) + dl->nr;
273  (*b) = 1;
274  }
275 
276  if ((dl->flag & DL_CYCL_V) && a == dl->parts - 1) {
277  (*p3) -= dl->nr * dl->parts;
278  (*p4) -= dl->nr * dl->parts;
279  }
280 
281  return true;
282 }
283 
284 /* ****************** make displists ********************* */
285 #ifdef __INTEL_COMPILER
286 /* ICC with the optimization -02 causes crashes. */
287 # pragma intel optimization_level 1
288 #endif
289 
290 static void curve_to_displist(const Curve *cu,
291  const ListBase *nubase,
292  const bool for_render,
293  ListBase *r_dispbase)
294 {
295  const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
296 
297  LISTBASE_FOREACH (Nurb *, nu, nubase) {
298  if (nu->hide != 0 && editmode) {
299  continue;
300  }
301  if (!BKE_nurb_check_valid_u(nu)) {
302  continue;
303  }
304 
305  const int resolution = (for_render && cu->resolu_ren != 0) ? cu->resolu_ren : nu->resolu;
306  const bool is_cyclic = nu->flagu & CU_NURB_CYCLIC;
307  const BezTriple *bezt_first = &nu->bezt[0];
308  const BezTriple *bezt_last = &nu->bezt[nu->pntsu - 1];
309 
310  if (nu->type == CU_BEZIER) {
311  int samples_len = 0;
312  for (int i = 1; i < nu->pntsu; i++) {
313  const BezTriple *prevbezt = &nu->bezt[i - 1];
314  const BezTriple *bezt = &nu->bezt[i];
315  if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
316  samples_len++;
317  }
318  else {
319  samples_len += resolution;
320  }
321  }
322  if (is_cyclic) {
323  /* If the curve is cyclic, sample the last edge between the last and first points. */
324  if (bezt_first->h1 == HD_VECT && bezt_last->h2 == HD_VECT) {
325  samples_len++;
326  }
327  else {
328  samples_len += resolution;
329  }
330  }
331  else {
332  /* Otherwise, we only need one additional sample to complete the last edge. */
333  samples_len++;
334  }
335 
336  /* Check that there are more than two points so the curve doesn't loop back on itself. This
337  * needs to be separate from `is_cyclic` because cyclic sampling can work with two points
338  * and resolution > 1. */
339  const bool use_cyclic_sample = is_cyclic && (samples_len != 2);
340 
341  DispList *dl = MEM_callocN(sizeof(DispList), __func__);
342  /* Add one to the length because of 'BKE_curve_forward_diff_bezier'. */
343  dl->verts = MEM_mallocN(sizeof(float[3]) * (samples_len + 1), "dlverts");
344  BLI_addtail(r_dispbase, dl);
345  dl->parts = 1;
346  dl->nr = samples_len;
347  dl->col = nu->mat_nr;
348  dl->charidx = nu->charidx;
349 
350  dl->type = use_cyclic_sample ? DL_POLY : DL_SEGM;
351 
352  float *data = dl->verts;
353  for (int i = 1; i < nu->pntsu; i++) {
354  const BezTriple *prevbezt = &nu->bezt[i - 1];
355  const BezTriple *bezt = &nu->bezt[i];
356 
357  if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
358  copy_v3_v3(data, prevbezt->vec[1]);
359  data += 3;
360  }
361  else {
362  for (int j = 0; j < 3; j++) {
363  BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
364  prevbezt->vec[2][j],
365  bezt->vec[0][j],
366  bezt->vec[1][j],
367  data + j,
368  resolution,
369  sizeof(float[3]));
370  }
371  data += 3 * resolution;
372  }
373  }
374  if (is_cyclic) {
375  if (bezt_first->h1 == HD_VECT && bezt_last->h2 == HD_VECT) {
376  copy_v3_v3(data, bezt_last->vec[1]);
377  }
378  else {
379  for (int j = 0; j < 3; j++) {
380  BKE_curve_forward_diff_bezier(bezt_last->vec[1][j],
381  bezt_last->vec[2][j],
382  bezt_first->vec[0][j],
383  bezt_first->vec[1][j],
384  data + j,
385  resolution,
386  sizeof(float[3]));
387  }
388  }
389  }
390  else {
391  copy_v3_v3(data, bezt_last->vec[1]);
392  }
393  }
394  else if (nu->type == CU_NURBS) {
395  const int len = (resolution * SEGMENTSU(nu));
396  DispList *dl = MEM_callocN(sizeof(DispList), __func__);
397  dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
398  BLI_addtail(r_dispbase, dl);
399  dl->parts = 1;
400  dl->nr = len;
401  dl->col = nu->mat_nr;
402  dl->charidx = nu->charidx;
403  dl->type = is_cyclic ? DL_POLY : DL_SEGM;
404 
405  BKE_nurb_makeCurve(nu, dl->verts, NULL, NULL, NULL, resolution, sizeof(float[3]));
406  }
407  else if (nu->type == CU_POLY) {
408  const int len = nu->pntsu;
409  DispList *dl = MEM_callocN(sizeof(DispList), __func__);
410  dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
411  BLI_addtail(r_dispbase, dl);
412  dl->parts = 1;
413  dl->nr = len;
414  dl->col = nu->mat_nr;
415  dl->charidx = nu->charidx;
416  dl->type = (is_cyclic && (dl->nr != 2)) ? DL_POLY : DL_SEGM;
417 
418  float(*coords)[3] = (float(*)[3])dl->verts;
419  for (int i = 0; i < len; i++) {
420  const BPoint *bp = &nu->bp[i];
421  copy_v3_v3(coords[i], bp->vec);
422  }
423  }
424  }
425 }
426 
433 void BKE_displist_fill(const ListBase *dispbase,
434  ListBase *to,
435  const float normal_proj[3],
436  const bool flip_normal)
437 {
438  if (dispbase == NULL) {
439  return;
440  }
441  if (BLI_listbase_is_empty(dispbase)) {
442  return;
443  }
444 
445  const int scanfill_flag = BLI_SCANFILL_CALC_REMOVE_DOUBLES | BLI_SCANFILL_CALC_POLYS |
447 
448  MemArena *sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__);
449 
450  short colnr = 0;
451  int charidx = 0;
452  bool should_continue = true;
453  while (should_continue) {
454  should_continue = false;
455  bool nextcol = false;
456 
457  ScanFillContext sf_ctx;
458  BLI_scanfill_begin_arena(&sf_ctx, sf_arena);
459 
460  int totvert = 0;
461  short dl_flag_accum = 0;
462  short dl_rt_accum = 0;
463  LISTBASE_FOREACH (const DispList *, dl, dispbase) {
464  if (dl->type == DL_POLY) {
465  if (charidx < dl->charidx) {
466  should_continue = true;
467  }
468  else if (charidx == dl->charidx) { /* character with needed index */
469  if (colnr == dl->col) {
470 
471  sf_ctx.poly_nr++;
472 
473  /* Make verts and edges. */
474  ScanFillVert *sf_vert = NULL;
475  ScanFillVert *sf_vert_last = NULL;
476  ScanFillVert *sf_vert_new = NULL;
477  for (int i = 0; i < dl->nr; i++) {
478  sf_vert_last = sf_vert;
479  sf_vert = BLI_scanfill_vert_add(&sf_ctx, &dl->verts[3 * i]);
480  totvert++;
481  if (sf_vert_last == NULL) {
482  sf_vert_new = sf_vert;
483  }
484  else {
485  BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
486  }
487  }
488 
489  if (sf_vert != NULL && sf_vert_new != NULL) {
490  BLI_scanfill_edge_add(&sf_ctx, sf_vert, sf_vert_new);
491  }
492  }
493  else if (colnr < dl->col) {
494  /* got poly with next material at current char */
495  should_continue = true;
496  nextcol = true;
497  }
498  }
499  dl_flag_accum |= dl->flag;
500  dl_rt_accum |= dl->rt;
501  }
502  }
503 
504  const int triangles_len = BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, normal_proj);
505  if (totvert != 0 && triangles_len != 0) {
506  DispList *dlnew = MEM_callocN(sizeof(DispList), "filldisplist");
507  dlnew->type = DL_INDEX3;
508  dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE));
509  dlnew->rt = (dl_rt_accum & CU_SMOOTH);
510  dlnew->col = colnr;
511  dlnew->nr = totvert;
512  dlnew->parts = triangles_len;
513 
514  dlnew->index = MEM_mallocN(sizeof(int[3]) * triangles_len, "dlindex");
515  dlnew->verts = MEM_mallocN(sizeof(float[3]) * totvert, "dlverts");
516 
517  /* vert data */
518  int i;
519  LISTBASE_FOREACH_INDEX (ScanFillVert *, sf_vert, &sf_ctx.fillvertbase, i) {
520  copy_v3_v3(&dlnew->verts[3 * i], sf_vert->co);
521  sf_vert->tmp.i = i; /* Index number. */
522  }
523 
524  /* index data */
525  int *index = dlnew->index;
526  LISTBASE_FOREACH (ScanFillFace *, sf_tri, &sf_ctx.fillfacebase) {
527  index[0] = sf_tri->v1->tmp.i;
528  index[1] = flip_normal ? sf_tri->v3->tmp.i : sf_tri->v2->tmp.i;
529  index[2] = flip_normal ? sf_tri->v2->tmp.i : sf_tri->v3->tmp.i;
530  index += 3;
531  }
532 
533  BLI_addhead(to, dlnew);
534  }
535  BLI_scanfill_end_arena(&sf_ctx, sf_arena);
536 
537  if (nextcol) {
538  /* stay at current char but fill polys with next material */
539  colnr++;
540  }
541  else {
542  /* switch to next char and start filling from first material */
543  charidx++;
544  colnr = 0;
545  }
546  }
547 
548  BLI_memarena_free(sf_arena);
549  /* do not free polys, needed for wireframe display */
550 }
551 
552 static void bevels_to_filledpoly(const Curve *cu, ListBase *dispbase)
553 {
554  ListBase front = {NULL, NULL};
555  ListBase back = {NULL, NULL};
556 
557  LISTBASE_FOREACH (const DispList *, dl, dispbase) {
558  if (dl->type == DL_SURF) {
559  if ((dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) {
560  if ((cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) {
561  DispList *dlnew = MEM_callocN(sizeof(DispList), __func__);
562  BLI_addtail(&front, dlnew);
563  dlnew->verts = MEM_mallocN(sizeof(float[3]) * dl->parts, __func__);
564  dlnew->nr = dl->parts;
565  dlnew->parts = 1;
566  dlnew->type = DL_POLY;
567  dlnew->flag = DL_BACK_CURVE;
568  dlnew->col = dl->col;
569  dlnew->charidx = dl->charidx;
570 
571  const float *old_verts = dl->verts;
572  float *new_verts = dlnew->verts;
573  for (int i = 0; i < dl->parts; i++) {
574  copy_v3_v3(new_verts, old_verts);
575  new_verts += 3;
576  old_verts += 3 * dl->nr;
577  }
578  }
579  if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) {
580  DispList *dlnew = MEM_callocN(sizeof(DispList), __func__);
581  BLI_addtail(&back, dlnew);
582  dlnew->verts = MEM_mallocN(sizeof(float[3]) * dl->parts, __func__);
583  dlnew->nr = dl->parts;
584  dlnew->parts = 1;
585  dlnew->type = DL_POLY;
586  dlnew->flag = DL_FRONT_CURVE;
587  dlnew->col = dl->col;
588  dlnew->charidx = dl->charidx;
589 
590  const float *old_verts = dl->verts + 3 * (dl->nr - 1);
591  float *new_verts = dlnew->verts;
592  for (int i = 0; i < dl->parts; i++) {
593  copy_v3_v3(new_verts, old_verts);
594  new_verts += 3;
595  old_verts += 3 * dl->nr;
596  }
597  }
598  }
599  }
600  }
601 
602  const float z_up[3] = {0.0f, 0.0f, -1.0f};
603  BKE_displist_fill(&front, dispbase, z_up, true);
604  BKE_displist_fill(&back, dispbase, z_up, false);
605 
606  BKE_displist_free(&front);
607  BKE_displist_free(&back);
608 
609  BKE_displist_fill(dispbase, dispbase, z_up, false);
610 }
611 
612 static void curve_to_filledpoly(const Curve *cu, ListBase *dispbase)
613 {
614  if (!CU_DO_2DFILL(cu)) {
615  return;
616  }
617 
618  if (dispbase->first && ((DispList *)dispbase->first)->type == DL_SURF) {
619  bevels_to_filledpoly(cu, dispbase);
620  }
621  else {
622  const float z_up[3] = {0.0f, 0.0f, -1.0f};
623  BKE_displist_fill(dispbase, dispbase, z_up, false);
624  }
625 }
626 
627 /* taper rules:
628  * - only 1 curve
629  * - first point left, last point right
630  * - based on subdivided points in original curve, not on points in taper curve (still)
631  */
633  const Scene *scene,
634  Object *taperobj,
635  float fac)
636 {
637  DispList *dl;
638 
639  if (taperobj == NULL || taperobj->type != OB_CURVE) {
640  return 1.0;
641  }
642 
643  dl = taperobj->runtime.curve_cache ? taperobj->runtime.curve_cache->disp.first : NULL;
644  if (dl == NULL) {
645  BKE_displist_make_curveTypes(depsgraph, scene, taperobj, false, false);
646  dl = taperobj->runtime.curve_cache->disp.first;
647  }
648  if (dl) {
649  float minx, dx, *fp;
650  int a;
651 
652  /* horizontal size */
653  minx = dl->verts[0];
654  dx = dl->verts[3 * (dl->nr - 1)] - minx;
655  if (dx > 0.0f) {
656  fp = dl->verts;
657  for (a = 0; a < dl->nr; a++, fp += 3) {
658  if ((fp[0] - minx) / dx >= fac) {
659  /* interpolate with prev */
660  if (a > 0) {
661  float fac1 = (fp[-3] - minx) / dx;
662  float fac2 = (fp[0] - minx) / dx;
663  if (fac1 != fac2) {
664  return fp[1] * (fac1 - fac) / (fac1 - fac2) + fp[-2] * (fac - fac2) / (fac1 - fac2);
665  }
666  }
667  return fp[1];
668  }
669  }
670  return fp[-2]; // last y coord
671  }
672  }
673 
674  return 1.0;
675 }
676 
678  Depsgraph *depsgraph, const Scene *scene, Object *taperobj, int cur, int tot)
679 {
680  float fac = ((float)cur) / (float)(tot - 1);
681 
682  return displist_calc_taper(depsgraph, scene, taperobj, fac);
683 }
684 
686 {
687  if (!ob || ob->type != OB_MBALL) {
688  return;
689  }
690 
691  if (ob == BKE_mball_basis_find(scene, ob)) {
692  if (ob->runtime.curve_cache) {
694  }
695  else {
696  ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for MBall");
697  }
698 
701 
703 
704  /* NOP for MBALLs anyway... */
706  }
707 }
708 
710  Scene *scene,
711  Object *ob,
712  ListBase *dispbase)
713 {
714  BKE_mball_polygonize(depsgraph, scene, ob, dispbase);
716 
717  object_deform_mball(ob, dispbase);
718 }
719 
721  const Object *ob,
722  const bool for_render,
723  const bool editmode)
724 {
725  VirtualModifierData virtualModifierData;
726  ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData);
727  ModifierData *pretessellatePoint;
728  int required_mode;
729 
730  if (for_render) {
731  required_mode = eModifierMode_Render;
732  }
733  else {
734  required_mode = eModifierMode_Realtime;
735  }
736 
737  if (editmode) {
738  required_mode |= eModifierMode_Editmode;
739  }
740 
741  pretessellatePoint = NULL;
742  for (; md; md = md->next) {
743  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
744 
745  if (!BKE_modifier_is_enabled(scene, md, required_mode)) {
746  continue;
747  }
748  if (mti->type == eModifierTypeType_Constructive) {
749  return pretessellatePoint;
750  }
751 
753  pretessellatePoint = md;
754 
755  /* this modifiers are moving point of tessellation automatically
756  * (some of them even can't be applied on tessellated curve), set flag
757  * for information button in modifier's header
758  */
760  }
761  else if (md->mode & eModifierMode_ApplyOnSpline) {
762  pretessellatePoint = md;
763  }
764  }
765 
766  return pretessellatePoint;
767 }
768 
769 /* Return true if any modifier was applied. */
771  const Scene *scene,
772  Object *ob,
773  ListBase *source_nurb,
774  ListBase *target_nurb,
775  const bool for_render)
776 {
777  VirtualModifierData virtualModifierData;
778  ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData);
779  ModifierData *pretessellatePoint;
780  Curve *cu = ob->data;
781  int numElems = 0, numVerts = 0;
782  const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
783  ModifierApplyFlag apply_flag = 0;
784  float(*deformedVerts)[3] = NULL;
785  float *keyVerts = NULL;
786  int required_mode;
787  bool modified = false;
788 
790 
791  if (editmode) {
792  apply_flag |= MOD_APPLY_USECACHE;
793  }
794  if (for_render) {
795  apply_flag |= MOD_APPLY_RENDER;
796  required_mode = eModifierMode_Render;
797  }
798  else {
799  required_mode = eModifierMode_Realtime;
800  }
801 
802  const ModifierEvalContext mectx = {depsgraph, ob, apply_flag};
803 
804  pretessellatePoint = curve_get_tessellate_point(scene, ob, for_render, editmode);
805 
806  if (editmode) {
807  required_mode |= eModifierMode_Editmode;
808  }
809 
810  if (!editmode) {
811  keyVerts = BKE_key_evaluate_object(ob, &numElems);
812 
813  if (keyVerts) {
814  BLI_assert(BKE_keyblock_curve_element_count(source_nurb) == numElems);
815 
816  /* split coords from key data, the latter also includes
817  * tilts, which is passed through in the modifier stack.
818  * this is also the reason curves do not use a virtual
819  * shape key modifier yet. */
820  deformedVerts = BKE_curve_nurbs_key_vert_coords_alloc(source_nurb, keyVerts, &numVerts);
821  }
822  }
823 
824  if (pretessellatePoint) {
825  for (; md; md = md->next) {
826  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
827 
828  if (!BKE_modifier_is_enabled(scene, md, required_mode)) {
829  continue;
830  }
831  if (mti->type != eModifierTypeType_OnlyDeform) {
832  continue;
833  }
834 
835  if (!deformedVerts) {
836  deformedVerts = BKE_curve_nurbs_vert_coords_alloc(source_nurb, &numVerts);
837  }
838 
839  mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
840  modified = true;
841 
842  if (md == pretessellatePoint) {
843  break;
844  }
845  }
846  }
847 
848  if (deformedVerts) {
849  BKE_curve_nurbs_vert_coords_apply(target_nurb, deformedVerts, false);
850  MEM_freeN(deformedVerts);
851  }
852  if (keyVerts) { /* these are not passed through modifier stack */
853  BKE_curve_nurbs_key_vert_tilts_apply(target_nurb, keyVerts);
854  }
855 
856  if (keyVerts) {
857  MEM_freeN(keyVerts);
858  }
859  return modified;
860 }
861 
862 static float (*displist_vert_coords_alloc(ListBase *dispbase, int *r_vert_len))[3]
863 {
864  float(*allverts)[3], *fp;
865 
866  *r_vert_len = 0;
867 
868  LISTBASE_FOREACH (DispList *, dl, dispbase) {
869  *r_vert_len += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr;
870  }
871 
872  allverts = MEM_mallocN(sizeof(float[3]) * (*r_vert_len), "displist_vert_coords_alloc allverts");
873  fp = (float *)allverts;
874  LISTBASE_FOREACH (DispList *, dl, dispbase) {
875  int ofs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr);
876  memcpy(fp, dl->verts, sizeof(float) * ofs);
877  fp += ofs;
878  }
879 
880  return allverts;
881 }
882 
883 static void displist_vert_coords_apply(ListBase *dispbase, const float (*allverts)[3])
884 {
885  const float *fp;
886 
887  fp = (float *)allverts;
888  LISTBASE_FOREACH (DispList *, dl, dispbase) {
889  int ofs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr);
890  memcpy(dl->verts, fp, sizeof(float) * ofs);
891  fp += ofs;
892  }
893 }
894 
896  const Scene *scene,
897  Object *ob,
898  ListBase *dispbase,
899  Mesh **r_final,
900  const bool for_render,
901  const bool force_mesh_conversion)
902 {
903  VirtualModifierData virtualModifierData;
904  ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData);
905  ModifierData *pretessellatePoint;
906  const Curve *cu = ob->data;
907  int required_mode = 0, totvert = 0;
908  const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
909  Mesh *modified = NULL, *mesh_applied;
910  float(*vertCos)[3] = NULL;
911  int useCache = !for_render;
912  ModifierApplyFlag apply_flag = 0;
913 
914  if (for_render) {
915  apply_flag |= MOD_APPLY_RENDER;
916  required_mode = eModifierMode_Render;
917  }
918  else {
919  required_mode = eModifierMode_Realtime;
920  }
921 
922  const ModifierEvalContext mectx_deform = {
923  depsgraph, ob, editmode ? apply_flag | MOD_APPLY_USECACHE : apply_flag};
924  const ModifierEvalContext mectx_apply = {
925  depsgraph, ob, useCache ? apply_flag | MOD_APPLY_USECACHE : apply_flag};
926 
927  pretessellatePoint = curve_get_tessellate_point(scene, ob, for_render, editmode);
928 
929  if (editmode) {
930  required_mode |= eModifierMode_Editmode;
931  }
932 
933  if (pretessellatePoint) {
934  md = pretessellatePoint->next;
935  }
936 
937  if (r_final && *r_final) {
938  BKE_id_free(NULL, *r_final);
939  }
940 
941  for (; md; md = md->next) {
942  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
943 
944  if (!BKE_modifier_is_enabled(scene, md, required_mode)) {
945  continue;
946  }
947 
948  /* If we need normals, no choice, have to convert to mesh now. */
949  bool need_normal = mti->dependsOnNormals != NULL && mti->dependsOnNormals(md);
950  /* XXX 2.8 : now that batch cache is stored inside the ob->data
951  * we need to create a Mesh for each curve that uses modifiers. */
952  if (modified == NULL /* && need_normal */) {
953  if (vertCos != NULL) {
954  displist_vert_coords_apply(dispbase, vertCos);
955  }
956 
957  if (ELEM(ob->type, OB_CURVE, OB_FONT) && (cu->flag & CU_DEFORM_FILL)) {
958  curve_to_filledpoly(cu, dispbase);
959  }
960 
961  modified = BKE_mesh_new_nomain_from_curve_displist(ob, dispbase);
962  }
963 
964  if (mti->type == eModifierTypeType_OnlyDeform ||
965  (mti->type == eModifierTypeType_DeformOrConstruct && !modified)) {
966  if (modified) {
967  if (!vertCos) {
968  vertCos = BKE_mesh_vert_coords_alloc(modified, &totvert);
969  }
970  if (need_normal) {
971  BKE_mesh_ensure_normals(modified);
972  }
973  mti->deformVerts(md, &mectx_deform, modified, vertCos, totvert);
974  }
975  else {
976  if (!vertCos) {
977  vertCos = displist_vert_coords_alloc(dispbase, &totvert);
978  }
979  mti->deformVerts(md, &mectx_deform, NULL, vertCos, totvert);
980  }
981  }
982  else {
983  if (!r_final) {
984  /* makeDisplistCurveTypes could be used for beveling, where derived mesh
985  * is totally unnecessary, so we could stop modifiers applying
986  * when we found constructive modifier but derived mesh is unwanted result
987  */
988  break;
989  }
990 
991  if (modified) {
992  if (vertCos) {
993  Mesh *temp_mesh = (Mesh *)BKE_id_copy_ex(
994  NULL, &modified->id, NULL, LIB_ID_COPY_LOCALIZE);
995  BKE_id_free(NULL, modified);
996  modified = temp_mesh;
997 
998  BKE_mesh_vert_coords_apply(modified, vertCos);
999  }
1000  }
1001  else {
1002  if (vertCos) {
1003  displist_vert_coords_apply(dispbase, vertCos);
1004  }
1005 
1006  if (ELEM(ob->type, OB_CURVE, OB_FONT) && (cu->flag & CU_DEFORM_FILL)) {
1007  curve_to_filledpoly(cu, dispbase);
1008  }
1009 
1010  modified = BKE_mesh_new_nomain_from_curve_displist(ob, dispbase);
1011  }
1012 
1013  if (vertCos) {
1014  /* Vertex coordinates were applied to necessary data, could free it */
1015  MEM_freeN(vertCos);
1016  vertCos = NULL;
1017  }
1018 
1019  if (need_normal) {
1020  BKE_mesh_ensure_normals(modified);
1021  }
1022  mesh_applied = mti->modifyMesh(md, &mectx_apply, modified);
1023 
1024  if (mesh_applied) {
1025  /* Modifier returned a new derived mesh */
1026 
1027  if (modified && modified != mesh_applied) { /* Modifier */
1028  BKE_id_free(NULL, modified);
1029  }
1030  modified = mesh_applied;
1031  }
1032  }
1033  }
1034 
1035  if (vertCos) {
1036  if (modified) {
1037  Mesh *temp_mesh = (Mesh *)BKE_id_copy_ex(NULL, &modified->id, NULL, LIB_ID_COPY_LOCALIZE);
1038  BKE_id_free(NULL, modified);
1039  modified = temp_mesh;
1040 
1041  BKE_mesh_vert_coords_apply(modified, vertCos);
1043 
1044  MEM_freeN(vertCos);
1045  }
1046  else {
1047  displist_vert_coords_apply(dispbase, vertCos);
1048  MEM_freeN(vertCos);
1049  vertCos = NULL;
1050  }
1051  }
1052 
1053  if (r_final) {
1054  if (force_mesh_conversion && !modified) {
1055  /* XXX 2.8 : This is a workaround for by some deeper technical debts:
1056  * - DRW Batch cache is stored inside the ob->data.
1057  * - Curve data is not COWed for instances that use different modifiers.
1058  * This can causes the modifiers to be applied on all user of the same data-block
1059  * (see T71055)
1060  *
1061  * The easy workaround is to force to generate a Mesh that will be used for display data
1062  * since a Mesh output is already used for generative modifiers.
1063  * However it does not fix problems with actual edit data still being shared.
1064  *
1065  * The right solution would be to COW the Curve data block at the input of the modifier
1066  * stack just like what the mesh modifier does.
1067  */
1068  modified = BKE_mesh_new_nomain_from_curve_displist(ob, dispbase);
1069  }
1070 
1071  if (modified) {
1072 
1073  /* XXX2.8(Sybren): make sure the face normals are recalculated as well */
1074  BKE_mesh_ensure_normals(modified);
1075 
1076  /* Special tweaks, needed since neither BKE_mesh_new_nomain_from_template() nor
1077  * BKE_mesh_new_nomain_from_curve_displist() properly duplicate mat info...
1078  */
1079  BLI_strncpy(modified->id.name, cu->id.name, sizeof(modified->id.name));
1080  *((short *)modified->id.name) = ID_ME;
1081  MEM_SAFE_FREE(modified->mat);
1082  /* Set flag which makes it easier to see what's going on in a debugger. */
1084  modified->mat = MEM_dupallocN(cu->mat);
1085  modified->totcol = cu->totcol;
1086 
1087  (*r_final) = modified;
1088  }
1089  else {
1090  (*r_final) = NULL;
1091  }
1092  }
1093  else if (modified != NULL) {
1094  /* Pretty stupid to generate that whole mesh if it's unused, yet we have to free it. */
1095  BKE_id_free(NULL, modified);
1096  }
1097 }
1098 
1100 {
1101  int a, b, p1, p2, p3, p4;
1102  int *index;
1103 
1104  dl->totindex = 0;
1105 
1106  index = dl->index = MEM_mallocN(sizeof(int[4]) * (dl->parts + 1) * (dl->nr + 1),
1107  "index array nurbs");
1108 
1109  for (a = 0; a < dl->parts; a++) {
1110 
1111  if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) {
1112  break;
1113  }
1114 
1115  for (; b < dl->nr; b++, index += 4) {
1116  index[0] = p1;
1117  index[1] = p2;
1118  index[2] = p4;
1119  index[3] = p3;
1120 
1121  dl->totindex++;
1122 
1123  p2 = p1;
1124  p1++;
1125  p4 = p3;
1126  p3++;
1127  }
1128  }
1129 }
1130 
1132  const Scene *scene,
1133  Object *ob,
1134  ListBase *dispbase,
1135  Mesh **r_final,
1136  const bool for_render,
1137  const bool for_orco)
1138 {
1139  ListBase nubase = {NULL, NULL};
1140  Curve *cu = ob->data;
1141  DispList *dl;
1142  float *data;
1143  int len;
1144  bool force_mesh_conversion = false;
1145 
1146  if (!for_render && cu->editnurb) {
1148  }
1149  else {
1150  BKE_nurbList_duplicate(&nubase, &cu->nurb);
1151  }
1152 
1153  if (!for_orco) {
1154  force_mesh_conversion = BKE_curve_calc_modifiers_pre(
1155  depsgraph, scene, ob, &nubase, &nubase, for_render);
1156  }
1157 
1158  LISTBASE_FOREACH (Nurb *, nu, &nubase) {
1159  if (!(for_render || nu->hide == 0) || !BKE_nurb_check_valid_uv(nu)) {
1160  continue;
1161  }
1162 
1163  int resolu = nu->resolu, resolv = nu->resolv;
1164 
1165  if (for_render) {
1166  if (cu->resolu_ren) {
1167  resolu = cu->resolu_ren;
1168  }
1169  if (cu->resolv_ren) {
1170  resolv = cu->resolv_ren;
1171  }
1172  }
1173 
1174  if (nu->pntsv == 1) {
1175  len = SEGMENTSU(nu) * resolu;
1176 
1177  dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
1178  dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
1179 
1180  BLI_addtail(dispbase, dl);
1181  dl->parts = 1;
1182  dl->nr = len;
1183  dl->col = nu->mat_nr;
1184  dl->charidx = nu->charidx;
1185 
1186  /* dl->rt will be used as flag for render face and */
1187  /* CU_2D conflicts with R_NOPUNOFLIP */
1188  dl->rt = nu->flag;
1189 
1190  data = dl->verts;
1191  if (nu->flagu & CU_NURB_CYCLIC) {
1192  dl->type = DL_POLY;
1193  }
1194  else {
1195  dl->type = DL_SEGM;
1196  }
1197 
1198  BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, sizeof(float[3]));
1199  }
1200  else {
1201  len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
1202 
1203  dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
1204  dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
1205  BLI_addtail(dispbase, dl);
1206 
1207  dl->col = nu->mat_nr;
1208  dl->charidx = nu->charidx;
1209 
1210  /* dl->rt will be used as flag for render face and */
1211  /* CU_2D conflicts with R_NOPUNOFLIP */
1212  dl->rt = nu->flag;
1213 
1214  data = dl->verts;
1215  dl->type = DL_SURF;
1216 
1217  dl->parts = (nu->pntsu * resolu); /* in reverse, because makeNurbfaces works that way */
1218  dl->nr = (nu->pntsv * resolv);
1219  if (nu->flagv & CU_NURB_CYCLIC) {
1220  dl->flag |= DL_CYCL_U; /* reverse too! */
1221  }
1222  if (nu->flagu & CU_NURB_CYCLIC) {
1223  dl->flag |= DL_CYCL_V;
1224  }
1225 
1226  BKE_nurb_makeFaces(nu, data, 0, resolu, resolv);
1227 
1228  /* gl array drawing: using indices */
1230  }
1231  }
1232 
1233  if (!for_orco) {
1236  depsgraph, scene, ob, dispbase, r_final, for_render, force_mesh_conversion);
1237  }
1238 
1239  BKE_nurbList_free(&nubase);
1240 }
1241 
1242 static void rotateBevelPiece(const Curve *cu,
1243  const BevPoint *bevp,
1244  const BevPoint *nbevp,
1245  const DispList *dlb,
1246  const float bev_blend,
1247  const float widfac,
1248  const float radius_factor,
1249  float **r_data)
1250 {
1251  float *data = *r_data;
1252  const float *fp = dlb->verts;
1253  for (int b = 0; b < dlb->nr; b++, fp += 3, data += 3) {
1254  if (cu->flag & CU_3D) {
1255  float vec[3], quat[4];
1256 
1257  vec[0] = fp[1] + widfac;
1258  vec[1] = fp[2];
1259  vec[2] = 0.0;
1260 
1261  if (nbevp == NULL) {
1262  copy_v3_v3(data, bevp->vec);
1263  copy_qt_qt(quat, bevp->quat);
1264  }
1265  else {
1266  interp_v3_v3v3(data, bevp->vec, nbevp->vec, bev_blend);
1267  interp_qt_qtqt(quat, bevp->quat, nbevp->quat, bev_blend);
1268  }
1269 
1270  mul_qt_v3(quat, vec);
1271 
1272  data[0] += radius_factor * vec[0];
1273  data[1] += radius_factor * vec[1];
1274  data[2] += radius_factor * vec[2];
1275  }
1276  else {
1277  float sina, cosa;
1278 
1279  if (nbevp == NULL) {
1280  copy_v3_v3(data, bevp->vec);
1281  sina = bevp->sina;
1282  cosa = bevp->cosa;
1283  }
1284  else {
1285  interp_v3_v3v3(data, bevp->vec, nbevp->vec, bev_blend);
1286 
1287  /* perhaps we need to interpolate angles instead. but the thing is
1288  * cosa and sina are not actually sine and cosine
1289  */
1290  sina = nbevp->sina * bev_blend + bevp->sina * (1.0f - bev_blend);
1291  cosa = nbevp->cosa * bev_blend + bevp->cosa * (1.0f - bev_blend);
1292  }
1293 
1294  data[0] += radius_factor * (widfac + fp[1]) * sina;
1295  data[1] += radius_factor * (widfac + fp[1]) * cosa;
1296  data[2] += radius_factor * fp[2];
1297  }
1298  }
1299 
1300  *r_data = data;
1301 }
1302 
1303 static void fillBevelCap(const Nurb *nu,
1304  const DispList *dlb,
1305  const float *prev_fp,
1306  ListBase *dispbase)
1307 {
1308  DispList *dl;
1309 
1310  dl = MEM_callocN(sizeof(DispList), "makeDispListbev2");
1311  dl->verts = MEM_mallocN(sizeof(float[3]) * dlb->nr, "dlverts");
1312  memcpy(dl->verts, prev_fp, sizeof(float[3]) * dlb->nr);
1313 
1314  dl->type = DL_POLY;
1315 
1316  dl->parts = 1;
1317  dl->nr = dlb->nr;
1318  dl->col = nu->mat_nr;
1319  dl->charidx = nu->charidx;
1320 
1321  /* dl->rt will be used as flag for render face and */
1322  /* CU_2D conflicts with R_NOPUNOFLIP */
1323  dl->rt = nu->flag;
1324 
1325  BLI_addtail(dispbase, dl);
1326 }
1327 
1329  const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
1330 {
1331  float normlen, normsum = 0.0f;
1332  float *seglen = bl->seglen;
1333  int *segbevcount = bl->segbevcount;
1334  int bevcount = 0, nr = bl->nr;
1335 
1336  float bev_fl = bevfac * (bl->nr - 1);
1337  *r_bev = (int)bev_fl;
1338 
1339  while (bevcount < nr - 1) {
1340  normlen = *seglen / spline_length;
1341  if (normsum + normlen > bevfac) {
1342  bev_fl = bevcount + (bevfac - normsum) / normlen * *segbevcount;
1343  *r_bev = (int)bev_fl;
1344  *r_blend = bev_fl - *r_bev;
1345  break;
1346  }
1347  normsum += normlen;
1348  bevcount += *segbevcount;
1349  segbevcount++;
1350  seglen++;
1351  }
1352 }
1353 
1355  const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
1356 {
1357  const float len_target = bevfac * spline_length;
1358  BevPoint *bevp = bl->bevpoints;
1359  float len_next = 0.0f, len = 0.0f;
1360  int i = 0, nr = bl->nr;
1361 
1362  while (nr--) {
1363  bevp++;
1364  len_next = len + bevp->offset;
1365  if (len_next > len_target) {
1366  break;
1367  }
1368  len = len_next;
1369  i++;
1370  }
1371 
1372  *r_bev = i;
1373  *r_blend = (len_target - len) / bevp->offset;
1374 }
1375 
1377  const BevList *bl, int *r_start, float *r_firstblend, int *r_steps, float *r_lastblend)
1378 {
1379  *r_start = 0;
1380  *r_steps = bl->nr;
1381  *r_firstblend = 1.0f;
1382  *r_lastblend = 1.0f;
1383 }
1384 
1385 static void calc_bevfac_mapping(const Curve *cu,
1386  const BevList *bl,
1387  const Nurb *nu,
1388  int *r_start,
1389  float *r_firstblend,
1390  int *r_steps,
1391  float *r_lastblend)
1392 {
1393  float tmpf, total_length = 0.0f;
1394  int end = 0, i;
1395 
1396  if ((BKE_nurb_check_valid_u(nu) == false) ||
1397  /* not essential, but skips unnecessary calculation */
1398  (min_ff(cu->bevfac1, cu->bevfac2) == 0.0f && max_ff(cu->bevfac1, cu->bevfac2) == 1.0f)) {
1399  calc_bevfac_mapping_default(bl, r_start, r_firstblend, r_steps, r_lastblend);
1400  return;
1401  }
1402 
1405  for (i = 0; i < SEGMENTSU(nu); i++) {
1406  total_length += bl->seglen[i];
1407  }
1408  }
1409 
1410  switch (cu->bevfac1_mapping) {
1411  case CU_BEVFAC_MAP_RESOLU: {
1412  const float start_fl = cu->bevfac1 * (bl->nr - 1);
1413  *r_start = (int)start_fl;
1414  *r_firstblend = 1.0f - (start_fl - (*r_start));
1415  break;
1416  }
1417  case CU_BEVFAC_MAP_SEGMENT: {
1418  calc_bevfac_segment_mapping(bl, cu->bevfac1, total_length, r_start, r_firstblend);
1419  *r_firstblend = 1.0f - *r_firstblend;
1420  break;
1421  }
1422  case CU_BEVFAC_MAP_SPLINE: {
1423  calc_bevfac_spline_mapping(bl, cu->bevfac1, total_length, r_start, r_firstblend);
1424  *r_firstblend = 1.0f - *r_firstblend;
1425  break;
1426  }
1427  }
1428 
1429  switch (cu->bevfac2_mapping) {
1430  case CU_BEVFAC_MAP_RESOLU: {
1431  const float end_fl = cu->bevfac2 * (bl->nr - 1);
1432  end = (int)end_fl;
1433 
1434  *r_steps = 2 + end - *r_start;
1435  *r_lastblend = end_fl - end;
1436  break;
1437  }
1438  case CU_BEVFAC_MAP_SEGMENT: {
1439  calc_bevfac_segment_mapping(bl, cu->bevfac2, total_length, &end, r_lastblend);
1440  *r_steps = end - *r_start + 2;
1441  break;
1442  }
1443  case CU_BEVFAC_MAP_SPLINE: {
1444  calc_bevfac_spline_mapping(bl, cu->bevfac2, total_length, &end, r_lastblend);
1445  *r_steps = end - *r_start + 2;
1446  break;
1447  }
1448  }
1449 
1450  if (end < *r_start || (end == *r_start && *r_lastblend < 1.0f - *r_firstblend)) {
1451  SWAP(int, *r_start, end);
1452  tmpf = *r_lastblend;
1453  *r_lastblend = 1.0f - *r_firstblend;
1454  *r_firstblend = 1.0f - tmpf;
1455  *r_steps = end - *r_start + 2;
1456  }
1457 
1458  if (*r_start + *r_steps > bl->nr) {
1459  *r_steps = bl->nr - *r_start;
1460  *r_lastblend = 1.0f;
1461  }
1462 }
1463 
1465  const Scene *scene,
1466  Object *ob,
1467  ListBase *dispbase,
1468  const bool for_render,
1469  const bool for_orco,
1470  Mesh **r_final)
1471 {
1472  Curve *cu = ob->data;
1473 
1474  /* we do allow duplis... this is only displist on curve level */
1475  if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
1476  return;
1477  }
1478 
1479  if (ob->type == OB_SURF) {
1480  BKE_displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render, for_orco);
1481  }
1482  else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
1483  ListBase dlbev;
1484  ListBase nubase = {NULL, NULL};
1485  bool force_mesh_conversion = false;
1486 
1488 
1489  /* We only re-evaluate path if evaluation is not happening for orco.
1490  * If the calculation happens for orco, we should never free data which
1491  * was needed before and only not needed for orco calculation.
1492  */
1493  if (!for_orco) {
1496  }
1498  }
1499 
1500  if (ob->type == OB_FONT) {
1501  BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase);
1502  }
1503  else {
1505  }
1506 
1507  if (!for_orco) {
1508  force_mesh_conversion = BKE_curve_calc_modifiers_pre(
1509  depsgraph, scene, ob, &nubase, &nubase, for_render);
1510  }
1511 
1512  BKE_curve_bevelList_make(ob, &nubase, for_render);
1513 
1514  /* If curve has no bevel will return nothing */
1515  BKE_curve_bevel_make(ob, &dlbev);
1516 
1517  /* no bevel or extrude, and no width correction? */
1518  if (!dlbev.first && cu->width == 1.0f) {
1519  curve_to_displist(cu, &nubase, for_render, dispbase);
1520  }
1521  else {
1522  const float widfac = cu->width - 1.0f;
1523  BevList *bl = ob->runtime.curve_cache->bev.first;
1524  Nurb *nu = nubase.first;
1525 
1526  for (; bl && nu; bl = bl->next, nu = nu->next) {
1527  float *data;
1528 
1529  if (bl->nr == 0) { /* blank bevel lists can happen */
1530  continue;
1531  }
1532 
1533  /* exception handling; curve without bevel or extrude, with width correction */
1534  if (BLI_listbase_is_empty(&dlbev)) {
1535  DispList *dl = MEM_callocN(sizeof(DispList), "makeDispListbev");
1536  dl->verts = MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
1537  BLI_addtail(dispbase, dl);
1538 
1539  if (bl->poly != -1) {
1540  dl->type = DL_POLY;
1541  }
1542  else {
1543  dl->type = DL_SEGM;
1544  dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE);
1545  }
1546 
1547  dl->parts = 1;
1548  dl->nr = bl->nr;
1549  dl->col = nu->mat_nr;
1550  dl->charidx = nu->charidx;
1551 
1552  /* dl->rt will be used as flag for render face and */
1553  /* CU_2D conflicts with R_NOPUNOFLIP */
1554  dl->rt = nu->flag;
1555 
1556  int a = dl->nr;
1557  BevPoint *bevp = bl->bevpoints;
1558  data = dl->verts;
1559  while (a--) {
1560  data[0] = bevp->vec[0] + widfac * bevp->sina;
1561  data[1] = bevp->vec[1] + widfac * bevp->cosa;
1562  data[2] = bevp->vec[2];
1563  bevp++;
1564  data += 3;
1565  }
1566  }
1567  else {
1568  ListBase bottom_capbase = {NULL, NULL};
1569  ListBase top_capbase = {NULL, NULL};
1570  float bottom_no[3] = {0.0f};
1571  float top_no[3] = {0.0f};
1572  float first_blend = 0.0f, last_blend = 0.0f;
1573  int start, steps = 0;
1574 
1575  if (nu->flagu & CU_NURB_CYCLIC) {
1576  calc_bevfac_mapping_default(bl, &start, &first_blend, &steps, &last_blend);
1577  }
1578  else {
1579  if (fabsf(cu->bevfac2 - cu->bevfac1) < FLT_EPSILON) {
1580  continue;
1581  }
1582 
1583  calc_bevfac_mapping(cu, bl, nu, &start, &first_blend, &steps, &last_blend);
1584  }
1585 
1586  LISTBASE_FOREACH (DispList *, dlb, &dlbev) {
1587  /* for each part of the bevel use a separate displblock */
1588  DispList *dl = MEM_callocN(sizeof(DispList), "makeDispListbev1");
1589  dl->verts = data = MEM_mallocN(sizeof(float[3]) * dlb->nr * steps, "dlverts");
1590  BLI_addtail(dispbase, dl);
1591 
1592  dl->type = DL_SURF;
1593 
1594  dl->flag = dlb->flag & (DL_FRONT_CURVE | DL_BACK_CURVE);
1595  if (dlb->type == DL_POLY) {
1596  dl->flag |= DL_CYCL_U;
1597  }
1598  if ((bl->poly >= 0) && (steps > 2)) {
1599  dl->flag |= DL_CYCL_V;
1600  }
1601 
1602  dl->parts = steps;
1603  dl->nr = dlb->nr;
1604  dl->col = nu->mat_nr;
1605  dl->charidx = nu->charidx;
1606 
1607  /* dl->rt will be used as flag for render face and */
1608  /* CU_2D conflicts with R_NOPUNOFLIP */
1609  dl->rt = nu->flag;
1610 
1611  /* for each point of poly make a bevel piece */
1612  BevPoint *bevp_first = bl->bevpoints;
1613  BevPoint *bevp_last = &bl->bevpoints[bl->nr - 1];
1614  BevPoint *bevp = &bl->bevpoints[start];
1615  for (int i = start, a = 0; a < steps; i++, bevp++, a++) {
1616  float radius_factor = 1.0;
1617  float *cur_data = data;
1618 
1619  if (cu->taperobj == NULL) {
1620  radius_factor = bevp->radius;
1621  }
1622  else {
1623  float taper_factor;
1624  if (cu->flag & CU_MAP_TAPER) {
1625  float len = (steps - 3) + first_blend + last_blend;
1626 
1627  if (a == 0) {
1628  taper_factor = 0.0f;
1629  }
1630  else if (a == steps - 1) {
1631  taper_factor = 1.0f;
1632  }
1633  else {
1634  taper_factor = ((float)a - (1.0f - first_blend)) / len;
1635  }
1636  }
1637  else {
1638  float len = bl->nr - 1;
1639  taper_factor = (float)i / len;
1640 
1641  if (a == 0) {
1642  taper_factor += (1.0f - first_blend) / len;
1643  }
1644  else if (a == steps - 1) {
1645  taper_factor -= (1.0f - last_blend) / len;
1646  }
1647  }
1648 
1649  radius_factor = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_factor);
1650 
1652  radius_factor *= bevp->radius;
1653  }
1654  else if (cu->taper_radius_mode == CU_TAPER_RADIUS_ADD) {
1655  radius_factor += bevp->radius;
1656  }
1657  }
1658 
1659  /* rotate bevel piece and write in data */
1660  if ((a == 0) && (bevp != bevp_last)) {
1662  cu, bevp, bevp + 1, dlb, 1.0f - first_blend, widfac, radius_factor, &data);
1663  }
1664  else if ((a == steps - 1) && (bevp != bevp_first)) {
1666  cu, bevp, bevp - 1, dlb, 1.0f - last_blend, widfac, radius_factor, &data);
1667  }
1668  else {
1669  rotateBevelPiece(cu, bevp, NULL, dlb, 0.0f, widfac, radius_factor, &data);
1670  }
1671 
1672  if ((cu->flag & CU_FILL_CAPS) && !(nu->flagu & CU_NURB_CYCLIC)) {
1673  if (a == 1) {
1674  fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase);
1675  copy_v3_v3(bottom_no, bevp->dir);
1676  }
1677  if (a == steps - 1) {
1678  fillBevelCap(nu, dlb, cur_data, &top_capbase);
1679  negate_v3_v3(top_no, bevp->dir);
1680  }
1681  }
1682  }
1683 
1684  /* gl array drawing: using indices */
1686  }
1687 
1688  if (bottom_capbase.first) {
1689  BKE_displist_fill(&bottom_capbase, dispbase, bottom_no, false);
1690  BKE_displist_fill(&top_capbase, dispbase, top_no, false);
1691  BKE_displist_free(&bottom_capbase);
1692  BKE_displist_free(&top_capbase);
1693  }
1694  }
1695  }
1696  BKE_displist_free(&dlbev);
1697  }
1698 
1699  if (!(cu->flag & CU_DEFORM_FILL)) {
1700  curve_to_filledpoly(cu, dispbase);
1701  }
1702 
1703  if (!for_orco) {
1704  if ((cu->flag & CU_PATH) ||
1707  }
1708 
1711  depsgraph, scene, ob, dispbase, r_final, for_render, force_mesh_conversion);
1712  }
1713 
1714  if (cu->flag & CU_DEFORM_FILL && !ob->runtime.data_eval) {
1715  curve_to_filledpoly(cu, dispbase);
1716  }
1717 
1718  BKE_nurbList_free(&nubase);
1719  }
1720 }
1721 
1723  const Scene *scene,
1724  Object *ob,
1725  const bool for_render,
1726  const bool for_orco)
1727 {
1728  ListBase *dispbase;
1729 
1730  /* The same check for duplis as in do_makeDispListCurveTypes.
1731  * Happens when curve used for constraint/bevel was converted to mesh.
1732  * check there is still needed for render displist and orco displists. */
1733  if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
1734  return;
1735  }
1736 
1738 
1739  if (!ob->runtime.curve_cache) {
1740  ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for curve types");
1741  }
1742 
1743  dispbase = &(ob->runtime.curve_cache->disp);
1744 
1745  Mesh *mesh_eval = NULL;
1746  do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, for_render, for_orco, &mesh_eval);
1747 
1748  if (mesh_eval != NULL) {
1749  BKE_object_eval_assign_data(ob, &mesh_eval->id, true);
1750  }
1751 
1753 }
1754 
1756  const Scene *scene,
1757  Object *ob,
1758  ListBase *dispbase,
1759  Mesh **r_final,
1760  const bool for_orco)
1761 {
1762  if (ob->runtime.curve_cache == NULL) {
1763  ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
1764  }
1765 
1766  do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, true, for_orco, r_final);
1767 }
1768 
1769 void BKE_displist_minmax(const ListBase *dispbase, float min[3], float max[3])
1770 {
1771  const float *vert;
1772  int a, tot = 0;
1773  int doit = 0;
1774 
1775  LISTBASE_FOREACH (const DispList *, dl, dispbase) {
1776  tot = (dl->type == DL_INDEX3) ? dl->nr : dl->nr * dl->parts;
1777  vert = dl->verts;
1778  for (a = 0; a < tot; a++, vert += 3) {
1779  minmax_v3v3_v3(min, max, vert);
1780  }
1781  doit |= (tot != 0);
1782  }
1783 
1784  if (!doit) {
1785  /* there's no geometry in displist, use zero-sized boundbox */
1786  zero_v3(min);
1787  zero_v3(max);
1788  }
1789 }
1790 
1791 /* this is confusing, there's also min_max_object, applying the obmat... */
1793 {
1794  if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
1795  /* Curve's BB is already calculated as a part of modifier stack,
1796  * here we only calculate object BB based on final display list.
1797  */
1798 
1799  /* object's BB is calculated from final displist */
1800  if (ob->runtime.bb == NULL) {
1801  ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "boundbox");
1802  }
1803 
1804  Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
1805  if (mesh_eval) {
1806  BKE_object_boundbox_calc_from_mesh(ob, mesh_eval);
1807  }
1808  else {
1809  float min[3], max[3];
1810 
1811  INIT_MINMAX(min, max);
1814 
1815  ob->runtime.bb->flag &= ~BOUNDBOX_DIRTY;
1816  }
1817  }
1818 }
typedef float(TangentPoint)[2]
void BKE_anim_path_calc_data(struct Object *ob)
Definition: anim_path.c:72
void BKE_curve_bevelList_free(struct ListBase *bev)
Definition: curve.c:2635
float(* BKE_curve_nurbs_vert_coords_alloc(const struct ListBase *lb, int *r_vert_len))[3]
void BKE_curve_bevel_make(struct Object *ob, struct ListBase *disp)
Definition: curve_bevel.c:290
struct ListBase * BKE_curve_editNurbs_get(struct Curve *cu)
Definition: curve.c:437
#define CU_DO_2DFILL(cu)
Definition: BKE_curve.h:86
void BKE_nurb_makeFaces(const struct Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
bool BKE_nurb_check_valid_u(const struct Nurb *nu)
void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render)
Definition: curve.c:2653
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
Definition: curve.c:1804
void BKE_nurb_makeCurve(const struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
void BKE_nurbList_duplicate(struct ListBase *lb1, const struct ListBase *lb2)
void BKE_nurbList_free(struct ListBase *lb)
Definition: curve.c:660
void BKE_curve_nurbs_vert_coords_apply(struct ListBase *lb, const float(*vert_coords)[3], const bool constrain_2d)
Definition: curve.c:4740
void BKE_curve_nurbs_key_vert_tilts_apply(struct ListBase *lb, const float *key)
Definition: curve.c:4810
bool BKE_nurb_check_valid_uv(const struct Nurb *nu)
#define SEGMENTSU(nu)
Definition: BKE_curve.h:74
ListBase * BKE_curve_nurbs_get(struct Curve *cu)
Definition: curve.c:5079
float(* BKE_curve_nurbs_key_vert_coords_alloc(const struct ListBase *lb, float *key, int *r_vert_len))[3]
display list (or rather multi purpose list) stuff.
@ DL_CYCL_V
Definition: BKE_displist.h:54
@ DL_BACK_CURVE
Definition: BKE_displist.h:57
@ DL_FRONT_CURVE
Definition: BKE_displist.h:56
@ DL_CYCL_U
Definition: BKE_displist.h:53
@ DL_SURF
Definition: BKE_displist.h:40
@ DL_INDEX4
Definition: BKE_displist.h:44
@ DL_INDEX3
Definition: BKE_displist.h:42
@ DL_POLY
Definition: BKE_displist.h:36
@ DL_SEGM
Definition: BKE_displist.h:38
bool BKE_vfont_to_curve_nubase(struct Object *ob, int mode, struct ListBase *r_nubase)
Definition: font.c:1732
float * BKE_key_evaluate_object(struct Object *ob, int *r_totelem)
Definition: key.c:1616
int BKE_keyblock_curve_element_count(struct ListBase *nurb)
Definition: key.c:2044
bool object_deform_mball(struct Object *ob, struct ListBase *dispbase)
Definition: lattice.c:410
@ LIB_ID_COPY_LOCALIZE
Definition: BKE_lib_id.h:145
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag)
void BKE_id_free(struct Main *bmain, void *idv)
struct Object * BKE_mball_basis_find(struct Scene *scene, struct Object *ob)
This function finds the basis MetaBall.
Definition: mball.c:511
void BKE_mball_texspace_calc(struct Object *ob)
Definition: mball.c:278
void BKE_mball_polygonize(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase)
void BKE_mesh_calc_normals_mapping_simple(struct Mesh *me)
Definition: mesh_evaluate.c:90
void BKE_mesh_ensure_normals(struct Mesh *me)
void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const float(*vert_coords)[3])
Definition: mesh.c:1755
struct Mesh * BKE_mesh_new_nomain_from_curve_displist(struct Object *ob, struct ListBase *dispbase)
Definition: mesh_convert.c:526
float(* BKE_mesh_vert_coords_alloc(const struct Mesh *mesh, int *r_vert_len))[3]
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
bool BKE_modifier_is_enabled(const struct Scene *scene, struct ModifierData *md, int required_mode)
struct ModifierData * BKE_modifiers_get_virtual_modifierlist(const struct Object *ob, struct VirtualModifierData *data)
@ eModifierTypeType_OnlyDeform
Definition: BKE_modifier.h:58
@ eModifierTypeType_DeformOrConstruct
Definition: BKE_modifier.h:70
@ eModifierTypeType_Constructive
Definition: BKE_modifier.h:61
void BKE_modifiers_clear_errors(struct Object *ob)
ModifierApplyFlag
Definition: BKE_modifier.h:126
@ MOD_APPLY_USECACHE
Definition: BKE_modifier.h:131
@ MOD_APPLY_RENDER
Definition: BKE_modifier.h:128
General operations, lookup, etc. for blender objects.
void BKE_boundbox_init_from_minmax(struct BoundBox *bb, const float min[3], const float max[3])
Definition: object.c:3778
struct Mesh * BKE_object_get_evaluated_mesh(struct Object *object)
Definition: object.c:4459
void BKE_object_free_derived_caches(struct Object *ob)
Definition: object.c:1719
void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval)
Definition: object.c:3873
void BKE_object_eval_assign_data(struct Object *object, struct ID *data, bool is_owned)
Definition: object.c:1687
#define BLI_assert(a)
Definition: BLI_assert.h:58
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:257
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:87
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
Definition: BLI_listbase.h:180
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
Definition: math_geom.c:68
void mul_qt_v3(const float q[4], float r[3])
Definition: math_rotation.c:97
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], const float t)
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:52
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:49
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
Definition: math_vector.c:1020
MINLINE float normalize_v3(float r[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
Definition: BLI_memarena.c:109
struct MemArena * BLI_memarena_new(const size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2) ATTR_MALLOC
Definition: BLI_memarena.c:79
struct ScanFillVert * BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3])
Definition: scanfill.c:129
struct ScanFillEdge * BLI_scanfill_edge_add(ScanFillContext *sf_ctx, struct ScanFillVert *v1, struct ScanFillVert *v2)
Definition: scanfill.c:151
@ BLI_SCANFILL_CALC_POLYS
Definition: BLI_scanfill.h:106
@ BLI_SCANFILL_CALC_HOLES
Definition: BLI_scanfill.h:110
@ BLI_SCANFILL_CALC_REMOVE_DOUBLES
Definition: BLI_scanfill.h:103
void BLI_scanfill_begin_arena(ScanFillContext *sf_ctx, struct MemArena *arena)
Definition: scanfill.c:801
#define BLI_SCANFILL_ARENA_SIZE
Definition: BLI_scanfill.h:45
void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, struct MemArena *arena)
Definition: scanfill.c:818
unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float nor_proj[3])
Definition: scanfill.c:828
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
#define INIT_MINMAX(min, max)
#define SWAP(type, a, b)
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
@ DAG_EVAL_NEED_CURVE_PATH
Definition: DEG_depsgraph.h:70
uint32_t DEG_get_eval_flags_for_id(const struct Depsgraph *graph, struct ID *id)
@ LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT
Definition: DNA_ID.h:567
@ ID_ME
Definition: DNA_ID_enums.h:60
@ CU_BEZIER
@ CU_POLY
@ CU_NURBS
@ CU_SMOOTH
@ CU_TAPER_RADIUS_MULTIPLY
@ CU_TAPER_RADIUS_ADD
@ CU_NURB_CYCLIC
@ HD_VECT
@ CU_FILL_CAPS
@ CU_3D
@ CU_FRONT
@ CU_PATH
@ CU_MAP_TAPER
@ CU_DEFORM_FILL
@ CU_BACK
@ CU_BEVFAC_MAP_SPLINE
@ CU_BEVFAC_MAP_RESOLU
@ CU_BEVFAC_MAP_SEGMENT
@ eModifierMode_Render
@ eModifierMode_ApplyOnSpline
@ eModifierMode_Editmode
@ eModifierMode_Realtime
@ eModifierType_MeshDeform
@ eModifierType_Hook
@ eModifierType_Softbody
Object is a sort of wrapper for general info.
@ BOUNDBOX_DIRTY
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_CURVE
#define FO_EDIT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
Scene scene
const Depsgraph * depsgraph
static void displist_surf_indices(DispList *dl)
Definition: displist.c:1099
static void curve_to_filledpoly(const Curve *cu, ListBase *dispbase)
Definition: displist.c:612
static void bevels_to_filledpoly(const Curve *cu, ListBase *dispbase)
Definition: displist.c:552
static void boundbox_displist_object(Object *ob)
Definition: displist.c:1792
void BKE_displist_normals_add(ListBase *lb)
Definition: displist.c:140
void BKE_displist_make_curveTypes_forRender(Depsgraph *depsgraph, const Scene *scene, Object *ob, ListBase *dispbase, Mesh **r_final, const bool for_orco)
Definition: displist.c:1755
float BKE_displist_calc_taper(Depsgraph *depsgraph, const Scene *scene, Object *taperobj, int cur, int tot)
Definition: displist.c:677
void BKE_displist_make_mball_forRender(Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase)
Definition: displist.c:709
static float displist_calc_taper(Depsgraph *depsgraph, const Scene *scene, Object *taperobj, float fac)
Definition: displist.c:632
void BKE_displist_fill(const ListBase *dispbase, ListBase *to, const float normal_proj[3], const bool flip_normal)
Definition: displist.c:433
static void calc_bevfac_mapping_default(const BevList *bl, int *r_start, float *r_firstblend, int *r_steps, float *r_lastblend)
Definition: displist.c:1376
static void calc_bevfac_spline_mapping(const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
Definition: displist.c:1354
bool BKE_curve_calc_modifiers_pre(Depsgraph *depsgraph, const Scene *scene, Object *ob, ListBase *source_nurb, ListBase *target_nurb, const bool for_render)
Definition: displist.c:770
static float(* displist_vert_coords_alloc(ListBase *dispbase, int *r_vert_len))[3]
Definition: displist.c:862
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.c:1242
void BKE_displist_copy(ListBase *lbn, const ListBase *lb)
Definition: displist.c:127
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.c:1385
static void do_makeDispListCurveTypes(Depsgraph *depsgraph, const Scene *scene, Object *ob, ListBase *dispbase, const bool for_render, const bool for_orco, Mesh **r_final)
Definition: displist.c:1464
bool BKE_displist_surfindex_get(const DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
Definition: displist.c:254
static void fillBevelCap(const Nurb *nu, const DispList *dlb, const float *prev_fp, ListBase *dispbase)
Definition: displist.c:1303
static void displist_vert_coords_apply(ListBase *dispbase, const float(*allverts)[3])
Definition: displist.c:883
void BKE_displist_count(const ListBase *lb, int *totvert, int *totface, int *tottri)
Definition: displist.c:211
void BKE_displist_free(ListBase *lb)
Definition: displist.c:81
void BKE_displist_make_curveTypes(Depsgraph *depsgraph, const Scene *scene, Object *ob, const bool for_render, const bool for_orco)
Definition: displist.c:1722
void BKE_displist_make_mball(Depsgraph *depsgraph, Scene *scene, Object *ob)
Definition: displist.c:685
DispList * BKE_displist_find_or_create(ListBase *lb, int type)
Definition: displist.c:90
DispList * BKE_displist_find(ListBase *lb, int type)
Definition: displist.c:105
void BKE_displist_elem_free(DispList *dl)
Definition: displist.c:65
static void calc_bevfac_segment_mapping(const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
Definition: displist.c:1328
static void curve_calc_modifiers_post(Depsgraph *depsgraph, const Scene *scene, Object *ob, ListBase *dispbase, Mesh **r_final, const bool for_render, const bool force_mesh_conversion)
Definition: displist.c:895
static ModifierData * curve_get_tessellate_point(const Scene *scene, const Object *ob, const bool for_render, const bool editmode)
Definition: displist.c:720
bool BKE_displist_has_faces(const ListBase *lb)
Definition: displist.c:116
static void curve_to_displist(const Curve *cu, const ListBase *nubase, const bool for_render, ListBase *r_dispbase)
Definition: displist.c:290
void BKE_displist_make_surf(Depsgraph *depsgraph, const Scene *scene, Object *ob, ListBase *dispbase, Mesh **r_final, const bool for_render, const bool for_orco)
Definition: displist.c:1131
void BKE_displist_minmax(const ListBase *dispbase, float min[3], float max[3])
Definition: displist.c:1769
uint nor
uint col
#define fabsf(x)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
static unsigned a[3]
Definition: RandGen.cpp:92
static const int steps
Definition: sky_nishita.cpp:28
#define min(a, b)
Definition: sort.c:51
float vec[4]
struct BevList * next
float * seglen
BevPoint * bevpoints
int * segbevcount
float offset
float radius
float dir[3]
float quat[4]
float vec[3]
float vec[3][3]
ListBase bev
Definition: BKE_curve.h:50
ListBase disp
Definition: BKE_curve.h:49
ListBase deformed_nurbs
Definition: BKE_curve.h:51
const float * anim_path_accum_length
Definition: BKE_curve.h:58
struct Material ** mat
short totcol
float bevfac2
struct EditFont * editfont
char bevfac2_mapping
short resolv_ren
float bevfac1
EditNurb * editnurb
ListBase nurb
char taper_radius_mode
char bevfac1_mapping
float width
struct Object * taperobj
short resolu_ren
short type
Definition: BKE_displist.h:71
int totindex
Definition: BKE_displist.h:77
short col
Definition: BKE_displist.h:73
float * verts
Definition: BKE_displist.h:74
int * index
Definition: BKE_displist.h:75
short rt
Definition: BKE_displist.h:73
float * nors
Definition: BKE_displist.h:74
short flag
Definition: BKE_displist.h:71
int charidx
Definition: BKE_displist.h:76
int tag
Definition: DNA_ID.h:292
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
struct Material ** mat
short totcol
struct ModifierData * next
ModifierTypeType type
Definition: BKE_modifier.h:173
struct Mesh *(* modifyMesh)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh)
Definition: BKE_modifier.h:244
void(* deformVerts)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float(*vertexCos)[3], int numVerts)
Definition: BKE_modifier.h:197
bool(* dependsOnNormals)(struct ModifierData *md)
Definition: BKE_modifier.h:337
short flagu
struct Nurb * next
int charidx
short flag
short mat_nr
struct CurveCache * curve_cache
struct ID * data_eval
struct BoundBox * bb
Object_Runtime runtime
void * data
ListBase fillvertbase
Definition: BLI_scanfill.h:33
unsigned short poly_nr
Definition: BLI_scanfill.h:39
ListBase fillfacebase
Definition: BLI_scanfill.h:35
float max
uint len