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:
-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
-rw-r--r--source/blender/editors/object/object_modifier.c3
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c23
-rw-r--r--source/blender/modifiers/intern/MOD_array.c28
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c9
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c15
-rw-r--r--source/blender/modifiers/intern/MOD_build.c7
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c23
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c11
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c8
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c14
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c13
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c9
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c7
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c17
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c9
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c5
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c23
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim.c8
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c19
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c14
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c14
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c13
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c6
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c13
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c15
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c13
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c7
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c14
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c6
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c7
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c13
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c23
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c12
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c9
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c35
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c23
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c15
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c6
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c9
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c14
-rw-r--r--source/blender/modifiers/intern/MOD_softbody.c7
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c9
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c29
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c13
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c15
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c6
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c7
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c7
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c12
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c23
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c14
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c12
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c7
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c6
61 files changed, 523 insertions, 580 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);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index a02e68e8a60..e2197c58d49 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -631,6 +631,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
Curve *cu;
int numVerts;
float (*vertexCos)[3];
+ ModifierEvalContext mectx = {depsgraph, ob, 0};
if (ELEM(mti->type, eModifierTypeType_Constructive, eModifierTypeType_Nonconstructive)) {
BKE_report(reports, RPT_ERROR, "Cannot apply constructive modifiers on curve");
@@ -641,7 +642,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices");
vertexCos = BKE_curve_nurbs_vertexCos_get(&cu->nurb, &numVerts);
- modifier_deformVerts_DM_deprecated(md, depsgraph, ob, NULL, vertexCos, numVerts, 0);
+ modifier_deformVerts_DM_deprecated(md, &mectx, NULL, vertexCos, numVerts);
BK_curve_nurbs_vertexCos_apply(&cu->nurb, vertexCos);
MEM_freeN(vertexCos);
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index abbd7ba0fc8..f354ed3aada 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -110,17 +110,16 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, Mesh *mesh,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ Mesh *mesh,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
- armature_deform_verts(amd->object, ob, mesh, vertexCos, NULL,
+ armature_deform_verts(amd->object, ctx->object, mesh, vertexCos, NULL,
numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name);
/* free cache */
@@ -131,7 +130,7 @@ static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *em,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
@@ -147,7 +146,7 @@ static void deformVertsEM(
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
- armature_deform_verts(amd->object, ob, mesh_src, vertexCos, NULL,
+ armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, NULL,
numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name);
/* free cache */
@@ -163,7 +162,7 @@ static void deformVertsEM(
}
static void deformMatricesEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *em,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em,
Mesh *mesh, float (*vertexCos)[3],
float (*defMats)[3][3], int numVerts)
{
@@ -178,7 +177,7 @@ static void deformMatricesEM(
BM_mesh_bm_to_me(em->bm, mesh_src, &params);
}
- armature_deform_verts(amd->object, ob, mesh_src, vertexCos, defMats, numVerts,
+ armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts,
amd->deformflag, NULL, amd->defgrp_name);
if (!mesh) {
@@ -187,13 +186,13 @@ static void deformMatricesEM(
}
}
-static void deformMatrices(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, Mesh *mesh,
+static void deformMatrices(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
ArmatureModifierData *amd = (ArmatureModifierData *) md;
- Mesh *mesh_src = mesh ? mesh : ob->data;
+ Mesh *mesh_src = mesh ? mesh : ctx->object->data;
- armature_deform_verts(amd->object, ob, mesh_src, vertexCos, defMats, numVerts,
+ armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts,
amd->deformflag, NULL, amd->defgrp_name);
}
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 65ca02408ef..6dcb29abd63 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -351,8 +351,7 @@ static void mesh_merge_transform(
}
static Mesh *arrayModifier_doArray(
- ArrayModifierData *amd, Object *ob, Mesh *mesh,
- ModifierApplyFlag flag)
+ ArrayModifierData *amd, const ModifierEvalContext *ctx, Mesh *mesh)
{
const float eps = 1e-6f;
const MVert *src_mvert;
@@ -396,10 +395,11 @@ static Mesh *arrayModifier_doArray(
count = amd->count;
- if (amd->start_cap && amd->start_cap != ob && amd->start_cap->type == OB_MESH) {
- vgroup_start_cap_remap = BKE_object_defgroup_index_map_create(amd->start_cap, ob, &vgroup_start_cap_remap_len);
+ if (amd->start_cap && amd->start_cap != ctx->object && amd->start_cap->type == OB_MESH) {
+ vgroup_start_cap_remap = BKE_object_defgroup_index_map_create(
+ amd->start_cap, ctx->object, &vgroup_start_cap_remap_len);
- start_cap_mesh = get_mesh_eval_for_modifier(amd->start_cap, flag);
+ start_cap_mesh = get_mesh_eval_for_modifier(amd->start_cap, ctx->flag);
if (start_cap_mesh) {
start_cap_nverts = start_cap_mesh->totvert;
start_cap_nedges = start_cap_mesh->totedge;
@@ -407,10 +407,11 @@ static Mesh *arrayModifier_doArray(
start_cap_npolys = start_cap_mesh->totpoly;
}
}
- if (amd->end_cap && amd->end_cap != ob && amd->end_cap->type == OB_MESH) {
- vgroup_end_cap_remap = BKE_object_defgroup_index_map_create(amd->end_cap, ob, &vgroup_end_cap_remap_len);
+ if (amd->end_cap && amd->end_cap != ctx->object && amd->end_cap->type == OB_MESH) {
+ vgroup_end_cap_remap = BKE_object_defgroup_index_map_create(
+ amd->end_cap, ctx->object, &vgroup_end_cap_remap_len);
- end_cap_mesh = get_mesh_eval_for_modifier(amd->end_cap, flag);
+ end_cap_mesh = get_mesh_eval_for_modifier(amd->end_cap, ctx->flag);
if (end_cap_mesh) {
end_cap_nverts = end_cap_mesh->totvert;
end_cap_nedges = end_cap_mesh->totedge;
@@ -446,8 +447,8 @@ static Mesh *arrayModifier_doArray(
float obinv[4][4];
float result_mat[4][4];
- if (ob)
- invert_m4_m4(obinv, ob->obmat);
+ if (ctx->object)
+ invert_m4_m4(obinv, ctx->object->obmat);
else
unit_m4(obinv);
@@ -747,12 +748,11 @@ static Mesh *arrayModifier_doArray(
}
-static Mesh *applyModifier(ModifierData *md, Depsgraph *UNUSED(depsgraph),
- Object *ob, Mesh *mesh,
- ModifierApplyFlag flag)
+static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ Mesh *mesh)
{
ArrayModifierData *amd = (ArrayModifierData *) md;
- return arrayModifier_doArray(amd, ob, mesh, flag);
+ return arrayModifier_doArray(amd, ctx, mesh);
}
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index f12bad5c3e8..4134314bd85 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -86,9 +86,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
/*
* This calls the new bevel code (added since 2.64)
*/
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- struct Object *ob, DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
DerivedMesh *result;
BMesh *bm;
@@ -103,12 +102,12 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
const bool vertex_only = (bmd->flags & MOD_BEVEL_VERT) != 0;
const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK);
const int offset_type = bmd->val_flags;
- const int mat = CLAMPIS(bmd->mat, -1, ob->totcol - 1);
+ const int mat = CLAMPIS(bmd->mat, -1, ctx->object->totcol - 1);
const bool loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0;
bm = DM_to_bmesh(dm, true);
if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0])
- modifier_get_vgroup(ob, dm, bmd->defgrp_name, &dvert, &vgroup);
+ modifier_get_vgroup(ctx->object, dm, bmd->defgrp_name, &dvert, &vgroup);
if (vertex_only) {
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index e15c68c6e34..5057f69bf23 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -166,9 +166,8 @@ static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
}
static DerivedMesh *applyModifier(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
- DerivedMesh *dm,
- ModifierApplyFlag flag)
+ ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
BooleanModifierData *bmd = (BooleanModifierData *) md;
DerivedMesh *dm_other;
@@ -176,7 +175,7 @@ static DerivedMesh *applyModifier(
if (!bmd->object)
return dm;
- dm_other = get_dm_for_modifier(bmd->object, flag);
+ dm_other = get_dm_for_modifier(bmd->object, ctx->flag);
if (dm_other) {
DerivedMesh *result;
@@ -184,10 +183,10 @@ static DerivedMesh *applyModifier(
/* when one of objects is empty (has got no faces) we could speed up
* calculation a bit returning one of objects' derived meshes (or empty one)
* Returning mesh is depended on modifiers operation (sergey) */
- result = get_quick_derivedMesh(ob, dm, bmd->object, dm_other, bmd->operation);
+ result = get_quick_derivedMesh(ctx->object, dm, bmd->object, dm_other, bmd->operation);
if (result == NULL) {
- const bool is_flip = (is_negative_m4(ob->obmat) != is_negative_m4(bmd->object->obmat));
+ const bool is_flip = (is_negative_m4(ctx->object->obmat) != is_negative_m4(bmd->object->obmat));
BMesh *bm;
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_DM(dm, dm_other);
@@ -234,7 +233,7 @@ static DerivedMesh *applyModifier(
float imat[4][4];
float omat[4][4];
- invert_m4_m4(imat, ob->obmat);
+ invert_m4_m4(imat, ctx->object->obmat);
mul_m4_m4m4(omat, imat, bmd->object->obmat);
BMVert *eve;
@@ -260,7 +259,7 @@ static DerivedMesh *applyModifier(
const short ob_src_totcol = bmd->object->totcol;
short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
- BKE_material_remap_object_calc(ob, bmd->object, material_remap);
+ BKE_material_remap_object_calc(ctx->object, bmd->object, material_remap);
BMFace *efa;
i = 0;
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index 26895e0f3ad..aebf63c3100 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -80,9 +80,8 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static Mesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
- Object *UNUSED(ob), struct Mesh *mesh,
- ModifierApplyFlag UNUSED(flag))
+static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ struct Mesh *mesh)
{
Mesh *result;
BuildModifierData *bmd = (BuildModifierData *) md;
@@ -116,7 +115,7 @@ static Mesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
range_vn_i(edgeMap, numEdge_src, 0);
range_vn_i(faceMap, numPoly_src, 0);
- struct Scene *scene = DEG_get_input_scene(depsgraph);
+ struct Scene *scene = DEG_get_input_scene(ctx->depsgraph);
frac = (BKE_scene_frame_get(scene) - bmd->start) / bmd->length;
CLAMP(frac, 0.0f, 1.0f);
if (bmd->flag & MOD_BUILD_FLAG_REVERSE) {
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 3f049771682..11c8ba4a9cd 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -429,22 +429,21 @@ static void cuboid_do(
}
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
DerivedMesh *dm = NULL;
CastModifierData *cmd = (CastModifierData *)md;
- dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
- cuboid_do(cmd, ob, dm, vertexCos, numVerts);
+ cuboid_do(cmd, ctx->object, dm, vertexCos, numVerts);
}
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
- sphere_do(cmd, ob, dm, vertexCos, numVerts);
+ sphere_do(cmd, ctx->object, dm, vertexCos, numVerts);
}
if (dm != derivedData)
@@ -452,18 +451,18 @@ static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
+ DerivedMesh *dm = get_dm(ctx->object, editData, derivedData, NULL, false, false);
CastModifierData *cmd = (CastModifierData *)md;
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
- cuboid_do(cmd, ob, dm, vertexCos, numVerts);
+ cuboid_do(cmd, ctx->object, dm, vertexCos, numVerts);
}
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
- sphere_do(cmd, ob, dm, vertexCos, numVerts);
+ sphere_do(cmd, ctx->object, dm, vertexCos, numVerts);
}
if (dm != derivedData)
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 84cad91b32e..315ea73d086 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -69,8 +69,9 @@ static void initData(ModifierData *md)
cloth_init(clmd);
}
-static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
- int numVerts, ModifierApplyFlag UNUSED(flag))
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData, float (*vertexCos)[3],
+ int numVerts)
{
DerivedMesh *dm;
ClothModifierData *clmd = (ClothModifierData *) md;
@@ -83,7 +84,7 @@ static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph, Object *o
return;
}
- dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
if (dm == derivedData)
dm = CDDM_copy(dm);
@@ -94,7 +95,7 @@ static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph, Object *o
* Also hopefully new cloth system will arrive soon..
*/
if (derivedData == NULL && clmd->sim_parms->shapekey_rest) {
- KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ob),
+ KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ctx->object),
clmd->sim_parms->shapekey_rest);
if (kb && kb->data != NULL) {
float (*layerorco)[3];
@@ -109,7 +110,7 @@ static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph, Object *o
CDDM_apply_vert_coords(dm, vertexCos);
- clothModifier_do(clmd, depsgraph, md->scene, ob, dm, vertexCos);
+ clothModifier_do(clmd, ctx->depsgraph, md->scene, ctx->object, dm, vertexCos);
dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 4b4324c61fb..c8c00e31845 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -98,15 +98,15 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int UNUSED(numVerts),
- ModifierApplyFlag UNUSED(flag))
+ int UNUSED(numVerts))
{
CollisionModifierData *collmd = (CollisionModifierData *) md;
DerivedMesh *dm = NULL;
MVert *tempVert = NULL;
+ Object *ob = ctx->object;
/* if possible use/create DerivedMesh */
if (derivedData) dm = CDDM_copy(derivedData);
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index 23a36c31253..186f5a7cf89 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -713,12 +713,12 @@ error:
static void deformVerts(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
+ ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ DerivedMesh *dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
- correctivesmooth_modifier_do(md, ob, dm, vertexCos, (unsigned int)numVerts, NULL);
+ correctivesmooth_modifier_do(md, ctx->object, dm, vertexCos, (unsigned int)numVerts, NULL);
if (dm != derivedData) {
dm->release(dm);
@@ -727,12 +727,12 @@ static void deformVerts(
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
+ DerivedMesh *dm = get_dm(ctx->object, editData, derivedData, NULL, false, false);
- correctivesmooth_modifier_do(md, ob, dm, vertexCos, (unsigned int)numVerts, editData);
+ correctivesmooth_modifier_do(md, ctx->object, dm, vertexCos, (unsigned int)numVerts, editData);
if (dm != derivedData) {
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 2493e4f6860..7d10d6f687a 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -111,29 +111,28 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Curve Modifier");
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
CurveModifierData *cmd = (CurveModifierData *) md;
/* silly that defaxis and curve_deform_verts are off by 1
* but leave for now to save having to call do_versions */
- curve_deform_verts(cmd->object, ob, derivedData, vertexCos, numVerts,
+ curve_deform_verts(cmd->object, ctx->object, derivedData, vertexCos, numVerts,
cmd->name, cmd->defaxis - 1);
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *depsgraph, Object *ob, struct BMEditMesh *em,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
if (!derivedData) dm = CDDM_from_editbmesh(em, false, false);
- deformVerts(md, depsgraph, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, ctx, dm, vertexCos, numVerts);
if (!derivedData) dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index b2c4f707e3e..863a6a3bb14 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -148,15 +148,14 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
DT_TYPE_SHARP_FACE \
)
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData)
{
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
DerivedMesh *dm = derivedData;
ReportList reports;
/* Only used to check wehther we are operating on org data or not... */
- Mesh *me = ob->data;
+ Mesh *me = ctx->object->data;
const bool invert_vgroup = (dtmd->flags & MOD_DATATRANSFER_INVERT_VGROUP) != 0;
@@ -166,7 +165,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
SpaceTransform *space_transform = (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) ? &space_transform_data : NULL;
if (space_transform) {
- BLI_SPACE_TRANSFORM_SETUP(space_transform, ob, dtmd->ob_source);
+ BLI_SPACE_TRANSFORM_SETUP(space_transform, ctx->object, dtmd->ob_source);
}
MVert *mvert = dm->getVertArray(dm);
@@ -180,7 +179,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
BKE_reports_init(&reports, RPT_STORE);
/* Note: no islands precision for now here. */
- BKE_object_data_transfer_dm(depsgraph, md->scene, dtmd->ob_source, ob, dm, dtmd->data_types, false,
+ BKE_object_data_transfer_dm(ctx->depsgraph, md->scene, dtmd->ob_source, ctx->object, dm, dtmd->data_types, false,
dtmd->vmap_mode, dtmd->emap_mode, dtmd->lmap_mode, dtmd->pmap_mode,
space_transform, false, max_dist, dtmd->map_ray_radius, 0.0f,
dtmd->layers_select_src, dtmd->layers_select_dst,
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index 515be3f76c8..dfa76e53f84 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -86,9 +86,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
DecimateModifierData *dmd = (DecimateModifierData *) md;
DerivedMesh *dm = derivedData, *result = NULL;
@@ -136,7 +135,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
MDeformVert *dvert;
int defgrp_index;
- modifier_get_vgroup(ob, dm, dmd->defgrp_name, &dvert, &defgrp_index);
+ modifier_get_vgroup(ctx->object, dm, dmd->defgrp_name, &dvert, &defgrp_index);
if (dvert) {
const unsigned int vert_tot = dm->getNumVerts(dm);
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 10365aae607..7a715c9290c 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -368,15 +368,14 @@ static void displaceModifier_do(
}
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
- DerivedMesh *dm = get_cddm(ob, NULL, derivedData, vertexCos, dependsOnNormals(md));
+ DerivedMesh *dm = get_cddm(ctx->object, NULL, derivedData, vertexCos, dependsOnNormals(md));
- displaceModifier_do((DisplaceModifierData *)md, ob, dm,
+ displaceModifier_do((DisplaceModifierData *)md, ctx->object, dm,
vertexCos, numVerts);
if (dm != derivedData)
@@ -384,12 +383,12 @@ static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_cddm(ob, editData, derivedData, vertexCos, dependsOnNormals(md));
+ DerivedMesh *dm = get_cddm(ctx->object, editData, derivedData, vertexCos, dependsOnNormals(md));
- displaceModifier_do((DisplaceModifierData *)md, ob, dm,
+ displaceModifier_do((DisplaceModifierData *)md, ctx->object, dm,
vertexCos, numVerts);
if (dm != derivedData)
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index 645c6e43077..ea8ebbc52e0 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -105,15 +105,14 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, DerivedMesh *dm,
- ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md;
/* dont apply dynamic paint on orco dm stack */
- if (!(flag & MOD_APPLY_ORCO)) {
- return dynamicPaint_Modifier_do(pmd, depsgraph, md->scene, ob, dm);
+ if (!(ctx->flag & MOD_APPLY_ORCO)) {
+ return dynamicPaint_Modifier_do(pmd, ctx->depsgraph, md->scene, ctx->object, dm);
}
return dm;
}
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index 96699ddb9f6..e23b11309e7 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -121,9 +121,8 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *UNUSED(ob), DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *UNUSED(ctx),
+ DerivedMesh *dm)
{
DerivedMesh *result;
EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md;
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index a6a698bc22d..329d1cc49ef 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -787,8 +787,8 @@ static DerivedMesh *cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
}
static DerivedMesh *explodeMesh(
ExplodeModifierData *emd,
- ParticleSystemModifierData *psmd, struct Depsgraph *depsgraph, Scene *scene,
- Object *ob, DerivedMesh *to_explode)
+ ParticleSystemModifierData *psmd, const ModifierEvalContext *ctx, Scene *scene,
+ DerivedMesh *to_explode)
{
DerivedMesh *explode, *dm = to_explode;
MFace *mf = NULL, *mface;
@@ -813,9 +813,9 @@ static DerivedMesh *explodeMesh(
mface = dm->getTessFaceArray(dm);
totpart = psmd->psys->totpart;
- sim.depsgraph = depsgraph;
+ sim.depsgraph = ctx->depsgraph;
sim.scene = scene;
- sim.ob = ob;
+ sim.ob = ctx->object;
sim.psys = psmd->psys;
sim.psmd = psmd;
@@ -870,7 +870,7 @@ static DerivedMesh *explodeMesh(
/*dupvert = CDDM_get_verts(explode);*/
/* getting back to object space */
- invert_m4_m4(imat, ob->obmat);
+ invert_m4_m4(imat, ctx->object->obmat);
psmd->psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
@@ -901,7 +901,7 @@ static DerivedMesh *explodeMesh(
psys_get_particle_state(&sim, ed_v2, &state, 1);
vertco = CDDM_get_vert(explode, v)->co;
- mul_m4_v3(ob->obmat, vertco);
+ mul_m4_v3(ctx->object->obmat, vertco);
sub_v3_v3(vertco, birth.co);
@@ -995,13 +995,12 @@ static ParticleSystemModifierData *findPrecedingParticlesystem(Object *ob, Modif
}
return psmd;
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
DerivedMesh *dm = derivedData;
ExplodeModifierData *emd = (ExplodeModifierData *) md;
- ParticleSystemModifierData *psmd = findPrecedingParticlesystem(ob, md);
+ ParticleSystemModifierData *psmd = findPrecedingParticlesystem(ctx->object, md);
if (psmd) {
ParticleSystem *psys = psmd->psys;
@@ -1030,7 +1029,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
if (emd->flag & eExplodeFlag_EdgeCut) {
int *facepa = emd->facepa;
DerivedMesh *splitdm = cutEdges(emd, dm);
- DerivedMesh *explode = explodeMesh(emd, psmd, depsgraph, md->scene, ob, splitdm);
+ DerivedMesh *explode = explodeMesh(emd, psmd, ctx, md->scene, splitdm);
MEM_freeN(emd->facepa);
emd->facepa = facepa;
@@ -1038,7 +1037,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
return explode;
}
else
- return explodeMesh(emd, psmd, depsgraph, md->scene, ob, derivedData);
+ return explodeMesh(emd, psmd, ctx, md->scene, derivedData);
}
return derivedData;
}
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c
index 4f6f7bef24d..7014861bc12 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -82,9 +82,8 @@ static void copyData(ModifierData *md, ModifierData *target)
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *dm,
- ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *) md;
DerivedMesh *result = NULL;
@@ -98,7 +97,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
}
}
- result = fluidsimModifier_do(fluidmd, md->scene, ob, dm, flag & MOD_APPLY_RENDER, flag & MOD_APPLY_USECACHE);
+ result = fluidsimModifier_do(fluidmd, md->scene, ctx->object, dm,
+ ctx->flag & MOD_APPLY_RENDER, ctx->flag & MOD_APPLY_USECACHE);
return result ? result : dm;
}
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 195eb066a9b..7e7d43cdf20 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -352,32 +352,31 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm,
}
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts,
- ModifierApplyFlag UNUSED(flag))
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts)
{
HookModifierData *hmd = (HookModifierData *) md;
DerivedMesh *dm = derivedData;
/* We need a valid dm for meshes when a vgroup is set... */
- if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0')
- dm = get_dm(ob, NULL, dm, NULL, false, false);
+ if (!dm && ctx->object->type == OB_MESH && hmd->name[0] != '\0')
+ dm = get_dm(ctx->object, NULL, dm, NULL, false, false);
- deformVerts_do(hmd, ob, dm, vertexCos, numVerts);
+ deformVerts_do(hmd, ctx->object, dm, vertexCos, numVerts);
if (derivedData != dm)
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
+static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
HookModifierData *hmd = (HookModifierData *) md;
DerivedMesh *dm = derivedData;
/* We need a valid dm for meshes when a vgroup is set... */
- if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0')
- dm = get_dm(ob, editData, dm, NULL, false, false);
+ if (!dm && ctx->object->type == OB_MESH && hmd->name[0] != '\0')
+ dm = get_dm(ctx->object, editData, dm, NULL, false, false);
- deformVerts_do(hmd, ob, dm, vertexCos, numVerts);
+ deformVerts_do(hmd, ctx->object, dm, vertexCos, numVerts);
if (derivedData != dm)
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 2463344f7bd..ac39f4696ea 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -724,23 +724,23 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ DerivedMesh *dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
- LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ob, dm, vertexCos, numVerts);
+ LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ctx->object, dm, vertexCos, numVerts);
if (dm != derivedData) {
dm->release(dm);
}
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
- LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ob, dm,
+ DerivedMesh *dm = get_dm(ctx->object, editData, derivedData, NULL, false, false);
+ LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ctx->object, dm,
vertexCos, numVerts);
if (dm != derivedData) {
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 1017b3ca7d5..3b63a3ef5f8 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -506,17 +506,17 @@ static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm;
if (numVerts == 0)
return;
- dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
- laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ob, dm,
+ laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ctx->object, dm,
vertexCos, numVerts);
if (dm != derivedData)
@@ -524,7 +524,7 @@ static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), O
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm;
@@ -532,9 +532,9 @@ static void deformVertsEM(
if (numVerts == 0)
return;
- dm = get_dm(ob, editData, derivedData, NULL, false, false);
+ dm = get_dm(ctx->object, editData, derivedData, NULL, false, false);
- laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ob, dm,
+ laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ctx->object, dm,
vertexCos, numVerts);
if (dm != derivedData)
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index ecaaa5781a8..ac1107395b0 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -99,30 +99,29 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Lattice Modifier");
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
LatticeModifierData *lmd = (LatticeModifierData *) md;
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
- lattice_deform_verts(lmd->object, ob, derivedData,
+ lattice_deform_verts(lmd->object, ctx->object, derivedData,
vertexCos, numVerts, lmd->name, lmd->strength);
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *depsgraph, Object *ob, struct BMEditMesh *em,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
if (!derivedData) dm = CDDM_from_editbmesh(em, false, false);
- deformVerts(md, depsgraph, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, ctx, dm, vertexCos, numVerts);
if (!derivedData) dm->release(dm);
}
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 9a375cecbb0..a94f0ecff02 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -90,11 +90,11 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
MaskModifierData *mmd = (MaskModifierData *)md;
+ Object *ob = ctx->object;
const bool found_test = (mmd->flag & MOD_MASK_INV) == 0;
DerivedMesh *result = NULL;
GHash *vertHash = NULL, *edgeHash, *polyHash;
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index ffd3dfb1abc..4eb37a4953c 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -272,24 +272,23 @@ static void meshcache_do(
}
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md;
- meshcache_do(mcmd, ob, derivedData, vertexCos, numVerts);
+ meshcache_do(mcmd, ctx->object, derivedData, vertexCos, numVerts);
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *UNUSED(editData),
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md;
- meshcache_do(mcmd, ob, derivedData, vertexCos, numVerts);
+ meshcache_do(mcmd, ctx->object, derivedData, vertexCos, numVerts);
}
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index d17aeafff4f..8b25d192f7f 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -409,31 +409,30 @@ static void meshdeformModifier_do(
cagedm->release(cagedm);
}
-static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
DerivedMesh *derivedData,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
- DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ DerivedMesh *dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
- meshdeformModifier_do(md, depsgraph, ob, dm, vertexCos, numVerts);
+ meshdeformModifier_do(md, ctx->depsgraph, ctx->object, dm, vertexCos, numVerts);
if (dm && dm != derivedData)
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
+static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx,
struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts)
{
- DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ DerivedMesh *dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
- meshdeformModifier_do(md, depsgraph, ob, dm, vertexCos, numVerts);
+ meshdeformModifier_do(md, ctx->depsgraph, ctx->object, dm, vertexCos, numVerts);
if (dm && dm != derivedData)
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index e95148eb6b2..8ca5873f85c 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -90,15 +90,14 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (mcmd->cache_file == NULL) || (mcmd->object_path[0] == '\0');
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
#ifdef WITH_ALEMBIC
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
/* Only used to check whether we are operating on org data or not... */
- Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
+ Mesh *me = (ctx->object->type == OB_MESH) ? ctx->object->data : NULL;
DerivedMesh *org_dm = dm;
Scene *scene = md->scene;
@@ -113,7 +112,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
if (!mcmd->reader) {
mcmd->reader = CacheReader_open_alembic_object(cache_file->handle,
NULL,
- ob,
+ ctx->object,
mcmd->object_path);
if (!mcmd->reader) {
modifier_setError(md, "Could not create Alembic reader for file %s", cache_file->filepath);
@@ -132,7 +131,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
}
DerivedMesh *result = ABC_read_mesh(mcmd->reader,
- ob,
+ ctx->object,
dm,
time,
&err_str,
@@ -150,7 +149,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
return result ? result : dm;
#else
return dm;
- UNUSED_VARS(md, ob);
+ UNUSED_VARS(ctx, md);
#endif
}
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index ff3d16a85be..5c5b8e4f11d 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -330,14 +330,13 @@ static Mesh *mirrorModifier__doMirror(MirrorModifierData *mmd,
return result;
}
-static Mesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, Mesh *mesh,
- ModifierApplyFlag UNUSED(flag))
+static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ Mesh *mesh)
{
Mesh *result;
MirrorModifierData *mmd = (MirrorModifierData *) md;
- result = mirrorModifier__doMirror(mmd, ob, mesh);
+ result = mirrorModifier__doMirror(mmd, ctx->object, mesh);
BKE_mesh_calc_normals(result);
return result;
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 392a2606b93..32b15f11116 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -67,14 +67,14 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
- DerivedMesh *dm, ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
MultiresModifierData *mmd = (MultiresModifierData *)md;
DerivedMesh *result;
- Mesh *me = (Mesh *)ob->data;
- const bool useRenderParams = (flag & MOD_APPLY_RENDER) != 0;
- const bool ignore_simplify = (flag & MOD_APPLY_IGNORE_SIMPLIFY) != 0;
+ Mesh *me = (Mesh *)ctx->object->data;
+ const bool useRenderParams = (ctx->flag & MOD_APPLY_RENDER) != 0;
+ const bool ignore_simplify = (ctx->flag & MOD_APPLY_IGNORE_SIMPLIFY) != 0;
MultiresFlags flags = 0;
const bool has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
@@ -94,12 +94,12 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
if (ignore_simplify)
flags |= MULTIRES_IGNORE_SIMPLIFY;
- result = multires_make_derived_from_derived(dm, mmd, ob, flags);
+ result = multires_make_derived_from_derived(dm, mmd, ctx->object, flags);
if (result == dm)
return dm;
- if (useRenderParams || !(flag & MOD_APPLY_USECACHE)) {
+ if (useRenderParams || !(ctx->flag & MOD_APPLY_USECACHE)) {
DerivedMesh *cddm;
cddm = CDDM_copy(result);
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 25151015b3b..e056dffc160 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -517,10 +517,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
- DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
- return normalEditModifier_do((NormalEditModifierData *)md, ob, dm);
+ return normalEditModifier_do((NormalEditModifierData *)md, ctx->object, dm);
}
ModifierTypeInfo modifierType_NormalEdit = {
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index e8d58ccef44..bff12a55558 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -555,13 +555,12 @@ static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob),
}
#endif /* WITH_OCEANSIM */
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
DerivedMesh *result;
- result = doOcean(md, ob, derivedData, 0);
+ result = doOcean(md, ctx->object, derivedData, 0);
if (result != derivedData)
result->dirty |= DM_DIRTY_NORMALS;
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 399a02bd69b..56f6fa57b51 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -202,9 +202,8 @@ static void store_float_in_vcol(MLoopCol *vcol, float float_value)
vcol->a = 1.0f;
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
DerivedMesh *dm = derivedData, *result;
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md;
@@ -217,7 +216,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
int totvert, totpoly, totloop /* , totedge */;
int maxvert, maxpoly, maxloop, part_end = 0, part_start;
int k, p, p_skip;
- short track = ob->trackflag % 3, trackneg, axis = pimd->axis;
+ short track = ctx->object->trackflag % 3, trackneg, axis = pimd->axis;
float max_co = 0.0, min_co = 0.0, temp_co[3];
float *size = NULL;
float spacemat[4][4];
@@ -225,9 +224,9 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
const bool use_children = pimd->flag & eParticleInstanceFlag_Children;
bool between;
- trackneg = ((ob->trackflag > 2) ? 1 : 0);
+ trackneg = ((ctx->object->trackflag > 2) ? 1 : 0);
- if (pimd->ob == ob) {
+ if (pimd->ob == ctx->object) {
pimd->ob = NULL;
return derivedData;
}
@@ -252,7 +251,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
if (part_end == 0)
return derivedData;
- sim.depsgraph = depsgraph;
+ sim.depsgraph = ctx->depsgraph;
sim.scene = md->scene;
sim.ob = pimd->ob;
sim.psys = psys;
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 71dcd9f6677..9ab3f9ae937 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -97,11 +97,10 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
/* saves the current emitter state for a particle system and calculates particles */
-static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int UNUSED(numVerts),
- ModifierApplyFlag flag)
+ int UNUSED(numVerts))
{
DerivedMesh *dm = derivedData;
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
@@ -109,16 +108,16 @@ static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph,
bool needsFree = false;
/* float cfra = BKE_scene_frame_get(md->scene); */ /* UNUSED */
- if (ob->particlesystem.first)
+ if (ctx->object->particlesystem.first)
psys = psmd->psys;
else
return;
- if (!psys_check_enabled(ob, psys, (flag & MOD_APPLY_RENDER) != 0))
+ if (!psys_check_enabled(ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0))
return;
if (dm == NULL) {
- dm = get_dm(ob, NULL, NULL, vertexCos, false, true);
+ dm = get_dm(ctx->object, NULL, NULL, vertexCos, false, true);
if (!dm)
return;
@@ -163,11 +162,11 @@ static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph,
if (!psmd->dm_final->deformedOnly) {
/* XXX Think we can assume here that if current DM is not only-deformed, ob->deformedOnly has been set.
* This is awfully weak though. :| */
- if (ob->derivedDeform) {
- psmd->dm_deformed = CDDM_copy(ob->derivedDeform);
+ if (ctx->object->derivedDeform) {
+ psmd->dm_deformed = CDDM_copy(ctx->object->derivedDeform);
}
else { /* Can happen in some cases, e.g. when rendering from Edit mode... */
- psmd->dm_deformed = CDDM_from_mesh((Mesh *)ob->data);
+ psmd->dm_deformed = CDDM_from_mesh((Mesh *)ctx->object->data);
}
DM_ensure_tessface(psmd->dm_deformed);
}
@@ -184,9 +183,9 @@ static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph,
psmd->totdmface = psmd->dm_final->getNumTessFaces(psmd->dm_final);
}
- if (!(ob->transflag & OB_NO_PSYS_UPDATE)) {
+ if (!(ctx->object->transflag & OB_NO_PSYS_UPDATE)) {
psmd->flag &= ~eParticleSystemFlag_psys_updated;
- particle_system_update(depsgraph, md->scene, ob, psys, (flag & MOD_APPLY_RENDER) != 0);
+ particle_system_update(ctx->depsgraph, md->scene, ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0);
psmd->flag |= eParticleSystemFlag_psys_updated;
}
}
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index 6c3688f113c..254b82f3968 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -143,10 +143,8 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4])
}
static DerivedMesh *applyModifier(ModifierData *md,
- struct Depsgraph *UNUSED(depsgraph),
- Object *UNUSED(ob),
- DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+ const ModifierEvalContext *UNUSED(ctx),
+ DerivedMesh *dm)
{
RemeshModifierData *rmd;
DualConOutput *output;
@@ -205,10 +203,8 @@ static DerivedMesh *applyModifier(ModifierData *md,
#else /* !WITH_MOD_REMESH */
static DerivedMesh *applyModifier(ModifierData *UNUSED(md),
- struct Depsgraph *UNUSED(depsgraph),
- Object *UNUSED(ob),
- DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+ const ModifierEvalContext *UNUSED(ctx),
+ DerivedMesh *derivedData)
{
return derivedData;
}
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index e53d11d9b01..6335c453955 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -184,14 +184,13 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
DerivedMesh *dm = derivedData;
DerivedMesh *result;
ScrewModifierData *ltmd = (ScrewModifierData *) md;
- const bool use_render_params = (flag & MOD_APPLY_RENDER) != 0;
+ const bool use_render_params = (ctx->flag & MOD_APPLY_RENDER) != 0;
int *origindex;
int mpoly_index = 0;
@@ -279,7 +278,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
if (ltmd->ob_axis) {
/* calc the matrix relative to the axis object */
- invert_m4_m4(mtx_tmp_a, ob->obmat);
+ invert_m4_m4(mtx_tmp_a, ctx->object->obmat);
copy_m4_m4(mtx_tx_inv, ltmd->ob_axis->obmat);
mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv);
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 7908b42c1f9..8c4664414d5 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -44,28 +44,27 @@
#include "MOD_modifiertypes.h"
-static void deformVerts(ModifierData *UNUSED(md), struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *UNUSED(derivedData),
+static void deformVerts(ModifierData *UNUSED(md), const ModifierEvalContext *ctx,
+ DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
- Key *key = BKE_key_from_object(ob);
+ Key *key = BKE_key_from_object(ctx->object);
if (key && key->block.first) {
int deformedVerts_tot;
BKE_key_evaluate_object_ex(
- ob, &deformedVerts_tot,
+ ctx->object, &deformedVerts_tot,
(float *)vertexCos, sizeof(*vertexCos) * numVerts);
}
}
-static void deformMatrices(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, DerivedMesh *derivedData,
+static void deformMatrices(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
- Key *key = BKE_key_from_object(ob);
- KeyBlock *kb = BKE_keyblock_from_object(ob);
+ Key *key = BKE_key_from_object(ctx->object);
+ KeyBlock *kb = BKE_keyblock_from_object(ctx->object);
float scale[3][3];
(void)vertexCos; /* unused */
@@ -73,37 +72,37 @@ static void deformMatrices(ModifierData *md, struct Depsgraph *depsgraph, Object
if (kb && kb->totelem == numVerts && kb != key->refkey) {
int a;
- if (ob->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1);
+ if (ctx->object->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1);
else scale_m3_fl(scale, kb->curval);
for (a = 0; a < numVerts; a++)
copy_m3_m3(defMats[a], scale);
}
- deformVerts(md, depsgraph, ob, derivedData, vertexCos, numVerts, 0);
+ deformVerts(md, ctx, derivedData, vertexCos, numVerts);
}
-static void deformVertsEM(ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
+static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx,
struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts)
{
- Key *key = BKE_key_from_object(ob);
+ Key *key = BKE_key_from_object(ctx->object);
if (key && key->type == KEY_RELATIVE)
- deformVerts(md, depsgraph, ob, derivedData, vertexCos, numVerts, 0);
+ deformVerts(md, ctx, derivedData, vertexCos, numVerts);
}
-static void deformMatricesEM(ModifierData *UNUSED(md), struct Depsgraph *UNUSED(depsgraph),
- Object *ob, struct BMEditMesh *UNUSED(editData),
+static void deformMatricesEM(ModifierData *UNUSED(md), const ModifierEvalContext *ctx,
+ struct BMEditMesh *UNUSED(editData),
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
float (*defMats)[3][3],
int numVerts)
{
- Key *key = BKE_key_from_object(ob);
- KeyBlock *kb = BKE_keyblock_from_object(ob);
+ Key *key = BKE_key_from_object(ctx->object);
+ KeyBlock *kb = BKE_keyblock_from_object(ctx->object);
float scale[3][3];
(void)vertexCos; /* unused */
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 1ca8d573e8f..1e5f78bdbce 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -103,40 +103,39 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk,
walk(userData, ob, &smd->auxTarget, IDWALK_CB_NOP);
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag flag)
+ int numVerts)
{
DerivedMesh *dm = derivedData;
- CustomDataMask dataMask = requiredDataMask(ob, md);
- bool forRender = (flag & MOD_APPLY_RENDER) != 0;
+ CustomDataMask dataMask = requiredDataMask(ctx->object, md);
+ bool forRender = (ctx->flag & MOD_APPLY_RENDER) != 0;
/* ensure we get a CDDM with applied vertex coords */
if (dataMask) {
- dm = get_cddm(ob, NULL, dm, vertexCos, dependsOnNormals(md));
+ dm = get_cddm(ctx->object, NULL, dm, vertexCos, dependsOnNormals(md));
}
- shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts, forRender);
+ shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ctx->object, dm, vertexCos, numVerts, forRender);
if (dm != derivedData)
dm->release(dm);
}
-static void deformVertsEM(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
+static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx,
struct BMEditMesh *editData, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
- CustomDataMask dataMask = requiredDataMask(ob, md);
+ CustomDataMask dataMask = requiredDataMask(ctx->object, md);
/* ensure we get a CDDM with applied vertex coords */
if (dataMask) {
- dm = get_cddm(ob, editData, dm, vertexCos, dependsOnNormals(md));
+ dm = get_cddm(ctx->object, editData, dm, vertexCos, dependsOnNormals(md));
}
- shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts, false);
+ shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ctx->object, dm, vertexCos, numVerts, false);
if (dm != derivedData)
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index efe11ea7d9a..eec1cde3889 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -384,22 +384,21 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, struct Mesh *mesh,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ struct Mesh *mesh,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
- SimpleDeformModifier_do((SimpleDeformModifierData *)md, ob, mesh, vertexCos, numVerts);
+ SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh, vertexCos, numVerts);
}
-static void deformVertsEM(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, struct BMEditMesh *UNUSED(editData),
+static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *UNUSED(editData),
struct Mesh *mesh,
float (*vertexCos)[3],
int numVerts)
{
- SimpleDeformModifier_do((SimpleDeformModifierData *)md, ob, mesh, vertexCos, numVerts);
+ SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh, vertexCos, numVerts);
}
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 6415f64bd51..0055be3787b 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1917,10 +1917,8 @@ static void copyData(ModifierData *md, ModifierData *target)
}
static DerivedMesh *applyModifier(ModifierData *md,
- struct Depsgraph *UNUSED(depsgraph),
- Object *UNUSED(ob),
- DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+ const ModifierEvalContext *UNUSED(ctx),
+ DerivedMesh *dm)
{
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index e5875f6c637..d78d1277374 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -102,16 +102,15 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static DerivedMesh *applyModifier(ModifierData *md, Depsgraph *depsgraph,
- Object *ob, DerivedMesh *dm,
- ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
SmokeModifierData *smd = (SmokeModifierData *) md;
- if (flag & MOD_APPLY_ORCO)
+ if (ctx->flag & MOD_APPLY_ORCO)
return dm;
- return smokeModifier_do(smd, depsgraph, md->scene, ob, dm);
+ return smokeModifier_do(smd, ctx->depsgraph, md->scene, ctx->object, dm);
}
static bool dependsOnTime(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 34b44353e1d..b905e0f8118 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -215,12 +215,12 @@ static void smoothModifier_do(
MEM_freeN(uctmp);
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ DerivedMesh *dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
- smoothModifier_do((SmoothModifierData *)md, ob, dm,
+ smoothModifier_do((SmoothModifierData *)md, ctx->object, dm,
vertexCos, numVerts);
if (dm != derivedData)
@@ -228,12 +228,12 @@ static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), O
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
+ DerivedMesh *dm = get_dm(ctx->object, editData, derivedData, NULL, false, false);
- smoothModifier_do((SmoothModifierData *)md, ob, dm,
+ smoothModifier_do((SmoothModifierData *)md, ctx->object, dm,
vertexCos, numVerts);
if (dm != derivedData)
diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c
index 5f545e27f96..885c355254d 100644
--- a/source/blender/modifiers/intern/MOD_softbody.c
+++ b/source/blender/modifiers/intern/MOD_softbody.c
@@ -49,13 +49,12 @@
#include "MOD_modifiertypes.h"
-static void deformVerts(ModifierData *md, Depsgraph *depsgraph, Object *ob,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
- sbObjectStep(depsgraph, md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts);
+ sbObjectStep(ctx->depsgraph, md->scene, ctx->object, (float)md->scene->r.cfra, vertexCos, numVerts);
}
static bool dependsOnTime(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 86a37dfbd2d..d947ba139ed 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -205,9 +205,8 @@ BLI_INLINE void madd_v3v3short_fl(float r[3], const short a[3], const float f)
}
static DerivedMesh *applyModifier(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+ ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
DerivedMesh *result;
const SolidifyModifierData *smd = (SolidifyModifierData *) md;
@@ -223,7 +222,7 @@ static DerivedMesh *applyModifier(
unsigned int newLoops = 0, newFaces = 0, newEdges = 0, newVerts = 0, rimVerts = 0;
/* only use material offsets if we have 2 or more materials */
- const short mat_nr_max = ob->totcol > 1 ? ob->totcol - 1 : 0;
+ const short mat_nr_max = ctx->object->totcol > 1 ? ctx->object->totcol - 1 : 0;
const short mat_ofs = mat_nr_max ? smd->mat_ofs : 0;
const short mat_ofs_rim = mat_nr_max ? smd->mat_ofs_rim : 0;
@@ -261,7 +260,7 @@ static DerivedMesh *applyModifier(
/* array size is doubled in case of using a shell */
const unsigned int stride = do_shell ? 2 : 1;
- modifier_get_vgroup(ob, dm, smd->defgrp_name, &dvert, &defgrp_index);
+ modifier_get_vgroup(ctx->object, dm, smd->defgrp_name, &dvert, &defgrp_index);
orig_mvert = dm->getVertArray(dm);
orig_medge = dm->getEdgeArray(dm);
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 830c564b1e6..aea3aee8655 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -98,18 +98,17 @@ static bool isDisabled(ModifierData *md, int useRenderParams)
return get_render_subsurf_level(&md->scene->r, levels, useRenderParams != 0) == 0;
}
-static DerivedMesh *applyModifier(ModifierData *md, Depsgraph *depsgraph,
- Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
SubsurfModifierData *smd = (SubsurfModifierData *) md;
SubsurfFlags subsurf_flags = 0;
DerivedMesh *result;
- const bool useRenderParams = (flag & MOD_APPLY_RENDER) != 0;
- const bool isFinalCalc = (flag & MOD_APPLY_USECACHE) != 0;
+ const bool useRenderParams = (ctx->flag & MOD_APPLY_RENDER) != 0;
+ const bool isFinalCalc = (ctx->flag & MOD_APPLY_USECACHE) != 0;
#ifdef WITH_OPENSUBDIV
- const bool allow_gpu = (flag & MOD_APPLY_ALLOW_GPU) != 0;
+ const bool allow_gpu = (ctx->flag & MOD_APPLY_ALLOW_GPU) != 0;
#endif
bool do_cddm_convert = useRenderParams || !isFinalCalc;
@@ -117,7 +116,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Depsgraph *depsgraph,
subsurf_flags |= SUBSURF_USE_RENDER_PARAMS;
if (isFinalCalc)
subsurf_flags |= SUBSURF_IS_FINAL_CALC;
- if (ob->mode & OB_MODE_EDIT)
+ if (ctx->object->mode & OB_MODE_EDIT)
subsurf_flags |= SUBSURF_IN_EDIT_MODE;
#ifdef WITH_OPENSUBDIV
@@ -132,10 +131,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Depsgraph *depsgraph,
if (U.opensubdiv_compute_type == USER_OPENSUBDIV_COMPUTE_NONE) {
modifier_setError(md, "OpenSubdiv is disabled in User Preferences");
}
- else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
+ else if ((ctx->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
modifier_setError(md, "OpenSubdiv is not supported in paint modes");
}
- else if ((DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
+ else if ((DEG_get_eval_flags_for_id(ctx->depsgraph, &ctx->object->id) & DAG_EVAL_NEED_CPU) == 0) {
subsurf_flags |= SUBSURF_USE_GPU_BACKEND;
do_cddm_convert = false;
}
@@ -156,24 +155,22 @@ static DerivedMesh *applyModifier(ModifierData *md, Depsgraph *depsgraph,
#ifndef WITH_OPESUBDIV
(void) do_cddm_convert;
- UNUSED_VARS(depsgraph);
#endif
return result;
}
static DerivedMesh *applyModifierEM(
- ModifierData *md, Depsgraph *UNUSED(depsgraph),
- Object *UNUSED(ob), struct BMEditMesh *UNUSED(editData),
- DerivedMesh *derivedData,
- ModifierApplyFlag flag)
+ ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *UNUSED(editData),
+ DerivedMesh *derivedData)
{
SubsurfModifierData *smd = (SubsurfModifierData *) md;
DerivedMesh *result;
/* 'orco' using editmode flags would cause cache to be used twice in editbmesh_calc_modifiers */
- SubsurfFlags ss_flags = (flag & MOD_APPLY_ORCO) ? 0 : (SUBSURF_FOR_EDIT_MODE | SUBSURF_IN_EDIT_MODE);
+ SubsurfFlags ss_flags = (ctx->flag & MOD_APPLY_ORCO) ? 0 : (SUBSURF_FOR_EDIT_MODE | SUBSURF_IN_EDIT_MODE);
#ifdef WITH_OPENSUBDIV
- const bool allow_gpu = (flag & MOD_APPLY_ALLOW_GPU) != 0;
+ const bool allow_gpu = (ctx->flag & MOD_APPLY_ALLOW_GPU) != 0;
if (md->next == NULL && allow_gpu && smd->use_opensubdiv) {
modifier_setError(md, "OpenSubdiv is not supported in edit mode");
}
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index 8d6fafd5ab6..8bae5c3e6bc 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -85,11 +85,10 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
return true;
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int UNUSED(numVerts),
- ModifierApplyFlag UNUSED(flag))
+ int UNUSED(numVerts))
{
SurfaceModifierData *surmd = (SurfaceModifierData *) md;
@@ -98,9 +97,9 @@ static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
/* if possible use/create DerivedMesh */
if (derivedData) surmd->dm = CDDM_copy(derivedData);
- else surmd->dm = get_dm(ob, NULL, NULL, NULL, false, false);
+ else surmd->dm = get_dm(ctx->object, NULL, NULL, NULL, false, false);
- if (!ob->pd) {
+ if (!ctx->object->pd) {
printf("SurfaceModifier deformVerts: Should not happen!\n");
return;
}
@@ -141,7 +140,7 @@ static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
/* convert to global coordinates and calculate velocity */
for (i = 0, x = surmd->x, v = surmd->v; i < numverts; i++, x++, v++) {
vec = CDDM_get_vert(surmd->dm, i)->co;
- mul_m4_v3(ob->obmat, vec);
+ mul_m4_v3(ctx->object->obmat, vec);
if (init)
v->co[0] = v->co[1] = v->co[2] = 0.0f;
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 8616a8084cb..317bf3d8d20 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1181,21 +1181,20 @@ static void surfacedeformModifier_do(
}
static void deformVerts(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *UNUSED(derivedData),
- float (*vertexCos)[3], int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *UNUSED(derivedData),
+ float (*vertexCos)[3], int numVerts)
{
- surfacedeformModifier_do(md, vertexCos, numVerts, ob);
+ surfacedeformModifier_do(md, vertexCos, numVerts, ctx->object);
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, struct BMEditMesh *UNUSED(editData),
+ ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *UNUSED(editData),
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3], int numVerts)
{
- surfacedeformModifier_do(md, vertexCos, numVerts, ob);
+ surfacedeformModifier_do(md, vertexCos, numVerts, ctx->object);
}
static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index ed101a8874d..349897f2be6 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -85,10 +85,8 @@ static void copyData(ModifierData *md, ModifierData *target)
}
static DerivedMesh *applyModifier(ModifierData *md,
- struct Depsgraph *UNUSED(depsgraph),
- Object *UNUSED(ob),
- DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+ const ModifierEvalContext *UNUSED(ctx),
+ DerivedMesh *dm)
{
TriangulateModifierData *tmd = (TriangulateModifierData *)md;
DerivedMesh *result;
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 9c7f8832d4c..620d3c34584 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -316,14 +316,13 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
return dm;
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
DerivedMesh *result;
UVProjectModifierData *umd = (UVProjectModifierData *) md;
- result = uvprojectModifier_do(umd, ob, derivedData);
+ result = uvprojectModifier_do(umd, ctx->object, derivedData);
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 09e46748127..7ea2d6ad3b3 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -146,9 +146,8 @@ static void uv_warp_compute(
}
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *dm,
- ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
UVWarpModifierData *umd = (UVWarpModifierData *) md;
int numPolys, numLoops;
@@ -206,7 +205,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
mloop = dm->getLoopArray(dm);
/* make sure we are not modifying the original UV map */
mloopuv = CustomData_duplicate_referenced_layer_named(&dm->loopData, CD_MLOOPUV, uvname, numLoops);
- modifier_get_vgroup(ob, dm, umd->vgroup_name, &dvert, &defgrp_index);
+ modifier_get_vgroup(ctx->object, dm, umd->vgroup_name, &dvert, &defgrp_index);
UVWarpData data = {.mpoly = mpoly, .mloop = mloop, .mloopuv = mloopuv,
.dvert = dvert, .defgrp_index = defgrp_index,
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 6350cb2b049..f4ec7686a22 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -309,24 +309,24 @@ static int warp_needs_dm(WarpModifierData *wmd)
return wmd->texture || wmd->defgrp_name[0];
}
-static void deformVerts(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob, DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
+ float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = NULL;
int use_dm = warp_needs_dm((WarpModifierData *)md);
if (use_dm) {
- dm = get_cddm(ob, NULL, derivedData, vertexCos, false);
+ dm = get_cddm(ctx->object, NULL, derivedData, vertexCos, false);
}
- warpModifier_do((WarpModifierData *)md, ob, dm, vertexCos, numVerts);
+ warpModifier_do((WarpModifierData *)md, ctx->object, dm, vertexCos, numVerts);
if (use_dm) {
if (dm != derivedData) dm->release(dm);
}
}
-static void deformVertsEM(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, struct BMEditMesh *em,
+static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
@@ -337,7 +337,7 @@ static void deformVertsEM(ModifierData *md, struct Depsgraph *depsgraph, Object
dm = CDDM_from_editbmesh(em, false, false);
}
- deformVerts(md, depsgraph, ob, dm, vertexCos, numVerts, 0);
+ deformVerts(md, ctx, dm, vertexCos, numVerts);
if (use_dm) {
if (!derivedData) dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index e3bed600349..c5af7755578 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -302,40 +302,39 @@ static void waveModifier_do(WaveModifierData *md,
if (wmd->texture) MEM_freeN(tex_co);
}
-static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData,
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
DerivedMesh *dm = derivedData;
WaveModifierData *wmd = (WaveModifierData *)md;
if (wmd->flag & MOD_WAVE_NORM)
- dm = get_cddm(ob, NULL, dm, vertexCos, false);
+ dm = get_cddm(ctx->object, NULL, dm, vertexCos, false);
else if (wmd->texture || wmd->defgrp_name[0])
- dm = get_dm(ob, NULL, dm, NULL, false, false);
+ dm = get_dm(ctx->object, NULL, dm, NULL, false, false);
- waveModifier_do(wmd, depsgraph, ob, dm, vertexCos, numVerts);
+ waveModifier_do(wmd, ctx->depsgraph, ctx->object, dm, vertexCos, numVerts);
if (dm != derivedData)
dm->release(dm);
}
static void deformVertsEM(
- ModifierData *md, struct Depsgraph *depsgraph,
- Object *ob, struct BMEditMesh *editData,
+ ModifierData *md, const ModifierEvalContext *ctx,
+ struct BMEditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
WaveModifierData *wmd = (WaveModifierData *)md;
if (wmd->flag & MOD_WAVE_NORM)
- dm = get_cddm(ob, editData, dm, vertexCos, false);
+ dm = get_cddm(ctx->object, editData, dm, vertexCos, false);
else if (wmd->texture || wmd->defgrp_name[0])
- dm = get_dm(ob, editData, dm, NULL, false, false);
+ dm = get_dm(ctx->object, editData, dm, NULL, false, false);
- waveModifier_do(wmd, depsgraph, ob, dm, vertexCos, numVerts);
+ waveModifier_do(wmd, ctx->depsgraph, ctx->object, dm, vertexCos, numVerts);
if (dm != derivedData)
dm->release(dm);
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index e85ecb75cbd..1a9651909dd 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -155,10 +155,8 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
}
static DerivedMesh *applyModifier(ModifierData *md,
- struct Depsgraph *UNUSED(depsgraph),
- Object *ob,
- DerivedMesh *derivedData,
- ModifierApplyFlag UNUSED(flag))
+ const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md;
DerivedMesh *dm = derivedData;
@@ -183,11 +181,11 @@ static DerivedMesh *applyModifier(ModifierData *md,
/* Check if we can just return the original mesh.
* Must have verts and therefore verts assigned to vgroups to do anything useful!
*/
- if ((numVerts == 0) || BLI_listbase_is_empty(&ob->defbase))
+ if ((numVerts == 0) || BLI_listbase_is_empty(&ctx->object->defbase))
return dm;
/* Get vgroup idx from its name. */
- defgrp_index = defgroup_name_index(ob, wmd->defgrp_name);
+ defgrp_index = defgroup_name_index(ctx->object, wmd->defgrp_name);
if (defgrp_index == -1)
return dm;
@@ -223,7 +221,7 @@ static DerivedMesh *applyModifier(ModifierData *md,
RNG *rng = NULL;
if (wmd->falloff_type == MOD_WVG_MAPPING_RANDOM)
- rng = BLI_rng_new_srandom(BLI_ghashutil_strhash(ob->id.name + 2));
+ rng = BLI_rng_new_srandom(BLI_ghashutil_strhash(ctx->object->id.name + 2));
weightvg_do_map(numVerts, new_w, wmd->falloff_type, wmd->cmap_curve, rng);
@@ -232,7 +230,7 @@ static DerivedMesh *applyModifier(ModifierData *md,
}
/* Do masking. */
- weightvg_do_mask(numVerts, NULL, org_w, new_w, ob, dm, wmd->mask_constant,
+ weightvg_do_mask(numVerts, NULL, org_w, new_w, ctx->object, dm, wmd->mask_constant,
wmd->mask_defgrp_name, wmd->modifier.scene, wmd->mask_texture,
wmd->mask_tex_use_channel, wmd->mask_tex_mapping,
wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name);
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index f14aba2f80e..9f32d5c6e30 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -201,8 +201,8 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (wmd->defgrp_name_a[0] == '\0');
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
- DerivedMesh *derivedData, ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md;
DerivedMesh *dm = derivedData;
@@ -226,16 +226,16 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
/* Check if we can just return the original mesh.
* Must have verts and therefore verts assigned to vgroups to do anything useful!
*/
- if ((numVerts == 0) || BLI_listbase_is_empty(&ob->defbase))
+ if ((numVerts == 0) || BLI_listbase_is_empty(&ctx->object->defbase))
return dm;
/* Get vgroup idx from its name. */
- defgrp_index = defgroup_name_index(ob, wmd->defgrp_name_a);
+ defgrp_index = defgroup_name_index(ctx->object, wmd->defgrp_name_a);
if (defgrp_index == -1)
return dm;
/* Get second vgroup idx from its name, if given. */
if (wmd->defgrp_name_b[0] != (char)0) {
- defgrp_index_other = defgroup_name_index(ob, wmd->defgrp_name_b);
+ defgrp_index_other = defgroup_name_index(ctx->object, wmd->defgrp_name_b);
if (defgrp_index_other == -1)
return dm;
}
@@ -352,7 +352,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
}
/* Do masking. */
- weightvg_do_mask(numIdx, indices, org_w, new_w, ob, dm, wmd->mask_constant,
+ weightvg_do_mask(numIdx, indices, org_w, new_w, ctx->object, dm, wmd->mask_constant,
wmd->mask_defgrp_name, wmd->modifier.scene, wmd->mask_texture,
wmd->mask_tex_use_channel, wmd->mask_tex_mapping,
wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name);
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index c3d19c38dee..7c94d555106 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -368,8 +368,8 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (wmd->proximity_ob_target == NULL);
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
- DerivedMesh *derivedData, ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *derivedData)
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md;
DerivedMesh *dm = derivedData;
@@ -377,6 +377,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
MDeformWeight **dw, **tdw;
int numVerts;
float (*v_cos)[3] = NULL; /* The vertices coordinates. */
+ Object *ob = ctx->object;
Object *obr = NULL; /* Our target object. */
int defgrp_index;
float *tw = NULL;
@@ -400,7 +401,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(dep
/* Check if we can just return the original mesh.
* Must have verts and therefore verts assigned to vgroups to do anything useful!
*/
- if ((numVerts == 0) || BLI_listbase_is_empty(&ob->defbase))
+ if ((numVerts == 0) || BLI_listbase_is_empty(&ctx->object->defbase))
return dm;
/* Get our target object. */
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index d49411343eb..f50b1446dc2 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -102,10 +102,10 @@ static DerivedMesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob,
}
-static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *UNUSED(depsgraph), Object *ob,
- DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+ DerivedMesh *dm)
{
- return WireframeModifier_do((WireframeModifierData *)md, ob, dm);
+ return WireframeModifier_do((WireframeModifierData *)md, ctx->object, dm);
}