diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-10-08 02:05:30 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-10-08 02:05:30 +0400 |
commit | fd511eb984a23b63b373e171666667c8213579c0 (patch) | |
tree | 16ab444b76eb93d953364824bbf48025d2140ab3 /source/blender/editors | |
parent | 1b7e5b9abe7c2431d1572cd39d687a139e7acb9a (diff) |
Node Bugfixes:
* Compo node backdrop works again.
* Compo node previews and backdrop now get correct color management
float to byte conversion.
* Compo nodes got unecessarily recalculated while moving nodes.
* Fix compo node viewer nodes not getting activated correctly.
* Main compo node preview render computations are now outside of
mutex lock, so better for multithreading.
* Tex node outputs did not work in some files loaded from 2.4.
* Change RNA updates to take into account groups that may be shared
between multiple node trees.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_node.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 45 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 85 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 2 |
7 files changed, 101 insertions, 57 deletions
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 305b2a64ffe..667a4ecb144 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -33,12 +33,13 @@ struct Scene; struct Tex; struct bContext; struct bNode; +struct ID; /* drawnode.c */ void ED_init_node_butfuncs(void); /* node_draw.c */ -void ED_node_changed_update(struct bContext *C, struct bNode *node); +void ED_node_changed_update(struct ID *id, struct bNode *node); /* node_edit.c */ void ED_node_shader_default(struct Material *ma); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index b8da42079c4..33be0b83f20 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -89,6 +89,7 @@ #include "UI_resources.h" #include "RE_pipeline.h" +#include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "node_intern.h" @@ -2106,12 +2107,13 @@ void node_rename_but(char *s) #endif -void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode) +void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) { if((snode->flag & SNODE_BACKDRAW) && snode->treetype==NTREE_COMPOSIT) { Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + void *lock; + ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); if(ibuf) { float x, y; @@ -2126,13 +2128,21 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode) x = (ar->winx-ibuf->x)/2 + snode->xof; y = (ar->winy-ibuf->y)/2 + snode->yof; + if(!ibuf->rect) { + if(color_manage) + ibuf->profile= IB_PROFILE_SRGB; + else + ibuf->profile = IB_PROFILE_NONE; + IMB_rect_from_float(ibuf); + } + if(ibuf->rect) glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - else if(ibuf->channels==4) - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float); wmPopMatrix(); } + + BKE_image_release_ibuf(ima, lock); } } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index dd2dc0d796a..26601958c8a 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -95,19 +95,19 @@ extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select); extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); extern void ui_draw_tria_icon(float x, float y, float aspect, char dir); -void ED_node_changed_update(bContext *C, bNode *node) +void ED_node_changed_update(ID *id, bNode *node) { - SpaceNode *snode= CTX_wm_space_node(C); + bNodeTree *nodetree, *edittree; + int treetype; - if(!snode) - return; + node_tree_from_ID(id, &nodetree, &edittree, &treetype); - if(snode->treetype==NTREE_SHADER) { - DAG_id_flush_update(snode->id, 0); - WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, snode->id); + if(treetype==NTREE_SHADER) { + DAG_id_flush_update(id, 0); + WM_main_add_notifier(NC_MATERIAL|ND_SHADING, id); } - else if(snode->treetype==NTREE_COMPOSIT) { - NodeTagChanged(snode->edittree, node); + else if(treetype==NTREE_COMPOSIT) { + NodeTagChanged(edittree, node); /* don't use NodeTagIDChanged, it gives far too many recomposites for image, scene layers, ... */ /* not the best implementation of the world... but we need it to work now :) */ @@ -122,23 +122,26 @@ void ED_node_changed_update(bContext *C, bNode *node) //addqueue(curarea->win, UI_BUT_EVENT, B_NODE_TREE_EXEC); } else { - node= node_tree_get_editgroup(snode->nodetree); + node= node_tree_get_editgroup(nodetree); if(node) - NodeTagIDChanged(snode->nodetree, node->id); + NodeTagIDChanged(nodetree, node->id); } - WM_event_add_notifier(C, NC_SCENE|ND_NODES, CTX_data_scene(C)); + + WM_main_add_notifier(NC_SCENE|ND_NODES, id); } - else if(snode->treetype==NTREE_TEXTURE) { - DAG_id_flush_update(snode->id, 0); - WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); + else if(treetype==NTREE_TEXTURE) { + DAG_id_flush_update(id, 0); + WM_main_add_notifier(NC_TEXTURE|ND_NODES, id); } - } static void do_node_internal_buttons(bContext *C, void *node_v, int event) { - if(event==B_NODE_EXEC) - ED_node_changed_update(C, node_v); + if(event==B_NODE_EXEC) { + SpaceNode *snode= CTX_wm_space_node(C); + if(snode && snode->id) + ED_node_changed_update(snode->id, node_v); + } } @@ -648,7 +651,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); /* premul graphics */ glColor4f(1.0, 1.0, 1.0, 1.0); - glaDrawPixelsTex(prv->xmin, prv->ymin, preview->xsize, preview->ysize, GL_FLOAT, preview->rect); + glaDrawPixelsTex(prv->xmin, prv->ymin, preview->xsize, preview->ysize, GL_UNSIGNED_BYTE, preview->rect); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glDisable(GL_BLEND); @@ -1075,6 +1078,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) float col[3]; View2DScrollers *scrollers; SpaceNode *snode= CTX_wm_space_node(C); + Scene *scene= CTX_data_scene(C); + int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0); @@ -1094,7 +1099,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) UI_view2d_constant_grid_draw(C, v2d); /* backdrop */ - draw_nodespace_back_pix(ar, snode); + draw_nodespace_back_pix(ar, snode, color_manage); /* nodes */ snode_set_context(snode, CTX_data_scene(C)); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 50a99650ec0..cee90b5a148 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -62,8 +62,6 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" -#include "ED_render.h" - #include "BIF_gl.h" #include "BLI_arithb.h" @@ -74,8 +72,10 @@ #include "IMB_imbuf_types.h" -#include "ED_space_api.h" +#include "ED_node.h" +#include "ED_render.h" #include "ED_screen.h" +#include "ED_space_api.h" #include "ED_transform.h" #include "ED_types.h" @@ -581,13 +581,45 @@ void ED_node_texture_default(Tex *tx) ntreeSolveOrder(tx->nodetree); /* needed for pointers */ } +void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype) +{ + bNode *node; + short idtype= GS(id->name); + + if(idtype == ID_MA) { + *ntree= ((Material*)id)->nodetree; + if(treetype) *treetype= NTREE_SHADER; + } + else if(idtype == ID_SCE) { + *ntree= ((Scene*)id)->nodetree; + if(treetype) *treetype= NTREE_COMPOSIT; + } + else if(idtype == ID_TE) { + *ntree= ((Tex*)id)->nodetree; + if(treetype) *treetype= NTREE_TEXTURE; + } + + /* find editable group */ + if(edittree) { + if(*ntree) + for(node= (*ntree)->nodes.first; node; node= node->next) + if(node->flag & NODE_GROUP_EDIT) + break; + + if(node && node->id) + *edittree= (bNodeTree *)node->id; + else + *edittree= *ntree; + } +} + /* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */ void snode_set_context(SpaceNode *snode, Scene *scene) { Object *ob= OBACT; - bNode *node= NULL; snode->nodetree= NULL; + snode->edittree= NULL; snode->id= snode->from= NULL; if(snode->treetype==NTREE_SHADER) { @@ -597,7 +629,6 @@ void snode_set_context(SpaceNode *snode, Scene *scene) if(ma) { snode->from= &ob->id; snode->id= &ma->id; - snode->nodetree= ma->nodetree; } } } @@ -608,8 +639,6 @@ void snode_set_context(SpaceNode *snode, Scene *scene) /* bit clumsy but reliable way to see if we draw first time */ if(snode->nodetree==NULL) ntreeCompositForceHidden(scene->nodetree, scene); - - snode->nodetree= scene->nodetree; } else if(snode->treetype==NTREE_TEXTURE) { Tex *tx= NULL; @@ -648,22 +677,11 @@ void snode_set_context(SpaceNode *snode, Scene *scene) tx= mtex->tex; } - if(tx) { - snode->id= &tx->id; - snode->nodetree= tx->nodetree; - } + snode->id= &tx->id; } - - /* find editable group */ - if(snode->nodetree) - for(node= snode->nodetree->nodes.first; node; node= node->next) - if(node->flag & NODE_GROUP_EDIT) - break; - - if(node && node->id) - snode->edittree= (bNodeTree *)node->id; - else - snode->edittree= snode->nodetree; + + if(snode->id) + node_tree_from_ID(snode->id, &snode->nodetree, &snode->edittree, NULL); } #if 0 @@ -691,15 +709,13 @@ static void node_active_image(Image *ima) void node_set_active(SpaceNode *snode, bNode *node) { - nodeSetActive(snode->edittree, node); - #if 0 - // XXX if(node->type!=NODE_GROUP) { - /* tree specific activate calls */ if(snode->treetype==NTREE_SHADER) { + // XXX +#if 0 /* when we select a material, active texture is cleared, for buttons */ if(node->id && GS(node->id->name)==ID_MA) @@ -709,8 +725,11 @@ void node_set_active(SpaceNode *snode, bNode *node) // allqueue(REDRAWBUTSSHADING, 1); // allqueue(REDRAWIPO, 0); +#endif } else if(snode->treetype==NTREE_COMPOSIT) { + Scene *scene= (Scene*)snode->id; + /* make active viewer, currently only 1 supported... */ if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { bNode *tnode; @@ -731,31 +750,37 @@ void node_set_active(SpaceNode *snode, bNode *node) if(gnode) NodeTagIDChanged(snode->nodetree, gnode->id); - // XXX snode_handle_recalc(snode); + ED_node_changed_update(snode->id, node); } /* addnode() doesnt link this yet... */ node->id= (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } else if(node->type==CMP_NODE_IMAGE) { + // XXX +#if 0 if(node->id) node_active_image((Image *)node->id); +#endif } else if(node->type==CMP_NODE_R_LAYERS) { - if(node->id==NULL || node->id==(ID *)G.scene) { - G.scene->r.actlay= node->custom1; + if(node->id==NULL || node->id==(ID *)scene) { + scene->r.actlay= node->custom1; + // XXX // allqueue(REDRAWBUTSSCENE, 0); } } } else if(snode->treetype==NTREE_TEXTURE) { + // XXX +#if 0 if(node->id) ; // XXX BIF_preview_changed(-1); // allqueue(REDRAWBUTSSHADING, 1); // allqueue(REDRAWIPO, 0); +#endif } } - #endif /* 0 */ } /* ***************** Edit Group operator ************* */ diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 2a929472c68..9f28a5e3dcb 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -69,9 +69,10 @@ void NODE_OT_select_border(struct wmOperatorType *ot); void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link); void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int th_col2, int do_shaded); int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol); -void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode); +void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage); /* node_edit.c */ +void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype); void snode_handle_recalc(bContext *C, SpaceNode *snode); bNode *next_node(bNodeTree *ntree); bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float locy); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 5612e60e899..06d0832cb8b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1961,6 +1961,8 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) v3d->zbuf= TRUE; glEnable(GL_DEPTH_TEST); } + else + v3d->zbuf= FALSE; // needs to be done always, gridview is adjusted in drawgrid() now v3d->gridview= v3d->grid; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b5920210381..839c3543515 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -322,7 +322,7 @@ static void viewRedrawForce(bContext *C, TransInfo *t) else if(t->spacetype == SPACE_NODE) { //ED_area_tag_redraw(t->sa); - WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE, NULL); } else if(t->spacetype == SPACE_SEQ) { |