[Bf-blender-cvs] [2496c08c390] blender2.8: Modifier stack: move Edge Split to new Mesh-based system.

Bastien Montagne noreply at git.blender.org
Mon May 7 12:29:29 CEST 2018


Commit: 2496c08c3905d448686d99535b980f8eebdc6ece
Author: Bastien Montagne
Date:   Mon May 7 12:26:42 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2496c08c3905d448686d99535b980f8eebdc6ece

Modifier stack: move Edge Split to new Mesh-based system.

===================================================================

M	source/blender/modifiers/intern/MOD_edgesplit.c

===================================================================

diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index e23b11309e7..10e26a918be 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -41,26 +41,37 @@
 #include "BLI_math.h"
 
 #include "BKE_cdderivedmesh.h"
+#include "BKE_library.h"
+#include "BKE_mesh.h"
 #include "BKE_modifier.h"
 
 #include "bmesh.h"
 #include "bmesh_tools.h"
 
+#include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
 
 #include "MOD_modifiertypes.h"
 
-static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
+static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierEvalContext *ctx)
 {
-	DerivedMesh *result;
+	Mesh *result;
 	BMesh *bm;
 	BMIter iter;
 	BMEdge *e;
 	float threshold = cosf(emd->split_angle + 0.000000175f);
 	const bool calc_face_normals = (emd->flags & MOD_EDGESPLIT_FROMANGLE) != 0;
 
-	bm = DM_to_bmesh(dm, calc_face_normals);
-	
+	bm = BKE_mesh_to_bmesh_ex(
+	        mesh,
+	        &(struct BMeshCreateParams){0},
+	        &(struct BMeshFromMeshParams){
+	            .calc_face_normal = calc_face_normals,
+	            .add_key_index = false,
+	            .use_shapekey = true,
+	            .active_shapekey = ctx->object->shapenr,
+	        });
+
 	if (emd->flags & MOD_EDGESPLIT_FROMANGLE) {
 		BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
 			/* check for 1 edge having 2 face users */
@@ -78,7 +89,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
 			}
 		}
 	}
-	
+
 	if (emd->flags & MOD_EDGESPLIT_FROMFLAG) {
 		BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
 			/* check for 2 or more edge users */
@@ -91,15 +102,16 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
 			}
 		}
 	}
-	
+
 	BM_mesh_edgesplit(bm, false, true, false);
 
 	/* BM_mesh_validate(bm); */ /* for troubleshooting */
 
-	result = CDDM_from_bmesh(bm, true);
+	result = BKE_id_new_nomain(ID_ME, mesh->id.name);
+	BM_mesh_bm_to_me(bm, result, &((struct BMeshToMeshParams){0}));
 	BM_mesh_free(bm);
 
-	result->dirty |= DM_DIRTY_NORMALS;
+	result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
 	return result;
 }
 
@@ -121,16 +133,17 @@ static void copyData(ModifierData *md, ModifierData *target)
 	modifier_copyData_generic(md, target);
 }
 
-static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *UNUSED(ctx),
-                                  DerivedMesh *dm)
+static Mesh *applyModifier(ModifierData *md,
+                           const ModifierEvalContext *ctx,
+                           Mesh *mesh)
 {
-	DerivedMesh *result;
+	Mesh *result;
 	EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md;
 
 	if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG)))
-		return dm;
+		return mesh;
 
-	result = doEdgeSplit(dm, emd);
+	result = doEdgeSplit(mesh, emd, ctx);
 
 	return result;
 }
@@ -153,14 +166,14 @@ ModifierTypeInfo modifierType_EdgeSplit = {
 	/* deformMatrices_DM */ NULL,
 	/* deformVertsEM_DM */  NULL,
 	/* deformMatricesEM_DM*/NULL,
-	/* applyModifier_DM */  applyModifier,
+	/* applyModifier_DM */  NULL,
 	/* applyModifierEM_DM */NULL,
 
 	/* deformVerts */       NULL,
 	/* deformMatrices */    NULL,
 	/* deformVertsEM */     NULL,
 	/* deformMatricesEM */  NULL,
-	/* applyModifier */     NULL,
+	/* applyModifier */     applyModifier,
 	/* applyModifierEM */   NULL,
 
 	/* initData */          initData,



More information about the Bf-blender-cvs mailing list