[Bf-blender-cvs] [d354e6a8468] blender-v2.93-release: Texture Paint: changing paint slots and viewport could go out of sync

Philipp Oeser noreply at git.blender.org
Wed Jun 9 08:54:46 CEST 2021


Commit: d354e6a84688948aac39b1402c35295ccbd3a013
Author: Philipp Oeser
Date:   Fri Jun 4 16:00:51 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBd354e6a84688948aac39b1402c35295ccbd3a013

Texture Paint: changing paint slots and viewport could go out of sync

When changing to another texture paint slot, the texture displayed in
the viewport should change accordingly (as well as the image displayed
in the Image Editor).

The procedure to find the texture to display in the viewport
(BKE_texpaint_slot_material_find_node) could fail
though because it assumed iterating nodes would always happen in the
same order (it was index based). This is not the case though, nodes can
get sorted differently based on selection (see ED_node_sort).

Now check the actual image being referenced in the paint slot for
comparison.

ref T88788 (probably enough to call this a fix, the other issue(s)
mentioned in the report are more likely a feature request)

Reviewed By: mano-wii

Maniphest Tasks: T88788

Differential Revision: https://developer.blender.org/D11496

===================================================================

M	source/blender/blenkernel/intern/material.c

===================================================================

diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 37d47a984cc..8e80a4bc9ae 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1367,16 +1367,16 @@ void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob)
 }
 
 struct FindTexPaintNodeData {
-  bNode *node;
-  short iter_index;
-  short index;
+  Image *ima;
+  bNode *r_node;
 };
 
 static bool texpaint_slot_node_find_cb(bNode *node, void *userdata)
 {
   struct FindTexPaintNodeData *find_data = userdata;
-  if (find_data->iter_index++ == find_data->index) {
-    find_data->node = node;
+  Image *ima = (Image *)node->id;
+  if (find_data->ima == ima) {
+    find_data->r_node = node;
     return false;
   }
 
@@ -1385,10 +1385,10 @@ static bool texpaint_slot_node_find_cb(bNode *node, void *userdata)
 
 bNode *BKE_texpaint_slot_material_find_node(Material *ma, short texpaint_slot)
 {
-  struct FindTexPaintNodeData find_data = {NULL, 0, texpaint_slot};
+  struct FindTexPaintNodeData find_data = {ma->texpaintslot[texpaint_slot].ima, NULL};
   ntree_foreach_texnode_recursive(ma->nodetree, texpaint_slot_node_find_cb, &find_data);
 
-  return find_data.node;
+  return find_data.r_node;
 }
 
 /* r_col = current value, col = new value, (fac == 0) is no change */



More information about the Bf-blender-cvs mailing list