Fix T101316: workbench texture mode not working with geometry nodes

The `ED_object_get_active_image` is used from the renderer which deals with
evaluated objects. This means the material api for evaluated objects has
to be used.
This commit is contained in:
Jacques Lucke 2022-10-20 17:34:22 +02:00
parent 3bac6f17f1
commit 4b30ee773c
Notes: blender-bot 2023-02-14 09:03:55 +01:00
Referenced by issue #101316, Workbench texture mode does not work if the material was set by Geometry Nodes
1 changed files with 3 additions and 1 deletions

View File

@ -37,6 +37,7 @@
#include "BKE_node.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "ED_image.h"
#include "ED_mesh.h"
@ -113,7 +114,8 @@ bool ED_object_get_active_image(Object *ob,
bNode **r_node,
bNodeTree **r_ntree)
{
Material *ma = BKE_object_material_get(ob, mat_nr);
Material *ma = DEG_is_evaluated_object(ob) ? BKE_object_material_get_eval(ob, mat_nr) :
BKE_object_material_get(ob, mat_nr);
bNodeTree *ntree = (ma && ma->use_nodes) ? ma->nodetree : NULL;
bNode *node = (ntree) ? nodeGetActiveTexture(ntree) : NULL;