diff options
-rw-r--r-- | source/blender/include/BSE_node.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_color_types.h | 5 | ||||
-rw-r--r-- | source/blender/src/drawnode.c | 53 | ||||
-rw-r--r-- | source/blender/src/editsima.c | 38 | ||||
-rw-r--r-- | source/blender/src/interface_draw.c | 29 |
5 files changed, 113 insertions, 15 deletions
diff --git a/source/blender/include/BSE_node.h b/source/blender/include/BSE_node.h index b1854e31d50..9e6acc7af04 100644 --- a/source/blender/include/BSE_node.h +++ b/source/blender/include/BSE_node.h @@ -103,6 +103,9 @@ void node_rename_but(char *s); void init_node_butfuncs(void); +void node_curvemap_sample(float *col); + + /* exported to CMP and SHD nodes */ //void node_ID_title_cb(void *node_v, void *unused_v); //void node_but_title_cb(void *node_v, void *but_v); diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index a4224976f5f..3caa74c9a72 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -69,13 +69,16 @@ typedef struct CurveMapping { CurveMap cm[4]; /* max 4 builtin curves per mapping struct now */ float black[3], white[3]; /* black/white point (black[0] abused for current frame) */ - float bwmul[3], padf; /* black/white point multiply value, for speed */ + float bwmul[3]; /* black/white point multiply value, for speed */ + + float sample[3]; /* sample values, if flag set it draws line and intersection */ } CurveMapping; /* cumapping->flag */ #define CUMA_DO_CLIP 1 #define CUMA_PREMULLED 2 #define CUMA_DRAW_CFRA 4 +#define CUMA_DRAW_SAMPLE 8 #endif diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c index 961cad5f840..cca13671017 100644 --- a/source/blender/src/drawnode.c +++ b/source/blender/src/drawnode.c @@ -348,7 +348,7 @@ static int node_buts_time(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *b if(cumap) cumap->flag |= CUMA_DRAW_CFRA; if(node->custom1<node->custom2) - cumap->black[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1); + cumap->sample[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1); uiBlockBeginAlign(block); uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Sta:", @@ -380,9 +380,23 @@ static int node_buts_curvevec(uiBlock *block, bNodeTree *ntree, bNode *node, rct return (int)(node->width-NODE_DY); } +static float *_sample_col= NULL; // bad bad, 2.5 will do better? +void node_curvemap_sample(float *col) +{ + _sample_col= col; +} + static int node_buts_curvecol(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr) { if(block) { + CurveMapping *cumap= node->storage; + if(_sample_col) { + cumap->flag |= CUMA_DRAW_SAMPLE; + VECCOPY(cumap->sample, _sample_col); + } + else + cumap->flag &= ~CUMA_DRAW_SAMPLE; + curvemap_buttons(block, node->storage, 'c', B_NODE_EXEC+node->nr, B_REDR, butr); } return (int)(node->width-NODE_DY); @@ -2112,7 +2126,40 @@ static void draw_nodespace_grid(SpaceNode *snode) glEnd(); } -static void draw_nodespace_back(ScrArea *sa, SpaceNode *snode) +static void draw_nodespace_back_pix(ScrArea *sa, SpaceNode *snode) +{ + + draw_nodespace_grid(snode); + + if(snode->flag & SNODE_BACKDRAW) { + Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + if(ibuf) { + int x, y; + /* somehow the offset has to be calculated inverse */ + + glaDefine2DArea(&sa->winrct); + /* ortho at pixel level curarea */ + myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375); + + x = (sa->winx-ibuf->x)/2 + snode->xof; + y = (sa->winx-ibuf->y)/2 + snode->yof; + + 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); + + /* sort this out, this should not be needed */ + myortho2(snode->v2d.cur.xmin, snode->v2d.cur.xmax, snode->v2d.cur.ymin, snode->v2d.cur.ymax); + bwin_clear_viewmat(sa->win); /* clear buttons view */ + glLoadIdentity(); + } + } +} + +/* note: needs to be userpref or opengl profile option */ +static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode) { draw_nodespace_grid(snode); @@ -3062,7 +3109,7 @@ void drawnodespace(ScrArea *sa, void *spacedata) snode->curfont= uiSetCurFont_ext(snode->aspect); /* backdrop */ - draw_nodespace_back(sa, snode); + draw_nodespace_back_pix(sa, snode); /* nodes */ snode_set_context(snode); diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c index c5215615618..0c29bceba37 100644 --- a/source/blender/src/editsima.c +++ b/source/blender/src/editsima.c @@ -97,6 +97,7 @@ #include "BSE_drawipo.h" #include "BSE_edit.h" #include "BSE_filesel.h" +#include "BSE_node.h" #include "BSE_trans_types.h" #include "BDR_editobject.h" @@ -1889,6 +1890,7 @@ void sima_sample_color(void) if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) { float *fp= NULL, *zpf= NULL; + float vec[3]; int *zp= NULL; char *cp= NULL; @@ -1907,14 +1909,14 @@ void sima_sample_color(void) if(ibuf->rect_float) fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); + if(fp==NULL) { + fp= vec; + vec[0]= (float)cp[0]/255.0f; + vec[1]= (float)cp[1]/255.0f; + vec[2]= (float)cp[2]/255.0f; + } + if(G.sima->cumap) { - float vec[3]; - if(fp==NULL) { - fp= vec; - vec[0]= (float)cp[0]/255.0f; - vec[1]= (float)cp[1]/255.0f; - vec[2]= (float)cp[2]/255.0f; - } if(ibuf->channels==4) { if(G.qual & LR_CTRLKEY) { @@ -1928,18 +1930,36 @@ void sima_sample_color(void) } } + { + ScrArea *sa, *cur= curarea; + + node_curvemap_sample(fp); /* sends global to node editor */ + for(sa= G.curscreen->areabase.first; sa; sa= sa->next) { + if(sa->spacetype==SPACE_NODE) { + areawinset(sa->win); + scrarea_do_windraw(sa); + } + } + node_curvemap_sample(NULL); /* clears global in node editor */ + curarea= cur; + } + + areawinset(curarea->win); scrarea_do_windraw(curarea); myortho2(-0.375, curarea->winx-0.375, -0.375, curarea->winy-0.375); glLoadIdentity(); - sima_show_info(ibuf->channels, x, y, cp, fp, zp, zpf); + + sima_show_info(ibuf->channels, x, y, cp, (ibuf->rect_float)?fp:NULL, zp, zpf); + screen_swapbuffers(); + } - } BIF_wait_for_statechange(); } scrarea_queue_winredraw(curarea); + } /* Image functions */ diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index 4f1d5056111..9ca260edefa 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -2234,10 +2234,35 @@ static void ui_draw_but_CURVE(uiBut *but) if(cumap->flag & CUMA_DRAW_CFRA) { glColor3ub(0x60, 0xc0, 0x40); glBegin(GL_LINES); - glVertex2f(but->x1 + zoomx*(cumap->black[0]-offsx), but->y1); - glVertex2f(but->x1 + zoomx*(cumap->black[0]-offsx), but->y2); + glVertex2f(but->x1 + zoomx*(cumap->sample[0]-offsx), but->y1); + glVertex2f(but->x1 + zoomx*(cumap->sample[0]-offsx), but->y2); glEnd(); } + /* sample option */ + if(cumap->flag & CUMA_DRAW_SAMPLE) { + if(cumap->cur==3) { + float lum= cumap->sample[0]*0.35f + cumap->sample[1]*0.45f + cumap->sample[2]*0.2f; + glColor3ub(240, 240, 240); + + glBegin(GL_LINES); + glVertex2f(but->x1 + zoomx*(lum-offsx), but->y1); + glVertex2f(but->x1 + zoomx*(lum-offsx), but->y2); + glEnd(); + } + else { + if(cumap->cur==0) + glColor3ub(240, 100, 100); + else if(cumap->cur==1) + glColor3ub(100, 240, 100); + else + glColor3ub(100, 100, 240); + + glBegin(GL_LINES); + glVertex2f(but->x1 + zoomx*(cumap->sample[cumap->cur]-offsx), but->y1); + glVertex2f(but->x1 + zoomx*(cumap->sample[cumap->cur]-offsx), but->y2); + glEnd(); + } + } /* the curve */ BIF_ThemeColorBlend(TH_TEXT, TH_BUT_NEUTRAL, 0.35); |