diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-06-14 01:22:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-06-14 02:21:52 +0400 |
commit | 19b1da2b7b73c227807e4fc343efd88914a624cf (patch) | |
tree | 9534a95f2d2a3a982d7c9b8e9974f80d678d213d /source/blender/blenlib/intern/polyfill2d.c | |
parent | 7529e36f493c7fa0f61255274afdfa67a6dbd436 (diff) |
Polyfill2d: avoid calculating polygon winding (its known in all cases)
Diffstat (limited to 'source/blender/blenlib/intern/polyfill2d.c')
-rw-r--r-- | source/blender/blenlib/intern/polyfill2d.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/polyfill2d.c b/source/blender/blenlib/intern/polyfill2d.c index f7aaca6a0f3..1c0b936a881 100644 --- a/source/blender/blenlib/intern/polyfill2d.c +++ b/source/blender/blenlib/intern/polyfill2d.c @@ -423,6 +423,7 @@ static void pf_ear_tip_cut(PolyFill *pf, PolyIndex *pi_ear_tip) static void polyfill_calc_ex( const float (*coords)[2], const unsigned int coords_tot, + int coords_sign, unsigned int (*r_tris)[3], PolyIndex *r_indices) @@ -444,9 +445,22 @@ static void polyfill_calc_ex( pf.tris = r_tris; pf.tris_tot = 0; - if ((coords_tot < 3) || - cross_poly_v2(coords, coords_tot) > 0.0f) - { + if (coords_sign == 0) { + coords_sign = (cross_poly_v2(coords, coords_tot) >= 0.0f) ? 1 : -1; + } + else { + /* chech we're passing in correcty args */ +#ifndef NDEBUG + if (coords_sign == 1) { + BLI_assert(cross_poly_v2(coords, coords_tot) >= 0.0f); + } + else { + BLI_assert(cross_poly_v2(coords, coords_tot) <= 0.0f); + } +#endif + } + + if (coords_sign == 1) { for (i = 0; i < coords_tot; i++) { indices[i].next = &indices[i + 1]; indices[i].prev = &indices[i - 1]; @@ -481,6 +495,7 @@ static void polyfill_calc_ex( void BLI_polyfill_calc_arena( const float (*coords)[2], const unsigned int coords_tot, + const int coords_sign, unsigned int (*r_tris)[3], struct MemArena *arena) @@ -492,7 +507,7 @@ void BLI_polyfill_calc_arena( #endif polyfill_calc_ex( - coords, coords_tot, + coords, coords_tot, coords_sign, r_tris, /* cache */ @@ -509,6 +524,7 @@ void BLI_polyfill_calc_arena( void BLI_polyfill_calc( const float (*coords)[2], const unsigned int coords_tot, + const int coords_sign, unsigned int (*r_tris)[3]) { PolyIndex *indices = BLI_array_alloca(indices, coords_tot); @@ -518,7 +534,7 @@ void BLI_polyfill_calc( #endif polyfill_calc_ex( - coords, coords_tot, + coords, coords_tot, coords_sign, r_tris, /* cache */ |