From 5eca59cf0d05fd8063eb83ad80b2caf9c5eacedc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 10 Apr 2012 14:11:45 +0000 Subject: Fix #30882: using an image sequence in the displace modifier did not update properly in animation rendering. --- source/blender/modifiers/intern/MOD_displace.c | 2 ++ source/blender/modifiers/intern/MOD_util.c | 16 ++++++++++++++-- source/blender/modifiers/intern/MOD_util.h | 1 + source/blender/modifiers/intern/MOD_warp.c | 2 ++ source/blender/modifiers/intern/MOD_wave.c | 2 ++ source/blender/modifiers/intern/MOD_weightvg_util.c | 5 ++++- source/blender/modifiers/intern/MOD_weightvg_util.h | 7 ++++--- source/blender/modifiers/intern/MOD_weightvgedit.c | 5 +++-- source/blender/modifiers/intern/MOD_weightvgmix.c | 5 +++-- source/blender/modifiers/intern/MOD_weightvgproximity.c | 5 +++-- 10 files changed, 38 insertions(+), 12 deletions(-) (limited to 'source/blender/modifiers/intern') diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index f3d7a24e517..293a8a8c686 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -187,6 +187,8 @@ static void displaceModifier_do( "displaceModifier_do tex_co"); get_texture_coords((MappingInfoModifierData *)dmd, ob, dm, vertexCos, tex_co, numVerts); + modifier_init_texture(dmd->modifier.scene, dmd->texture); + for (i = 0; i < numVerts; ++i) { TexResult texres; float delta = 0, strength = dmd->strength; diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 17ff4dd1842..e134ff9dcca 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -32,11 +32,13 @@ #include +#include "DNA_curve_types.h" +#include "DNA_image_types.h" #include "DNA_lattice_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "DNA_curve_types.h" -#include "DNA_meshdata_types.h" +#include "DNA_scene_types.h" #include "BLI_utildefines.h" #include "BLI_math_vector.h" @@ -44,6 +46,7 @@ #include "BKE_cdderivedmesh.h" #include "BKE_deform.h" +#include "BKE_image.h" #include "BKE_lattice.h" #include "BKE_mesh.h" #include "BKE_displist.h" @@ -57,6 +60,15 @@ #include "RE_shader_ext.h" +void modifier_init_texture(Scene *scene, Tex *tex) +{ + if (!tex) + return; + + if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) + BKE_image_user_calc_frame(&tex->iuser, scene->r.cfra, 0); +} + void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) { int result_type; diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h index 8641afcb481..eadf7af553b 100644 --- a/source/blender/modifiers/intern/MOD_util.h +++ b/source/blender/modifiers/intern/MOD_util.h @@ -40,6 +40,7 @@ struct Scene; struct Tex; struct TexResult; +void modifier_init_texture(struct Scene *scene, struct Tex *texture); void get_texture_value(struct Tex *texture, float *tex_co, struct TexResult *texres); void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm, float (*co)[3], float (*texco)[3], int numVerts); void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]); diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index a318d9b68af..dd89ad59abd 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -222,6 +222,8 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, if (wmd->texture) { tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, "warpModifier_do tex_co"); get_texture_coords((MappingInfoModifierData *)wmd, ob, dm, vertexCos, tex_co, numVerts); + + modifier_init_texture(wmd->modifier.scene, wmd->texture); } for (i = 0; i < numVerts; i++) { diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 87c0df3e12f..78e76e27c02 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -221,6 +221,8 @@ static void waveModifier_do(WaveModifierData *md, tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, "waveModifier_do tex_co"); get_texture_coords((MappingInfoModifierData *)wmd, ob, dm, vertexCos, tex_co, numVerts); + + modifier_init_texture(wmd->modifier.scene, wmd->texture); } if (lifefac != 0.0f) { diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 47a2aeaf4a2..fad83286d8e 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -38,6 +38,7 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BKE_cdderivedmesh.h" #include "BKE_colortools.h" /* CurveMapping. */ @@ -113,7 +114,7 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm */ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *new_w, Object *ob, DerivedMesh *dm, float fact, const char defgrp_name[MAX_VGROUP_NAME], - Tex *texture, int tex_use_channel, int tex_mapping, + Scene *scene, Tex *texture, int tex_use_channel, int tex_mapping, Object *tex_map_object, const char *tex_uvlayer_name) { int ref_didx; @@ -145,6 +146,8 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne get_texture_coords(&t_map, ob, dm, v_co, tex_co, num); MEM_freeN(v_co); + modifier_init_texture(scene, texture); + /* For each weight (vertex), make the mix between org and new weights. */ for (i = 0; i < num; ++i) { int idx = indices ? indices[i] : i; diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h index 57ba115c04e..209b784d573 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.h +++ b/source/blender/modifiers/intern/MOD_weightvg_util.h @@ -39,6 +39,7 @@ struct CurveMapping; struct DerivedMesh; struct Object; struct Tex; +struct Scene; /* * XXX I'd like to make modified weights visible in WeightPaint mode, @@ -73,9 +74,9 @@ void weightvg_do_map(int num, float *new_w, short mode, struct CurveMapping *cma * XXX The standard "factor" value is assumed in [0.0, 1.0] range. Else, weird results might appear. */ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *new_w, Object *ob, - DerivedMesh *dm, float fact, const char defgrp_name[MAX_VGROUP_NAME], Tex *texture, - int tex_use_channel, int tex_mapping, Object *tex_map_object, - const char *tex_uvlayer_name); + DerivedMesh *dm, float fact, const char defgrp_name[MAX_VGROUP_NAME], + struct Scene *scene, Tex *texture, int tex_use_channel, int tex_mapping, + Object *tex_map_object, const char *tex_uvlayer_name); /* Applies weights to given vgroup (defgroup), and optionally add/remove vertices from the group. * If indices is not NULL, it must be a table of same length as weights, mapping to the real diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index d6bcca5524a..b8961870043 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -243,8 +243,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Do masking. */ weightvg_do_mask(numVerts, NULL, org_w, new_w, ob, dm, wmd->mask_constant, - wmd->mask_defgrp_name, wmd->mask_texture, wmd->mask_tex_use_channel, - wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); + 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); /* Update/add/remove from vgroup. */ weightvg_update_vg(dvert, defgrp_idx, dw, numVerts, NULL, org_w, do_add, wmd->add_threshold, diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index cf4f9b31a7f..b7bbc717981 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -370,8 +370,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Do masking. */ weightvg_do_mask(numIdx, indices, org_w, new_w, ob, dm, wmd->mask_constant, - wmd->mask_defgrp_name, wmd->mask_texture, wmd->mask_tex_use_channel, - wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); + 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); /* Update (add to) vgroup. * XXX Depending on the MOD_WVG_SET_xxx option chosen, we might have to add vertices to vgroup. diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 241fcd05eab..bcfdced4ffd 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -504,8 +504,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Do masking. */ weightvg_do_mask(numIdx, indices, org_w, new_w, ob, dm, wmd->mask_constant, - wmd->mask_defgrp_name, wmd->mask_texture, wmd->mask_tex_use_channel, - wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); + 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); /* Update vgroup. Note we never add nor remove vertices from vgroup here. */ weightvg_update_vg(dvert, defgrp_idx, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f); -- cgit v1.2.3