forked from bartvdbraak/blender
Polyfill2d: avoid calculating polygon winding (its known in all cases)
This commit is contained in:
parent
7529e36f49
commit
19b1da2b7b
@ -1411,7 +1411,7 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, CustomData *ldata, CustomDat
|
|||||||
mul_v2_m3v3(projverts[j], axis_mat, mvert[ml->v].co);
|
mul_v2_m3v3(projverts[j], axis_mat, mvert[ml->v].co);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_polyfill_calc_arena((const float (*)[2])projverts, mp_totloop, tris, arena);
|
BLI_polyfill_calc_arena((const float (*)[2])projverts, mp_totloop, -1, tris, arena);
|
||||||
|
|
||||||
/* apply fill */
|
/* apply fill */
|
||||||
for (j = 0; j < totfilltri; j++) {
|
for (j = 0; j < totfilltri; j++) {
|
||||||
|
@ -26,6 +26,7 @@ struct MemArena;
|
|||||||
void BLI_polyfill_calc_arena(
|
void BLI_polyfill_calc_arena(
|
||||||
const float (*coords)[2],
|
const float (*coords)[2],
|
||||||
const unsigned int coords_tot,
|
const unsigned int coords_tot,
|
||||||
|
const int coords_sign,
|
||||||
unsigned int (*r_tris)[3],
|
unsigned int (*r_tris)[3],
|
||||||
|
|
||||||
struct MemArena *arena);
|
struct MemArena *arena);
|
||||||
@ -33,6 +34,7 @@ void BLI_polyfill_calc_arena(
|
|||||||
void BLI_polyfill_calc(
|
void BLI_polyfill_calc(
|
||||||
const float (*coords)[2],
|
const float (*coords)[2],
|
||||||
const unsigned int coords_tot,
|
const unsigned int coords_tot,
|
||||||
|
const int coords_sign,
|
||||||
unsigned int (*r_tris)[3]);
|
unsigned int (*r_tris)[3]);
|
||||||
|
|
||||||
#endif /* __BLI_POLYFILL2D_H__ */
|
#endif /* __BLI_POLYFILL2D_H__ */
|
||||||
|
@ -423,6 +423,7 @@ static void pf_ear_tip_cut(PolyFill *pf, PolyIndex *pi_ear_tip)
|
|||||||
static void polyfill_calc_ex(
|
static void polyfill_calc_ex(
|
||||||
const float (*coords)[2],
|
const float (*coords)[2],
|
||||||
const unsigned int coords_tot,
|
const unsigned int coords_tot,
|
||||||
|
int coords_sign,
|
||||||
unsigned int (*r_tris)[3],
|
unsigned int (*r_tris)[3],
|
||||||
|
|
||||||
PolyIndex *r_indices)
|
PolyIndex *r_indices)
|
||||||
@ -444,9 +445,22 @@ static void polyfill_calc_ex(
|
|||||||
pf.tris = r_tris;
|
pf.tris = r_tris;
|
||||||
pf.tris_tot = 0;
|
pf.tris_tot = 0;
|
||||||
|
|
||||||
if ((coords_tot < 3) ||
|
if (coords_sign == 0) {
|
||||||
cross_poly_v2(coords, coords_tot) > 0.0f)
|
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++) {
|
for (i = 0; i < coords_tot; i++) {
|
||||||
indices[i].next = &indices[i + 1];
|
indices[i].next = &indices[i + 1];
|
||||||
indices[i].prev = &indices[i - 1];
|
indices[i].prev = &indices[i - 1];
|
||||||
@ -481,6 +495,7 @@ static void polyfill_calc_ex(
|
|||||||
void BLI_polyfill_calc_arena(
|
void BLI_polyfill_calc_arena(
|
||||||
const float (*coords)[2],
|
const float (*coords)[2],
|
||||||
const unsigned int coords_tot,
|
const unsigned int coords_tot,
|
||||||
|
const int coords_sign,
|
||||||
unsigned int (*r_tris)[3],
|
unsigned int (*r_tris)[3],
|
||||||
|
|
||||||
struct MemArena *arena)
|
struct MemArena *arena)
|
||||||
@ -492,7 +507,7 @@ void BLI_polyfill_calc_arena(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
polyfill_calc_ex(
|
polyfill_calc_ex(
|
||||||
coords, coords_tot,
|
coords, coords_tot, coords_sign,
|
||||||
r_tris,
|
r_tris,
|
||||||
/* cache */
|
/* cache */
|
||||||
|
|
||||||
@ -509,6 +524,7 @@ void BLI_polyfill_calc_arena(
|
|||||||
void BLI_polyfill_calc(
|
void BLI_polyfill_calc(
|
||||||
const float (*coords)[2],
|
const float (*coords)[2],
|
||||||
const unsigned int coords_tot,
|
const unsigned int coords_tot,
|
||||||
|
const int coords_sign,
|
||||||
unsigned int (*r_tris)[3])
|
unsigned int (*r_tris)[3])
|
||||||
{
|
{
|
||||||
PolyIndex *indices = BLI_array_alloca(indices, coords_tot);
|
PolyIndex *indices = BLI_array_alloca(indices, coords_tot);
|
||||||
@ -518,7 +534,7 @@ void BLI_polyfill_calc(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
polyfill_calc_ex(
|
polyfill_calc_ex(
|
||||||
coords, coords_tot,
|
coords, coords_tot, coords_sign,
|
||||||
r_tris,
|
r_tris,
|
||||||
/* cache */
|
/* cache */
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ void BM_face_calc_tessellation(const BMFace *f, BMLoop **r_loops, unsigned int (
|
|||||||
} while ((l_iter = l_iter->next) != l_first);
|
} while ((l_iter = l_iter->next) != l_first);
|
||||||
|
|
||||||
/* complete the loop */
|
/* complete the loop */
|
||||||
BLI_polyfill_calc((const float (*)[2])projverts, f->len, r_index);
|
BLI_polyfill_calc((const float (*)[2])projverts, f->len, -1, r_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -833,7 +833,7 @@ void BM_face_triangulate(BMesh *bm, BMFace *f,
|
|||||||
mul_v2_m3v3(projverts[i], axis_mat, l_iter->v->co);
|
mul_v2_m3v3(projverts[i], axis_mat, l_iter->v->co);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_polyfill_calc_arena((const float (*)[2])projverts, f->len, tris,
|
BLI_polyfill_calc_arena((const float (*)[2])projverts, f->len, -1, tris,
|
||||||
sf_arena);
|
sf_arena);
|
||||||
|
|
||||||
if (use_beauty) {
|
if (use_beauty) {
|
||||||
@ -1303,7 +1303,7 @@ void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptr
|
|||||||
j++;
|
j++;
|
||||||
} while ((l_iter = l_iter->next) != l_first);
|
} while ((l_iter = l_iter->next) != l_first);
|
||||||
|
|
||||||
BLI_polyfill_calc_arena((const float (*)[2])projverts, efa->len, tris, arena);
|
BLI_polyfill_calc_arena((const float (*)[2])projverts, efa->len, -1, tris, arena);
|
||||||
|
|
||||||
for (j = 0; j < totfilltri; j++) {
|
for (j = 0; j < totfilltri; j++) {
|
||||||
BMLoop **l_ptr = looptris[i++];
|
BMLoop **l_ptr = looptris[i++];
|
||||||
|
Loading…
Reference in New Issue
Block a user