Blender  V2.93
polyfill_2d_beautify.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 
37 #include "BLI_math.h"
38 #include "BLI_utildefines.h"
39 
40 #include "BLI_heap.h"
41 #include "BLI_memarena.h"
42 
43 #include "BLI_polyfill_2d_beautify.h" /* own include */
44 
45 #include "BLI_strict_flags.h"
46 
47 /* Used to find matching edges. */
48 struct OrderEdge {
49  uint verts[2];
51 };
52 
53 /* Half edge used for rotating in-place. */
54 struct HalfEdge {
59 };
60 
61 static int oedge_cmp(const void *a1, const void *a2)
62 {
63  const struct OrderEdge *x1 = a1, *x2 = a2;
64  if (x1->verts[0] > x2->verts[0]) {
65  return 1;
66  }
67  if (x1->verts[0] < x2->verts[0]) {
68  return -1;
69  }
70 
71  if (x1->verts[1] > x2->verts[1]) {
72  return 1;
73  }
74  if (x1->verts[1] < x2->verts[1]) {
75  return -1;
76  }
77 
78  /* Only for predictability. */
79  if (x1->e_half > x2->e_half) {
80  return 1;
81  }
82  if (x1->e_half < x2->e_half) {
83  return -1;
84  }
85  /* Should never get here, no two edges should be the same. */
86  BLI_assert(false);
87  return 0;
88 }
89 
90 BLI_INLINE bool is_boundary_edge(uint i_a, uint i_b, const uint coord_last)
91 {
92  BLI_assert(i_a < i_b);
93  return ((i_a + 1 == i_b) || UNLIKELY((i_a == 0) && (i_b == coord_last)));
94 }
111  const float v2[2],
112  const float v3[2],
113  const float v4[2],
114  const bool lock_degenerate,
115  float *r_area)
116 {
117  /* not a loop (only to be able to break out) */
118  do {
119  /* Allow very small faces to be considered non-zero. */
120  const float eps_zero_area = 1e-12f;
121  const float area_2x_234 = cross_tri_v2(v2, v3, v4);
122  const float area_2x_241 = cross_tri_v2(v2, v4, v1);
123 
124  const float area_2x_123 = cross_tri_v2(v1, v2, v3);
125  const float area_2x_134 = cross_tri_v2(v1, v3, v4);
126 
127  BLI_assert((ELEM(v1, v2, v3, v4) == false) && (ELEM(v2, v1, v3, v4) == false) &&
128  (ELEM(v3, v1, v2, v4) == false) && (ELEM(v4, v1, v2, v3) == false));
129 
130  if (r_area) {
131  *r_area = fabsf(area_2x_234) + fabsf(area_2x_241) +
132  /* Include both pairs for predictable results. */
133  fabsf(area_2x_123) + fabsf(area_2x_134) / 8.0f;
134  }
135 
136  /*
137  * Test for unusable (1-3) state.
138  * - Area sign flipping to check faces aren't going to point in opposite directions.
139  * - Area epsilon check that the one of the faces won't be zero area.
140  */
141  if ((area_2x_123 >= 0.0f) != (area_2x_134 >= 0.0f)) {
142  break;
143  }
144  if ((fabsf(area_2x_123) <= eps_zero_area) || (fabsf(area_2x_134) <= eps_zero_area)) {
145  break;
146  }
147 
148  /* Test for unusable (2-4) state (same as above). */
149  if ((area_2x_234 >= 0.0f) != (area_2x_241 >= 0.0f)) {
150  if (lock_degenerate) {
151  break;
152  }
153 
154  return -FLT_MAX; /* always rotate */
155  }
156  if ((fabsf(area_2x_234) <= eps_zero_area) || (fabsf(area_2x_241) <= eps_zero_area)) {
157  return -FLT_MAX; /* always rotate */
158  }
159 
160  {
161  /* testing rule: the area divided by the perimeter,
162  * check if (1-3) beats the existing (2-4) edge rotation */
163  float area_a, area_b;
164  float prim_a, prim_b;
165  float fac_24, fac_13;
166 
167  float len_12, len_23, len_34, len_41, len_24, len_13;
168 
169  /* edges around the quad */
170  len_12 = len_v2v2(v1, v2);
171  len_23 = len_v2v2(v2, v3);
172  len_34 = len_v2v2(v3, v4);
173  len_41 = len_v2v2(v4, v1);
174  /* edges crossing the quad interior */
175  len_13 = len_v2v2(v1, v3);
176  len_24 = len_v2v2(v2, v4);
177 
178  /* note, area is in fact (area * 2),
179  * but in this case its OK, since we're comparing ratios */
180 
181  /* edge (2-4), current state */
182  area_a = fabsf(area_2x_234);
183  area_b = fabsf(area_2x_241);
184  prim_a = len_23 + len_34 + len_24;
185  prim_b = len_41 + len_12 + len_24;
186  fac_24 = (area_a / prim_a) + (area_b / prim_b);
187 
188  /* edge (1-3), new state */
189  area_a = fabsf(area_2x_123);
190  area_b = fabsf(area_2x_134);
191  prim_a = len_12 + len_23 + len_13;
192  prim_b = len_34 + len_41 + len_13;
193  fac_13 = (area_a / prim_a) + (area_b / prim_b);
194 
195  /* negative number if (1-3) is an improved state */
196  return fac_24 - fac_13;
197  }
198  } while (false);
199 
200  return FLT_MAX;
201 }
202 
203 static float polyedge_rotate_beauty_calc(const float (*coords)[2],
204  const struct HalfEdge *edges,
205  const struct HalfEdge *e_a,
206  float *r_area)
207 {
208  const struct HalfEdge *e_b = &edges[e_a->e_radial];
209 
210  const struct HalfEdge *e_a_other = &edges[edges[e_a->e_next].e_next];
211  const struct HalfEdge *e_b_other = &edges[edges[e_b->e_next].e_next];
212 
213  const float *v1, *v2, *v3, *v4;
214 
215  v1 = coords[e_a_other->v];
216  v2 = coords[e_a->v];
217  v3 = coords[e_b_other->v];
218  v4 = coords[e_b->v];
219 
220  return BLI_polyfill_beautify_quad_rotate_calc_ex(v1, v2, v3, v4, false, r_area);
221 }
222 
223 static void polyedge_beauty_cost_update_single(const float (*coords)[2],
224  const struct HalfEdge *edges,
225  struct HalfEdge *e,
226  Heap *eheap,
227  HeapNode **eheap_table)
228 {
229  const uint i = e->base_index;
230  /* recalculate edge */
231  float area;
232  const float cost = polyedge_rotate_beauty_calc(coords, edges, e, &area);
233  /* We can get cases where both choices generate very small negative costs,
234  * which leads to infinite loop. Anyway, costs above that are not worth recomputing,
235  * maybe we could even optimize it to a smaller limit?
236  * Actually, FLT_EPSILON is too small in some cases, 1e-6f seems to work OK hopefully?
237  * See T43578, T49478.
238  *
239  * In fact a larger epsilon can still fail when the area of the face is very large,
240  * now the epsilon is scaled by the face area.
241  * See T56532. */
242  if (cost < -1e-6f * max_ff(area, 1.0f)) {
243  BLI_heap_insert_or_update(eheap, &eheap_table[i], cost, e);
244  }
245  else {
246  if (eheap_table[i]) {
247  BLI_heap_remove(eheap, eheap_table[i]);
248  eheap_table[i] = NULL;
249  }
250  }
251 }
252 
253 static void polyedge_beauty_cost_update(const float (*coords)[2],
254  struct HalfEdge *edges,
255  struct HalfEdge *e,
256  Heap *eheap,
257  HeapNode **eheap_table)
258 {
259  struct HalfEdge *e_arr[4];
260  e_arr[0] = &edges[e->e_next];
261  e_arr[1] = &edges[e_arr[0]->e_next];
262 
263  e = &edges[e->e_radial];
264  e_arr[2] = &edges[e->e_next];
265  e_arr[3] = &edges[e_arr[2]->e_next];
266 
267  for (uint i = 0; i < 4; i++) {
268  if (e_arr[i] && e_arr[i]->base_index != UINT_MAX) {
269  polyedge_beauty_cost_update_single(coords, edges, e_arr[i], eheap, eheap_table);
270  }
271  }
272 }
273 
274 static void polyedge_rotate(struct HalfEdge *edges, struct HalfEdge *e)
275 {
291  struct HalfEdge *ed[6];
292  uint ed_index[6];
293 
294  ed_index[0] = (uint)(e - edges);
295  ed[0] = &edges[ed_index[0]];
296  ed_index[1] = ed[0]->e_next;
297  ed[1] = &edges[ed_index[1]];
298  ed_index[2] = ed[1]->e_next;
299  ed[2] = &edges[ed_index[2]];
300 
301  ed_index[3] = e->e_radial;
302  ed[3] = &edges[ed_index[3]];
303  ed_index[4] = ed[3]->e_next;
304  ed[4] = &edges[ed_index[4]];
305  ed_index[5] = ed[4]->e_next;
306  ed[5] = &edges[ed_index[5]];
307 
308  ed[0]->e_next = ed_index[2];
309  ed[1]->e_next = ed_index[3];
310  ed[2]->e_next = ed_index[4];
311  ed[3]->e_next = ed_index[5];
312  ed[4]->e_next = ed_index[0];
313  ed[5]->e_next = ed_index[1];
314 
315  ed[0]->v = ed[5]->v;
316  ed[3]->v = ed[2]->v;
317 }
318 
325 void BLI_polyfill_beautify(const float (*coords)[2],
326  const uint coords_tot,
327  uint (*tris)[3],
328 
329  /* structs for reuse */
330  MemArena *arena,
331  Heap *eheap)
332 {
333  const uint coord_last = coords_tot - 1;
334  const uint tris_len = coords_tot - 2;
335  /* internal edges only (between 2 tris) */
336  const uint edges_len = tris_len - 1;
337 
338  HeapNode **eheap_table;
339 
340  const uint half_edges_len = 3 * tris_len;
341  struct HalfEdge *half_edges = BLI_memarena_alloc(arena, sizeof(*half_edges) * half_edges_len);
342  struct OrderEdge *order_edges = BLI_memarena_alloc(arena,
343  sizeof(struct OrderEdge) * 2 * edges_len);
344  uint order_edges_len = 0;
345 
346  /* first build edges */
347  for (uint i = 0; i < tris_len; i++) {
348  for (uint j_curr = 0, j_prev = 2; j_curr < 3; j_prev = j_curr++) {
349  const uint e_index_prev = (i * 3) + j_prev;
350  const uint e_index_curr = (i * 3) + j_curr;
351 
352  half_edges[e_index_prev].v = tris[i][j_prev];
353  half_edges[e_index_prev].e_next = e_index_curr;
354  half_edges[e_index_prev].e_radial = UINT_MAX;
355  half_edges[e_index_prev].base_index = UINT_MAX;
356 
357  uint e_pair[2] = {tris[i][j_prev], tris[i][j_curr]};
358  if (e_pair[0] > e_pair[1]) {
359  SWAP(uint, e_pair[0], e_pair[1]);
360  }
361 
362  /* ensure internal edges. */
363  if (!is_boundary_edge(e_pair[0], e_pair[1], coord_last)) {
364  order_edges[order_edges_len].verts[0] = e_pair[0];
365  order_edges[order_edges_len].verts[1] = e_pair[1];
366  order_edges[order_edges_len].e_half = e_index_prev;
367  order_edges_len += 1;
368  }
369  }
370  }
371  BLI_assert(edges_len * 2 == order_edges_len);
372 
373  qsort(order_edges, order_edges_len, sizeof(struct OrderEdge), oedge_cmp);
374 
375  for (uint i = 0, base_index = 0; i < order_edges_len; base_index++) {
376  const struct OrderEdge *oe_a = &order_edges[i++];
377  const struct OrderEdge *oe_b = &order_edges[i++];
378  BLI_assert(oe_a->verts[0] == oe_a->verts[0] && oe_a->verts[1] == oe_a->verts[1]);
379  half_edges[oe_a->e_half].e_radial = oe_b->e_half;
380  half_edges[oe_b->e_half].e_radial = oe_a->e_half;
381  half_edges[oe_a->e_half].base_index = base_index;
382  half_edges[oe_b->e_half].base_index = base_index;
383  }
384  /* order_edges could be freed now. */
385 
386  /* Now perform iterative rotations. */
387 #if 0
388  eheap_table = BLI_memarena_alloc(arena, sizeof(HeapNode *) * (size_t)edges_len);
389 #else
390  /* We can re-use this since its big enough. */
391  eheap_table = (void *)order_edges;
392  order_edges = NULL;
393 #endif
394 
395  /* Build heap. */
396  {
397  struct HalfEdge *e = half_edges;
398  for (uint i = 0; i < half_edges_len; i++, e++) {
399  /* Accounts for boundary edged too (UINT_MAX). */
400  if (e->e_radial < i) {
401  const float cost = polyedge_rotate_beauty_calc(coords, half_edges, e, NULL);
402  if (cost < 0.0f) {
403  eheap_table[e->base_index] = BLI_heap_insert(eheap, cost, e);
404  }
405  else {
406  eheap_table[e->base_index] = NULL;
407  }
408  }
409  }
410  }
411 
412  while (BLI_heap_is_empty(eheap) == false) {
413  struct HalfEdge *e = BLI_heap_pop_min(eheap);
414  eheap_table[e->base_index] = NULL;
415 
416  polyedge_rotate(half_edges, e);
417 
418  /* recalculate faces connected on the heap */
419  polyedge_beauty_cost_update(coords, half_edges, e, eheap, eheap_table);
420  }
421 
422  BLI_heap_clear(eheap, NULL);
423 
424  /* MEM_freeN(eheap_table); */ /* arena */
425 
426  /* get tris from half edge. */
427  uint tri_index = 0;
428  for (uint i = 0; i < half_edges_len; i++) {
429  struct HalfEdge *e = &half_edges[i];
430  if (e->v != UINT_MAX) {
431  uint *tri = tris[tri_index++];
432 
433  tri[0] = e->v;
434  e->v = UINT_MAX;
435 
436  e = &half_edges[e->e_next];
437  tri[1] = e->v;
438  e->v = UINT_MAX;
439 
440  e = &half_edges[e->e_next];
441  tri[2] = e->v;
442  e->v = UINT_MAX;
443  }
444  }
445 }
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_INLINE
A min-heap / priority queue ADT.
void BLI_heap_insert_or_update(Heap *heap, HeapNode **node_p, float value, void *ptr) ATTR_NONNULL(1
void void bool BLI_heap_is_empty(const Heap *heap) ATTR_NONNULL(1)
Definition: BLI_heap.c:305
void * BLI_heap_pop_min(Heap *heap) ATTR_NONNULL(1)
Definition: BLI_heap.c:338
void BLI_heap_clear(Heap *heap, HeapFreeFP ptrfreefp) ATTR_NONNULL(1)
Definition: BLI_heap.c:243
HeapNode * BLI_heap_insert(Heap *heap, float value, void *ptr) ATTR_NONNULL(1)
Definition: BLI_heap.c:268
void void BLI_heap_remove(Heap *heap, HeapNode *node) ATTR_NONNULL(1
MINLINE float max_ff(float a, float b)
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2])
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
Definition: BLI_memarena.c:131
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
unsigned int uint
Definition: BLI_sys_types.h:83
#define SWAP(type, a, b)
#define UNLIKELY(x)
#define ELEM(...)
_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 GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
_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
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
#define UINT_MAX
Definition: hash_md5.c:58
#define fabsf(x)
static void area(int d1, int d2, int e1, int e2, float weights[2])
float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2], const float v2[2], const float v3[2], const float v4[2], const bool lock_degenerate, float *r_area)
static float polyedge_rotate_beauty_calc(const float(*coords)[2], const struct HalfEdge *edges, const struct HalfEdge *e_a, float *r_area)
static void polyedge_rotate(struct HalfEdge *edges, struct HalfEdge *e)
static void polyedge_beauty_cost_update_single(const float(*coords)[2], const struct HalfEdge *edges, struct HalfEdge *e, Heap *eheap, HeapNode **eheap_table)
void BLI_polyfill_beautify(const float(*coords)[2], const uint coords_tot, uint(*tris)[3], MemArena *arena, Heap *eheap)
static void polyedge_beauty_cost_update(const float(*coords)[2], struct HalfEdge *edges, struct HalfEdge *e, Heap *eheap, HeapNode **eheap_table)
static int oedge_cmp(const void *a1, const void *a2)
BLI_INLINE bool is_boundary_edge(uint i_a, uint i_b, const uint coord_last)
Definition: BLI_heap.c:57