bmesh optimization (noted as todo), avoid recalculating normal every time BM_face_legal_splits() runs,
assume normal is valid (assert when its not).
This commit is contained in:
@@ -1061,7 +1061,7 @@ void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len)
|
||||
{
|
||||
const int len2 = len * 2;
|
||||
BMLoop *l;
|
||||
float v1[2], v2[2], v3[2] /*, v4[3 */, no[3], mid[2], *p1, *p2, *p3, *p4;
|
||||
float v1[2], v2[2], v3[2], mid[2], *p1, *p2, *p3, *p4;
|
||||
float out[2] = {-FLT_MAX, -FLT_MAX};
|
||||
float axis_mat[3][3];
|
||||
float (*projverts)[2] = BLI_array_alloca(projverts, f->len);
|
||||
@@ -1069,10 +1069,9 @@ void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len)
|
||||
float fac1 = 1.0000001f, fac2 = 0.9f; //9999f; //0.999f;
|
||||
int i, j, a = 0, clen;
|
||||
|
||||
/* TODO, the face normal may already be correct */
|
||||
BM_face_calc_normal(f, no);
|
||||
BLI_assert(BM_face_is_normal_valid(f));
|
||||
|
||||
axis_dominant_v3_to_m3(axis_mat, no);
|
||||
axis_dominant_v3_to_m3(axis_mat, f->no);
|
||||
|
||||
for (i = 0, l = BM_FACE_FIRST_LOOP(f); i < f->len; i++, l = l->next) {
|
||||
BM_elem_index_set(l, i); /* set_loop */
|
||||
|
||||
@@ -1719,6 +1719,18 @@ bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use within assert's to check normals are valid.
|
||||
*/
|
||||
bool BM_face_is_normal_valid(BMFace *f)
|
||||
{
|
||||
const float eps = 0.0001f;
|
||||
float no[3];
|
||||
|
||||
BM_face_calc_normal(f, no);
|
||||
return len_squared_v3v3(no, f->no) < (eps * eps);
|
||||
}
|
||||
|
||||
static void bm_mesh_calc_volume_face(BMFace *f, float *r_vol)
|
||||
{
|
||||
int tottri = f->len - 2;
|
||||
|
||||
@@ -116,6 +116,8 @@ bool BM_edge_is_any_vert_flag_test(BMEdge *e, const char hflag);
|
||||
bool BM_face_is_any_vert_flag_test(BMFace *f, const char hflag);
|
||||
bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag);
|
||||
|
||||
bool BM_face_is_normal_valid(BMFace *f);
|
||||
|
||||
float BM_mesh_calc_volume(BMesh *bm, bool is_signed);
|
||||
|
||||
int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
|
||||
|
||||
@@ -214,6 +214,7 @@ void bmo_connect_verts_nonplanar_exec(BMesh *bm, BMOperator *op)
|
||||
if (bm_face_split_by_angle(bm, f, f_pair, angle_limit)) {
|
||||
int j;
|
||||
for (j = 0; j < 2; j++) {
|
||||
BM_face_normal_update(f_pair[j]);
|
||||
if (f_pair[j]->len > 3) {
|
||||
STACK_PUSH(fstack, f_pair[j]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user