[Bf-blender-cvs] [002dcd20017] blender2.8: Modifiers: pass the ob->data to the modifier if the mesh param is NULL

Sybren A. Stüvel noreply at git.blender.org
Tue May 8 12:34:41 CEST 2018


Commit: 002dcd200178c602474c3794c3c21e3b212e6e25
Author: Sybren A. Stüvel
Date:   Tue May 8 12:34:01 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB002dcd200178c602474c3794c3c21e3b212e6e25

Modifiers: pass the ob->data to the modifier if the mesh param is NULL

This enables the modifiers to access things like vertex groups. Care should
be taken to not modifier the mesh itself in this case.

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

M	source/blender/modifiers/intern/MOD_lattice.c
M	source/blender/modifiers/intern/MOD_simpledeform.c

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

diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 84e7e41efcb..69c814279be 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -109,11 +109,11 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
                         int numVerts)
 {
 	LatticeModifierData *lmd = (LatticeModifierData *) md;
-
+	struct Mesh *mesh_src = mesh ? mesh : ctx->object->data;
 
 	modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
 
-	lattice_deform_verts(lmd->object, ctx->object, mesh,
+	lattice_deform_verts(lmd->object, ctx->object, mesh_src,
 	                     vertexCos, numVerts, lmd->name, lmd->strength);
 }
 
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index eec1cde3889..c1dbf1989ea 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -40,6 +40,7 @@
 #include "BLI_utildefines.h"
 
 #include "BKE_cdderivedmesh.h"
+#include "BKE_editmesh.h"
 #include "BKE_mesh.h"
 #include "BKE_library_query.h"
 #include "BKE_modifier.h"
@@ -47,6 +48,8 @@
 
 #include "MOD_util.h"
 
+#include "bmesh.h"
+
 #define BEND_EPS 0.000001f
 
 /* Re-maps the indicies for X Y Z by shifting them up and wrapping, such that
@@ -389,16 +392,21 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
                         float (*vertexCos)[3],
                         int numVerts)
 {
-	SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh, vertexCos, numVerts);
+	Mesh *mesh_src = mesh ? mesh : ctx->object->data;
+	SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
 }
 
 static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx,
-                          struct BMEditMesh *UNUSED(editData),
+                          struct BMEditMesh *editData,
                           struct Mesh *mesh,
                           float (*vertexCos)[3],
                           int numVerts)
 {
-	SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh, vertexCos, numVerts);
+	Mesh *mesh_src = mesh;
+	if (!mesh) {
+		mesh_src = BKE_bmesh_to_mesh_nomain(editData->bm, &(struct BMeshToMeshParams){0});
+	}
+	SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
 }



More information about the Bf-blender-cvs mailing list