diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-20 21:31:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-20 21:31:07 +0400 |
commit | 8944dab58a4f9efed28bc40ea45f3555026d0f0b (patch) | |
tree | 4d0db78870394094026c7c898d6ed25af37c8d86 /source/blender/modifiers | |
parent | 0a590aadf5655175f73af5b59e61acfb0fe0b144 (diff) |
bmesh decimator support for loop & edge customdata. (most importantly UVs and vertex colors).
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_decimate.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index 171d601ea6d..765e264365b 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -51,6 +51,8 @@ /* testing only! - Campbell */ // #define USE_DECIMATE_BMESH +// #include "PIL_time.h" + #ifdef WITH_MOD_DECIMATE #include "LOD_decimation.h" @@ -87,16 +89,30 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), BMEditMesh *em; BMesh *bm; + // TIMEIT_START(decim); + + if (dmd->percent == 1.0f) { + return dm; + } + else if (dm->getNumPolys(dm) <= 3) { + modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces.")); + return dm; + } + em = DM_to_editbmesh(dm, NULL, FALSE); bm = em->bm; BM_mesh_decimate(bm, dmd->percent); + dmd->faceCount = bm->totface; + BLI_assert(em->looptris == NULL); result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE); BMEdit_Free(em); MEM_freeN(em); + // TIMEIT_END(decim); + return result; } @@ -113,6 +129,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), int totvert, totface; int a, numTris; + // TIMEIT_START(decim); + DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ mvert = dm->getVertArray(dm); @@ -214,6 +232,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), MEM_freeN(lod.vertex_normal_buffer); MEM_freeN(lod.triangle_index_buffer); + // TIMEIT_END(decim); + if (result) { CDDM_tessfaces_to_faces(result); /*builds ngon faces from tess (mface) faces*/ |