[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42204] branches/bmesh/blender/source/ blender/modifiers/intern: basic bevel modifier working again in bmesh, closely matches the edge split modifier since it calls out to the bevel operator .

Campbell Barton ideasman42 at gmail.com
Mon Nov 28 05:19:57 CET 2011


Revision: 42204
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42204
Author:   campbellbarton
Date:     2011-11-28 04:19:44 +0000 (Mon, 28 Nov 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c
    branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c	2011-11-28 03:41:14 UTC (rev 42203)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_bevel.c	2011-11-28 04:19:44 UTC (rev 42204)
@@ -32,19 +32,22 @@
  *  \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 "MOD_util.h"
+#include "BKE_bmesh.h" /* only for defines */
 
+#include "DNA_object_types.h"
 
+#include "MEM_guardedalloc.h"
+
+
 static void initData(ModifierData *md)
 {
 	BevelModifierData *bmd = (BevelModifierData*) md;
@@ -85,15 +88,91 @@
 	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 @@
 	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)

Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c	2011-11-28 03:41:14 UTC (rev 42203)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_edgesplit.c	2011-11-28 04:19:44 UTC (rev 42204)
@@ -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
 




More information about the Bf-blender-cvs mailing list