bugfix [#23068] Image editor: Update Automatically not updating the compositor.
[#23637] Replacing an image used in the compositor crashes [#23343] changes in images doesn't update compositor image nodes
This commit is contained in:
@@ -192,7 +192,7 @@ int nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
|
||||
void nodeClearActiveID(struct bNodeTree *ntree, short idtype);
|
||||
|
||||
void NodeTagChanged(struct bNodeTree *ntree, struct bNode *node);
|
||||
void NodeTagIDChanged(struct bNodeTree *ntree, struct ID *id);
|
||||
int NodeTagIDChanged(struct bNodeTree *ntree, struct ID *id);
|
||||
|
||||
/* ************** Groups ****************** */
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_packedFile.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_node.h"
|
||||
|
||||
//XXX #include "BIF_editseq.h"
|
||||
|
||||
@@ -1447,6 +1448,17 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* dont use notifiers because they are not 100% sure to succseed
|
||||
* this also makes sure all scenes are accounted for. */
|
||||
{
|
||||
Scene *scene;
|
||||
for(scene= G.main->scene.first; scene; scene= scene->id.next) {
|
||||
if(scene->nodetree) {
|
||||
NodeTagIDChanged(scene->nodetree, &ima->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if layer or pass changes, we need an index for the imbufs list */
|
||||
|
||||
@@ -1787,18 +1787,25 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node)
|
||||
}
|
||||
}
|
||||
|
||||
void NodeTagIDChanged(bNodeTree *ntree, ID *id)
|
||||
int NodeTagIDChanged(bNodeTree *ntree, ID *id)
|
||||
{
|
||||
int change = FALSE;
|
||||
|
||||
if(id==NULL)
|
||||
return;
|
||||
return change;
|
||||
|
||||
if(ntree->type==NTREE_COMPOSIT) {
|
||||
bNode *node;
|
||||
|
||||
for(node= ntree->nodes.first; node; node= node->next)
|
||||
if(node->id==id)
|
||||
for(node= ntree->nodes.first; node; node= node->next) {
|
||||
if(node->id==id) {
|
||||
change= TRUE;
|
||||
NodeTagChanged(ntree, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return change;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4534,29 +4534,8 @@ static void paint_redraw(bContext *C, ImagePaintState *s, int final)
|
||||
if(s->image)
|
||||
GPU_free_image(s->image);
|
||||
|
||||
/* compositor listener deals with updating */
|
||||
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image);
|
||||
|
||||
// XXX node update
|
||||
#if 0
|
||||
if(!s->sima && s->image) {
|
||||
/* after paint, tag Image or RenderResult nodes changed */
|
||||
if(s->scene->nodetree) {
|
||||
imagepaint_composite_tags(s->scene->nodetree, image, &s->sima->iuser);
|
||||
}
|
||||
/* signal composite (hurmf, need an allqueue?) */
|
||||
if(s->sima->lock) {
|
||||
ScrArea *sa;
|
||||
for(sa=s->screen->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_NODE) {
|
||||
if(((SpaceNode *)sa->spacedata.first)->treetype==NTREE_COMPOSIT) {
|
||||
addqueue(sa->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
if(!s->sima || !s->sima->lock)
|
||||
|
||||
@@ -1919,33 +1919,6 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot)
|
||||
}
|
||||
|
||||
|
||||
/* ************************* */
|
||||
|
||||
void imagepaint_composite_tags(bNodeTree *ntree, Image *image, ImageUser *iuser)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
if(ntree==NULL)
|
||||
return;
|
||||
|
||||
/* search for renderresults */
|
||||
if(image->type==IMA_TYPE_R_RESULT) {
|
||||
for(node= ntree->nodes.first; node; node= node->next) {
|
||||
if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
|
||||
/* imageuser comes from ImageWin, so indexes are offset 1 */
|
||||
if(node->custom1==iuser->layer-1)
|
||||
NodeTagChanged(ntree, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(node= ntree->nodes.first; node; node= node->next) {
|
||||
if(node->id== &image->id)
|
||||
NodeTagChanged(ntree, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ****************** Make Group operator ******************* */
|
||||
|
||||
static int node_group_make_exec(bContext *C, wmOperator *op)
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_node.h"
|
||||
|
||||
#include "ED_render.h"
|
||||
#include "ED_screen.h"
|
||||
@@ -158,7 +159,10 @@ static void node_init(struct wmWindowManager *wm, ScrArea *sa)
|
||||
|
||||
static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
{
|
||||
|
||||
/* note, ED_area_tag_refresh will re-execute compositor */
|
||||
/* XXX, should edit some to check for the nodeTree type, especially NC_NODE|NA_EDITED which refreshes all types */
|
||||
SpaceNode *snode= sa->spacedata.first;
|
||||
|
||||
/* preview renders */
|
||||
switch(wmn->category) {
|
||||
case NC_SCENE:
|
||||
@@ -200,6 +204,20 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
if (wmn->action == NA_EDITED)
|
||||
ED_area_tag_refresh(sa);
|
||||
break;
|
||||
|
||||
case NC_IMAGE:
|
||||
if (wmn->action == NA_EDITED) {
|
||||
if(snode->treetype==NTREE_COMPOSIT) {
|
||||
Scene *scene= wmn->window->screen->scene;
|
||||
|
||||
/* note that NodeTagIDChanged is alredy called by BKE_image_signal() on all
|
||||
* scenes so really this is just to know if the images is used in the compo else
|
||||
* painting on images could become very slow when the compositor is open. */
|
||||
if(NodeTagIDChanged(scene->nodetree, wmn->reference))
|
||||
ED_area_tag_refresh(sa);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user