diff options
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_decimate_collapse.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_decimate_collapse.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/bmesh/intern/bmesh_decimate_collapse.c b/source/blender/bmesh/intern/bmesh_decimate_collapse.c index feeb2a926f3..1f92a8f9227 100644 --- a/source/blender/bmesh/intern/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/intern/bmesh_decimate_collapse.c @@ -45,11 +45,13 @@ /* defines for testing */ #define USE_CUSTOMDATA #define USE_TRIANGULATE +#define USE_VERT_NORMAL_INTERP /* has the advantage that flipped faces don't mess up vertex normals */ /* these checks are for rare cases that we can't avoid since they are valid meshes still */ #define USE_SAFETY_CHECKS #define BOUNDARY_PRESERVE_WEIGHT 100.0f +#define OPTIMIZE_EPS 0.01f /* FLT_EPSILON is too small, see [#33106] */ typedef enum CD_UseFlag { CD_DO_VERT = (1 << 0), @@ -96,7 +98,7 @@ static void bm_decim_build_quadrics(BMesh *bm, Quadric *vquadrics) f = e->l->f; cross_v3_v3v3(edge_cross, edge_vector, f->no); - if (fabsf(normalize_v3(edge_cross)) > FLT_EPSILON) { + if (normalize_v3(edge_cross) > FLT_EPSILON) { Quadric q; BLI_quadric_from_v3_dist(&q, edge_cross, -dot_v3v3(edge_cross, e->v1->co)); BLI_quadric_mul(&q, BOUNDARY_PRESERVE_WEIGHT); @@ -122,7 +124,7 @@ static void bm_decim_calc_target_co(BMEdge *e, float optimize_co[3], &vquadrics[BM_elem_index_get(e->v2)]); - if (BLI_quadric_optimize(&q, optimize_co)) { + if (BLI_quadric_optimize(&q, optimize_co, OPTIMIZE_EPS)) { return; /* all is good */ } else { @@ -774,6 +776,11 @@ static void bm_decim_edge_collapse(BMesh *bm, BMEdge *e, float optimize_co[3]; float customdata_fac; +#ifdef USE_VERT_NORMAL_INTERP + float v_clear_no[3]; + copy_v3_v3(v_clear_no, e->v2->no); +#endif + bm_decim_calc_target_co(e, optimize_co, vquadrics); /* use for customdata merging */ @@ -822,7 +829,13 @@ static void bm_decim_edge_collapse(BMesh *bm, BMEdge *e, /* in fact face normals are not used for progressive updates, no need to update them */ // BM_vert_normal_update_all(v); +#ifdef USE_VERT_NORMAL_INTERP + interp_v3_v3v3(v_other->no, v_other->no, v_clear_no, customdata_fac); + normalize_v3(v_other->no); +#else BM_vert_normal_update(v_other); +#endif + /* update error costs and the eheap */ if (LIKELY(v_other->e)) { |