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:
authorBastien Montagne <montagne29@wanadoo.fr>2018-12-07 17:45:53 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-12-07 20:55:08 +0300
commitde491abf996281785391b18b3547d1bff305355f (patch)
tree9f6f13c1a48658353f2c4a5ea4885f324daf1b95 /source/blender/modifiers/intern/MOD_wave.c
parent38ef3d6b91e128c93557991cb8cb9911c9b21f90 (diff)
Fix modifiers evaluation outside of depsgraph/CoW context.
Fix T58237: Exporters: Curve Modifier not applied when "apply modifiers" are selected. Fix T58856: Python: "to_mesh" broken in 2.8. ...And many other cases... ;) Thing is, we need target IDs to always be evaluated ones (at least I cannot see any case where having orig ones is desired effect here). Depsgraph/Cow system ensures us that when modifiers are evaluated by it, but they can also be called outside of this context, e.g. when doing binding, or object conversion... So we need to ensure in modifiers code that we actually are always working with eval data for those targets. Note that I did not touch to physics modifiers, those are a bit touchy and rather not 'fix' something there until proven broken!
Diffstat (limited to 'source/blender/modifiers/intern/MOD_wave.c')
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index f6192d645e9..cc3035d3d9b 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -157,7 +157,7 @@ static bool dependsOnNormals(ModifierData *md)
static void waveModifier_do(
WaveModifierData *md,
- Depsgraph *depsgraph,
+ const ModifierEvalContext *ctx,
Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
@@ -165,7 +165,7 @@ static void waveModifier_do(
MVert *mvert = NULL;
MDeformVert *dvert;
int defgrp_index;
- float ctime = DEG_get_ctime(depsgraph);
+ float ctime = DEG_get_ctime(ctx->depsgraph);
float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
float lifefac = wmd->height;
float (*tex_co)[3] = NULL;
@@ -177,11 +177,11 @@ static void waveModifier_do(
mvert = mesh->mvert;
}
- if (wmd->objectcenter) {
+ if (wmd->objectcenter != NULL) {
float mat[4][4];
/* get the control object's location in local coordinates */
invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat);
+ mul_m4_m4m4(mat, ob->imat, DEG_get_evaluated_object(ctx->depsgraph, wmd->objectcenter)->obmat);
wmd->startx = mat[3][0];
wmd->starty = mat[3][1];
@@ -205,11 +205,12 @@ static void waveModifier_do(
}
}
- if (mesh != NULL && wmd->texture) {
+ Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &wmd->texture->id);
+ if (mesh != NULL && tex_target != NULL) {
tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "waveModifier_do tex_co");
- MOD_get_texture_coords((MappingInfoModifierData *)wmd, ob, mesh, vertexCos, tex_co);
+ MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co);
- MOD_init_texture(depsgraph, wmd->texture);
+ MOD_init_texture((MappingInfoModifierData *)wmd, ctx);
}
if (lifefac != 0.0f) {
@@ -279,11 +280,11 @@ static void waveModifier_do(
amplit = (float)(1.0f / expf(amplit * amplit) - minfac);
/*apply texture*/
- if (wmd->texture) {
- Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ if (tex_target) {
+ Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
TexResult texres;
texres.nor = NULL;
- BKE_texture_get_value(scene, wmd->texture, tex_co[i], &texres, false);
+ BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false);
amplit *= texres.tin;
}
@@ -329,7 +330,7 @@ static void deformVerts(
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
}
- waveModifier_do(wmd, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts);
+ waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
@@ -351,7 +352,7 @@ static void deformVertsEM(
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
}
- waveModifier_do(wmd, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts);
+ waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);