diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-28 08:19:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-28 08:19:44 +0400 |
commit | 52558fbe2ebfcfa6d60341da02bb33a264846660 (patch) | |
tree | 8574e155920440fc2d2148b7837f15e04a0106d5 | |
parent | 9776f56a39fd29ef1448ff35551eba27ab8b7c16 (diff) |
basic bevel modifier working again in bmesh, closely matches the edge split modifier since it calls out to the bevel operator.
- edge angles are ok
- width is interpreted as percent
added BMESH_TODO comments with details about what needs working on.
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 102 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_edgesplit.c | 15 |
2 files changed, 97 insertions, 20 deletions
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 1ae79825d48..239b479472b 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -32,17 +32,20 @@ * \ingroup modifiers */ -#include "MEM_guardedalloc.h" - #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BLI_string.h" -#include "BKE_bmesh.h" #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" -#include "BKE_particle.h" +#include "BKE_tessmesh.h" +#include "BKE_mesh.h" + +#include "BKE_bmesh.h" /* only for defines */ + +#include "DNA_object_types.h" -#include "MOD_util.h" +#include "MEM_guardedalloc.h" static void initData(ModifierData *md) @@ -85,15 +88,91 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } +#define EDGE_MARK 1 + + +/* BMESH_TODO + * + * this bevel calls the operator which is missing many of the options + * which the bevel modifier in trunk has. + * - width is interpreted as percent (not distance) + * - no vertex bevel + * - no weight bevel + * + * These will need to be added to the bmesh operator. + * - campbell + * + * note: this code is very close to MOD_edgesplit.c. + * note: if 0'd code from trunk included below. + */ +static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob, + DerivedMesh *dm, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) +{ + BMesh *bm; + BMEditMesh *em; + DerivedMesh *cddm; + BMIter iter; + BMEdge *e; + BevelModifierData *bmd = (BevelModifierData*) md; + /* int allocsize[] = {512, 512, 2048, 512}; */ /* UNUSED */ + float threshold = cos((bmd->bevel_angle + 0.00001) * M_PI / 180.0); + + if (!CDDM_Check(dm)) { + cddm = CDDM_copy(dm, 0); + } else cddm = dm; + + em = CDDM_To_BMesh(ob, dm, NULL); + bm = em->bm; + + BM_Compute_Normals(bm); + BMO_push(bm, NULL); + + if (bmd->lim_flags & BME_BEVEL_ANGLE) { + BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { + /* check for 1 edge having 2 face users */ + BMLoop *l1, *l2; + if ( (l1= e->l) && + (l2= e->l->radial_next) != l1) + { + if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { + BMO_SetFlag(bm, e, EDGE_MARK); + } + } + } + } + else { + /* crummy, is there a way just to operator on all? - campbell */ + BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { + BMO_SetFlag(bm, e, EDGE_MARK); + } + } + + BMO_CallOpf(bm, "bevel geom=%fe percent=%f", EDGE_MARK, bmd->value); + BMO_pop(bm); + BMEdit_RecalcTesselation(em); + + if (cddm != dm) { + cddm->needsFree = 1; + cddm->release(cddm); + } + + cddm = CDDM_from_BMEditMesh(em, NULL, 1); + BMEdit_Free(em); + MEM_freeN(em); + + return cddm; +} + + +#if 0 /* from trunk, see note above */ + static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), DerivedMesh *derivedData, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { -#if 1 /*BMESH_TODO*/ - (void)md; - return CDDM_copy(derivedData, 0); -#else DerivedMesh *result; BME_Mesh *bm; @@ -116,9 +195,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), BME_free_mesh(bm); CDDM_calc_normals(result); -#endif + + return result; } +#endif + static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, struct BMEditMesh *UNUSED(editData), DerivedMesh *derivedData) diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index ae39a4ed6f0..6c2e233712e 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -36,29 +36,24 @@ /* EdgeSplit modifier: Splits edges in the mesh according to sharpness flag * or edge angle (can be used to achieve autosmoothing) */ -#include "DNA_meshdata_types.h" - #include "BLI_utildefines.h" -#include "BLI_listbase.h" -#include "BLI_memarena.h" -#include "BLI_edgehash.h" #include "BLI_math.h" -#include "BLI_array.h" -#include "BLI_smallhash.h" -#include "BLI_linklist.h" #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" -#include "BKE_particle.h" #include "BKE_tessmesh.h" #include "BKE_mesh.h" +#include "DNA_object_types.h" + #include "MEM_guardedalloc.h" /* EdgeSplit */ /* EdgeSplit modifier: Splits edges in the mesh according to sharpness flag * or edge angle (can be used to achieve autosmoothing) -*/ + * + * note: this code is very close to MOD_bevel.c + */ #define EDGE_MARK 1 |