Blender  V2.93
bmesh_wireframe.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 
23 #include "MEM_guardedalloc.h"
24 
25 #include "DNA_meshdata_types.h"
26 
27 #include "BLI_math.h"
28 
29 #include "bmesh.h"
30 
31 #include "BKE_customdata.h"
32 #include "BKE_deform.h"
33 
34 #include "bmesh_wireframe.h"
35 
37 {
38  BMLoop *l, *l_first;
39 
40  l = l_first = e->l;
41  do {
43  return l;
44  }
45  } while ((l = l->radial_next) != l_first);
46 
47  /* in the case this is used, we know this will never happen */
48  return NULL;
49 }
50 
52  BMVert *v, float r_no[3], float r_no_face[3], BMVert **r_va_other, BMVert **r_vb_other)
53 {
54  BMIter iter;
55  BMEdge *e_iter;
56 
57  BMEdge *e_a = NULL, *e_b = NULL;
58  BMVert *v_a, *v_b;
59 
60  BMLoop *l_a, *l_b;
61 
62  float no_face[3], no_edge[3];
63  float tvec_a[3], tvec_b[3];
64 
65  /* get 2 boundary edges, there should only _be_ 2,
66  * in case there are more - results wont be valid of course */
67  BM_ITER_ELEM (e_iter, &iter, v, BM_EDGES_OF_VERT) {
68  if (BM_elem_flag_test(e_iter, BM_ELEM_TAG)) {
69  if (e_a == NULL) {
70  e_a = e_iter;
71  }
72  else {
73  e_b = e_iter;
74  break;
75  }
76  }
77  }
78 
79  if (e_a && e_b) {
80  /* note, with an incorrectly flushed selection this can crash */
81  l_a = bm_edge_tag_faceloop(e_a);
83 
84  /* average edge face normal */
85  add_v3_v3v3(no_face, l_a->f->no, l_b->f->no);
86  normalize_v3(no_face);
87 
88  /* average edge direction */
89  v_a = BM_edge_other_vert(e_a, v);
90  v_b = BM_edge_other_vert(e_b, v);
91 
92  sub_v3_v3v3(tvec_a, v->co, v_a->co);
93  sub_v3_v3v3(tvec_b, v_b->co, v->co);
94  normalize_v3(tvec_a);
95  normalize_v3(tvec_b);
96  add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */
97 
98  /* check are we flipped the right way */
99  BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
100  BM_edge_calc_face_tangent(e_b, l_b, tvec_b);
101  add_v3_v3(tvec_a, tvec_b);
102 
103  *r_va_other = v_a;
104  *r_vb_other = v_b;
105  }
106  else {
107  /* degenerate case - vertex connects a boundary edged face to other faces,
108  * so we have only one boundary face - only use it for calculations */
109  l_a = bm_edge_tag_faceloop(e_a);
110 
111  copy_v3_v3(no_face, l_a->f->no);
112 
113  /* edge direction */
114  v_a = BM_edge_other_vert(e_a, v);
115  v_b = NULL;
116 
117  sub_v3_v3v3(no_edge, v->co, v_a->co);
118 
119  /* check are we flipped the right way */
120  BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
121 
122  *r_va_other = NULL;
123  *r_vb_other = NULL;
124  }
125 
126  /* find the normal */
127  cross_v3_v3v3(r_no, no_edge, no_face);
128  normalize_v3(r_no);
129 
130  if (dot_v3v3(r_no, tvec_a) > 0.0f) {
131  negate_v3(r_no);
132  }
133 
134  copy_v3_v3(r_no_face, no_face);
135 }
136 
137 /* check if we are the only tagged loop-face around this edge */
138 static bool bm_loop_is_radial_boundary(BMLoop *l_first)
139 {
140  BMLoop *l = l_first->radial_next;
141 
142  if (l == l_first) {
143  return true; /* a real boundary */
144  }
145 
146  do {
147  if (BM_elem_flag_test(l->f, BM_ELEM_TAG)) {
148  return false;
149  }
150  } while ((l = l->radial_next) != l_first);
151 
152  return true;
153 }
154 
162  const float offset,
163  const float offset_fac,
164  const float offset_fac_vg,
165  const bool use_replace,
166  const bool use_boundary,
167  const bool use_even_offset,
168  const bool use_relative_offset,
169  const bool use_crease,
170  const float crease_weight,
171  const int defgrp_index,
172  const bool defgrp_invert,
173  const short mat_offset,
174  const short mat_max,
175  /* for operators */
176  const bool use_tag)
177 {
178  const float ofs_orig = -(((-offset_fac + 1.0f) * 0.5f) * offset);
179  const float ofs_new = offset + ofs_orig;
180  const float ofs_mid = (ofs_orig + ofs_new) / 2.0f;
181  const float inset = offset / 2.0f;
182  int cd_edge_crease_offset = use_crease ? CustomData_get_offset(&bm->edata, CD_CREASE) : -1;
183  const int cd_dvert_offset = (defgrp_index != -1) ?
185  -1;
186  const float offset_fac_vg_inv = 1.0f - offset_fac_vg;
187 
188  const int totvert_orig = bm->totvert;
189 
190  BMIter iter;
191  BMIter itersub;
192 
193  /* filled only with boundary verts */
194  BMVert **verts_src = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__);
195  BMVert **verts_neg = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__);
196  BMVert **verts_pos = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__);
197 
198  /* will over-alloc, but makes for easy lookups by index to keep aligned */
199  BMVert **verts_boundary = use_boundary ? MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__) :
200  NULL;
201 
202  float *verts_relfac = (use_relative_offset || (cd_dvert_offset != -1)) ?
203  MEM_mallocN(sizeof(float) * totvert_orig, __func__) :
204  NULL;
205 
206  /* may over-alloc if not all faces have wire */
207  BMVert **verts_loop;
208  int verts_loop_tot = 0;
209 
210  BMVert *v_src;
211 
212  BMFace *f_src;
213  BMLoop *l;
214 
215  float tvec[3];
216  float fac, fac_shell;
217 
218  int i;
219 
220  if (use_crease && cd_edge_crease_offset == -1) {
222  cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
223  }
224 
225  BM_ITER_MESH_INDEX (v_src, &iter, bm, BM_VERTS_OF_MESH, i) {
226  BM_elem_index_set(v_src, i); /* set_inline */
227 
228  verts_src[i] = v_src;
230  }
232 
233  /* setup tags, all faces and verts will be tagged which will be duplicated */
234 
235  BM_ITER_MESH_INDEX (f_src, &iter, bm, BM_FACES_OF_MESH, i) {
236  BM_elem_index_set(f_src, i); /* set_inline */
237 
238  if (use_tag) {
239  if (!BM_elem_flag_test(f_src, BM_ELEM_TAG)) {
240  continue;
241  }
242  }
243  else {
245  }
246 
247  verts_loop_tot += f_src->len;
248  BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
250 
251  /* also tag boundary edges */
253  }
254  }
256 
257  /* duplicate tagged verts */
258  for (i = 0; i < totvert_orig; i++) {
259  v_src = verts_src[i];
260  if (BM_elem_flag_test(v_src, BM_ELEM_TAG)) {
261  fac = 1.0f;
262 
263  if (verts_relfac) {
264  if (use_relative_offset) {
265  verts_relfac[i] = BM_vert_calc_median_tagged_edge_length(v_src);
266  }
267  else {
268  verts_relfac[i] = 1.0f;
269  }
270 
271  if (cd_dvert_offset != -1) {
272  MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(v_src, cd_dvert_offset);
273  float defgrp_fac = BKE_defvert_find_weight(dvert, defgrp_index);
274 
275  if (defgrp_invert) {
276  defgrp_fac = 1.0f - defgrp_fac;
277  }
278 
279  if (offset_fac_vg > 0.0f) {
280  defgrp_fac = (offset_fac_vg + (defgrp_fac * offset_fac_vg_inv));
281  }
282 
283  verts_relfac[i] *= defgrp_fac;
284  }
285 
286  fac *= verts_relfac[i];
287  }
288 
289  verts_neg[i] = BM_vert_create(bm, NULL, v_src, BM_CREATE_NOP);
290  verts_pos[i] = BM_vert_create(bm, NULL, v_src, BM_CREATE_NOP);
291 
292  if (offset == 0.0f) {
293  madd_v3_v3v3fl(verts_neg[i]->co, v_src->co, v_src->no, ofs_orig * fac);
294  madd_v3_v3v3fl(verts_pos[i]->co, v_src->co, v_src->no, ofs_new * fac);
295  }
296  else {
297  madd_v3_v3v3fl(tvec, v_src->co, v_src->no, ofs_mid * fac);
298 
299  madd_v3_v3v3fl(verts_neg[i]->co, tvec, v_src->no, (ofs_orig - ofs_mid) * fac);
300  madd_v3_v3v3fl(verts_pos[i]->co, tvec, v_src->no, (ofs_new - ofs_mid) * fac);
301  }
302  }
303  else {
304  /* could skip this */
305  verts_neg[i] = NULL;
306  verts_pos[i] = NULL;
307  }
308 
309  /* conflicts with BM_vert_calc_median_tagged_edge_length */
310  if (use_relative_offset == false) {
312  }
313  }
314 
315  if (use_relative_offset) {
317  }
318 
319  verts_loop = MEM_mallocN(sizeof(BMVert *) * verts_loop_tot, __func__);
320  verts_loop_tot = 0; /* count up again */
321 
322  BM_ITER_MESH (f_src, &iter, bm, BM_FACES_OF_MESH) {
323 
324  if (use_tag && !BM_elem_flag_test(f_src, BM_ELEM_TAG)) {
325  continue;
326  }
327 
328  BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
329  /* Because some faces might be skipped! */
330  BM_elem_index_set(l, verts_loop_tot); /* set_dirty */
331 
333 
334  /* create offset vert */
335  fac = 1.0f;
336 
337  if (verts_relfac) {
338  fac *= verts_relfac[BM_elem_index_get(l->v)];
339  }
340 
341  fac_shell = fac;
342  if (use_even_offset) {
343  fac_shell *= shell_angle_to_dist(((float)M_PI - BM_loop_calc_face_angle(l)) * 0.5f);
344  }
345 
346  madd_v3_v3v3fl(tvec, l->v->co, tvec, inset * fac_shell);
347  if (offset != 0.0f) {
348  madd_v3_v3fl(tvec, l->v->no, ofs_mid * fac);
349  }
350  verts_loop[verts_loop_tot] = BM_vert_create(bm, tvec, l->v, BM_CREATE_NOP);
351 
352  if (use_boundary) {
353  if (BM_elem_flag_test(l->e, BM_ELEM_TAG)) { /* is this a boundary? */
354  BMVert *v_pair[2] = {l->v, l->next->v};
355 
356  for (i = 0; i < 2; i++) {
357  BMVert *v_boundary = v_pair[i];
358  if (!BM_elem_flag_test(v_boundary, BM_ELEM_TAG)) {
359  const int v_boundary_index = BM_elem_index_get(v_boundary);
360  float no_face[3];
361  BMVert *va_other;
362  BMVert *vb_other;
363 
364  BM_elem_flag_enable(v_boundary, BM_ELEM_TAG);
365 
366  bm_vert_boundary_tangent(v_boundary, tvec, no_face, &va_other, &vb_other);
367 
368  /* create offset vert */
369  /* similar to code above but different angle calc */
370  fac = 1.0f;
371 
372  if (verts_relfac) {
373  fac *= verts_relfac[v_boundary_index];
374  }
375 
376  fac_shell = fac;
377  if (use_even_offset) {
378  if (va_other) { /* for verts with only one boundary edge - this will be NULL */
379  fac_shell *= shell_angle_to_dist(
380  ((float)M_PI - angle_on_axis_v3v3v3_v3(
381  va_other->co, v_boundary->co, vb_other->co, no_face)) *
382  0.5f);
383  }
384  }
385 
386  madd_v3_v3v3fl(tvec, v_boundary->co, tvec, inset * fac_shell);
387  if (offset != 0.0f) {
388  madd_v3_v3fl(tvec, v_boundary->no, ofs_mid * fac);
389  }
390  verts_boundary[v_boundary_index] = BM_vert_create(
391  bm, tvec, v_boundary, BM_CREATE_NOP);
392  }
393  }
394  }
395  }
396 
397  verts_loop_tot++;
398  }
399  }
401 
402  BM_ITER_MESH (f_src, &iter, bm, BM_FACES_OF_MESH) {
403 
404  /* skip recently added faces */
405  if (BM_elem_index_get(f_src) == -1) {
406  continue;
407  }
408 
409  if (use_tag && !BM_elem_flag_test(f_src, BM_ELEM_TAG)) {
410  continue;
411  }
412 
414 
415  BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
416  BMFace *f_new;
417  BMLoop *l_new;
418  BMLoop *l_next = l->next;
419  BMVert *v_l1 = verts_loop[BM_elem_index_get(l)];
420  BMVert *v_l2 = verts_loop[BM_elem_index_get(l_next)];
421 
422  BMVert *v_src_l1 = l->v;
423  BMVert *v_src_l2 = l_next->v;
424 
425  const int i_1 = BM_elem_index_get(v_src_l1);
426  const int i_2 = BM_elem_index_get(v_src_l2);
427 
428  BMVert *v_neg1 = verts_neg[i_1];
429  BMVert *v_neg2 = verts_neg[i_2];
430 
431  BMVert *v_pos1 = verts_pos[i_1];
432  BMVert *v_pos2 = verts_pos[i_2];
433 
434  f_new = BM_face_create_quad_tri(bm, v_l1, v_l2, v_neg2, v_neg1, f_src, BM_CREATE_NOP);
435  if (mat_offset) {
436  f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
437  }
439  l_new = BM_FACE_FIRST_LOOP(f_new);
440 
441  BM_elem_attrs_copy(bm, bm, l, l_new);
442  BM_elem_attrs_copy(bm, bm, l, l_new->prev);
443  BM_elem_attrs_copy(bm, bm, l_next, l_new->next);
444  BM_elem_attrs_copy(bm, bm, l_next, l_new->next->next);
445 
446  f_new = BM_face_create_quad_tri(bm, v_l2, v_l1, v_pos1, v_pos2, f_src, BM_CREATE_NOP);
447 
448  if (mat_offset) {
449  f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
450  }
452  l_new = BM_FACE_FIRST_LOOP(f_new);
453 
454  BM_elem_attrs_copy(bm, bm, l_next, l_new);
455  BM_elem_attrs_copy(bm, bm, l_next, l_new->prev);
456  BM_elem_attrs_copy(bm, bm, l, l_new->next);
457  BM_elem_attrs_copy(bm, bm, l, l_new->next->next);
458 
459  if (use_boundary) {
460  if (BM_elem_flag_test(l->e, BM_ELEM_TAG)) {
461  /* we know its a boundary and this is the only face user (which is being wire'd) */
462  /* we know we only touch this edge/face once */
463  BMVert *v_b1 = verts_boundary[i_1];
464  BMVert *v_b2 = verts_boundary[i_2];
465 
466  f_new = BM_face_create_quad_tri(bm, v_b2, v_b1, v_neg1, v_neg2, f_src, BM_CREATE_NOP);
467  if (mat_offset) {
468  f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
469  }
471  l_new = BM_FACE_FIRST_LOOP(f_new);
472 
473  BM_elem_attrs_copy(bm, bm, l_next, l_new);
474  BM_elem_attrs_copy(bm, bm, l_next, l_new->prev);
475  BM_elem_attrs_copy(bm, bm, l, l_new->next);
476  BM_elem_attrs_copy(bm, bm, l, l_new->next->next);
477 
478  f_new = BM_face_create_quad_tri(bm, v_b1, v_b2, v_pos2, v_pos1, f_src, BM_CREATE_NOP);
479  if (mat_offset) {
480  f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
481  }
483  l_new = BM_FACE_FIRST_LOOP(f_new);
484 
485  BM_elem_attrs_copy(bm, bm, l, l_new);
486  BM_elem_attrs_copy(bm, bm, l, l_new->prev);
487  BM_elem_attrs_copy(bm, bm, l_next, l_new->next);
488  BM_elem_attrs_copy(bm, bm, l_next, l_new->next->next);
489 
490  if (use_crease) {
491  BMEdge *e_new;
492  e_new = BM_edge_exists(v_pos1, v_b1);
493  BM_ELEM_CD_SET_FLOAT(e_new, cd_edge_crease_offset, crease_weight);
494 
495  e_new = BM_edge_exists(v_pos2, v_b2);
496  BM_ELEM_CD_SET_FLOAT(e_new, cd_edge_crease_offset, crease_weight);
497 
498  e_new = BM_edge_exists(v_neg1, v_b1);
499  BM_ELEM_CD_SET_FLOAT(e_new, cd_edge_crease_offset, crease_weight);
500 
501  e_new = BM_edge_exists(v_neg2, v_b2);
502  BM_ELEM_CD_SET_FLOAT(e_new, cd_edge_crease_offset, crease_weight);
503  }
504  }
505  }
506 
507  if (use_crease) {
508  BMEdge *e_new;
509  e_new = BM_edge_exists(v_pos1, v_l1);
510  BM_ELEM_CD_SET_FLOAT(e_new, cd_edge_crease_offset, crease_weight);
511 
512  e_new = BM_edge_exists(v_pos2, v_l2);
513  BM_ELEM_CD_SET_FLOAT(e_new, cd_edge_crease_offset, crease_weight);
514 
515  e_new = BM_edge_exists(v_neg1, v_l1);
516  BM_ELEM_CD_SET_FLOAT(e_new, cd_edge_crease_offset, crease_weight);
517 
518  e_new = BM_edge_exists(v_neg2, v_l2);
519  BM_ELEM_CD_SET_FLOAT(e_new, cd_edge_crease_offset, crease_weight);
520  }
521  }
522  }
523 
524  if (use_boundary) {
525  MEM_freeN(verts_boundary);
526  }
527 
528  if (verts_relfac) {
529  MEM_freeN(verts_relfac);
530  }
531 
532  if (use_replace) {
533 
534  if (use_tag) {
535  /* only remove faces which are original and used to make wire,
536  * use 'verts_pos' and 'verts_neg' to avoid a feedback loop. */
537 
538  /* vertex must be from 'verts_src' */
539 #define VERT_DUPE_TEST_ORIG(v) (verts_neg[BM_elem_index_get(v)] != NULL)
540 #define VERT_DUPE_TEST(v) (verts_pos[BM_elem_index_get(v)] != NULL)
541 #define VERT_DUPE_CLEAR(v) \
542  { \
543  verts_pos[BM_elem_index_get(v)] = NULL; \
544  } \
545  (void)0
546 
547  /* first ensure we keep all verts which are used in faces that weren't
548  * entirely made into wire. */
549  BM_ITER_MESH (f_src, &iter, bm, BM_FACES_OF_MESH) {
550  int mix_flag = 0;
551  BMLoop *l_iter, *l_first;
552 
553  /* skip new faces */
554  if (BM_elem_index_get(f_src) == -1) {
555  continue;
556  }
557 
558  l_iter = l_first = BM_FACE_FIRST_LOOP(f_src);
559  do {
560  mix_flag |= (VERT_DUPE_TEST_ORIG(l_iter->v) ? 1 : 2);
561  if (mix_flag == (1 | 2)) {
562  break;
563  }
564  } while ((l_iter = l_iter->next) != l_first);
565 
566  if (mix_flag == (1 | 2)) {
567  l_iter = l_first = BM_FACE_FIRST_LOOP(f_src);
568  do {
569  VERT_DUPE_CLEAR(l_iter->v);
570  } while ((l_iter = l_iter->next) != l_first);
571  }
572  }
573 
574  /* now remove any verts which were made into wire by all faces */
575  for (i = 0; i < totvert_orig; i++) {
576  v_src = verts_src[i];
577  BLI_assert(i == BM_elem_index_get(v_src));
578  if (VERT_DUPE_TEST(v_src)) {
579  BM_vert_kill(bm, v_src);
580  }
581  }
582 
583 #undef VERT_DUPE_TEST_ORIG
584 #undef VERT_DUPE_TEST
585 #undef VERT_DUPE_CLEAR
586  }
587  else {
588  /* simple case, no tags - replace all */
589  for (i = 0; i < totvert_orig; i++) {
590  BM_vert_kill(bm, verts_src[i]);
591  }
592  }
593  }
594 
595  MEM_freeN(verts_src);
596  MEM_freeN(verts_neg);
597  MEM_freeN(verts_pos);
598  MEM_freeN(verts_loop);
599 }
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_offset(const struct CustomData *data, int type)
support for deformation groups and hooks.
float BKE_defvert_find_weight(const struct MDeformVert *dvert, const int defgroup)
Definition: deform.c:632
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define M_PI
Definition: BLI_math_base.h:38
MINLINE float shell_angle_to_dist(const float angle)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]) ATTR_WARN_UNUSED_RESULT
Definition: math_vector.c:574
MINLINE void negate_v3(float r[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
#define CLAMPIS(a, b, c)
@ CD_MDEFORMVERT
Read Guarded memory(de)allocation.
#define BM_ELEM_CD_SET_FLOAT(ele, offset, f)
Definition: bmesh_class.h:534
@ BM_LOOP
Definition: bmesh_class.h:385
@ BM_FACE
Definition: bmesh_class.h:386
@ BM_VERT
Definition: bmesh_class.h:383
@ BM_ELEM_TAG
Definition: bmesh_class.h:484
#define BM_FACE_FIRST_LOOP(p)
Definition: bmesh_class.h:553
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
Definition: bmesh_class.h:530
void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src, void *ele_dst)
BMFace * BM_face_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, const BMFace *f_example, const eBMCreateFlag create_flag)
Make Quad/Triangle.
BMVert * BM_vert_create(BMesh *bm, const float co[3], const BMVert *v_example, const eBMCreateFlag create_flag)
Main function for creating a new vertex.
Definition: bmesh_core.c:58
void BM_vert_kill(BMesh *bm, BMVert *v)
Definition: bmesh_core.c:1002
@ BM_CREATE_NOP
Definition: bmesh_core.h:27
#define BM_elem_index_get(ele)
Definition: bmesh_inline.h:124
#define BM_elem_flag_disable(ele, hflag)
Definition: bmesh_inline.h:29
#define BM_elem_flag_set(ele, hflag, val)
Definition: bmesh_inline.h:30
#define BM_elem_index_set(ele, index)
Definition: bmesh_inline.h:125
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:26
#define BM_elem_flag_enable(ele, hflag)
Definition: bmesh_inline.h:28
void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:894
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
@ BM_VERTS_OF_MESH
@ BM_FACES_OF_MESH
@ BM_EDGES_OF_VERT
@ BM_LOOPS_OF_FACE
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
BMEdge * BM_edge_exists(BMVert *v_a, BMVert *v_b)
Definition: bmesh_query.c:1995
float BM_vert_calc_median_tagged_edge_length(const BMVert *v)
Definition: bmesh_query.c:1903
void BM_loop_calc_face_tangent(const BMLoop *l, float r_tangent[3])
BM_loop_calc_face_tangent.
Definition: bmesh_query.c:1681
float BM_loop_calc_face_angle(const BMLoop *l)
Definition: bmesh_query.c:1531
void BM_edge_calc_face_tangent(const BMEdge *e, const BMLoop *e_loop, float r_tangent[3])
BMESH EDGE/FACE TANGENT.
Definition: bmesh_query.c:1803
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMLoop * l_b
ATTR_WARN_UNUSED_RESULT const BMVert * v
static BMLoop * bm_edge_tag_faceloop(BMEdge *e)
void BM_mesh_wireframe(BMesh *bm, const float offset, const float offset_fac, const float offset_fac_vg, const bool use_replace, const bool use_boundary, const bool use_even_offset, const bool use_relative_offset, const bool use_crease, const float crease_weight, const int defgrp_index, const bool defgrp_invert, const short mat_offset, const short mat_max, const bool use_tag)
#define VERT_DUPE_CLEAR(v)
#define VERT_DUPE_TEST(v)
static void bm_vert_boundary_tangent(BMVert *v, float r_no[3], float r_no_face[3], BMVert **r_va_other, BMVert **r_vb_other)
#define VERT_DUPE_TEST_ORIG(v)
static bool bm_loop_is_radial_boundary(BMLoop *l_first)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
short mat_nr
Definition: bmesh_class.h:281
int len
Definition: bmesh_class.h:279
float no[3]
Definition: bmesh_class.h:280
struct BMVert * v
Definition: bmesh_class.h:165
struct BMEdge * e
Definition: bmesh_class.h:176
struct BMLoop * radial_next
Definition: bmesh_class.h:216
struct BMLoop * prev
Definition: bmesh_class.h:245
struct BMFace * f
Definition: bmesh_class.h:183
struct BMLoop * next
Definition: bmesh_class.h:245
float co[3]
Definition: bmesh_class.h:99
float no[3]
Definition: bmesh_class.h:100
int totvert
Definition: bmesh_class.h:297
char elem_index_dirty
Definition: bmesh_class.h:305
CustomData vdata
Definition: bmesh_class.h:337
CustomData edata
Definition: bmesh_class.h:337