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.
This commit is contained in:
@@ -1246,9 +1246,12 @@ void nodeAddToPreview(bNode *node, float *col, int x, int y)
|
||||
if(preview) {
|
||||
if(x>=0 && y>=0) {
|
||||
if(x<preview->xsize && y<preview->ysize) {
|
||||
float *tar= preview->rect+ 4*((preview->xsize*y) + x);
|
||||
unsigned char *tar= preview->rect+ 4*((preview->xsize*y) + x);
|
||||
//if(tar[0]==0.0f) {
|
||||
QUATCOPY(tar, col);
|
||||
tar[0]= FTOCHAR(col[0]);
|
||||
tar[1]= FTOCHAR(col[1]);
|
||||
tar[2]= FTOCHAR(col[2]);
|
||||
tar[3]= FTOCHAR(col[3]);
|
||||
//}
|
||||
}
|
||||
//else printf("prv out bound x y %d %d\n", x, y);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
else if(snode->treetype==NTREE_TEXTURE) {
|
||||
DAG_id_flush_update(snode->id, 0);
|
||||
WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id);
|
||||
}
|
||||
|
||||
WM_main_add_notifier(NC_SCENE|ND_NODES, 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));
|
||||
|
||||
@@ -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 ************* */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -99,7 +99,7 @@ typedef struct bNodeSocket {
|
||||
#
|
||||
#
|
||||
typedef struct bNodePreview {
|
||||
float *rect;
|
||||
unsigned char *rect;
|
||||
short xsize, ysize;
|
||||
} bNodePreview;
|
||||
|
||||
|
||||
@@ -31,10 +31,12 @@
|
||||
|
||||
#include "rna_internal.h"
|
||||
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_texture_types.h"
|
||||
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_image.h"
|
||||
|
||||
@@ -140,11 +142,42 @@ static char *rna_Node_path(PointerRNA *ptr)
|
||||
return BLI_sprintfN("nodes[%d]", index);
|
||||
}
|
||||
|
||||
static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
if(ntree == lookup)
|
||||
return 1;
|
||||
|
||||
for(node=ntree->nodes.first; node; node=node->next)
|
||||
if(node->type == NODE_GROUP && node->id)
|
||||
if(has_nodetree((bNodeTree*)node->id, lookup))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rna_Node_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
bNodeTree *ntree= (bNodeTree*)ptr->id.data;
|
||||
bNode *node= (bNode*)ptr->data;
|
||||
Material *ma;
|
||||
Tex *tex;
|
||||
Scene *sce;
|
||||
|
||||
ED_node_changed_update(C, node);
|
||||
/* look through all datablocks, to support groups */
|
||||
for(ma=bmain->mat.first; ma; ma=ma->id.next)
|
||||
if(ma->nodetree && ma->use_nodes && has_nodetree(ma->nodetree, ntree))
|
||||
ED_node_changed_update(&ma->id, node);
|
||||
|
||||
for(tex=bmain->tex.first; tex; tex=tex->id.next)
|
||||
if(tex->nodetree && tex->use_nodes && has_nodetree(tex->nodetree, ntree))
|
||||
ED_node_changed_update(&tex->id, node);
|
||||
|
||||
for(sce=bmain->scene.first; sce; sce=sce->id.next)
|
||||
if(sce->nodetree && sce->use_nodes && has_nodetree(sce->nodetree, ntree))
|
||||
ED_node_changed_update(&sce->id, node);
|
||||
}
|
||||
|
||||
static void rna_Node_update_name(bContext *C, PointerRNA *ptr)
|
||||
|
||||
@@ -671,7 +671,7 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
|
||||
free_compbuf(img);
|
||||
}
|
||||
|
||||
generate_preview(node, out[0]->data);
|
||||
generate_preview(data, node, out[0]->data);
|
||||
}
|
||||
|
||||
static void node_composit_init_blur(bNode* node)
|
||||
|
||||
@@ -166,7 +166,7 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack
|
||||
break;
|
||||
}
|
||||
|
||||
generate_preview(node, outbuf);
|
||||
generate_preview(data, node, outbuf);
|
||||
out[0]->data=outbuf;
|
||||
if(out[1]->hasoutput)
|
||||
out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A);
|
||||
|
||||
@@ -154,7 +154,7 @@ static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack
|
||||
if(out[1]->hasoutput)
|
||||
out[1]->data= valbuf_from_rgbabuf(chromabuf, CHAN_A);
|
||||
|
||||
generate_preview(node, chromabuf);
|
||||
generate_preview(data, node, chromabuf);
|
||||
|
||||
if(cbuf!=in[0]->data)
|
||||
free_compbuf(cbuf);
|
||||
|
||||
@@ -95,7 +95,7 @@ static void node_composit_exec_color_matte(void *data, bNode *node, bNodeStack *
|
||||
if(out[1]->hasoutput)
|
||||
out[1]->data= valbuf_from_rgbabuf(colorbuf, CHAN_A);
|
||||
|
||||
generate_preview(node, colorbuf);
|
||||
generate_preview(data, node, colorbuf);
|
||||
|
||||
if(cbuf!=in[0]->data)
|
||||
free_compbuf(cbuf);
|
||||
|
||||
@@ -73,7 +73,7 @@ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **i
|
||||
zbuf->malloc= 0;
|
||||
free_compbuf(zbuf);
|
||||
}
|
||||
generate_preview(node, outbuf);
|
||||
generate_preview(data, node, outbuf);
|
||||
|
||||
/* we give outbuf to rr... */
|
||||
rr->rectf= outbuf->rect;
|
||||
@@ -91,7 +91,7 @@ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **i
|
||||
}
|
||||
}
|
||||
if(in[0]->data)
|
||||
generate_preview(node, in[0]->data);
|
||||
generate_preview(data, node, in[0]->data);
|
||||
}
|
||||
|
||||
bNodeType cmp_node_composite= {
|
||||
|
||||
@@ -108,7 +108,7 @@ static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack **
|
||||
out[0]->data=outbuf;
|
||||
if(out[1]->hasoutput)
|
||||
out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A);
|
||||
generate_preview(node, outbuf);
|
||||
generate_preview(data, node, outbuf);
|
||||
|
||||
if(imbuf1!=in[0]->data)
|
||||
free_compbuf(imbuf1);
|
||||
|
||||
@@ -111,7 +111,7 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac
|
||||
out[0]->data=workbuf;
|
||||
if(out[1]->hasoutput)
|
||||
out[1]->data=valbuf_from_rgbabuf(workbuf, CHAN_A);
|
||||
generate_preview(node, workbuf);
|
||||
generate_preview(data, node, workbuf);
|
||||
|
||||
if(inbuf!=in[0]->data)
|
||||
free_compbuf(inbuf);
|
||||
|
||||
@@ -212,7 +212,7 @@ static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in,
|
||||
|
||||
out[0]->data= stackbuf;
|
||||
|
||||
generate_preview(node, out[0]->data);
|
||||
generate_preview(data, node, out[0]->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **in, b
|
||||
if(out[1]->hasoutput)
|
||||
out[1]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A);
|
||||
|
||||
generate_preview(node, stackbuf);
|
||||
generate_preview(data, node, stackbuf);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -386,7 +386,7 @@ static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **in,
|
||||
|
||||
node_composit_rlayers_out(rd, rl, out, rr->rectx, rr->recty);
|
||||
|
||||
generate_preview(node, stackbuf);
|
||||
generate_preview(data, node, stackbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack *
|
||||
if(out[1]->hasoutput)
|
||||
out[1]->vec[0]= std_dev;
|
||||
|
||||
generate_preview(node, histogram);
|
||||
generate_preview(data, node, histogram);
|
||||
|
||||
if(cbuf!=in[0]->data)
|
||||
free_compbuf(cbuf);
|
||||
|
||||
@@ -87,7 +87,7 @@ static void node_composit_exec_luma_matte(void *data, bNode *node, bNodeStack **
|
||||
composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_luma_matte, CB_RGBA);
|
||||
composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_yuva_to_rgba, CB_RGBA);
|
||||
|
||||
generate_preview(node, outbuf);
|
||||
generate_preview(data, node, outbuf);
|
||||
out[0]->data=outbuf;
|
||||
if (out[1]->hasoutput)
|
||||
out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A);
|
||||
|
||||
@@ -74,7 +74,7 @@ static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in,
|
||||
|
||||
out[0]->data= stackbuf;
|
||||
|
||||
generate_preview(node, out[0]->data);
|
||||
generate_preview(data, node, out[0]->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack *
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
||||
generate_preview(node, cbuf);
|
||||
generate_preview(data, node, cbuf);
|
||||
|
||||
if(in[0]->data != cbuf)
|
||||
free_compbuf(cbuf);
|
||||
|
||||
@@ -121,7 +121,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack *
|
||||
|
||||
composit3_pixel_processor(node, cbuf, buf1, in[0]->vec, buf2, in[1]->vec, mask, NULL, do_copy_split_rgba, CB_RGBA, CB_RGBA, CB_VAL);
|
||||
|
||||
generate_preview(node, cbuf);
|
||||
generate_preview(data, node, cbuf);
|
||||
free_compbuf(cbuf);
|
||||
free_compbuf(mask);
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in,
|
||||
VECCOPY(prevbuf->procedural_size, in[1]->vec);
|
||||
prevbuf->procedural_type= CB_RGBA;
|
||||
composit1_pixel_processor(node, prevbuf, prevbuf, out[0]->vec, do_copy_rgba, CB_RGBA);
|
||||
generate_preview(node, prevbuf);
|
||||
generate_preview(data, node, prevbuf);
|
||||
free_compbuf(prevbuf);
|
||||
|
||||
if(out[0]->hasoutput) {
|
||||
|
||||
@@ -106,12 +106,12 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in,
|
||||
free_compbuf(zbuf);
|
||||
}
|
||||
|
||||
generate_preview(node, cbuf);
|
||||
generate_preview(data, node, cbuf);
|
||||
free_compbuf(cbuf);
|
||||
|
||||
}
|
||||
else if(in[0]->data) {
|
||||
generate_preview(node, in[0]->data);
|
||||
generate_preview(data, node, in[0]->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -604,9 +604,13 @@ static CompBuf *generate_procedural_preview(CompBuf *cbuf, int newx, int newy)
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
void generate_preview(bNode *node, CompBuf *stackbuf)
|
||||
void generate_preview(void *data, bNode *node, CompBuf *stackbuf)
|
||||
{
|
||||
RenderData *rd= data;
|
||||
bNodePreview *preview= node->preview;
|
||||
int xsize, ysize;
|
||||
int color_manage= rd->color_mgt_flag & R_COLOR_MANAGEMENT;
|
||||
unsigned char *rect;
|
||||
|
||||
if(preview && stackbuf) {
|
||||
CompBuf *cbuf, *stackbuf_use;
|
||||
@@ -615,30 +619,41 @@ void generate_preview(bNode *node, CompBuf *stackbuf)
|
||||
|
||||
stackbuf_use= typecheck_compbuf(stackbuf, CB_RGBA);
|
||||
|
||||
BLI_lock_thread(LOCK_PREVIEW);
|
||||
|
||||
if(stackbuf->x > stackbuf->y) {
|
||||
preview->xsize= 140;
|
||||
preview->ysize= (140*stackbuf->y)/stackbuf->x;
|
||||
xsize= 140;
|
||||
ysize= (140*stackbuf->y)/stackbuf->x;
|
||||
}
|
||||
else {
|
||||
preview->ysize= 140;
|
||||
preview->xsize= (140*stackbuf->x)/stackbuf->y;
|
||||
ysize= 140;
|
||||
xsize= (140*stackbuf->x)/stackbuf->y;
|
||||
}
|
||||
|
||||
if(stackbuf_use->rect_procedural)
|
||||
cbuf= generate_procedural_preview(stackbuf_use, preview->xsize, preview->ysize);
|
||||
cbuf= generate_procedural_preview(stackbuf_use, xsize, ysize);
|
||||
else
|
||||
cbuf= scalefast_compbuf(stackbuf_use, preview->xsize, preview->ysize);
|
||||
cbuf= scalefast_compbuf(stackbuf_use, xsize, ysize);
|
||||
|
||||
/* this ensures free-compbuf does the right stuff */
|
||||
SWAP(float *, cbuf->rect, node->preview->rect);
|
||||
/* convert to byte for preview */
|
||||
rect= MEM_callocN(sizeof(unsigned char)*4*xsize*ysize, "bNodePreview.rect");
|
||||
|
||||
BLI_unlock_thread(LOCK_PREVIEW);
|
||||
if(color_manage)
|
||||
floatbuf_to_srgb_byte(cbuf->rect, rect, 0, xsize, 0, ysize, xsize);
|
||||
else
|
||||
floatbuf_to_byte(cbuf->rect, rect, 0, xsize, 0, ysize, xsize);
|
||||
|
||||
free_compbuf(cbuf);
|
||||
if(stackbuf_use!=stackbuf)
|
||||
free_compbuf(stackbuf_use);
|
||||
|
||||
BLI_lock_thread(LOCK_PREVIEW);
|
||||
|
||||
if(preview->rect)
|
||||
MEM_freeN(preview->rect);
|
||||
preview->xsize= xsize;
|
||||
preview->ysize= ysize;
|
||||
preview->rect= rect;
|
||||
|
||||
BLI_unlock_thread(LOCK_PREVIEW);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ void composit4_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo
|
||||
int src1_type, int fac1_type, int src2_type, int fac2_type);
|
||||
|
||||
CompBuf *valbuf_from_rgbabuf(CompBuf *cbuf, int channel);
|
||||
void generate_preview(bNode *node, CompBuf *stackbuf);
|
||||
void generate_preview(void *data, bNode *node, CompBuf *stackbuf);
|
||||
|
||||
void do_copy_rgba(bNode *node, float *out, float *in);
|
||||
void do_copy_rgb(bNode *node, float *out, float *in);
|
||||
|
||||
@@ -93,20 +93,23 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
||||
tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread);
|
||||
tex_do_preview(node, params.coord, &target->tr);
|
||||
}
|
||||
else if(cdata->which_output == node->custom1) {
|
||||
TexParams params;
|
||||
params_from_cdata(¶ms, cdata);
|
||||
else {
|
||||
/* 0 means don't care, so just use first */
|
||||
if(cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) {
|
||||
TexParams params;
|
||||
params_from_cdata(¶ms, cdata);
|
||||
|
||||
osa(tex_input_rgba, &target->tr, in[0], ¶ms, cdata->thread);
|
||||
|
||||
osa(tex_input_rgba, &target->tr, in[0], ¶ms, cdata->thread);
|
||||
|
||||
target->tin = (target->tr + target->tg + target->tb) / 3.0f;
|
||||
target->talpha = 1.0f;
|
||||
|
||||
if(target->nor) {
|
||||
if(in[1]->hasinput)
|
||||
osa(tex_input_vec, target->nor, in[1], ¶ms, cdata->thread);
|
||||
else
|
||||
target->nor = 0;
|
||||
target->tin = (target->tr + target->tg + target->tb) / 3.0f;
|
||||
target->talpha = 1.0f;
|
||||
|
||||
if(target->nor) {
|
||||
if(in[1]->hasinput)
|
||||
osa(tex_input_vec, target->nor, in[1], ¶ms, cdata->thread);
|
||||
else
|
||||
target->nor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,10 +176,6 @@ void ntreeTexExecTree(
|
||||
TexResult dummy_texres;
|
||||
TexCallData data;
|
||||
|
||||
/* 0 means don't care, so just use first */
|
||||
if(which_output == 0)
|
||||
which_output = 1;
|
||||
|
||||
if(!texres) texres = &dummy_texres;
|
||||
data.coord = coord;
|
||||
data.dxt = dxt;
|
||||
|
||||
Reference in New Issue
Block a user