[Bf-blender-cvs] [3b2a01edf69] master: Texture Paint: sync changing active texture in the node editor to the active paint slot

Philipp Oeser noreply at git.blender.org
Tue Aug 31 12:30:13 CEST 2021


Commit: 3b2a01edf698fb27d9984fe12eb210df5246f16c
Author: Philipp Oeser
Date:   Fri Jun 4 10:24:01 2021 +0200
Branches: master
https://developer.blender.org/rB3b2a01edf698fb27d9984fe12eb210df5246f16c

Texture Paint: sync changing active texture in the node editor to the
active paint slot

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

When changing the active texture in the Node Editor though, only the
texture displayed in the viewport changes.

This _can_ be confusing because you can end up painting on a texture
that you are not looking at in the viewport (so you dont have any
feedback whatsoever). Not 100% sure this is desired in all scenarios,
but this change makes it so that the active paint slot changes to the
one that uses the texture we chaged to in the Node Editor (keeping them
in sync).

If this is not desired in all cases, this could be made an option.

ref T88788
ref D11496

Maniphest Tasks: T88788

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

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

M	source/blender/editors/space_node/node_edit.cc

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

diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc
index 5b1b737751c..fd907d41a62 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -719,11 +719,22 @@ void ED_node_set_active(
         ED_node_tag_update_nodetree(bmain, ntree, node);
       }
 
-      /* if active texture changed, free glsl materials */
       if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) {
+        /* If active texture changed, free glsl materials. */
         LISTBASE_FOREACH (Material *, ma, &bmain->materials) {
           if (ma->nodetree && ma->use_nodes && ntreeHasTree(ma->nodetree, ntree)) {
             GPU_material_free(&ma->gpumaterial);
+
+            /* Sync to active texpaint slot, otherwise we can end up painting on a different slot
+             * than we are looking at. */
+            if (ma->texpaintslot) {
+              Image *image = (Image *)node->id;
+              for (int i = 0; i < ma->tot_slots; i++) {
+                if (ma->texpaintslot[i].ima == image) {
+                  ma->paint_active_slot = i;
+                }
+              }
+            }
           }
         }



More information about the Bf-blender-cvs mailing list