fix for issues in new decimator

- when an edge exists across a quad, dont attempt to triangulate it. (such a case isn't so common anyway)
- silly mistake when checking if anything needed to be done in the modifier, percent was being checked for 1.0 even when not used.
This commit is contained in:
Campbell Barton 2012-10-23 06:37:58 +00:00
parent a82af0d220
commit 13940cc78e
3 changed files with 24 additions and 12 deletions

@ -231,12 +231,6 @@ static void bm_decim_build_edge_cost(BMesh *bm,
static int bm_decim_triangulate_begin(BMesh *bm) static int bm_decim_triangulate_begin(BMesh *bm)
{ {
#ifdef USE_SAFETY_CHECKS
const int check_double_edges = TRUE;
#else
const int check_double_edges = FALSE;
#endif
BMIter iter; BMIter iter;
BMFace *f; BMFace *f;
// int has_quad; // could optimize this a little // int has_quad; // could optimize this a little
@ -285,6 +279,9 @@ static int bm_decim_triangulate_begin(BMesh *bm)
l_b = f_l[3]; l_b = f_l[3];
} }
#ifdef USE_SAFETY_CHECKS
if (BM_edge_exists(l_a->v, l_b->v) == FALSE)
#endif
{ {
BMFace *f_new; BMFace *f_new;
BMLoop *l_new; BMLoop *l_new;
@ -293,7 +290,7 @@ static int bm_decim_triangulate_begin(BMesh *bm)
* - if there is a quad that has a free standing edge joining it along * - if there is a quad that has a free standing edge joining it along
* where we want to split the face, there isnt a good way we can handle this. * where we want to split the face, there isnt a good way we can handle this.
* currently that edge will get removed when joining the tris back into a quad. */ * currently that edge will get removed when joining the tris back into a quad. */
f_new = BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, check_double_edges); f_new = BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, FALSE);
if (f_new) { if (f_new) {
/* the value of this doesn't matter, only that the 2 loops match and have unique values */ /* the value of this doesn't matter, only that the 2 loops match and have unique values */

@ -1143,7 +1143,7 @@ static void rna_def_modifier_decimate(BlenderRNA *brna)
prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED); prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "iter"); RNA_def_property_int_sdna(prop, NULL, "iter");
RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_range(prop, 0, SHRT_MAX);
RNA_def_property_ui_range(prop, 1, 100, 1, 0); RNA_def_property_ui_range(prop, 0, 100, 1, 0);
RNA_def_property_ui_text(prop, "Iterations", "Number of times reduce the geometry (unsubdivide only)"); RNA_def_property_ui_text(prop, "Iterations", "Number of times reduce the geometry (unsubdivide only)");
RNA_def_property_update(prop, 0, "rna_Modifier_update"); RNA_def_property_update(prop, 0, "rna_Modifier_update");

@ -106,10 +106,25 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
TIMEIT_START(decim); TIMEIT_START(decim);
#endif #endif
switch (dmd->mode) {
case MOD_DECIM_MODE_COLLAPSE:
if (dmd->percent == 1.0f) { if (dmd->percent == 1.0f) {
return dm; return dm;
} }
else if (dm->getNumPolys(dm) <= 3) { break;
case MOD_DECIM_MODE_UNSUBDIV:
if (dmd->iter == 0) {
return dm;
}
break;
case MOD_DECIM_MODE_DISSOLVE:
if (dmd->angle == 0.0f) {
return dm;
}
break;
}
if (dm->getNumPolys(dm) <= 3) {
modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces")); modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces"));
return dm; return dm;
} }