Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_modifier.h173
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c38
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c9
-rw-r--r--source/blender/blenkernel/intern/displist.c26
-rw-r--r--source/blender/blenkernel/intern/lattice.c3
-rw-r--r--source/blender/blenkernel/intern/modifier.c149
-rw-r--r--source/blender/blenkernel/intern/multires.c6
7 files changed, 195 insertions, 209 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index c0203ddc630..02337110289 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -127,13 +127,21 @@ typedef enum ModifierApplyFlag {
*/
} ModifierApplyFlag;
-
typedef struct ModifierUpdateDepsgraphContext {
struct Scene *scene;
struct Object *object;
struct DepsNodeHandle *node;
} ModifierUpdateDepsgraphContext;
+/* Contains the information for deformXXX and applyXXX functions below that
+ * doesn't change between consecutive modifiers. */
+typedef struct ModifierEvalContext {
+ struct Depsgraph *depsgraph;
+ struct Object *object;
+ ModifierApplyFlag flag;
+} ModifierEvalContext;
+
+
typedef struct ModifierTypeInfo {
/* The user visible name for this modifier */
char name[32];
@@ -165,26 +173,25 @@ typedef struct ModifierTypeInfo {
* the object it can obtain it from the derivedData argument if non-NULL,
* and otherwise the ob argument.
*/
- void (*deformVerts_DM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts,
- ModifierApplyFlag flag);
+ void (*deformVerts_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts);
/* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */
- void (*deformMatrices_DM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *derivedData,
- float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
+ void (*deformMatrices_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct DerivedMesh *derivedData,
+ float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
/* Like deformVerts but called during editmode (for supporting modifiers)
*/
- void (*deformVertsEM_DM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts);
+ void (*deformVertsEM_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
+ struct DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts);
/* Set deform matrix per vertex for crazyspace correction */
- void (*deformMatricesEM_DM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
+ void (*deformMatricesEM_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
struct DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
@@ -197,21 +204,11 @@ typedef struct ModifierTypeInfo {
* should read the object data from the derived object instead of the
* actual object data.
*
- * The useRenderParams argument indicates if the modifier is being
- * applied in the service of the renderer which may alter quality
- * settings.
- *
- * The isFinalCalc parameter indicates if the modifier is being
- * calculated for a final result or for something temporary
- * (like orcos). This is a hack at the moment, it is meant so subsurf
- * can know if it is safe to reuse its internal cache.
- *
* The modifier may reuse the derivedData argument (i.e. return it in
* modified form), but must not release it.
*/
- struct DerivedMesh *(*applyModifier_DM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *derivedData,
- ModifierApplyFlag flag);
+ struct DerivedMesh *(*applyModifier_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct DerivedMesh *derivedData);
/* Like applyModifier but called during editmode (for supporting
* modifiers).
@@ -220,9 +217,9 @@ typedef struct ModifierTypeInfo {
* are expected from editmode objects. The same qualifications regarding
* derivedData apply as for applyModifier.
*/
- struct DerivedMesh *(*applyModifierEM_DM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct DerivedMesh *derivedData, ModifierApplyFlag flag);
+ struct DerivedMesh *(*applyModifierEM_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
+ struct DerivedMesh *derivedData);
/********************* Deform modifier functions *********************/
@@ -232,28 +229,23 @@ typedef struct ModifierTypeInfo {
* the object it can obtain it from the mesh argument if non-NULL,
* and otherwise the ob argument.
*/
- void (*deformVerts)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh,
- float (*vertexCos)[3], int numVerts,
- ModifierApplyFlag flag);
+ void (*deformVerts)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct Mesh *mesh, float (*vertexCos)[3], int numVerts);
/* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */
- void (*deformMatrices)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh,
- float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
+ void (*deformMatrices)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct Mesh *mesh, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
/* Like deformVerts but called during editmode (for supporting modifiers)
*/
- void (*deformVertsEM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct Mesh *mesh,
- float (*vertexCos)[3], int numVerts);
+ void (*deformVertsEM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
+ struct Mesh *mesh, float (*vertexCos)[3], int numVerts);
/* Set deform matrix per vertex for crazyspace correction */
- void (*deformMatricesEM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct Mesh *mesh,
- float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
+ void (*deformMatricesEM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
+ struct Mesh *mesh, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
/********************* Non-deform modifier functions *********************/
@@ -263,21 +255,11 @@ typedef struct ModifierTypeInfo {
* should read the object data from the mesh object instead of the
* actual object data.
*
- * The useRenderParams argument indicates if the modifier is being
- * applied in the service of the renderer which may alter quality
- * settings.
- *
- * The isFinalCalc parameter indicates if the modifier is being
- * calculated for a final result or for something temporary
- * (like orcos). This is a hack at the moment, it is meant so subsurf
- * can know if it is safe to reuse its internal cache.
- *
* The modifier may reuse the mesh argument (i.e. return it in
* modified form), but must not release it.
*/
- struct Mesh *(*applyModifier)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh,
- ModifierApplyFlag flag);
+ struct Mesh *(*applyModifier)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct Mesh *mesh);
/* Like applyModifier but called during editmode (for supporting
* modifiers).
@@ -286,9 +268,9 @@ typedef struct ModifierTypeInfo {
* are expected from editmode objects. The same qualifications regarding
* mesh apply as for applyModifier.
*/
- struct Mesh *(*applyModifierEM)(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct Mesh *mesh, ModifierApplyFlag flag);
+ struct Mesh *(*applyModifierEM)(struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
+ struct Mesh *mesh);
/********************* Optional functions *********************/
@@ -490,24 +472,20 @@ const char *modifier_path_relbase(struct Object *ob);
/* wrappers for modifier callbacks that ensure valid normals */
struct DerivedMesh *modwrap_applyModifier(
- ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *dm,
- ModifierApplyFlag flag);
+ ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct DerivedMesh *dm);
struct DerivedMesh *modwrap_applyModifierEM(
- ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *em,
- struct DerivedMesh *dm,
- ModifierApplyFlag flag);
+ ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *em, struct DerivedMesh *dm);
void modwrap_deformVerts(
- ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *dm,
- float (*vertexCos)[3], int numVerts,
- ModifierApplyFlag flag);
+ ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct DerivedMesh *dm,
+ float (*vertexCos)[3], int numVerts);
void modwrap_deformVertsEM(
- ModifierData *md, struct Depsgraph *depsgraph, struct Object *ob,
+ ModifierData *md, const struct ModifierEvalContext *ctx,
struct BMEditMesh *em, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts);
@@ -516,64 +494,59 @@ void modwrap_deformVertsEM(
*/
void modifier_deformVerts(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh,
- float (*vertexCos)[3], int numVerts, ModifierApplyFlag flag);
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct Mesh *mesh, float (*vertexCos)[3], int numVerts);
void modifier_deformMatrices(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh,
- float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct Mesh *mesh, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
void modifier_deformVertsEM(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData, struct Mesh *mesh,
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct Mesh *mesh,
float (*vertexCos)[3], int numVerts);
void modifier_deformMatricesEM(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData, struct Mesh *mesh,
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct Mesh *mesh,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
struct Mesh *modifier_applyModifier(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh, ModifierApplyFlag flag);
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct Mesh *mesh);
struct Mesh *modifier_applyModifierEM(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct Mesh *mesh, ModifierApplyFlag flag);
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct Mesh *mesh);
/* depricated variants of above that accept DerivedMesh */
void modifier_deformVerts_DM_deprecated(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *dm,
- float (*vertexCos)[3], int numVerts, ModifierApplyFlag flag);
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts);
void modifier_deformMatrices_DM_deprecated(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *dm,
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct DerivedMesh *dm,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
void modifier_deformVertsEM_DM_deprecated(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *dm,
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts);
void modifier_deformMatricesEM_DM_deprecated(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *dm,
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct DerivedMesh *dm,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
struct DerivedMesh *modifier_applyModifier_DM_deprecated(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *dm, ModifierApplyFlag flag);
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct DerivedMesh *dm);
struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(
- struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct DerivedMesh *dm, ModifierApplyFlag flag);
+ struct ModifierData *md, const struct ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct DerivedMesh *dm);
#endif
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 2c69bc90acb..fa0c1da5f63 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1145,6 +1145,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
DerivedMesh *dm;
KeyBlock *kb;
+ ModifierEvalContext mectx = {depsgraph, ob, 0};
md->scene = scene;
@@ -1167,7 +1168,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
Mesh *mesh_orig_id = (Mesh *)DEG_get_original_id(&me->id);
float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(mesh_orig_id, &numVerts);
- modwrap_deformVerts(md, depsgraph, ob, NULL, deformedVerts, numVerts, 0);
+ modwrap_deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
dm = mesh_create_derived(me, deformedVerts);
if (build_shapekey_layers)
@@ -1181,7 +1182,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
if (build_shapekey_layers)
add_shapekey_layers(tdm, me, ob);
- dm = modwrap_applyModifier(md, depsgraph, ob, tdm, 0);
+ dm = modwrap_applyModifier(md, &mectx, tdm);
ASSERT_IS_VALID_DM(dm);
if (tdm != dm) tdm->release(tdm);
@@ -1796,6 +1797,12 @@ static void mesh_calc_modifiers(
if (useDeform)
deform_app_flags |= MOD_APPLY_USECACHE;
+ /* TODO(sybren): do we really need three context objects? Or do we modify
+ * them on the fly to change the flags where needed? */
+ const ModifierEvalContext mectx_deform = {depsgraph, ob, deform_app_flags};
+ const ModifierEvalContext mectx_apply = {depsgraph, ob, app_flags};
+ const ModifierEvalContext mectx_orco = {depsgraph, ob, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO};
+
md = firstmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
modifiers_clearErrors(ob);
@@ -1845,7 +1852,7 @@ static void mesh_calc_modifiers(
if (!deformedVerts)
deformedVerts = BKE_mesh_vertexCos_get(mesh_orig_id, &numVerts);
- modwrap_deformVerts(md, depsgraph, ob, NULL, deformedVerts, numVerts, deform_app_flags);
+ modwrap_deformVerts(md, &mectx_deform, NULL, deformedVerts, numVerts);
}
else {
break;
@@ -1986,7 +1993,7 @@ static void mesh_calc_modifiers(
}
}
- modwrap_deformVerts(md, depsgraph, ob, dm, deformedVerts, numVerts, deform_app_flags);
+ modwrap_deformVerts(md, &mectx_deform, dm, deformedVerts, numVerts);
}
else {
DerivedMesh *ndm;
@@ -2061,7 +2068,7 @@ static void mesh_calc_modifiers(
}
}
- ndm = modwrap_applyModifier(md, depsgraph, ob, dm, app_flags);
+ ndm = modwrap_applyModifier(md, &mectx_apply, dm);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2088,7 +2095,7 @@ static void mesh_calc_modifiers(
(mti->requiredDataMask ?
mti->requiredDataMask(ob, md) : 0));
- ndm = modwrap_applyModifier(md, depsgraph, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, &mectx_orco, orcodm);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2106,7 +2113,7 @@ static void mesh_calc_modifiers(
nextmask &= ~CD_MASK_CLOTH_ORCO;
DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX);
- ndm = modwrap_applyModifier(md, depsgraph, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, &mectx_orco, clothorcodm);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
@@ -2300,6 +2307,11 @@ static void editbmesh_calc_modifiers(
const bool do_mod_wmcol = do_init_wmcol;
VirtualModifierData virtualModifierData;
+ /* TODO(sybren): do we really need multiple objects, or shall we change the flags where needed? */
+ const ModifierEvalContext mectx = {depsgraph, ob, 0};
+ const ModifierEvalContext mectx_orco = {depsgraph, ob, MOD_APPLY_ORCO};
+ const ModifierEvalContext mectx_cache_gpu = {depsgraph, ob, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU};
+
const bool do_loop_normals = (((Mesh *)(ob->data))->flag & ME_AUTOSMOOTH) != 0;
const float loop_normals_split_angle = ((Mesh *)(ob->data))->smoothresh;
@@ -2363,9 +2375,9 @@ static void editbmesh_calc_modifiers(
}
if (mti->deformVertsEM || mti->deformVertsEM_DM)
- modwrap_deformVertsEM(md, depsgraph, ob, em, dm, deformedVerts, numVerts);
+ modwrap_deformVertsEM(md, &mectx, em, dm, deformedVerts, numVerts);
else
- modwrap_deformVerts(md, depsgraph, ob, dm, deformedVerts, numVerts, 0);
+ modwrap_deformVerts(md, &mectx, dm, deformedVerts, numVerts);
}
else {
DerivedMesh *ndm;
@@ -2410,10 +2422,10 @@ static void editbmesh_calc_modifiers(
DM_set_only_copy(orcodm, mask | CD_MASK_ORIGINDEX);
if (mti->applyModifierEM || mti->applyModifierEM_DM) {
- ndm = modwrap_applyModifierEM(md, depsgraph, ob, em, orcodm, MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifierEM(md, &mectx_orco, em, orcodm);
}
else {
- ndm = modwrap_applyModifier(md, depsgraph, ob, orcodm, MOD_APPLY_ORCO);
+ ndm = modwrap_applyModifier(md, &mectx_orco, orcodm);
}
ASSERT_IS_VALID_DM(ndm);
@@ -2438,9 +2450,9 @@ static void editbmesh_calc_modifiers(
}
if (mti->applyModifierEM || mti->applyModifierEM_DM)
- ndm = modwrap_applyModifierEM(md, depsgraph, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
+ ndm = modwrap_applyModifierEM(md, &mectx_cache_gpu, em, dm);
else
- ndm = modwrap_applyModifier(md, depsgraph, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
+ ndm = modwrap_applyModifier(md, &mectx_cache_gpu, dm);
ASSERT_IS_VALID_DM(ndm);
if (ndm) {
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index ad332220032..0a31411d638 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -261,6 +261,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL;
VirtualModifierData virtualModifierData;
+ ModifierEvalContext mectx = {depsgraph, ob, 0};
modifiers_clearErrors(ob);
@@ -292,7 +293,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
unit_m3(defmats[a]);
}
- modifier_deformMatricesEM_DM_deprecated(md, depsgraph, ob, em, dm, deformedVerts, defmats, numVerts);
+ modifier_deformMatricesEM_DM_deprecated(md, &mectx, em, dm, deformedVerts, defmats, numVerts);
}
else
break;
@@ -323,6 +324,7 @@ int BKE_sculpt_get_first_deform_matrices(
const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
int numleft = 0;
VirtualModifierData virtualModifierData;
+ ModifierEvalContext mectx = {depsgraph, ob, 0};
if (has_multires) {
*deformmats = NULL;
@@ -350,7 +352,7 @@ int BKE_sculpt_get_first_deform_matrices(
}
if (mti->deformMatrices || mti->deformMatrices_DM) {
- modifier_deformMatrices_DM_deprecated(md, depsgraph, ob, dm, deformedVerts, defmats, numVerts);
+ modifier_deformMatrices_DM_deprecated(md, &mectx, dm, deformedVerts, defmats, numVerts);
}
else break;
}
@@ -388,6 +390,7 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Obje
int i, deformed = 0;
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
+ ModifierEvalContext mectx = {depsgraph, ob, 0};
Mesh *me = (Mesh *)ob->data;
for (; md; md = md->next) {
@@ -401,7 +404,7 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Obje
if ((mti->deformMatrices || mti->deformMatrices_DM) && !deformed)
continue;
- modifier_deformVerts_DM_deprecated(md, depsgraph, ob, NULL, deformedVerts, me->totvert, 0);
+ modifier_deformVerts_DM_deprecated(md, &mectx, NULL, deformedVerts, me->totvert);
deformed = 1;
}
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 74825130b03..fa996b8f73e 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -827,6 +827,8 @@ static void curve_calc_modifiers_pre(
else
required_mode = eModifierMode_Realtime;
+ const ModifierEvalContext mectx = {depsgraph, ob, app_flag};
+
pretessellatePoint = curve_get_tessellate_point(scene, ob, use_render_resolution, editmode);
if (editmode)
@@ -860,7 +862,7 @@ static void curve_calc_modifiers_pre(
deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts);
}
- modifier_deformVerts_DM_deprecated(md, depsgraph, ob, NULL, deformedVerts, numVerts, app_flag);
+ modifier_deformVerts_DM_deprecated(md, &mectx, NULL, deformedVerts, numVerts);
if (md == pretessellatePoint)
break;
@@ -935,6 +937,11 @@ static void curve_calc_modifiers_post(
else
required_mode = eModifierMode_Realtime;
+ const ModifierEvalContext mectx_deform = {depsgraph, ob,
+ editmode ? app_flag | MOD_APPLY_USECACHE : app_flag};
+ const ModifierEvalContext mectx_apply = {depsgraph, ob,
+ useCache ? app_flag | MOD_APPLY_USECACHE : app_flag};
+
pretessellatePoint = curve_get_tessellate_point(scene, ob, use_render_resolution, editmode);
if (editmode)
@@ -950,8 +957,6 @@ static void curve_calc_modifiers_post(
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- ModifierApplyFlag appf = app_flag;
-
md->scene = scene;
if (!modifier_isEnabled(scene, md, required_mode))
@@ -960,8 +965,6 @@ static void curve_calc_modifiers_post(
if (mti->type == eModifierTypeType_OnlyDeform ||
(mti->type == eModifierTypeType_DeformOrConstruct && !dm))
{
- if (editmode)
- appf |= MOD_APPLY_USECACHE;
if (dm) {
if (!vertCos) {
totvert = dm->getNumVerts(dm);
@@ -969,14 +972,14 @@ static void curve_calc_modifiers_post(
dm->getVertCos(dm, vertCos);
}
- modifier_deformVerts_DM_deprecated(md, depsgraph, ob, dm, vertCos, totvert, appf);
+ modifier_deformVerts_DM_deprecated(md, &mectx_deform, dm, vertCos, totvert);
}
else {
if (!vertCos) {
vertCos = displist_get_allverts(dispbase, &totvert);
}
- modifier_deformVerts_DM_deprecated(md, depsgraph, ob, NULL, vertCos, totvert, appf);
+ modifier_deformVerts_DM_deprecated(md, &mectx_deform, NULL, vertCos, totvert);
}
}
else {
@@ -1015,10 +1018,7 @@ static void curve_calc_modifiers_post(
vertCos = NULL;
}
- if (useCache)
- appf |= MOD_APPLY_USECACHE;
-
- ndm = modwrap_applyModifier(md, depsgraph, ob, dm, appf);
+ ndm = modwrap_applyModifier(md, &mectx_apply, dm);
if (ndm) {
/* Modifier returned a new derived mesh */
@@ -1162,6 +1162,8 @@ static void curve_calc_orcodm(
else
required_mode = eModifierMode_Realtime;
+ const ModifierEvalContext mectx = {depsgraph, ob, app_flag};
+
pretessellatePoint = curve_get_tessellate_point(scene, ob, use_render_resolution, editmode);
if (editmode)
@@ -1190,7 +1192,7 @@ static void curve_calc_orcodm(
if (mti->type != eModifierTypeType_Constructive)
continue;
- ndm = modwrap_applyModifier(md, depsgraph, ob, orcodm, app_flag);
+ ndm = modwrap_applyModifier(md, &mectx, orcodm);
if (ndm) {
/* if the modifier returned a new dm, release the old one */
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 570ad9c8980..7ec7da74e55 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -1033,6 +1033,7 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
float (*vertexCos)[3] = NULL;
int numVerts, editmode = (lt->editlatt != NULL);
+ const ModifierEvalContext mectx = {depsgraph, ob, 0};
if (ob->curve_cache) {
BKE_displist_free(&ob->curve_cache->disp);
@@ -1053,7 +1054,7 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
if (mti->type != eModifierTypeType_OnlyDeform) continue;
if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts);
- modifier_deformVerts_DM_deprecated(md, depsgraph, ob, NULL, vertexCos, numVerts, 0);
+ modifier_deformVerts_DM_deprecated(md, &mectx, NULL, vertexCos, numVerts);
}
/* always displist to make this work like derivedmesh */
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index eafa7292908..6ee6db66935 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -789,9 +789,8 @@ void modifier_path_init(char *path, int path_maxlen, const char *name)
/* wrapper around ModifierTypeInfo.applyModifier that ensures valid normals */
struct DerivedMesh *modwrap_applyModifier(
- ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, struct DerivedMesh *dm,
- ModifierApplyFlag flag)
+ ModifierData *md, const ModifierEvalContext *ctx,
+ struct DerivedMesh *dm)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
BLI_assert(CustomData_has_layer(&dm->polyData, CD_NORMAL) == false);
@@ -799,14 +798,12 @@ struct DerivedMesh *modwrap_applyModifier(
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- return modifier_applyModifier_DM_deprecated(md, depsgraph, ob, dm, flag);
+ return modifier_applyModifier_DM_deprecated(md, ctx, dm);
}
struct DerivedMesh *modwrap_applyModifierEM(
- ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, struct BMEditMesh *em,
- DerivedMesh *dm,
- ModifierApplyFlag flag)
+ ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *em, DerivedMesh *dm)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
BLI_assert(CustomData_has_layer(&dm->polyData, CD_NORMAL) == false);
@@ -814,14 +811,12 @@ struct DerivedMesh *modwrap_applyModifierEM(
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- return modifier_applyModifierEM_DM_deprecated(md, depsgraph, ob, em, dm, flag);
+ return modifier_applyModifierEM_DM_deprecated(md, ctx, em, dm);
}
void modwrap_deformVerts(
- ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, DerivedMesh *dm,
- float (*vertexCos)[3], int numVerts,
- ModifierApplyFlag flag)
+ ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm, float (*vertexCos)[3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
BLI_assert(!dm || CustomData_has_layer(&dm->polyData, CD_NORMAL) == false);
@@ -829,11 +824,11 @@ void modwrap_deformVerts(
if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- modifier_deformVerts_DM_deprecated(md, depsgraph, ob, dm, vertexCos, numVerts, flag);
+ modifier_deformVerts_DM_deprecated(md, ctx, dm, vertexCos, numVerts);
}
void modwrap_deformVertsEM(
- ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
+ ModifierData *md, const ModifierEvalContext *ctx,
struct BMEditMesh *em, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
{
@@ -843,7 +838,7 @@ void modwrap_deformVertsEM(
if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm);
}
- modifier_deformVertsEM_DM_deprecated(md, depsgraph, ob, em, dm, vertexCos, numVerts);
+ modifier_deformVertsEM_DM_deprecated(md, ctx, em, dm, vertexCos, numVerts);
}
/* end modifier callback wrappers */
@@ -852,15 +847,14 @@ void modwrap_deformVertsEM(
* depending on if the modifier has been ported to Mesh or is still using DerivedMesh
*/
-void modifier_deformVerts(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh,
- float (*vertexCos)[3], int numVerts,
- ModifierApplyFlag flag)
+void modifier_deformVerts(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct Mesh *mesh,
+ float (*vertexCos)[3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->deformVerts) {
- mti->deformVerts(md, depsgraph, ob, mesh, vertexCos, numVerts, flag);
+ mti->deformVerts(md, ctx, mesh, vertexCos, numVerts);
}
else {
DerivedMesh *dm = NULL;
@@ -868,7 +862,7 @@ void modifier_deformVerts(struct ModifierData *md, struct Depsgraph *depsgraph,
dm = CDDM_from_mesh(mesh);
}
- mti->deformVerts_DM(md, depsgraph, ob, dm, vertexCos, numVerts, flag);
+ mti->deformVerts_DM(md, ctx, dm, vertexCos, numVerts);
if (dm) {
dm->release(dm);
@@ -876,14 +870,14 @@ void modifier_deformVerts(struct ModifierData *md, struct Depsgraph *depsgraph,
}
}
-void modifier_deformMatrices(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh,
+void modifier_deformMatrices(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct Mesh *mesh,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->deformMatrices) {
- mti->deformMatrices(md, depsgraph, ob, mesh, vertexCos, defMats, numVerts);
+ mti->deformMatrices(md, ctx, mesh, vertexCos, defMats, numVerts);
}
else {
DerivedMesh *dm = NULL;
@@ -891,7 +885,7 @@ void modifier_deformMatrices(struct ModifierData *md, struct Depsgraph *depsgrap
dm = CDDM_from_mesh(mesh);
}
- mti->deformMatrices_DM(md, depsgraph, ob, dm, vertexCos, defMats, numVerts);
+ mti->deformMatrices_DM(md, ctx, dm, vertexCos, defMats, numVerts);
if (dm) {
dm->release(dm);
@@ -899,14 +893,14 @@ void modifier_deformMatrices(struct ModifierData *md, struct Depsgraph *depsgrap
}
}
-void modifier_deformVertsEM(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData, struct Mesh *mesh,
+void modifier_deformVertsEM(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->deformVertsEM) {
- mti->deformVertsEM(md, depsgraph, ob, editData, mesh, vertexCos, numVerts);
+ mti->deformVertsEM(md, ctx, editData, mesh, vertexCos, numVerts);
}
else {
DerivedMesh *dm = NULL;
@@ -914,7 +908,7 @@ void modifier_deformVertsEM(struct ModifierData *md, struct Depsgraph *depsgraph
dm = CDDM_from_mesh(mesh);
}
- mti->deformVertsEM_DM(md, depsgraph, ob, editData, dm, vertexCos, numVerts);
+ mti->deformVertsEM_DM(md, ctx, editData, dm, vertexCos, numVerts);
if (dm) {
dm->release(dm);
@@ -922,14 +916,14 @@ void modifier_deformVertsEM(struct ModifierData *md, struct Depsgraph *depsgraph
}
}
-void modifier_deformMatricesEM(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData, struct Mesh *mesh,
+void modifier_deformMatricesEM(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct Mesh *mesh,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->deformMatricesEM) {
- mti->deformMatricesEM(md, depsgraph, ob, editData, mesh, vertexCos, defMats, numVerts);
+ mti->deformMatricesEM(md, ctx, editData, mesh, vertexCos, defMats, numVerts);
}
else {
DerivedMesh *dm = NULL;
@@ -937,7 +931,7 @@ void modifier_deformMatricesEM(struct ModifierData *md, struct Depsgraph *depsgr
dm = CDDM_from_mesh(mesh);
}
- mti->deformMatricesEM_DM(md, depsgraph, ob, editData, dm, vertexCos, defMats, numVerts);
+ mti->deformMatricesEM_DM(md, ctx, editData, dm, vertexCos, defMats, numVerts);
if (dm) {
dm->release(dm);
@@ -945,48 +939,48 @@ void modifier_deformMatricesEM(struct ModifierData *md, struct Depsgraph *depsgr
}
}
-struct Mesh *modifier_applyModifier(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct Mesh *mesh, ModifierApplyFlag flag)
+struct Mesh *modifier_applyModifier(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct Mesh *mesh)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->applyModifier) {
- return mti->applyModifier(md, depsgraph, ob, mesh, flag);
+ return mti->applyModifier(md, ctx, mesh);
}
else {
DerivedMesh *dm = CDDM_from_mesh(mesh);
- DerivedMesh *ndm = mti->applyModifier_DM(md, depsgraph, ob, dm, flag);
+ DerivedMesh *ndm = mti->applyModifier_DM(md, ctx, dm);
if(ndm != dm) {
dm->release(dm);
}
- DM_to_mesh(ndm, mesh, ob, CD_MASK_EVERYTHING, true);
+ DM_to_mesh(ndm, mesh, ctx->object, CD_MASK_EVERYTHING, true);
return mesh;
}
}
-struct Mesh *modifier_applyModifierEM(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct Mesh *mesh, ModifierApplyFlag flag)
+struct Mesh *modifier_applyModifierEM(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
+ struct Mesh *mesh)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->applyModifierEM) {
- return mti->applyModifierEM(md, depsgraph, ob, editData, mesh, flag);
+ return mti->applyModifierEM(md, ctx, editData, mesh);
}
else {
DerivedMesh *dm = CDDM_from_mesh(mesh);
- DerivedMesh *ndm = mti->applyModifierEM_DM(md, depsgraph, ob, editData, dm, flag);
+ DerivedMesh *ndm = mti->applyModifierEM_DM(md, ctx, editData, dm);
if(ndm != dm) {
dm->release(dm);
}
- DM_to_mesh(ndm, mesh, ob, CD_MASK_EVERYTHING, true);
+ DM_to_mesh(ndm, mesh, ctx->object, CD_MASK_EVERYTHING, true);
return mesh;
}
@@ -994,15 +988,14 @@ struct Mesh *modifier_applyModifierEM(struct ModifierData *md, struct Depsgraph
/* depricated variants of above that accept DerivedMesh */
-void modifier_deformVerts_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *dm,
- float (*vertexCos)[3], int numVerts,
- ModifierApplyFlag flag)
+void modifier_deformVerts_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct DerivedMesh *dm,
+ float (*vertexCos)[3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->deformVerts_DM) {
- mti->deformVerts_DM(md, depsgraph, ob, dm, vertexCos, numVerts, flag);
+ mti->deformVerts_DM(md, ctx, dm, vertexCos, numVerts);
}
else {
/* TODO(sybren): deduplicate all the copies of this code in this file. */
@@ -1010,10 +1003,10 @@ void modifier_deformVerts_DM_deprecated(struct ModifierData *md, struct Depsgrap
if (dm != NULL) {
mesh = BKE_libblock_alloc_notest(ID_ME);
BKE_mesh_init(mesh);
- DM_to_mesh(dm, mesh, ob, CD_MASK_EVERYTHING, false);
+ DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
- mti->deformVerts(md, depsgraph, ob, mesh, vertexCos, numVerts, flag);
+ mti->deformVerts(md, ctx, mesh, vertexCos, numVerts);
if (mesh != NULL) {
BKE_mesh_free(mesh);
@@ -1022,15 +1015,15 @@ void modifier_deformVerts_DM_deprecated(struct ModifierData *md, struct Depsgrap
}
}
-void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *dm,
+void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct DerivedMesh *dm,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->deformMatrices_DM) {
- mti->deformMatrices_DM(md, depsgraph, ob, dm, vertexCos, defMats, numVerts);
+ mti->deformMatrices_DM(md, ctx, dm, vertexCos, defMats, numVerts);
}
else {
/* TODO(sybren): deduplicate all the copies of this code in this file. */
@@ -1038,10 +1031,10 @@ void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, struct Depsg
if (dm != NULL) {
mesh = BKE_libblock_alloc_notest(ID_ME);
BKE_mesh_init(mesh);
- DM_to_mesh(dm, mesh, ob, CD_MASK_EVERYTHING, false);
+ DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
- mti->deformMatrices(md, depsgraph, ob, mesh, vertexCos, defMats, numVerts);
+ mti->deformMatrices(md, ctx, mesh, vertexCos, defMats, numVerts);
if (mesh != NULL) {
BKE_mesh_free(mesh);
@@ -1050,14 +1043,14 @@ void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, struct Depsg
}
}
-void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *dm,
+void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->deformVertsEM_DM) {
- mti->deformVertsEM_DM(md, depsgraph, ob, editData, dm, vertexCos, numVerts);
+ mti->deformVertsEM_DM(md, ctx, editData, dm, vertexCos, numVerts);
}
else {
/* TODO(sybren): deduplicate all the copies of this code in this file. */
@@ -1065,10 +1058,10 @@ void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, struct Depsgr
if (dm != NULL) {
mesh = BKE_libblock_alloc_notest(ID_ME);
BKE_mesh_init(mesh);
- DM_to_mesh(dm, mesh, ob, CD_MASK_EVERYTHING, false);
+ DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
- mti->deformVertsEM(md, depsgraph, ob, editData, mesh, vertexCos, numVerts);
+ mti->deformVertsEM(md, ctx, editData, mesh, vertexCos, numVerts);
if (mesh != NULL) {
BKE_mesh_free(mesh);
@@ -1077,14 +1070,14 @@ void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, struct Depsgr
}
}
-void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *dm,
+void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *editData, struct DerivedMesh *dm,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->deformMatricesEM_DM) {
- mti->deformMatricesEM_DM(md, depsgraph, ob, editData, dm, vertexCos, defMats, numVerts);
+ mti->deformMatricesEM_DM(md, ctx, editData, dm, vertexCos, defMats, numVerts);
}
else {
/* TODO(sybren): deduplicate all the copies of this code in this file. */
@@ -1092,10 +1085,10 @@ void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, struct Dep
if (dm != NULL) {
mesh = BKE_libblock_alloc_notest(ID_ME);
BKE_mesh_init(mesh);
- DM_to_mesh(dm, mesh, ob, CD_MASK_EVERYTHING, false);
+ DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
- mti->deformMatricesEM(md, depsgraph, ob, editData, mesh, vertexCos, defMats, numVerts);
+ mti->deformMatricesEM(md, ctx, editData, mesh, vertexCos, defMats, numVerts);
if (mesh != NULL) {
BKE_mesh_free(mesh);
@@ -1104,13 +1097,13 @@ void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, struct Dep
}
}
-struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct DerivedMesh *dm, ModifierApplyFlag flag)
+struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct DerivedMesh *dm)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->applyModifier_DM) {
- return mti->applyModifier_DM(md, depsgraph, ob, dm, flag);
+ return mti->applyModifier_DM(md, ctx, dm);
}
else {
/* TODO(sybren): deduplicate all the copies of this code in this file. */
@@ -1118,10 +1111,10 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md
if (dm != NULL) {
mesh = BKE_libblock_alloc_notest(ID_ME);
BKE_mesh_init(mesh);
- DM_to_mesh(dm, mesh, ob, CD_MASK_EVERYTHING, false);
+ DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
- struct Mesh *new_mesh = mti->applyModifier(md, depsgraph, ob, mesh, flag);
+ struct Mesh *new_mesh = mti->applyModifier(md, ctx, mesh);
/* Make a DM that doesn't reference new_mesh so we can free the latter. */
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE);
@@ -1139,14 +1132,14 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md
}
}
-struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph,
- struct Object *ob, struct BMEditMesh *editData,
- struct DerivedMesh *dm, ModifierApplyFlag flag)
+struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
+ struct DerivedMesh *dm)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->applyModifierEM) {
- return mti->applyModifierEM_DM(md, depsgraph, ob, editData, dm, flag);
+ return mti->applyModifierEM_DM(md, ctx, editData, dm);
}
else {
/* TODO(sybren): deduplicate all the copies of this code in this file. */
@@ -1154,10 +1147,10 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *
if (dm != NULL) {
mesh = BKE_libblock_alloc_notest(ID_ME);
BKE_mesh_init(mesh);
- DM_to_mesh(dm, mesh, ob, CD_MASK_EVERYTHING, false);
+ DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
}
- struct Mesh *new_mesh = mti->applyModifierEM(md, depsgraph, ob, editData, mesh, flag);
+ struct Mesh *new_mesh = mti->applyModifierEM(md, ctx, editData, mesh);
/* Make a DM that doesn't reference new_mesh so we can free the latter. */
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 0dcb4a46b3f..ee32c2398b2 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -282,8 +282,9 @@ DerivedMesh *get_multires_dm(struct Depsgraph *depsgraph, Scene *scene, Multires
ModifierData *md = (ModifierData *)mmd;
DerivedMesh *tdm = mesh_get_derived_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
DerivedMesh *dm;
+ ModifierEvalContext mectx = {depsgraph, ob, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY};
- dm = modifier_applyModifier_DM_deprecated(md, depsgraph, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY);
+ dm = modifier_applyModifier_DM_deprecated(md, &mectx, tdm);
if (dm == tdm) {
dm = CDDM_copy(tdm);
}
@@ -431,6 +432,7 @@ int multiresModifier_reshapeFromDeformMod(struct Depsgraph *depsgraph, Scene *sc
DerivedMesh *dm, *ndm;
int numVerts, result;
float (*deformedVerts)[3];
+ const ModifierEvalContext mectx = {depsgraph, ob, 0};
if (multires_get_level(ob, mmd, false, true) == 0)
return 0;
@@ -441,7 +443,7 @@ int multiresModifier_reshapeFromDeformMod(struct Depsgraph *depsgraph, Scene *sc
deformedVerts = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "multiresReshape_deformVerts");
dm->getVertCos(dm, deformedVerts);
- modifier_deformVerts_DM_deprecated(md, depsgraph, ob, dm, deformedVerts, numVerts, 0);
+ modifier_deformVerts_DM_deprecated(md, &mectx, dm, deformedVerts, numVerts);
ndm = CDDM_copy(dm);
CDDM_apply_vert_coords(ndm, deformedVerts);