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_displace.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_displace.c')
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 1da1897bfce..7cad6af6d34 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -171,6 +171,7 @@ typedef struct DisplaceUserdata {
int defgrp_index;
int direction;
bool use_global_direction;
+ Tex *tex_target;
float (*tex_co)[3];
float (*vertexCos)[3];
float local_mat[4][4];
@@ -209,9 +210,9 @@ static void displaceModifier_do_task(
}
}
- if (dmd->texture) {
+ if (data->tex_target) {
texres.nor = NULL;
- BKE_texture_get_value_ex(data->scene, dmd->texture, tex_co[iter], &texres, data->pool, false);
+ BKE_texture_get_value_ex(data->scene, data->tex_target, tex_co[iter], &texres, data->pool, false);
delta = texres.tin - dmd->midlevel;
}
else {
@@ -282,7 +283,6 @@ static void displaceModifier_do(
Mesh *mesh, float (*vertexCos)[3], const int numVerts)
{
Object *ob = ctx->object;
- Depsgraph *depsgraph = ctx->depsgraph;
MVert *mvert;
MDeformVert *dvert;
int direction = dmd->direction;
@@ -293,18 +293,19 @@ static void displaceModifier_do(
float local_mat[4][4] = {{0}};
const bool use_global_direction = dmd->space == MOD_DISP_SPACE_GLOBAL;
- if (!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) return;
+ if (dmd->texture == NULL && dmd->direction == MOD_DISP_DIR_RGB_XYZ) return;
if (dmd->strength == 0.0f) return;
mvert = mesh->mvert;
MOD_get_vgroup(ob, mesh, dmd->defgrp_name, &dvert, &defgrp_index);
- if (dmd->texture) {
+ Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &dmd->texture->id);
+ if (tex_target != NULL) {
tex_co = MEM_calloc_arrayN((size_t)numVerts, sizeof(*tex_co),
"displaceModifier_do tex_co");
- MOD_get_texture_coords((MappingInfoModifierData *)dmd, ob, mesh, vertexCos, tex_co);
+ MOD_get_texture_coords((MappingInfoModifierData *)dmd, ctx, ob, mesh, vertexCos, tex_co);
- MOD_init_texture(depsgraph, dmd->texture);
+ MOD_init_texture((MappingInfoModifierData *)dmd, ctx);
}
else {
tex_co = NULL;
@@ -343,14 +344,15 @@ static void displaceModifier_do(
data.defgrp_index = defgrp_index;
data.direction = direction;
data.use_global_direction = use_global_direction;
+ data.tex_target = tex_target;
data.tex_co = tex_co;
data.vertexCos = vertexCos;
copy_m4_m4(data.local_mat, local_mat);
data.mvert = mvert;
data.vert_clnors = vert_clnors;
- if (dmd->texture != NULL) {
+ if (tex_target != NULL) {
data.pool = BKE_image_pool_new();
- BKE_texture_fetch_images_for_pool(dmd->texture, data.pool);
+ BKE_texture_fetch_images_for_pool(tex_target, data.pool);
}
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);