From e527ce552e9e3864c7a2f5bb688ffa1d4cd0d5f1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Oct 2012 10:40:32 +0000 Subject: add option to initialize heap with a known number of elements, since this may be known in advance - it avoids re-allocing too much. --- source/blender/modifiers/intern/MOD_decimate.c | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index cb6681bfa68..171d601ea6d 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -47,6 +47,10 @@ #include "BKE_particle.h" #include "BKE_cdderivedmesh.h" +#include "BKE_tessmesh.h" + +/* testing only! - Campbell */ +// #define USE_DECIMATE_BMESH #ifdef WITH_MOD_DECIMATE #include "LOD_decimation.h" @@ -70,6 +74,33 @@ static void copyData(ModifierData *md, ModifierData *target) } #ifdef WITH_MOD_DECIMATE +#ifdef USE_DECIMATE_BMESH + +#include "bmesh.h" + +static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) +{ + DecimateModifierData *dmd = (DecimateModifierData *) md; + DerivedMesh *dm = derivedData, *result = NULL; + BMEditMesh *em; + BMesh *bm; + + em = DM_to_editbmesh(dm, NULL, FALSE); + bm = em->bm; + + BM_mesh_decimate(bm, dmd->percent); + + BLI_assert(em->looptris == NULL); + result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE); + BMEdit_Free(em); + MEM_freeN(em); + + return result; +} + +#else static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), DerivedMesh *derivedData, ModifierApplyFlag UNUSED(flag)) @@ -192,6 +223,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), return dm; } } +#endif // USE_DECIMATE_BMESH #else // WITH_MOD_DECIMATE static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob), DerivedMesh *derivedData, -- cgit v1.2.3