Blender V5.0
BLI_polyfill_2d_beautify.h File Reference
#include <stdbool.h>

Go to the source code of this file.

Macros

#define BLI_polyfill_beautify_quad_rotate_calc(v1, v2, v3, v4)
#define BLI_POLYFILL_ALLOC_NGON_RESERVE   64

Functions

void BLI_polyfill_beautify (const float(*coords)[2], unsigned int coords_num, unsigned int(*tris)[3], struct MemArena *arena, struct Heap *eheap)
float BLI_polyfill_beautify_quad_rotate_calc_ex (const float v1[2], const float v2[2], const float v3[2], const float v4[2], bool lock_degenerate, float *r_area)
float BLI_polyfill_edge_calc_rotate_beauty__area (const float v1[3], const float v2[3], const float v3[3], const float v4[3], bool lock_degenerate)

Macro Definition Documentation

◆ BLI_POLYFILL_ALLOC_NGON_RESERVE

◆ BLI_polyfill_beautify_quad_rotate_calc

#define BLI_polyfill_beautify_quad_rotate_calc ( v1,
v2,
v3,
v4 )
Value:
float BLI_polyfill_beautify_quad_rotate_calc_ex(const float v1[2], const float v2[2], const float v3[2], const float v4[2], bool lock_degenerate, float *r_area)
ATTR_WARN_UNUSED_RESULT const BMVert * v2

Definition at line 51 of file BLI_polyfill_2d_beautify.h.

Referenced by bmesh_calc_tessellation_for_face_beauty().

Function Documentation

◆ BLI_polyfill_beautify()

void BLI_polyfill_beautify ( const float(*) coords[2],
unsigned int coords_num,
unsigned int(*) tris[3],
struct MemArena * arena,
struct Heap * eheap )

◆ BLI_polyfill_beautify_quad_rotate_calc_ex()

float BLI_polyfill_beautify_quad_rotate_calc_ex ( const float v1[2],
const float v2[2],
const float v3[2],
const float v4[2],
bool lock_degenerate,
float * r_area )

Assuming we have 2 triangles sharing an edge (2 - 4), check if the edge running from (1 - 3) gives better results.

Parameters
lock_degenerateUse to avoid rotating out of a degenerate state:
  • When true, an existing zero area face on either side of the (2 - 4 split will return a positive value.
  • When false, the check must be non-biased towards either split direction.
r_areaReturn the area of the quad, This can be useful when comparing the return value with near zero epsilons. In this case the epsilon can be scaled by the area to avoid the return value of very large faces not having a reliable way to detect near-zero output.
Returns
(negative number means the edge can be rotated, lager == better).

Definition at line 86 of file polyfill_2d_beautify.cc.

References BLI_assert, cross_tri_v2(), ELEM, fabsf, FLT_MAX, len_v2v2(), and v2.

Referenced by BLI_polyfill_edge_calc_rotate_beauty__area(), and polyedge_rotate_beauty_calc().

◆ BLI_polyfill_edge_calc_rotate_beauty__area()

float BLI_polyfill_edge_calc_rotate_beauty__area ( const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3],
bool lock_degenerate )

Check if input faces are already flipped. Logic for 'signum_i' addition is:

Accept:

  • (1, 1) or (-1, -1): same side (common case).
  • (-1/1, 0): one degenerate, OK since we may rotate into a valid state.

Ignore:

  • (-1, 1): opposite winding, ignore.
  • ( 0, 0): both degenerate, ignore.
Note
The cross product is divided by 'no_scale' so the rotation calculation is scale independent.

Important to lock degenerate here, since the triangle pars will be projected into different 2D spaces. Allowing to rotate out of a degenerate state can flip the faces (when performed iteratively).

Definition at line 180 of file polyfill_2d_beautify.cc.

References add_v3_v3v3(), axis_dominant_v3_to_m3(), BLI_assert, BLI_polyfill_beautify_quad_rotate_calc_ex(), cross_tri_v2(), cross_tri_v3(), ELEM, eps, FLT_MAX, mul_v2_m3v3(), normalize_v3(), signum_i_ex(), UNLIKELY, and v2.

Referenced by BM_verts_calc_rotate_beauty(), and blender::geometry::quad::calc_quad_direction_beauty().