diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-14 14:37:51 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-14 14:37:51 +0300 |
commit | c6ca842e234024b0276e5b294455ed2dbbe998e0 (patch) | |
tree | e1c3fb393507c0fe4092e3e133f3ddaec239463e | |
parent | d8f1b18d9b7494070715dd7a74e0c7753a43a3aa (diff) |
Fix T61937: image sequences not updating in workbench display mode.
Need to pass the image user along to get the frame number.
5 files changed, 43 insertions, 25 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 21bb7c6128d..7baea8b9e39 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -793,7 +793,7 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) } static WORKBENCH_MaterialData *get_or_create_material_data( - WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type, int interp) + WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, ImageUser *iuser, int color_type, int interp) { WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; @@ -809,6 +809,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data( material_template.object_id = OBJECT_ID_PASS_ENABLED(wpd) ? engine_object_data->object_id : 1; material_template.color_type = color_type; material_template.ima = ima; + material_template.iuser = iuser; material_template.interp = interp; uint hash = workbench_material_get_hash(&material_template, is_ghost); @@ -852,10 +853,11 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *o if (draw_as == PART_DRAW_PATH) { Material *mat; Image *image; + ImageUser *iuser; int interp; - workbench_material_get_image_and_mat(ob, part->omat, &image, &interp, &mat); + workbench_material_get_image_and_mat(ob, part->omat, &image, &iuser, &interp, &mat); int color_type = workbench_material_determine_color_type(wpd, image, ob); - WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, color_type, interp); + WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, iuser, color_type, interp); struct GPUShader *shader = (color_type != V3D_SHADING_TEXTURE_COLOR) ? wpd->prepass_solid_hair_sh : @@ -920,10 +922,11 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (geom_array != NULL && geom_array[i] != NULL) { Material *mat; Image *image; + ImageUser *iuser; int interp; - workbench_material_get_image_and_mat(ob, i + 1, &image, &interp, &mat); + workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat); int color_type = workbench_material_determine_color_type(wpd, image, ob); - material = get_or_create_material_data(vedata, ob, mat, image, color_type, interp); + material = get_or_create_material_data(vedata, ob, mat, image, iuser, color_type, interp); DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob); } } @@ -936,12 +939,12 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) { /* Hack */ wpd->shading.xray_alpha = ob->color[3]; - material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0); + material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0); has_transp_mat = true; } else { /* Draw solid color */ - material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0); + material = get_or_create_material_data(vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0); } if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat); @@ -958,7 +961,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (is_sculpt_mode) { /* Multiple materials are not supported in sculpt mode yet. */ Material *mat = give_current_material(ob, 1); - material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); + material = get_or_create_material_data(vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0); DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat); } else { @@ -973,11 +976,11 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (mat != NULL && mat->a < 1.0f) { /* Hack */ wpd->shading.xray_alpha = mat->a; - material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); + material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0); has_transp_mat = true; } else { - material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); + material = get_or_create_material_data(vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0); } DRW_shgroup_call_object_add(material->shgrp, geoms[i], ob); } diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 685c37b51df..d6a11a2b1e7 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -138,7 +138,7 @@ static void workbench_init_object_data(DrawData *dd) } WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data( - WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type, int interp) + WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, ImageUser *iuser, int color_type, int interp) { WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; @@ -154,6 +154,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data( material_template.object_id = OBJECT_ID_PASS_ENABLED(wpd) ? engine_object_data->object_id : 1; material_template.color_type = color_type; material_template.ima = ima; + material_template.iuser = iuser; material_template.interp = interp; uint hash = workbench_material_get_hash(&material_template, false); @@ -189,7 +190,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data( if (workbench_material_determine_color_type(wpd, material->ima, ob) == V3D_SHADING_TEXTURE_COLOR) { material->shgrp_object_outline = DRW_shgroup_create( e_data.object_outline_texture_sh, psl->object_outline_pass); - GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false); + GPUTexture *tex = GPU_texture_from_blender(material->ima, material->iuser, GL_TEXTURE_2D, false); DRW_shgroup_uniform_texture(material->shgrp_object_outline, "image", tex); } else { @@ -457,10 +458,11 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O if (draw_as == PART_DRAW_PATH) { Material *mat; Image *image; + ImageUser *iuser; int interp; - workbench_material_get_image_and_mat(ob, part->omat, &image, &interp, &mat); + workbench_material_get_image_and_mat(ob, part->omat, &image, &iuser, &interp, &mat); int color_type = workbench_material_determine_color_type(wpd, image, ob); - WORKBENCH_MaterialData *material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, color_type, interp); + WORKBENCH_MaterialData *material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, iuser, color_type, interp); struct GPUShader *shader = (color_type != V3D_SHADING_TEXTURE_COLOR) ? wpd->transparent_accum_hair_sh @@ -538,10 +540,11 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) for (int i = 0; i < materials_len; i++) { Material *mat; Image *image; + ImageUser *iuser; int interp; - workbench_material_get_image_and_mat(ob, i + 1, &image, &interp, &mat); + workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat); int color_type = workbench_material_determine_color_type(wpd, image, ob); - material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, color_type, interp); + material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, iuser, color_type, interp); DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob); DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob); } @@ -557,7 +560,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) /* No material split needed */ struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { - material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0); + material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0); if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat); if (!is_wire) { @@ -588,7 +591,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) } Material *mat = give_current_material(ob, i + 1); - material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); + material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0); if (is_sculpt_mode) { DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat); if (!is_wire) { diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index e721a4ccdb8..47895f8729b 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -220,11 +220,11 @@ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *i return color_type; } -void workbench_material_get_image_and_mat(Object *ob, int mat_nr, Image **r_image, int *r_interp, Material **r_mat) +void workbench_material_get_image_and_mat(Object *ob, int mat_nr, Image **r_image, ImageUser **r_iuser, int *r_interp, Material **r_mat) { bNode *node; *r_mat = give_current_material(ob, mat_nr); - ED_object_get_active_image(ob, mat_nr, r_image, NULL, &node, NULL); + ED_object_get_active_image(ob, mat_nr, r_image, r_iuser, &node, NULL); if (node && *r_image) { switch (node->type) { case SH_NODE_TEX_IMAGE: @@ -258,11 +258,11 @@ void workbench_material_shgroup_uniform( } if (workbench_material_determine_color_type(wpd, material->ima, ob) == V3D_SHADING_TEXTURE_COLOR) { - ImBuf *ibuf = BKE_image_acquire_ibuf(material->ima, NULL, NULL); + ImBuf *ibuf = BKE_image_acquire_ibuf(material->ima, material->iuser, NULL); const bool do_color_correction = wpd->use_color_management && (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0); BKE_image_release_ibuf(material->ima, ibuf, NULL); - GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false); + GPUTexture *tex = GPU_texture_from_blender(material->ima, material->iuser, GL_TEXTURE_2D, false); DRW_shgroup_uniform_texture(grp, "image", tex); DRW_shgroup_uniform_bool_copy(grp, "imageSrgb", do_color_correction); DRW_shgroup_uniform_bool_copy(grp, "imageNearest", (interp == SHD_INTERP_CLOSEST)); @@ -296,4 +296,5 @@ void workbench_material_copy(WORKBENCH_MaterialData *dest_material, const WORKBE dest_material->metallic = source_material->metallic; dest_material->roughness = source_material->roughness; dest_material->ima = source_material->ima; + dest_material->iuser = source_material->iuser; } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index da6df4c93bd..115868bc268 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -278,6 +278,7 @@ typedef struct WORKBENCH_MaterialData { int color_type; int interp; Image *ima; + ImageUser *iuser; /* Linked shgroup for drawing */ DRWShadingGroup *shgrp; @@ -322,7 +323,7 @@ void workbench_forward_cache_finish(WORKBENCH_Data *vedata); void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd); void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd); WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data( - WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type, int interp); + WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, ImageUser *iuser, int color_type, int interp); /* workbench_effect_aa.c */ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx); @@ -350,7 +351,7 @@ void workbench_dof_draw_pass(WORKBENCH_Data *vedata); /* workbench_materials.c */ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima, Object *ob); -void workbench_material_get_image_and_mat(Object *ob, int mat_nr, Image **r_image, int *r_interp, Material **r_mat); +void workbench_material_get_image_and_mat(Object *ob, int mat_nr, Image **r_image, ImageUser **r_iuser, int *r_interp, Material **r_mat); char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair); void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, WORKBENCH_MaterialData *data); uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template, bool is_ghost); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 5d73f0c8b04..f771feeff2c 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -159,7 +159,17 @@ bool ED_object_get_active_image( if (node && is_image_texture_node(node)) { if (r_ima) *r_ima = (Image *)node->id; - if (r_iuser) *r_iuser = NULL; + if (r_iuser) { + if (node->type == SH_NODE_TEX_IMAGE) { + *r_iuser = &((NodeTexImage *)node->storage)->iuser; + } + else if (node->type == SH_NODE_TEX_ENVIRONMENT) { + *r_iuser = &((NodeTexEnvironment *)node->storage)->iuser; + } + else { + *r_iuser = NULL; + } + } if (r_node) *r_node = node; if (r_ntree) *r_ntree = ntree; return true; |