diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2021-06-04 11:24:01 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2021-08-31 13:29:14 +0300 |
commit | 3b2a01edf698fb27d9984fe12eb210df5246f16c (patch) | |
tree | 6c9b94f960a5aa315c646eb69d276c73125c2cc5 /source/blender | |
parent | d8b445e728da286d374152fa2535b1076f352313 (diff) |
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
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_node/node_edit.cc | 13 |
1 files changed, 12 insertions, 1 deletions
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; + } + } + } } } |