From cc2c511207bafdd0116cc7bf264e9bd48a4bf75f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 14 Jun 2011 15:55:46 +0000 Subject: [PATCH 01/92] Nodes display now follow 'DPI' user pref too --- source/blender/editors/space_node/node_draw.c | 115 +++++++++++------- source/blender/editors/space_node/node_edit.c | 2 +- .../blender/editors/space_node/node_intern.h | 4 +- 3 files changed, 71 insertions(+), 50 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 0c9f12966ef..5f8ab0dded5 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -288,7 +288,7 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); layout= uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, - node->locx+NODE_DYS, dy, node->butr.xmax, 20, U.uistyles.first); + node->locx+NODE_DYS, dy, node->butr.xmax, NODE_DY, U.uistyles.first); node->typeinfo->uifunc(layout, (bContext *)C, &ptr); uiBlockEndAlign(node->block); @@ -392,6 +392,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode bNode *node; bNodeSocket *sock, *gsock; rctf *rect= &gnode->totr; + float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; int counter; int dy; @@ -430,7 +431,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->inputs)-1); for(gsock=ngroup->inputs.first, sock=gnode->inputs.first; gsock; gsock=gsock->next, sock=sock->next) { gsock->locx = rect->xmin; - sock->locx = rect->xmin - NODE_GROUP_FRAME; + sock->locx = rect->xmin - node_group_frame; sock->locy = gsock->locy = dy; /* prevent long socket lists from growing out of the group box */ @@ -446,7 +447,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->outputs)-1); for(gsock=ngroup->outputs.first, sock=gnode->outputs.first; gsock; gsock=gsock->next, sock=sock->next) { gsock->locx = rect->xmax; - sock->locx = rect->xmax + NODE_GROUP_FRAME; + sock->locx = rect->xmax + node_group_frame; sock->locy = gsock->locy = dy - NODE_DYS; /* prevent long socket lists from growing out of the group box */ @@ -654,7 +655,7 @@ static uiBlock *socket_vector_menu(bContext *C, ARegion *ar, void *args_v) block= uiBeginBlock(C, ar, "socket menu", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); - layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, 20, U.uistyles.first), 0); + layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, U.uistyles.first), 0); uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE); @@ -675,7 +676,7 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c switch (sock->type) { case SOCK_VALUE: bt=uiDefButR(block, NUM, B_NODE_EXEC, name, - x, y+1, width, 17, + x, y+1, width, NODE_DY-2, &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL); if (cb) uiButSetFunc(bt, cb, arg1, arg2); @@ -693,7 +694,7 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c args->arg2 = arg2; uiDefBlockButN(block, socket_vector_menu, args, name, - x, y+1, width, 17, + x, y+1, width, NODE_DY-2, ""); break; @@ -701,14 +702,14 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c labelw= width - 40; bt=uiDefButR(block, COL, B_NODE_EXEC, "", - x, y+2, (labelw>0 ? 40 : width), 15, + x, y+2, (labelw>0 ? 40 : width), NODE_DY-2, &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL); if (cb) uiButSetFunc(bt, cb, arg1, arg2); if (name[0]!='\0' && labelw>0) uiDefBut(block, LABEL, 0, name, - x + 40, y+2, labelw, 15, + x + 40, y+2, labelw, NODE_DY-2, NULL, 0, 0, 0, 0, ""); break; } @@ -719,6 +720,8 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN bNodeSocket *sock; rctf *rct= &node->totr; float iconofs; + float socket_size= NODE_SOCKSIZE*U.dpi/72; + float iconbutw= 0.8f*UI_UNIT_X; int color_id= node_get_colorid(node); char showname[128]; /* 128 used below */ View2D *v2d = &ar->v2d; @@ -761,32 +764,32 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN icon_id= ICON_MATERIAL; else icon_id= ICON_MATERIAL_DATA; - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, icon_id, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } if(node->type == NODE_GROUP) { - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, ICON_NODETREE, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } if(node->typeinfo->flag & NODE_OPTIONS) { - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, ICON_BUTS, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } { /* always hide/reveal unused sockets */ int shade; - iconofs-=15.0f; + iconofs-=iconbutw; // XXX re-enable /*if(node_has_hidden_sockets(node)) shade= -40; else*/ shade= -90; uiDefIconBut(node->block, LABEL, B_REDR, ICON_PLUS, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } /* title */ @@ -851,7 +854,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* socket inputs, buttons */ for(sock= node->inputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); if(node->block && sock->link==NULL) { node_draw_socket_button(ntree, sock, sock->name, node->block, sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY, node_sync_cb, snode, node); @@ -869,7 +872,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN float slen; int ofs= 0; - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); UI_ThemeColor(TH_TEXT); slen= snode->aspect*UI_GetStringWidth(sock->name); @@ -904,6 +907,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b rctf *rct= &node->totr; float dx, centy= 0.5f*(rct->ymax+rct->ymin); float hiddenrad= 0.5f*(rct->ymax-rct->ymin); + float socket_size= NODE_SOCKSIZE*U.dpi/72; int color_id= node_get_colorid(node); char showname[128]; /* 128 is used below */ @@ -978,12 +982,12 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b /* sockets */ for(sock= node->inputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); } for(sock= node->outputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); } uiEndBlock(C, node->block); @@ -1043,17 +1047,30 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN { bNodeTree *ngroup= (bNodeTree *)gnode->id; bNodeSocket *sock; - rctf rect= gnode->totr; - int index; uiLayout *layout; PointerRNA ptr; uiBut *bt; + rctf rect= gnode->totr; + float socket_size= NODE_SOCKSIZE*U.dpi/72; + float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; + float group_header= 26*U.dpi/72; + float arrowbutw= 0.8f*UI_UNIT_X; + /* layout stuff for buttons on group left frame */ + float col1= 6, colw1= 0.6f*node_group_frame; + float col2= col1 + colw1+6; + float col3= node_group_frame - arrowbutw - 6; + /* layout stuff for buttons on group right frame */ + float cor1= 6; + float cor2= cor1 + arrowbutw + 6; + float cor3= cor2 + arrowbutw + 6, corw3= node_group_frame - cor3-6; + + int index; /* backdrop header */ glEnable(GL_BLEND); uiSetRoundBox(3); UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); - uiDrawBox(GL_POLYGON, rect.xmin-NODE_GROUP_FRAME, rect.ymax, rect.xmax+NODE_GROUP_FRAME, rect.ymax+26, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymax, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD); /* backdrop body */ UI_ThemeColorShadeAlpha(TH_BACK, -8, -70); @@ -1063,12 +1080,12 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* input column */ UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); uiSetRoundBox(8); - uiDrawBox(GL_POLYGON, rect.xmin-NODE_GROUP_FRAME, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD); /* output column */ UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); uiSetRoundBox(4); - uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+NODE_GROUP_FRAME, rect.ymax, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+node_group_frame, rect.ymax, BASIS_RAD); /* input column separator */ glColor4ub(200, 200, 200, 140); @@ -1088,15 +1105,15 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiSetRoundBox(15); glColor4ub(200, 200, 200, 140); glEnable( GL_LINE_SMOOTH ); - uiDrawBox(GL_LINE_LOOP, rect.xmin-NODE_GROUP_FRAME, rect.ymin, rect.xmax+NODE_GROUP_FRAME, rect.ymax+26, BASIS_RAD); + uiDrawBox(GL_LINE_LOOP, rect.xmin-node_group_frame, rect.ymin, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD); glDisable( GL_LINE_SMOOTH ); glDisable(GL_BLEND); /* backdrop title */ UI_ThemeColor(TH_TEXT_HI); - layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+23), - MIN2((int)(rect.xmax - rect.xmin-18.0f), 140), 20, U.uistyles.first); + layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+group_header), + MIN2((int)(rect.xmax - rect.xmin-18.0f), node_group_frame+20), group_header, U.uistyles.first); RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr); uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL); uiBlockLayoutResolve(gnode->block, NULL, NULL); @@ -1106,31 +1123,33 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* group sockets */ for(sock=ngroup->inputs.first, index=0; sock; sock=sock->next, ++index) { - socket_circle_draw(sock, NODE_SOCKSIZE); + float locx= sock->locx - node_group_frame; + + socket_circle_draw(sock, socket_size); /* small hack to use socket_circle_draw function with offset */ - sock->locx -= NODE_GROUP_FRAME; - socket_circle_draw(sock, NODE_SOCKSIZE); - sock->locx += NODE_GROUP_FRAME; + sock->locx -= node_group_frame; + socket_circle_draw(sock, socket_size); + sock->locx += node_group_frame; bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx-114, sock->locy+1, 72, NODE_DY, + locx+col1, sock->locy+1, colw1, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); node_draw_socket_button(ngroup, sock, "", gnode->block, - sock->locx-114, sock->locy-NODE_DY, 72, + locx+col1, sock->locy-NODE_DY, colw1, NULL, NULL, NULL); uiBlockSetDirection(gnode->block, UI_TOP); uiBlockBeginAlign(gnode->block); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP, - sock->locx-40, sock->locy, 16, 16, ""); + locx+col2, sock->locy, arrowbutw, arrowbutw, ""); if (!sock->prev) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_IN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN, - sock->locx-40, sock->locy-16, 16, 16, ""); + locx+col2, sock->locy-arrowbutw, arrowbutw, arrowbutw, ""); if (!sock->next) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); @@ -1140,22 +1159,24 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiBlockSetEmboss(gnode->block, UI_EMBOSSN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X, - sock->locx-22, sock->locy-8, 16, 16, ""); + locx+col3, sock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, ""); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_IN); uiBlockSetEmboss(gnode->block, UI_EMBOSS); } for(sock=ngroup->outputs.first, index=0; sock; sock=sock->next, ++index) { - socket_circle_draw(sock, NODE_SOCKSIZE); + float locx= sock->locx; + + socket_circle_draw(sock, socket_size); /* small hack to use socket_circle_draw function with offset */ - sock->locx += NODE_GROUP_FRAME; - socket_circle_draw(sock, NODE_SOCKSIZE); - sock->locx -= NODE_GROUP_FRAME; + sock->locx += node_group_frame; + socket_circle_draw(sock, socket_size); + sock->locx -= node_group_frame; uiBlockSetEmboss(gnode->block, UI_EMBOSSN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X, - sock->locx+6, sock->locy-8, 16, 16, ""); + locx+col1, sock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, ""); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_OUT); uiBlockSetEmboss(gnode->block, UI_EMBOSS); @@ -1163,13 +1184,13 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiBlockSetDirection(gnode->block, UI_TOP); uiBlockBeginAlign(gnode->block); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP, - sock->locx+24, sock->locy, 16, 16, ""); + locx+cor2, sock->locy, arrowbutw, arrowbutw, ""); if (!sock->prev) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_OUT); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN, - sock->locx+24, sock->locy-16, 16, 16, ""); + locx+cor2, sock->locy-arrowbutw, arrowbutw, arrowbutw, ""); if (!sock->next) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); @@ -1179,17 +1200,17 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN if (sock->link) { bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx+42, sock->locy-NODE_DYS+1, 72, NODE_DY, + locx+cor3, sock->locy-NODE_DYS+1, corw3, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); } else { bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx+42, sock->locy+1, 72, NODE_DY, + locx+cor3, sock->locy+1, corw3, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); - node_draw_socket_button(ngroup, sock, "", gnode->block, sock->locx+42, sock->locy-NODE_DY, 72, NULL, NULL, NULL); + node_draw_socket_button(ngroup, sock, "", gnode->block, locx+cor3, sock->locy-NODE_DY, corw3, NULL, NULL, NULL); } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index e539334c282..46c66c55d51 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1332,7 +1332,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) } else { node->width= nsw->oldwidth + mx - nsw->mxstart; - CLAMP(node->width, node->typeinfo->minwidth, node->typeinfo->maxwidth); + CLAMP(node->width, UI_DPI_FAC*node->typeinfo->minwidth, UI_DPI_FAC*node->typeinfo->maxwidth); } } diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index fcf1c182600..a1c0f5535fe 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -152,8 +152,8 @@ extern const char *node_context_dir[]; // XXX from BSE_node.h #define HIDDEN_RAD 15.0f #define BASIS_RAD 8.0f -#define NODE_DYS 10 -#define NODE_DY 20 +#define NODE_DYS (U.widget_unit/2) +#define NODE_DY U.widget_unit #define NODE_SOCKSIZE 5 // XXX button events (butspace) From 3fe26d7093b86c6e3bd83be178f2bce5361f0fa3 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 14 Jun 2011 17:48:42 +0000 Subject: [PATCH 02/92] RGB curve widget follows user preference DPI now too. --- .../editors/interface/interface_templates.c | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index bbd1bd8773b..32a20e82d2f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1586,21 +1586,22 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu CurveMapping *cumap = cumap_v; uiBlock *block; uiBut *bt; + float width= 8*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS); /* use this for a fake extra empy space around the buttons */ - uiDefBut(block, LABEL, 0, "", -4, 16, 128, 106, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "", -4, 16, width+8, 6*UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); bt= uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping", - 0,100,120,18, &cumap->flag, 0.0, 0.0, 10, 0, ""); + 0,5*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, ""); uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL); uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "Min X ", 0,74,120,18, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, ""); - uiDefButF(block, NUM, 0, "Min Y ", 0,56,120,18, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, ""); - uiDefButF(block, NUM, 0, "Max X ", 0,38,120,18, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "Max Y ", 0,20,120,18, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "Min X ", 0,4*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, ""); + uiDefButF(block, NUM, 0, "Min Y ", 0,3*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, ""); + uiDefButF(block, NUM, 0, "Max X ", 0,2*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "Max Y ", 0,UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, ""); uiBlockSetDirection(block, UI_RIGHT); @@ -1644,17 +1645,17 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap_v) { uiBlock *block; - short yco= 0, menuwidth=120; + short yco= 0, menuwidth=10*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 4, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 5, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1666,15 +1667,15 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void *cumap_v) { uiBlock *block; - short yco= 0, menuwidth=120; + short yco= 0, menuwidth=10*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1728,15 +1729,15 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1746,19 +1747,19 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[3].curve) { - bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1768,15 +1769,15 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1791,24 +1792,24 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in"); + bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in"); uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL); - bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out"); + bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out"); uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL); if(brush) - bt= uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, 18, "Tools"); + bt= uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, "Tools"); else - bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, 18, "Tools"); + bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, "Tools"); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT; - bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, 18, "Clipping Options"); + bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, "Clipping Options"); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - bt= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points"); + bt= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points"); uiButSetNFunc(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap); uiBlockSetEmboss(block, UI_EMBOSS); From 62ba2d4c6811c1b2b27163c46f9bbc0e696f63ee Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 00:16:30 +0000 Subject: [PATCH 03/92] Changes to quick explode - fix python error when the object had an empty material slot - initialize start frame from the current frame - set frame range to 300000 max (which is blenders own maximum) - mesh order was arbitrary, instead use selected -> active, removed invert option. also fix for missing include in bpy_extras.view3d_utils --- .../modules/bpy_extras/view3d_utils.py | 2 + .../bl_operators/object_quick_effects.py | 110 ++++++++++-------- 2 files changed, 65 insertions(+), 47 deletions(-) diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py index 45f537ebd2f..f2f2e53240b 100644 --- a/release/scripts/modules/bpy_extras/view3d_utils.py +++ b/release/scripts/modules/bpy_extras/view3d_utils.py @@ -114,6 +114,8 @@ def location_3d_to_region_2d(region, rv3d, coord): :return: 2d location :rtype: :class:`Vector` """ + from mathutils import Vector + prj = Vector((coord[0], coord[1], coord[2], 1.0)) * rv3d.perspective_matrix if prj.w > 0.0: width_half = region.width / 2.0 diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index 90b0fa0af83..2ecca8ab168 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -22,6 +22,24 @@ from mathutils import Vector import bpy from bpy.props import BoolProperty, EnumProperty, IntProperty, FloatProperty, FloatVectorProperty + +def object_ensure_material(obj, mat_name): + """ Use an existing material or add a new one. + """ + mat = mat_slot = None + for mat_slot in obj.material_slots: + mat = mat_slot.material + if mat: + break + if mat is None: + mat = bpy.data.materials.new(mat_name) + if mat_slot: + mat_slot.material = mat + else: + obj.data.materials.append(mat) + return mat + + class QuickFur(bpy.types.Operator): bl_idname = "object.quick_fur" bl_label = "Quick Fur" @@ -78,6 +96,7 @@ class QuickFur(bpy.types.Operator): return {'FINISHED'} + class QuickExplode(bpy.types.Operator): bl_idname = "object.quick_explode" bl_label = "Quick Explode" @@ -93,40 +112,44 @@ class QuickExplode(bpy.types.Operator): amount = IntProperty(name="Amount of pieces", default=100, min=2, max=10000, soft_min=2, soft_max=10000) - duration = IntProperty(name="Duration", - default=50, min=1, max=10000, soft_min=1, soft_max=10000) + frame_duration = IntProperty(name="Duration", + default=50, min=1, max=300000, soft_min=1, soft_max=10000) - start_frame = IntProperty(name="Start Frame", - default=1, min=1, max=10000, soft_min=1, soft_max=10000) + frame_start = IntProperty(name="Start Frame", + default=1, min=1, max=300000, soft_min=1, soft_max=10000) - end_frame = IntProperty(name="End Frame", - default=10, min=1, max=10000, soft_min=1, soft_max=10000) + frame_end = IntProperty(name="End Frame", + default=10, min=1, max=300000, soft_min=1, soft_max=10000) velocity = FloatProperty(name="Outwards Velocity", - default=1, min=0, max=1000, soft_min=0, soft_max=10) + default=1, min=0, max=300000, soft_min=0, soft_max=10) fade = BoolProperty(name="Fade", description="Fade the pieces over time.", default=True) - invert_order = BoolProperty(name="Invert Order", - description="Blend objects in the opposite direction (only for Blend style explosion).", - default=False) - def execute(self, context): fake_context = bpy.context.copy() - mesh_objects = [obj for obj in context.selected_objects if obj.type == 'MESH'] + obj_act = context.active_object + + if obj_act.type != 'MESH': + self.report({'ERROR'}, "Active object is not a mesh") + return {'CANCELLED'} + + mesh_objects = [obj for obj in context.selected_objects + if obj.type == 'MESH' and obj != obj_act] + mesh_objects.insert(0, obj_act) if self.style == 'BLEND' and len(mesh_objects) != 2: - self.report({'ERROR'}, "Select two mesh objects.") + self.report({'ERROR'}, "Select two mesh objects") return {'CANCELLED'} elif not mesh_objects: - self.report({'ERROR'}, "Select at least one mesh object.") + self.report({'ERROR'}, "Select at least one mesh object") return {'CANCELLED'} for obj in mesh_objects: - if len(obj.particle_systems) > 0: - self.report({'ERROR'}, "Selected object's can't have particle systems.") + if obj.particle_systems: + self.report({'ERROR'}, "Object %r already has a particle system" % obj.name) return {'CANCELLED'} if self.fade: @@ -137,16 +160,12 @@ class QuickExplode(bpy.types.Operator): tex.color_ramp.elements[0].position = 0.333 tex.color_ramp.elements[1].position = 0.666 - tex.color_ramp.elements[0].color[3] = 1 - tex.color_ramp.elements[1].color[3] = 0 + tex.color_ramp.elements[0].color[3] = 1.0 + tex.color_ramp.elements[1].color[3] = 0.0 if self.style == 'BLEND': - if self.invert_order: - from_obj = mesh_objects[1] - to_obj = mesh_objects[0] - else: - from_obj = mesh_objects[0] - to_obj = mesh_objects[1] + from_obj = mesh_objects[1] + to_obj = mesh_objects[0] for obj in mesh_objects: fake_context["object"] = obj @@ -154,31 +173,28 @@ class QuickExplode(bpy.types.Operator): settings = obj.particle_systems[-1].settings settings.count = self.amount - settings.frame_start = self.start_frame - settings.frame_end = self.end_frame - self.duration - settings.lifetime = self.duration + settings.frame_start = self.frame_start + settings.frame_end = self.frame_end - self.frame_duration + settings.lifetime = self.frame_duration settings.normal_factor = self.velocity settings.render_type = 'NONE' - bpy.ops.object.modifier_add(fake_context, type='EXPLODE') - explode = obj.modifiers[-1] + explode = obj.modifiers.new(name='Explode', type='EXPLODE') explode.use_edge_cut = True if self.fade: explode.show_dead = False - bpy.ops.mesh.uv_texture_add(fake_context); + bpy.ops.mesh.uv_texture_add(fake_context) uv = obj.data.uv_textures[-1] uv.name = "Explode fade" explode.particle_uv = uv.name - if len(obj.material_slots) == 0: - obj.data.materials.append(bpy.data.materials.new("Explode fade")) + mat = object_ensure_material(obj, "Explode Fade") - mat = obj.data.materials[0] mat.use_transparency = True mat.use_transparent_shadows = True - mat.alpha = 0 - mat.specular_alpha = 0 + mat.alpha = 0.0 + mat.specular_alpha = 0.0 tex_slot = mat.texture_slots.add() @@ -190,16 +206,12 @@ class QuickExplode(bpy.types.Operator): if self.style == 'BLEND': if obj == to_obj: - tex_slot.alpha_factor = -1 + tex_slot.alpha_factor = -1.0 elem = tex.color_ramp.elements[1] - elem.color[0] = mat.diffuse_color[0] - elem.color[1] = mat.diffuse_color[1] - elem.color[2] = mat.diffuse_color[2] + elem.color = mat.diffuse_color else: elem = tex.color_ramp.elements[0] - elem.color[0] = mat.diffuse_color[0] - elem.color[1] = mat.diffuse_color[1] - elem.color[2] = mat.diffuse_color[2] + elem.color = mat.diffuse_color else: tex_slot.use_map_color_diffuse = False @@ -223,14 +235,18 @@ class QuickExplode(bpy.types.Operator): explode.show_dead = True else: settings.factor_random = self.velocity - settings.angular_velocity_factor = self.velocity/10 + settings.angular_velocity_factor = self.velocity / 10.0 return {'FINISHED'} + def invoke(self, context, event): + self.frame_start = context.scene.frame_current + self.frame_end = self.frame_start + self.frame_duration + return self.execute(context) def obj_bb_minmax(obj, min_co, max_co): for i in range(0, 8): - bb_vec = Vector((obj.bound_box[i][0], obj.bound_box[i][1], obj.bound_box[i][2])) * obj.matrix_world + bb_vec = Vector(obj.bound_box[i]) * obj.matrix_world min_co[0] = min(bb_vec[0], min_co[0]) min_co[1] = min(bb_vec[1], min_co[1]) @@ -260,8 +276,8 @@ class QuickSmoke(bpy.types.Operator): def execute(self, context): fake_context = bpy.context.copy() mesh_objects = [obj for obj in context.selected_objects if obj.type == 'MESH'] - min_co = Vector((100000, 100000, 100000)) - max_co = Vector((-100000, -100000, -100000)) + min_co = Vector((100000.0, 100000.0, 100000.0)) + max_co = -min_co if not mesh_objects: self.report({'ERROR'}, "Select at least one mesh object.") @@ -441,4 +457,4 @@ class QuickFluid(bpy.types.Operator): if self.start_baking: bpy.ops.fluid.bake() - return {'FINISHED'} \ No newline at end of file + return {'FINISHED'} From 1d41694e6974ee870fdeef2a5516d8368a2b9853 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 01:56:49 +0000 Subject: [PATCH 04/92] fix [#27662] Storing png/tga images ignore Alpha settings - don't clear alpha when baking RGB images - when baking results in partial alpha. set the depth to 32. --- source/blender/blenpluginapi/iff.h | 3 ++- source/blender/editors/object/object_bake.c | 21 +++++++++++++++++-- source/blender/imbuf/IMB_imbuf.h | 3 ++- source/blender/imbuf/intern/rectop.c | 17 ++++++++++++++- .../blender/render/intern/source/rendercore.c | 20 ++++++++++++++++-- 5 files changed, 57 insertions(+), 7 deletions(-) diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h index bccc7bdb769..77cdf889ea5 100644 --- a/source/blender/blenpluginapi/iff.h +++ b/source/blender/blenpluginapi/iff.h @@ -113,9 +113,10 @@ LIBIMPORT void interlace(struct ImBuf *ib); LIBIMPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height); -LIBIMPORT void IMB_rectfill(struct ImBuf *drect, float col[4]); +LIBIMPORT void IMB_rectfill(struct ImBuf *drect, const float col[4]); LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); +LIBIMPORT void IMB_rectfill_alpha(struct ImBuf *drect, const float value); #endif /* IFF_H */ diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 565c5810cff..c669a69b157 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -854,10 +854,14 @@ static void finish_images(MultiresBakeRender *bkr) Image *ima= (Image*)link->data; int i; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + short is_new_alpha; if(ibuf->x<=0 || ibuf->y<=0) continue; + /* must check before filtering */ + is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); + /* Margin */ if(bkr->bake_filter) { char *temprect; @@ -882,6 +886,18 @@ static void finish_images(MultiresBakeRender *bkr) IMB_filter_extend(ibuf, (char *)ibuf->userdata); } + /* if the bake results in new alpha then change the image setting */ + if(is_new_alpha) { + ibuf->depth= 32; + } + else { + if(bkr->bake_filter) { + /* clear alpha added by filtering */ + IMB_rectfill_alpha(ibuf, 1.0f); + } + } + + ibuf->userflags|= IB_BITMAPDIRTY; if(ibuf->mipmap[0]) { ibuf->userflags|= IB_MIPMAP_INVALID; @@ -1028,7 +1044,8 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l static void clear_images(MTFace *mtface, int totface) { int a; - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; for(a= 0; aid.flag&= ~LIB_DOIT; @@ -1039,7 +1056,7 @@ static void clear_images(MTFace *mtface, int totface) if((ima->id.flag&LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - IMB_rectfill(ibuf, vec); + IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); ima->id.flag|= LIB_DOIT; } } diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 5d61452e149..e9592fdc164 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -442,8 +442,9 @@ void IMB_freezbuffloatImBuf(struct ImBuf *ibuf); * * @attention Defined in rectop.c */ -void IMB_rectfill(struct ImBuf *drect, float col[4]); +void IMB_rectfill(struct ImBuf *drect, const float col[4]); void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); +void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value); /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 44af7ffdb3f..844478e03cb 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -450,7 +450,7 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, /* fill */ -void IMB_rectfill(struct ImBuf *drect, float col[4]) +void IMB_rectfill(struct ImBuf *drect, const float col[4]) { int num; @@ -561,3 +561,18 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i if (!ibuf) return; buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, x1, y1, x2, y2); } + + +void IMB_rectfill_alpha(ImBuf *ibuf, const float value) +{ + int i; + if (ibuf->rect_float) { + float *fbuf= ibuf->rect_float + 3; + for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf+= 4) { *fbuf = value; } + } + else { + const unsigned char cvalue= value * 255; + unsigned char *cbuf= ((unsigned char *)ibuf->rect) + 3; + for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf+= 4) { *cbuf = cvalue; } + } +} diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 0087be8cca9..e6206007b7a 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2464,7 +2464,8 @@ static int get_next_bake_face(BakeShade *bs) if(tface && tface->tpage) { Image *ima= tface->tpage; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; if(ibuf==NULL) continue; @@ -2484,7 +2485,7 @@ static int get_next_bake_face(BakeShade *bs) imb_freerectImBuf(ibuf); /* clear image */ if(R.r.bake_flag & R_BAKE_CLEAR) - IMB_rectfill(ibuf, vec); + IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); /* might be read by UI to set active image for display */ R.bakebuf= ima; @@ -2671,10 +2672,14 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up for(ima= G.main->image.first; ima; ima= ima->id.next) { if((ima->id.flag & LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + short is_new_alpha; if(!ibuf) continue; + /* must check before filtering */ + is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); + if(re->r.bake_filter) { if (usemask) { /* extend the mask +2 pixels from the image, @@ -2706,6 +2711,17 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up } } + /* if the bake results in new alpha then change the image setting */ + if(is_new_alpha) { + ibuf->depth= 32; + } + else { + if(re->r.bake_filter) { + /* clear alpha added by filtering */ + IMB_rectfill_alpha(ibuf, 1.0f); + } + } + ibuf->userflags |= IB_BITMAPDIRTY; if (ibuf->rect_float) IMB_rect_from_float(ibuf); } From b89924f5dde483fffbd071a5c84713a2bb357557 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 02:14:38 +0000 Subject: [PATCH 05/92] de-duplicate multires image filter function. (no functional change) --- source/blender/editors/object/object_bake.c | 41 +-------- .../render/extern/include/RE_shader_ext.h | 4 +- .../blender/render/intern/source/rendercore.c | 87 +++++++++---------- 3 files changed, 47 insertions(+), 85 deletions(-) diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index c669a69b157..fc5f09f2fe0 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -854,49 +854,11 @@ static void finish_images(MultiresBakeRender *bkr) Image *ima= (Image*)link->data; int i; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - short is_new_alpha; if(ibuf->x<=0 || ibuf->y<=0) continue; - /* must check before filtering */ - is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); - - /* Margin */ - if(bkr->bake_filter) { - char *temprect; - - /* extend the mask +2 pixels from the image, - * this is so colors dont blend in from outside */ - - for(i=0; ibake_filter; i++) - IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); - - temprect = MEM_dupallocN(ibuf->userdata); - - /* expand twice to clear this many pixels, so they blend back in */ - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - - /* clear all pixels in the margin */ - IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); - MEM_freeN(temprect); - - for(i= 0; ibake_filter; i++) - IMB_filter_extend(ibuf, (char *)ibuf->userdata); - } - - /* if the bake results in new alpha then change the image setting */ - if(is_new_alpha) { - ibuf->depth= 32; - } - else { - if(bkr->bake_filter) { - /* clear alpha added by filtering */ - IMB_rectfill_alpha(ibuf, 1.0f); - } - } - + RE_bake_ibuf_filter(ibuf, (unsigned char *)ibuf->userdata, bkr->bake_filter); ibuf->userflags|= IB_BITMAPDIRTY; if(ibuf->mipmap[0]) { @@ -1349,7 +1311,6 @@ static void finish_bake_internal(BakeRender *bkr) /* freed when baking is done, but if its canceled we need to free here */ if (ibuf->userdata) { - printf("freed\n"); MEM_freeN(ibuf->userdata); ibuf->userdata= NULL; } diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 958c19ab9ca..a59ebdaa5a2 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -193,6 +193,8 @@ typedef struct ShadeInput /* node shaders... */ struct Tex; struct MTex; +struct ImBuf; + /* this one uses nodes */ int multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres); /* nodes disabled */ @@ -209,6 +211,6 @@ struct Object; void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr); int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress); struct Image *RE_bake_shade_get_image(void); +void RE_bake_ibuf_filter(struct ImBuf *ibuf, unsigned char *mask, const int filter); #endif /* RE_SHADER_EXT_H */ - diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index e6206007b7a..d0daf5b817a 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2590,6 +2590,48 @@ static void *do_bake_thread(void *bs_v) return NULL; } +void RE_bake_ibuf_filter(ImBuf *ibuf, unsigned char *mask, const int filter) +{ + /* must check before filtering */ + const short is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); + + /* Margin */ + if(filter) { + char *temprect; + int i; + + /* extend the mask +2 pixels from the image, + * this is so colors dont blend in from outside */ + + for(i=0; i< filter; i++) + IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); + + temprect = MEM_dupallocN(ibuf->userdata); + + /* expand twice to clear this many pixels, so they blend back in */ + IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); + IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); + + /* clear all pixels in the margin */ + IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); + MEM_freeN(temprect); + + for(i= 0; i < filter; i++) + IMB_filter_extend(ibuf, (char *)ibuf->userdata); + } + + /* if the bake results in new alpha then change the image setting */ + if(is_new_alpha) { + ibuf->depth= 32; + } + else { + if(filter) { + /* clear alpha added by filtering */ + IMB_rectfill_alpha(ibuf, 1.0f); + } + } +} + /* using object selection tags, the faces with UV maps get baked */ /* render should have been setup */ /* returns 0 if nothing was handled */ @@ -2677,50 +2719,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up if(!ibuf) continue; - /* must check before filtering */ - is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); - - if(re->r.bake_filter) { - if (usemask) { - /* extend the mask +2 pixels from the image, - * this is so colors dont blend in from outside */ - char *temprect; - - for(a=0; ar.bake_filter; a++) - IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); - - temprect = MEM_dupallocN(ibuf->userdata); - - /* expand twice to clear this many pixels, so they blend back in */ - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - - /* clear all pixels in the margin*/ - IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); - MEM_freeN(temprect); - } - - for(a=0; ar.bake_filter; a++) { - /*the mask, ibuf->userdata - can be null, in this case only zero alpha is used */ - IMB_filter_extend(ibuf, (char *)ibuf->userdata); - } - - if (ibuf->userdata) { - MEM_freeN(ibuf->userdata); - ibuf->userdata= NULL; - } - } - - /* if the bake results in new alpha then change the image setting */ - if(is_new_alpha) { - ibuf->depth= 32; - } - else { - if(re->r.bake_filter) { - /* clear alpha added by filtering */ - IMB_rectfill_alpha(ibuf, 1.0f); - } - } + RE_bake_ibuf_filter(ibuf, (unsigned char *)ibuf->userdata, re->r.bake_filter); ibuf->userflags |= IB_BITMAPDIRTY; if (ibuf->rect_float) IMB_rect_from_float(ibuf); From 1669ab6648c81b7f17601cc28dd9bcf3c04f9bbb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 02:17:39 +0000 Subject: [PATCH 06/92] correction for own commit r37492 --- source/blender/render/intern/source/rendercore.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index d0daf5b817a..6b50ba417eb 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2625,7 +2625,7 @@ void RE_bake_ibuf_filter(ImBuf *ibuf, unsigned char *mask, const int filter) ibuf->depth= 32; } else { - if(filter) { + if(filter && ibuf->depth != 32) { /* clear alpha added by filtering */ IMB_rectfill_alpha(ibuf, 1.0f); } @@ -2714,7 +2714,6 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up for(ima= G.main->image.first; ima; ima= ima->id.next) { if((ima->id.flag & LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - short is_new_alpha; if(!ibuf) continue; From b09bb948ee5d59f80a4951ffd99733dd64f12a4a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 06:25:05 +0000 Subject: [PATCH 07/92] fix [#27658] Bake action operator error on non armature objects add support for baking object transformations too, also add option to clear constraints (off by default). --- release/scripts/startup/bl_operators/nla.py | 125 ++++++++++++++++---- 1 file changed, 104 insertions(+), 21 deletions(-) diff --git a/release/scripts/startup/bl_operators/nla.py b/release/scripts/startup/bl_operators/nla.py index 923ca92a162..6b324111903 100644 --- a/release/scripts/startup/bl_operators/nla.py +++ b/release/scripts/startup/bl_operators/nla.py @@ -16,17 +16,16 @@ # # ##### END GPL LICENSE BLOCK ##### -# +# import bpy -def pose_info(): +def pose_frame_info(obj): from mathutils import Matrix info = {} - obj = bpy.context.object pose = obj.pose pose_items = pose.bones.items() @@ -51,7 +50,6 @@ def pose_info(): except: binfo["matrix_pose_inv"] = Matrix() - print(binfo["matrix_pose"]) info[name] = binfo for name, pbone in pose_items: @@ -67,45 +65,84 @@ def pose_info(): matrix = binfo_parent["matrix_pose_inv"] * matrix rest_matrix = binfo_parent["matrix_local_inv"] * rest_matrix - matrix = rest_matrix.inverted() * matrix - - binfo["matrix_key"] = matrix.copy() + binfo["matrix_key"] = rest_matrix.inverted() * matrix return info -def bake(frame_start, frame_end, step=1, only_selected=False): +def obj_frame_info(obj): + info = {} + # parent = obj.parent + info["matrix_key"] = obj.matrix_local.copy() + return info + + +def bake(frame_start, + frame_end, step=1, + only_selected=False, + do_pose=True, + do_object=True, + do_constraint_clear=False, + ): + scene = bpy.context.scene obj = bpy.context.object pose = obj.pose + frame_back = scene.frame_current - info_ls = [] + if pose is None: + do_pose = False + + if do_pose is None and do_object is None: + return None + + pose_info = [] + obj_info = [] frame_range = range(frame_start, frame_end + 1, step) - # could spped this up by applying steps here too... + # ------------------------------------------------------------------------- + # Collect transformations + + # could speed this up by applying steps here too... for f in frame_range: scene.frame_set(f) - info = pose_info() - info_ls.append(info) + if do_pose: + pose_info.append(pose_frame_info(obj)) + if do_object: + obj_info.append(obj_frame_info(obj)) + f += 1 + # ------------------------------------------------------------------------- + # Create action + action = bpy.data.actions.new("Action") + obj.animation_data.action = action - bpy.context.object.animation_data.action = action + if do_pose: + pose_items = pose.bones.items() + else: + pose_items = [] # skip - pose_items = pose.bones.items() + # ------------------------------------------------------------------------- + # Apply transformations to action - for name, pbone in pose_items: + # pose + for name, pbone in (pose_items if do_pose else ()): if only_selected and not pbone.bone.select: continue - for f in frame_range: - matrix = info_ls[int((f - frame_start) / step)][name]["matrix_key"] + if do_constraint_clear: + while pbone.constraints: + pbone.constraints.remove(pbone.constraints[0]) - #pbone.location = matrix.to_translation() - #pbone.rotation_quaternion = matrix.to_quaternion() + for f in frame_range: + matrix = pose_info[(f - frame_start) // step][name]["matrix_key"] + + # pbone.location = matrix.to_translation() + # pbone.rotation_quaternion = matrix.to_quaternion() pbone.matrix_basis = matrix pbone.keyframe_insert("location", -1, f, name) @@ -121,10 +158,35 @@ def bake(frame_start, frame_end, step=1, only_selected=False): pbone.keyframe_insert("scale", -1, f, name) + # object. TODO. multiple objects + if do_object: + if do_constraint_clear: + while obj.constraints: + obj.constraints.remove(obj.constraints[0]) + + for f in frame_range: + matrix = obj_info[(f - frame_start) // step]["matrix_key"] + obj.matrix_local = matrix + + obj.keyframe_insert("location", -1, f) + + rotation_mode = obj.rotation_mode + + if rotation_mode == 'QUATERNION': + obj.keyframe_insert("rotation_quaternion", -1, f) + elif rotation_mode == 'AXIS_ANGLE': + obj.keyframe_insert("rotation_axis_angle", -1, f) + else: # euler, XYZ, ZXY etc + obj.keyframe_insert("rotation_euler", -1, f) + + obj.keyframe_insert("scale", -1, f) + + scene.frame_set(frame_back) + return action -from bpy.props import IntProperty, BoolProperty +from bpy.props import IntProperty, BoolProperty, EnumProperty class BakeAction(bpy.types.Operator): @@ -144,10 +206,31 @@ class BakeAction(bpy.types.Operator): default=1, min=1, max=120) only_selected = BoolProperty(name="Only Selected", default=True) + clear_consraints = BoolProperty(name="Clear Constraints", + default=False) + bake_types = EnumProperty( + name="Bake Data", + options={'ENUM_FLAG'}, + items=(('POSE', "Pose", ""), + ('OBJECT', "Object", ""), + ), + default={'POSE'}, + ) def execute(self, context): - action = bake(self.frame_start, self.frame_end, self.step, self.only_selected) + action = bake(self.frame_start, + self.frame_end, + self.step, + self.only_selected, + 'POSE' in self.bake_types, + 'OBJECT' in self.bake_types, + self.clear_consraints, + ) + + if action is None: + self.report({'INFO'}, "Nothing to bake") + return {'CANCELLED'} # basic cleanup, could move elsewhere for fcu in action.fcurves: From 5e418071352977f0e55e0f84ffbb02ff8c5a6763 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 15 Jun 2011 09:45:26 +0000 Subject: [PATCH 08/92] Fix #27654: vertex parenting not working with constructive modifiers. Vertex parents were not requesting the original index layer, now do this as part of depsgraph building, and make constraints with vertex groups use the same system. Fix is based on patch by Campbell, but with some changes. --- source/blender/blenkernel/depsgraph_private.h | 3 ++- source/blender/blenkernel/intern/constraint.c | 13 +++---------- source/blender/blenkernel/intern/depsgraph.c | 17 +++++++++++++++-- source/blender/blenkernel/intern/object.c | 5 +++-- source/blender/blenloader/intern/readfile.c | 1 + source/blender/makesdna/DNA_object_types.h | 5 ++--- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 1fed115893c..ef4f320602b 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -69,8 +69,9 @@ typedef struct DagNode void * ob; void * first_ancestor; int ancestor_count; - unsigned int lay; // accumulated layers of its relations + itself + unsigned int lay; // accumulated layers of its relations + itself unsigned int scelay; // layers due to being in scene + unsigned int customdata_mask; // customdata mask int lasttime; // if lasttime != DagForest->time, this node was not evaluated yet for flushing int BFS_dist; // BFS distance int DFS_dist; // DFS distance diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index d3c14a9dd12..18c9ab7dc90 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -449,16 +449,9 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substr freeDM= 1; } else { - /* when not in EditMode, use the 'final' derived mesh - * - check if the custom data masks for derivedFinal mean that we can just use that - * (this is more effficient + sufficient for most cases) - */ - if (!(ob->lastDataMask & CD_MASK_MDEFORMVERT)) { - dm = mesh_get_derived_final(scene, ob, CD_MASK_MDEFORMVERT); - freeDM= 1; - } - else - dm = (DerivedMesh *)ob->derivedFinal; + /* when not in EditMode, use the 'final' derived mesh, depsgraph + * ensures we build with CD_MDEFORMVERT layer */ + dm = (DerivedMesh *)ob->derivedFinal; } /* only continue if there's a valid DerivedMesh */ diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 472d7d77b80..c2800410657 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -372,6 +372,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O node2->first_ancestor = ob; node2->ancestor_count += 1; } + + /* also build a custom data mask for dependencies that need certain layers */ + node->customdata_mask= 0; if (ob->type == OB_ARMATURE) { if (ob->pose){ @@ -451,8 +454,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O case PARSKEL: dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); break; - case PARVERT1: case PARVERT3: case PARBONE: + case PARVERT1: case PARVERT3: dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent"); + node2->customdata_mask |= CD_MASK_ORIGINDEX; + break; + case PARBONE: + dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent"); break; default: if(ob->parent->type==OB_LATTICE) @@ -647,8 +654,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO)) dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); else { - if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) + if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) { dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + if (obt->type == OB_MESH) + node2->customdata_mask |= CD_MASK_MDEFORMVERT; + } else dag_add_relation(dag, node2, node, DAG_RL_OB_OB, cti->name); } @@ -722,6 +732,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) itA->node->color |= itA->type; } } + + /* also flush custom data mask */ + ((Object*)node->ob)->customdata_mask= node->customdata_mask; } } /* now set relations equal, so that when only one parent changes, the correct recalcs are found */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 16fa1605467..dff62b05bd3 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2641,11 +2641,12 @@ void object_handle_update(Scene *scene, Object *ob) #else /* ensure CD_MASK_BAREMESH for now */ EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; + unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; if(em) { - makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */ + makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */ BKE_mesh_end_editmesh(ob->data, em); } else - makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH); + makeDerivedMesh(scene, ob, NULL, data_mask); #endif } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1e604c45772..222c4bcf6fc 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4321,6 +4321,7 @@ static void direct_link_object(FileData *fd, Object *ob) MEM_freeN(hook); } + ob->customdata_mask= 0; ob->bb= NULL; ob->derivedDeform= NULL; ob->derivedFinal= NULL; diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 54a885a0860..f4488c140a0 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -250,12 +250,11 @@ typedef struct Object { struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */ struct DerivedMesh *derivedDeform, *derivedFinal; - int lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ + unsigned int lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ + unsigned int customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */ unsigned int state; /* bit masks of game controllers that are active */ unsigned int init_state; /* bit masks of initial state as recorded by the users */ - int pad2; - ListBase gpulamp; /* runtime, for lamps only */ ListBase pc_ids; ListBase *duplilist; /* for temporary dupli list storage, only for use by RNA API */ From aaf7dae5f18d918cce34e6c54eb971778cdd1bb9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 15 Jun 2011 10:17:06 +0000 Subject: [PATCH 09/92] Code cleanup: remove unused shaded draw mode code. --- source/blender/blenkernel/BKE_displist.h | 5 - source/blender/blenkernel/intern/blender.c | 1 - source/blender/blenkernel/intern/displist.c | 496 ------------------ source/blender/editors/mesh/mesh_data.c | 5 +- source/blender/editors/object/object_add.c | 2 - .../blender/editors/object/object_relations.c | 2 - .../blender/editors/space_view3d/drawobject.c | 104 +--- .../editors/space_view3d/view3d_draw.c | 4 - .../editors/transform/transform_conversions.c | 4 - .../editors/transform/transform_generics.c | 3 - .../render/extern/include/RE_shader_ext.h | 1 - .../blender/render/intern/source/rendercore.c | 34 -- .../windowmanager/intern/wm_init_exit.c | 1 - 13 files changed, 3 insertions(+), 659 deletions(-) diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 68745975dae..b00db53a199 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -97,15 +97,10 @@ extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); extern void makeDispListMBall(struct Scene *scene, struct Object *ob); extern void makeDispListMBall_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -extern void shadeDispList(struct Scene *scene, struct Base *base); -extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *me); int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); -void reshadeall_displist(struct Scene *scene); void filldisplist(struct ListBase *dispbase, struct ListBase *to, int flipnormal); -void fastshade_free_render(void); - float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); /* add Orco layer to the displist object which has got derived mesh and return orco */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 5a9432552d2..0f545ad3ff9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -154,7 +154,6 @@ static void clear_global(void) { // extern short winqueue_break; /* screen.c */ - fastshade_free_render(); /* lamps hang otherwise */ free_main(G.main); /* free all lib data */ // free_vertexpaint(); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 9aa794aa97e..8f57490d057 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -65,9 +65,6 @@ #include "BKE_lattice.h" #include "BKE_modifier.h" -#include "RE_pipeline.h" -#include "RE_shader_ext.h" - #include "BLO_sys_types.h" // for intptr_t support #include "ED_curve.h" /* for BKE_curve_nurbs */ @@ -286,499 +283,6 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i return 1; } -/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */ - -/* create default shade input... save cpu cycles with ugly global */ -/* XXXX bad code warning: local ShadeInput initialize... */ -static ShadeInput shi; -static void init_fastshade_shadeinput(Render *re) -{ - memset(&shi, 0, sizeof(ShadeInput)); - shi.lay= RE_GetScene(re)->lay; - shi.view[2]= -1.0f; - shi.passflag= SCE_PASS_COMBINED; - shi.combinedflag= -1; -} - -static Render *fastshade_get_render(Scene *UNUSED(scene)) -{ - // XXX 2.5: this crashes combined with previewrender - // due to global R so disabled for now -#if 0 - /* XXX ugly global still, but we can't do preview while rendering */ - if(G.rendering==0) { - - Render *re= RE_GetRender("_Shade View_"); - if(re==NULL) { - re= RE_NewRender("_Shade View_"); - - RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */ - } - return re; - } -#endif - - return NULL; -} - -/* called on file reading */ -void fastshade_free_render(void) -{ - Render *re= RE_GetRender("_Shade View_"); - - if(re) { - RE_Database_Free(re); - RE_FreeRender(re); - } -} - - -static void fastshade_customdata(CustomData *fdata, int a, int j, Material *ma) -{ - CustomDataLayer *layer; - MTFace *mtface; - int index, needuv= ma->texco & TEXCO_UV; - char *vertcol; - - shi.totuv= 0; - shi.totcol= 0; - - for(index=0; indextotlayer; index++) { - layer= &fdata->layers[index]; - - if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) { - mtface= &((MTFace*)layer->data)[a]; - - shi.uv[shi.totuv].uv[0]= 2.0f*mtface->uv[j][0]-1.0f; - shi.uv[shi.totuv].uv[1]= 2.0f*mtface->uv[j][1]-1.0f; - shi.uv[shi.totuv].uv[2]= 1.0f; - - shi.uv[shi.totuv].name= layer->name; - shi.totuv++; - } - else if(layer->type == CD_MCOL && shi.totcol < MAX_MCOL) { - vertcol= (char*)&((MCol*)layer->data)[a*4 + j]; - - shi.col[shi.totcol].col[0]= ((float)vertcol[3])/255.0f; - shi.col[shi.totcol].col[1]= ((float)vertcol[2])/255.0f; - shi.col[shi.totcol].col[2]= ((float)vertcol[1])/255.0f; - - shi.col[shi.totcol].name= layer->name; - shi.totcol++; - } - } - - if(needuv && shi.totuv == 0) - VECCOPY(shi.uv[0].uv, shi.lo); - - if(shi.totcol) - VECCOPY(shi.vcol, shi.col[0].col); -} - -static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2) -{ - ShadeResult shr; - int a; - - VECCOPY(shi.co, co); - shi.vn[0]= -nor[0]; - shi.vn[1]= -nor[1]; - shi.vn[2]= -nor[2]; - VECCOPY(shi.vno, shi.vn); - VECCOPY(shi.facenor, shi.vn); - - if(ma->texco) { - VECCOPY(shi.lo, orco); - - if(ma->texco & TEXCO_GLOB) { - VECCOPY(shi.gl, shi.lo); - } - if(ma->texco & TEXCO_WINDOW) { - VECCOPY(shi.winco, shi.lo); - } - if(ma->texco & TEXCO_STICKY) { - VECCOPY(shi.sticky, shi.lo); - } - if(ma->texco & TEXCO_OBJECT) { - VECCOPY(shi.co, shi.lo); - } - if(ma->texco & TEXCO_NORM) { - VECCOPY(shi.orn, shi.vn); - } - if(ma->texco & TEXCO_REFL) { - float inp= 2.0f * (shi.vn[2]); - shi.ref[0]= (inp*shi.vn[0]); - shi.ref[1]= (inp*shi.vn[1]); - shi.ref[2]= (-1.0f + inp*shi.vn[2]); - } - } - - shi.mat= ma; /* set each time... node shaders change it */ - RE_shade_external(NULL, &shi, &shr); - - a= 256.0f*(shr.combined[0]); - col1[0]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[1]); - col1[1]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[2]); - col1[2]= CLAMPIS(a, 0, 255); - - if(col2) { - shi.vn[0]= -shi.vn[0]; - shi.vn[1]= -shi.vn[1]; - shi.vn[2]= -shi.vn[2]; - - shi.mat= ma; /* set each time... node shaders change it */ - RE_shade_external(NULL, &shi, &shr); - - a= 256.0f*(shr.combined[0]); - col2[0]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[1]); - col2[1]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[2]); - col2[2]= CLAMPIS(a, 0, 255); - } -} - -static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3]) -{ - float tmat[4][4]; - float amb[3]= {0.0f, 0.0f, 0.0f}; - int a; - - /* initialize globals in render */ - RE_shade_external(re, NULL, NULL); - - /* initialize global here */ - init_fastshade_shadeinput(re); - - RE_DataBase_GetView(re, tmat); - mul_m4_m4m4(mat, ob->obmat, tmat); - - invert_m4_m4(tmat, mat); - copy_m3_m4(imat, tmat); - if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0); - - if (need_orco_r) *need_orco_r= 0; - for(a=0; atotcol; a++) { - Material *ma= give_current_material(ob, a+1); - if(ma) { - init_render_material(ma, 0, amb); - - if(ma->texco & TEXCO_ORCO) { - if (need_orco_r) *need_orco_r= 1; - } - } - } -} - -static void end_fastshade_for_ob(Object *ob) -{ - int a; - - for(a=0; atotcol; a++) { - Material *ma= give_current_material(ob, a+1); - if(ma) - end_render_material(ma); - } -} - - -static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r) -{ - Mesh *me= ob->data; - DerivedMesh *dm; - MVert *mvert; - MFace *mface; - unsigned int *col1, *col2; - float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3]; - int a, i, need_orco, totface, totvert; - CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL - | CD_MASK_MTFACE | CD_MASK_NORMAL; - - - init_fastshade_for_ob(re, ob, &need_orco, mat, imat); - - if(need_orco) - dataMask |= CD_MASK_ORCO; - - if (onlyForMesh) - dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask); - else - dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask); - - mvert = dm->getVertArray(dm); - mface = dm->getFaceArray(dm); - nors = dm->getFaceDataArray(dm, CD_NORMAL); - totvert = dm->getNumVerts(dm); - totface = dm->getNumFaces(dm); - orco= dm->getVertDataArray(dm, CD_ORCO); - - if (onlyForMesh) { - col1 = *col1_r; - col2 = NULL; - } else { - *col1_r = col1 = MEM_mallocN(sizeof(*col1)*totface*4, "col1"); - - if (col2_r && (me->flag & ME_TWOSIDED)) - col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2"); - else - col2 = NULL; - - if (col2_r) *col2_r = col2; - } - - /* vertexnormals */ - vnors= MEM_mallocN(totvert*3*sizeof(float), "vnors disp"); - for (a=0; ano[0]; - float yn= mv->no[1]; - float zn= mv->no[2]; - - /* transpose ! */ - vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; - vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; - vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - normalize_v3(vn); - } - - for (i=0; imat_nr+1); - int j, vidx[4], nverts= mf->v4?4:3; - unsigned char *col1base= (unsigned char*) &col1[i*4]; - unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL); - float nor[3], n1[3]; - - if(ma==NULL) ma= &defmaterial; - - vidx[0]= mf->v1; - vidx[1]= mf->v2; - vidx[2]= mf->v3; - vidx[3]= mf->v4; - - if (nors) { - VECCOPY(nor, &nors[i*3]); - } else { - if (mf->v4) - normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); - else - normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); - } - - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - for (j=0; jflag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; - - mul_v3_m4v3(vec, mat, mv->co); - - mul_v3_v3fl(vec, vn, 0.001f); - - fastshade_customdata(&dm->faceData, i, j, ma); - fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2); - } - } - MEM_freeN(vnors); - - dm->release(dm); - - end_fastshade_for_ob(ob); -} - -void shadeMeshMCol(Scene *scene, Object *ob, Mesh *me) -{ - Render *re= fastshade_get_render(scene); - int a; - char *cp; - unsigned int *mcol= (unsigned int*)me->mcol; - - if(re) { - mesh_create_shadedColors(re, ob, 1, &mcol, NULL); - me->mcol= (MCol*)mcol; - - /* swap bytes */ - for(cp= (char *)me->mcol, a= 4*me->totface; a>0; a--, cp+=4) { - SWAP(char, cp[0], cp[3]); - SWAP(char, cp[1], cp[2]); - } - } -} - -/* has base pointer, to check for layer */ -/* called from drawobject.c */ -void shadeDispList(Scene *scene, Base *base) -{ - Object *ob= base->object; - DispList *dl, *dlob; - Material *ma = NULL; - Render *re; - float imat[3][3], mat[4][4], vec[3]; - float *fp, *nor, n1[3]; - unsigned int *col1; - int a, need_orco; - - re= fastshade_get_render(scene); - if(re==NULL) - return; - - dl = find_displist(&ob->disp, DL_VERTCOL); - if (dl) { - BLI_remlink(&ob->disp, dl); - free_disp_elem(dl); - } - - if(ob->type==OB_MESH) { - dl= MEM_callocN(sizeof(DispList), "displistshade"); - dl->type= DL_VERTCOL; - - mesh_create_shadedColors(re, ob, 0, &dl->col1, &dl->col2); - - /* add dl to ob->disp after mesh_create_shadedColors, because it - might indirectly free ob->disp */ - BLI_addtail(&ob->disp, dl); - } - else { - - init_fastshade_for_ob(re, ob, &need_orco, mat, imat); - - if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - - /* now we need the normals */ - dl= ob->disp.first; - - while(dl) { - dlob= MEM_callocN(sizeof(DispList), "displistshade"); - BLI_addtail(&ob->disp, dlob); - dlob->type= DL_VERTCOL; - dlob->parts= dl->parts; - dlob->nr= dl->nr; - - if(dl->type==DL_INDEX3) { - col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); - } - else { - col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->parts*dl->nr, "col1"); - } - - - ma= give_current_material(ob, dl->col+1); - if(ma==NULL) ma= &defmaterial; - - if(dl->type==DL_INDEX3) { - if(dl->nors) { - /* there's just one normal */ - n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2]; - n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2]; - n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2]; - normalize_v3(n1); - - fp= dl->verts; - - a= dl->nr; - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; col1++; - } - } - } - else if(dl->type==DL_SURF) { - if(dl->nors) { - a= dl->nr*dl->parts; - fp= dl->verts; - nor= dl->nors; - - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; nor+= 3; col1++; - } - } - } - dl= dl->next; - } - } - else if(ob->type==OB_MBALL) { - /* there are normals already */ - dl= ob->disp.first; - - while(dl) { - - if(dl->type==DL_INDEX4) { - if(dl->nors) { - if(dl->col1) MEM_freeN(dl->col1); - col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); - - ma= give_current_material(ob, dl->col+1); - if(ma==NULL) ma= &defmaterial; - - fp= dl->verts; - nor= dl->nors; - - a= dl->nr; - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - /* transpose ! */ - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; col1++; nor+= 3; - } - } - } - dl= dl->next; - } - } - - end_fastshade_for_ob(ob); - } -} - -/* frees render and shade part of displists */ -/* note: dont do a shade again, until a redraw happens */ -void reshadeall_displist(Scene *scene) -{ - Base *base; - Object *ob; - - fastshade_free_render(); - - for(base= scene->base.first; base; base= base->next) { - ob= base->object; - - if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) - freedisplist(&ob->disp); - - if(base->lay & scene->lay) { - /* Metaballs have standard displist at the Object */ - if(ob->type==OB_MBALL) shadeDispList(scene, base); - } - } -} - /* ****************** make displists ********************* */ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender) diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index f3e26cfee36..c4a302d4d18 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -235,7 +235,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me) return 1; } -int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const char *name, int active_set) +int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mesh *me, const char *name, int active_set) { EditMesh *em; MCol *mcol; @@ -272,9 +272,6 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const cha CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum); mesh_update_customdata_pointers(me); - - if(!mcol) - shadeMeshMCol(scene, ob, me); } DAG_id_tag_update(&me->id, 0); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index c5236a38970..7ca172c6945 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -823,8 +823,6 @@ static int object_delete_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - if(islamp) reshadeall_displist(scene); /* only frees displist */ - DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index f7158e4b4ec..aa2e6d2c145 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1127,8 +1127,6 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - - if(islamp) reshadeall_displist(scene); /* only frees */ /* warning, active object may be hidden now */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 35edd961b1e..dcdb7954b16 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -215,7 +215,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - return (scene->gm.matmode == GAME_MAT_GLSL) && (dt >= OB_SHADED); + return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID); } static int check_material_alpha(Base *base, Mesh *me, int glsl) @@ -2584,7 +2584,6 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D const short is_paint_sel= (ob==OBACT && paint_facesel_test(ob)); int draw_wire = 0; int /* totvert,*/ totedge, totface; - DispList *dl; DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); if(!dm) @@ -2718,10 +2717,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if(dt==OB_SHADED) { - int do_draw= 1; /* to resolve all G.f settings below... */ - if(ob==OBACT) { - do_draw= 0; if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* enforce default material settings */ GPU_enable_material(0, NULL); @@ -2750,38 +2746,6 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material); } } - else do_draw= 1; - } - if(do_draw) { - dl = ob->disp.first; - if (!dl || !dl->col1) { - /* release and reload derivedmesh because it might be freed in - shadeDispList due to a different datamask */ - dm->release(dm); - shadeDispList(scene, base); - dl = find_displist(&ob->disp, DL_VERTCOL); - dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); - } - - if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire) { - draw_mesh_object_outline(v3d, ob, dm); - } - - /* False for dupliframe objects */ - if (dl) { - unsigned int *obCol1 = dl->col1; - unsigned int *obCol2 = dl->col2; - - dm->drawFacesColored(dm, me->flag&ME_TWOSIDED, (unsigned char*) obCol1, (unsigned char*) obCol2); - } - - if(base->flag & SELECT) { - UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT); - } else { - UI_ThemeColor(TH_WIRE); - } - if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) - dm->drawLooseEdges(dm); } } @@ -3139,57 +3103,6 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) glFrontFace(GL_CCW); } -static void drawDispListshaded(ListBase *lb, Object *ob) -{ - DispList *dl, *dlob; - unsigned int *cdata; - - if(lb==NULL) return; - - glShadeModel(GL_SMOOTH); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - - dl= lb->first; - dlob= ob->disp.first; - while(dl && dlob) { - - cdata= dlob->col1; - if(cdata==NULL) break; - - switch(dl->type) { - case DL_SURF: - if(dl->index) { - glVertexPointer(3, GL_FLOAT, 0, dl->verts); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata); - glDrawElements(GL_QUADS, 4*dl->totindex, GL_UNSIGNED_INT, dl->index); - } - break; - - case DL_INDEX3: - - glVertexPointer(3, GL_FLOAT, 0, dl->verts); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata); - glDrawElements(GL_TRIANGLES, 3*dl->parts, GL_UNSIGNED_INT, dl->index); - break; - - case DL_INDEX4: - - glVertexPointer(3, GL_FLOAT, 0, dl->verts); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata); - glDrawElements(GL_QUADS, 4*dl->parts, GL_UNSIGNED_INT, dl->index); - break; - } - - dl= dl->next; - dlob= dlob->next; - } - - glShadeModel(GL_FLAT); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); -} - static void drawCurveDMWired(Object *ob) { DerivedMesh *dm = ob->derivedFinal; @@ -3270,10 +3183,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas drawDispListsolid(lb, ob, 1); GPU_end_object_materials(); } - else if(dt == OB_SHADED) { - if(ob->disp.first==NULL) shadeDispList(scene, base); - drawDispListshaded(lb, ob); - } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); @@ -3312,10 +3221,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas drawDispListsolid(lb, ob, 1); GPU_end_object_materials(); } - else if(dt==OB_SHADED) { - if(ob->disp.first==NULL) shadeDispList(scene, base); - drawDispListshaded(lb, ob); - } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); @@ -3341,11 +3246,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas drawDispListsolid(lb, ob, 1); GPU_end_object_materials(); } - else if(dt == OB_SHADED) { - dl= lb->first; - if(dl && dl->col1==NULL) shadeDispList(scene, base); - drawDispListshaded(lb, ob); - } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); @@ -6311,7 +6211,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } } - if(dtflag2 & V3D_RENDER_OVERRIDE)==0) { + if(dt<=OB_SOLID && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { if((ob->gameflag & OB_DYNAMIC) || ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) { float imat[4][4], vec[3]= {0.0f, 0.0f, 0.0f}; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 573951da4ca..d316ef50679 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2074,10 +2074,6 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d) { CustomDataMask mask= 0; - if(v3d->drawtype == OB_SHADED) { - /* this includes normals for mesh_create_shadedColors */ - mask |= CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_NORMAL | CD_MASK_ORCO; - } if((v3d->drawtype == OB_TEXTURE) || ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 68aa27a7b62..bf14b6e99ec 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5077,10 +5077,6 @@ void special_aftertrans_update(bContext *C, TransInfo *t) #if 0 // TRANSFORM_FIX_ME if(resetslowpar) reset_slowparents(); - - /* note; should actually only be done for all objects when a lamp is moved... (ton) */ - if(t->spacetype==SPACE_VIEW3D && G.vd->drawtype == OB_SHADED) - reshadeall_displist(); #endif } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 71ebe5e051c..20a26d8c58d 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -840,9 +840,6 @@ void recalcData(TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } - - if(((View3D*)t->view)->drawtype == OB_SHADED) - reshadeall_displist(t->scene); } } diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index a59ebdaa5a2..b6af781f4d4 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -208,7 +208,6 @@ struct Render; struct Image; struct Object; -void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr); int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress); struct Image *RE_bake_shade_get_image(void); void RE_bake_ibuf_filter(struct ImBuf *ibuf, unsigned char *mask, const int filter); diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 6b50ba417eb..7c197bb440e 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1956,40 +1956,6 @@ void add_halo_flare(Render *re) R.r.mode= mode; } -/* ************************* used for shaded view ************************ */ - -/* if *re, then initialize, otherwise execute */ -void RE_shade_external(Render *re, ShadeInput *shi, ShadeResult *shr) -{ - static VlakRen vlr; - static ObjectRen obr; - static ObjectInstanceRen obi; - - /* init */ - if(re) { - R= *re; - - /* fake render face */ - memset(&vlr, 0, sizeof(VlakRen)); - memset(&obr, 0, sizeof(ObjectRen)); - memset(&obi, 0, sizeof(ObjectInstanceRen)); - obr.lay= -1; - obi.obr= &obr; - - return; - } - shi->vlr= &vlr; - shi->obr= &obr; - shi->obi= &obi; - - if(shi->mat->nodetree && shi->mat->use_nodes) - ntreeShaderExecTree(shi->mat->nodetree, shi, shr); - else { - shade_input_init_material(shi); - shade_material_loop(shi, shr); - } -} - /* ************************* bake ************************ */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index d57c94a5826..2a733bf28a9 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -379,7 +379,6 @@ void WM_exit(bContext *C) BKE_freecubetable(); - fastshade_free_render(); /* shaded view */ ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ if(C && CTX_wm_manager(C)) From 39443dcb53d56192bdc3165436933c87f4b3f961 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 15 Jun 2011 10:19:35 +0000 Subject: [PATCH 10/92] Code cleanup: remove reference to workob global that no longer exists. --- source/blender/makesdna/DNA_object_types.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index f4488c140a0..dfc7d42793d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -290,10 +290,6 @@ typedef struct DupliObject { float orco[3], uv[2]; } DupliObject; -/* this work object is defined in object.c */ -extern Object workob; - - /* **************** OBJECT ********************* */ /* used many places... should be specialized */ From 2164847928eeadaf754a08e17b030ee93f3815aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 11:50:45 +0000 Subject: [PATCH 11/92] fix for openexr include path, for both cmake and scons a custom openexr install wouldn't work since it expected BF_OPENEXR/include and BF_OPENEXR/include/OpenEXR to be in the search path. --- .../imbuf/intern/openexr/openexr_api.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 9fd6cd1c3fa..7b528ed9624 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -76,18 +76,18 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include #include #else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif using namespace Imf; From 4f3936083a67cd106124dd0392c5ef4a4dcdad7b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 12:09:02 +0000 Subject: [PATCH 12/92] replace own inline cmake include search logic for a typical FindXXX.cmake module. --- CMakeLists.txt | 31 ++------ build_files/cmake/Modules/FindOpenEXR.cmake | 76 +++++++++++++++++++ build_files/cmake/macros.cmake | 4 +- .../imbuf/intern/openexr/CMakeLists.txt | 2 +- 4 files changed, 87 insertions(+), 26 deletions(-) create mode 100644 build_files/cmake/Modules/FindOpenEXR.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c27076c10e..cca34fca36e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,23 +342,8 @@ if(UNIX AND NOT APPLE) endif() if(WITH_IMAGE_OPENEXR) - set(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory") - mark_as_advanced(OPENEXR) - find_path(OPENEXR_INC - ImfXdr.h - PATHS - ${OPENEXR}/include/OpenEXR - /usr/local/include/OpenEXR - /sw/include/OpenEXR - /opt/local/include/OpenEXR - /opt/csw/include/OpenEXR - /opt/include/OpenEXR - ) - mark_as_advanced(OPENEXR_INC) - - set(OPENEXR_LIB Half IlmImf Iex Imath) - - if(NOT OPENEXR_INC) + find_package(OpenEXR) # our own module + if(NOT OPENEXR_FOUND) set(WITH_IMAGE_OPENEXR OFF) endif() endif() @@ -657,10 +642,10 @@ elseif(WIN32) set(MSVC_INC) endif() set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread) + set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread) set(OPENEXR_LIBPATH ${OPENEXR}/lib${MSVC_LIB}) set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC}) - set(OPENEXR_INC ${OPENEXR_INCUDE}/ ${OPENEXR_INCUDE}/IlmImf ${OPENEXR_INCUDE}/Iex ${OPENEXR_INCUDE}/Imath) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCUDE}/ ${OPENEXR_INCUDE}/IlmImf ${OPENEXR_INCUDE}/Iex ${OPENEXR_INCUDE}/Imath) endif() if(WITH_IMAGE_TIFF) @@ -759,8 +744,8 @@ elseif(WIN32) if(WITH_IMAGE_OPENEXR) set(OPENEXR ${LIBDIR}/gcc/openexr) - set(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR) - set(OPENEXR_LIB Half IlmImf Imath IlmThread) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include ${OPENEXR}/include/OpenEXR) + set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread) set(OPENEXR_LIBPATH ${OPENEXR}/lib) # TODO, gives linking errors, force off @@ -892,8 +877,8 @@ elseif(APPLE) if(WITH_IMAGE_OPENEXR) set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include) - set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR ${OPENEXR}/include) + set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread) set(OPENEXR_LIBPATH ${OPENEXR}/lib) endif() diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake new file mode 100644 index 00000000000..8ddd3ca344d --- /dev/null +++ b/build_files/cmake/Modules/FindOpenEXR.cmake @@ -0,0 +1,76 @@ +# - Find OpenEXR library (copied from FindTIFF.cmake, v 2.8.5) +# Find the native OpenEXR includes and library +# This module defines +# OPENEXR_INCLUDE_DIRS, where to find ImfXdr.h, etc. Set when +# OPENEXR_INCLUDE_DIR is found. +# OPENEXR_LIBRARIES, libraries to link against to use OpenEXR. +# OPENEXR_ROOT_DIR, The base directory to search for OpenEXR. +# This can also be an environment variable. +# OPENEXR_FOUND, If false, do not try to use OpenEXR. +# also defined, but not for general use are +# OPENEXR_LIBRARY, where to find the OpenEXR library. + +#============================================================================= +# Copyright 2002-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# If OPENEXR_ROOT_DIR was defined in the environment, use it. +IF(NOT OPENEXR_ROOT_DIR AND NOT $ENV{OPENEXR_ROOT_DIR} STREQUAL "") + SET(OPENEXR_ROOT_DIR $ENV{OPENEXR_ROOT_DIR}) +ENDIF() + +SET(_openexr_FIND_COMPONENTS + Half + IlmImf + Iex + Imath +) + +SET(_openexr_SEARCH_DIRS + ${OPENEXR_ROOT_DIR} + /usr/local + /opt/csw +) + +FIND_PATH(OPENEXR_INCLUDE_DIR ImfXdr.h + HINTS + ${_openexr_SEARCH_DIRS} + PATH_SUFFIXES + include/OpenEXR +) + +SET(_openexr_LIBRARIES) +FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS}) + STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) + + FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY NAMES ${COMPONENT} + HINTS ${_openexr_SEARCH_DIRS} + PATH_SUFFIXES lib + ) + LIST(APPEND _openexr_LIBRARIES "${OPENEXR_${UPPERCOMPONENT}_LIBRARY}") +ENDFOREACH() + +# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG + ${_openexr_LIBRARIES} OPENEXR_INCLUDE_DIR) + +IF(OPENEXR_FOUND) + SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES}) + SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR}) +ENDIF(OPENEXR_FOUND) + +MARK_AS_ADVANCED( + ${_openexr_LIBRARIES} + OPENEXR_INCLUDE_DIR +) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 8189769cbbc..a862034c002 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -205,13 +205,13 @@ macro(setup_liblinks endif() if(WITH_IMAGE_OPENEXR) if(WIN32 AND NOT UNIX) - foreach(_LOOP_VAR ${OPENEXR_LIB}) + foreach(_LOOP_VAR ${OPENEXR_LIBRARIES}) target_link_libraries(${target} debug ${_LOOP_VAR}_d) target_link_libraries(${target} optimized ${_LOOP_VAR}) endforeach() unset(_LOOP_VAR) else() - target_link_libraries(${target} ${OPENEXR_LIB}) + target_link_libraries(${target} ${OPENEXR_LIBRARIES}) endif() endif() if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE) diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt index c1140bc59a9..9ca4dff5bc8 100644 --- a/source/blender/imbuf/intern/openexr/CMakeLists.txt +++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt @@ -44,7 +44,7 @@ set(SRC ) if(WITH_IMAGE_OPENEXR) - list(APPEND INC_SYS ${OPENEXR_INC}) + list(APPEND INC_SYS ${OPENEXR_INCLUDE_DIRS}) add_definitions(-DWITH_OPENEXR) endif() From bb6e0834e0f55070e4406ca4d385c9e6dc246655 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 13:42:02 +0000 Subject: [PATCH 13/92] cmake: combine debug/optimized into one target_link_libraries() call. --- build_files/cmake/macros.cmake | 48 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index a862034c002..10d6f712da1 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -150,15 +150,22 @@ macro(setup_liblinks target) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS} ") - target_link_libraries(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${LLIBS}) + target_link_libraries(${target} + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} + ${JPEG_LIBRARIES} + ${PNG_LIBRARIES} + ${ZLIB_LIBRARIES} + ${LLIBS}) # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs target_link_libraries(${target} ${PYTHON_LINKFLAGS}) if(WIN32 AND NOT UNIX) - target_link_libraries(${target} debug ${PYTHON_LIBRARY}_d) - target_link_libraries(${target} optimized ${PYTHON_LIBRARY}) + target_link_libraries(${target} + debug ${PYTHON_LIBRARY}_d + optimized ${PYTHON_LIBRARY}) else() target_link_libraries(${target} ${PYTHON_LIBRARY}) endif() @@ -168,8 +175,12 @@ macro(setup_liblinks target_link_libraries(${target} ${GLEW_LIBRARY}) endif() - target_link_libraries(${target} ${OPENGL_glu_LIBRARY} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) - target_link_libraries(${target} ${FREETYPE_LIBRARY}) + target_link_libraries(${target} + ${OPENGL_glu_LIBRARY} + ${JPEG_LIBRARIES} + ${PNG_LIBRARIES} + ${ZLIB_LIBRARIES} + ${FREETYPE_LIBRARY}) if(WITH_INTERNATIONAL) target_link_libraries(${target} ${GETTEXT_LIB}) @@ -206,8 +217,9 @@ macro(setup_liblinks if(WITH_IMAGE_OPENEXR) if(WIN32 AND NOT UNIX) foreach(_LOOP_VAR ${OPENEXR_LIBRARIES}) - target_link_libraries(${target} debug ${_LOOP_VAR}_d) - target_link_libraries(${target} optimized ${_LOOP_VAR}) + target_link_libraries(${target} + debug ${_LOOP_VAR}_d + optimized ${_LOOP_VAR}) endforeach() unset(_LOOP_VAR) else() @@ -223,20 +235,24 @@ macro(setup_liblinks if(WITH_OPENCOLLADA) if(WIN32 AND NOT UNIX) foreach(_LOOP_VAR ${OPENCOLLADA_LIB}) - target_link_libraries(${target} debug ${_LOOP_VAR}_d) - target_link_libraries(${target} optimized ${_LOOP_VAR}) + target_link_libraries(${target} + debug ${_LOOP_VAR}_d + optimized ${_LOOP_VAR}) endforeach() unset(_LOOP_VAR) - target_link_libraries(${target} debug ${PCRE_LIB}_d) - target_link_libraries(${target} optimized ${PCRE_LIB}) + target_link_libraries(${target} + debug ${PCRE_LIB}_d + optimized ${PCRE_LIB}) if(EXPAT_LIB) - target_link_libraries(${target} debug ${EXPAT_LIB}_d) - target_link_libraries(${target} optimized ${EXPAT_LIB}) + target_link_libraries(${target} + debug ${EXPAT_LIB}_d + optimized ${EXPAT_LIB}) endif() else() - target_link_libraries(${target} ${OPENCOLLADA_LIB}) - target_link_libraries(${target} ${PCRE_LIB}) - target_link_libraries(${target} ${EXPAT_LIB}) + target_link_libraries(${target} + ${OPENCOLLADA_LIB} + ${PCRE_LIB} + ${EXPAT_LIB}) endif() endif() if(WITH_MEM_JEMALLOC) From c02121b7080533c73625180ad850d145ba639378 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 13:54:57 +0000 Subject: [PATCH 14/92] use full library paths for openexr & msvc, also remove unneeded exr includes --- CMakeLists.txt | 28 +++++++++++++++++++--------- build_files/cmake/macros.cmake | 5 +++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cca34fca36e..f767b2c3e3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -628,10 +628,7 @@ elseif(WIN32) endif() if(WITH_IMAGE_OPENEXR) - if(MSVC80) - set(MSVC_LIB _vs2005) - set(MSVC_INC) - elseif(MSVC90) + if(MSVC90) set(MSVC_LIB _vs2008) set(MSVC_INC) elseif(MSVC10) @@ -641,11 +638,24 @@ elseif(WIN32) set(MSVC_LIB msvc) set(MSVC_INC) endif() - set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread) + set(OPENEXR ${LIBDIR}/openexr) set(OPENEXR_LIBPATH ${OPENEXR}/lib${MSVC_LIB}) + set(OPENEXR_LIBRARIES + ${OPENEXR_LIBPATH}/Iex.lib + ${OPENEXR_LIBPATH}/Half.lib + ${OPENEXR_LIBPATH}/IlmImf.lib + ${OPENEXR_LIBPATH}/Imath.lib + ${OPENEXR_LIBPATH}/IlmThread.lib + ) set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC}) - set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCUDE}/ ${OPENEXR_INCUDE}/IlmImf ${OPENEXR_INCUDE}/Iex ${OPENEXR_INCUDE}/Imath) + set(OPENEXR_INCLUDE_DIRS + ${OPENEXR_INCUDE} + ${OPENEXR_INCUDE}/IlmImf + ${OPENEXR_INCUDE}/Iex + ${OPENEXR_INCUDE}/Imath + ) + unset(OPENEXR_INCUDE) + unset(OPENEXR_LIBPATH) endif() if(WITH_IMAGE_TIFF) @@ -744,7 +754,7 @@ elseif(WIN32) if(WITH_IMAGE_OPENEXR) set(OPENEXR ${LIBDIR}/gcc/openexr) - set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include ${OPENEXR}/include/OpenEXR) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR) set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread) set(OPENEXR_LIBPATH ${OPENEXR}/lib) @@ -877,7 +887,7 @@ elseif(APPLE) if(WITH_IMAGE_OPENEXR) set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR ${OPENEXR}/include) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR) set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread) set(OPENEXR_LIBPATH ${OPENEXR}/lib) endif() diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 10d6f712da1..1e8c66f9302 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -214,14 +214,15 @@ macro(setup_liblinks if(WITH_IMAGE_TIFF) target_link_libraries(${target} ${TIFF_LIBRARY}) endif() - if(WITH_IMAGE_OPENEXR) if(WIN32 AND NOT UNIX) foreach(_LOOP_VAR ${OPENEXR_LIBRARIES}) + string(REGEX REPLACE ".lib$" "_d.lib" _LOOP_VAR_DEBUG ${_LOOP_VAR}) target_link_libraries(${target} - debug ${_LOOP_VAR}_d + debug ${_LOOP_VAR_DEBUG} optimized ${_LOOP_VAR}) endforeach() unset(_LOOP_VAR) + unset(_LOOP_VAR_DEBUG) else() target_link_libraries(${target} ${OPENEXR_LIBRARIES}) endif() From 04c5f054d809a602bf5f23b95a6922d91e97f62c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 14:00:50 +0000 Subject: [PATCH 15/92] error in recent commit --- build_files/cmake/macros.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 1e8c66f9302..7a8158227a9 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -214,6 +214,7 @@ macro(setup_liblinks if(WITH_IMAGE_TIFF) target_link_libraries(${target} ${TIFF_LIBRARY}) endif() + if(WITH_IMAGE_OPENEXR) if(WIN32 AND NOT UNIX) foreach(_LOOP_VAR ${OPENEXR_LIBRARIES}) string(REGEX REPLACE ".lib$" "_d.lib" _LOOP_VAR_DEBUG ${_LOOP_VAR}) From 08c155845db4ba8157519f60707fcb156f27fd2b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Jun 2011 14:06:25 +0000 Subject: [PATCH 16/92] remove unused arguments --- source/blender/blenkernel/BKE_action.h | 2 +- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/constraint.c | 20 +++++++++---------- .../Converter/BL_ActionActuator.cpp | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 698f0f0fecf..7d3de68c005 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -216,7 +216,7 @@ void pose_remove_group(struct Object *ob); /* Assorted Evaluation ----------------- */ /* Used for the Action Constraint */ -void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); +void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); /* for proxy */ void copy_pose_result(struct bPose *to, struct bPose *from); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 77f56058a4f..f7086c81756 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1128,7 +1128,7 @@ void copy_pose_result(bPose *to, bPose *from) /* For the calculation of the effects of an Action at the given frame on an object * This is currently only used for the Action Constraint */ -void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) +void what_does_obaction (Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) { bActionGroup *agrp= action_groups_find_named(act, groupname); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 18c9ab7dc90..7be4744a224 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -424,7 +424,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* ------------ General Target Matrix Tools ---------- */ /* function that sets the given matrix based on given vertex group in mesh */ -static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substring, float mat[][4]) +static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat[][4]) { DerivedMesh *dm = NULL; Mesh *me= ob->data; @@ -580,7 +580,7 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* generic function to get the appropriate matrix for most target cases */ /* The cases where the target can be object data have not been implemented */ -static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) +static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) { /* Case OBJECT */ if (!strlen(substring)) { @@ -597,7 +597,7 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *sub * way as constraints can only really affect things on object/bone level. */ else if (ob->type == OB_MESH) { - contarget_get_mesh_mat(scene, ob, substring, mat); + contarget_get_mesh_mat(ob, substring, mat); constraint_mat_convertspace(ob, NULL, mat, from, to); } else if (ob->type == OB_LATTICE) { @@ -677,10 +677,10 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { /* This function should be used for the get_target_matrix member of all * constraints that are not picky about what happens to their target matrix. */ -static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) unit_m4(ct->matrix); } @@ -1152,7 +1152,7 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra bKinematicConstraint *data= con->data; if (VALID_CONS_TARGET(ct)) - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) { if (data->flag & CONSTRAINT_IK_AUTO) { Object *ob= cob->ob; @@ -2039,7 +2039,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT /* firstly calculate the matrix the normal way, then let the py-function override * this matrix if it needs to do so */ - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); /* only execute target calculation if allowed */ #ifdef WITH_PYTHON @@ -2158,7 +2158,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint unit_m4(ct->matrix); /* get the transform matrix of the target */ - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); /* determine where in transform range target is */ /* data->type is mapped as follows for backwards compatability: @@ -2209,7 +2209,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint tchan->rotmode= pchan->rotmode; /* evaluate action using workob (it will only set the PoseChannel in question) */ - what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, pchan->name, t); + what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t); /* convert animation to matrices for use here */ pchan_calc_mat(tchan); @@ -2223,7 +2223,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* evaluate using workob */ // FIXME: we don't have any consistent standards on limiting effects on object... - what_does_obaction(cob->scene, cob->ob, &workob, NULL, data->act, NULL, t); + what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); object_to_mat4(&workob, ct->matrix); } else { diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index c00e7ec7e29..7e353d590bb 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -405,7 +405,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) // 2.5x - could also do this but looks too high level, constraints use this, it works ok. // Object workob; /* evaluate using workob */ -// what_does_obaction((Scene *)obj->GetScene(), obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime); +// what_does_obaction(obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime); } // done getting the pose from the action From a3e296fc4060ab9aac46a8ec2f18696d6776d653 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 15 Jun 2011 18:59:22 +0000 Subject: [PATCH 17/92] Committing patch #25676 Anisotropic filtering in viewport and BGE by me. This patch adds anisotropic filtering of textures in the viewport and the BGE. The quality of the filtering is adjustable in the user preferences under System. For more information on anisotropic filtering: http://en.wikipedia.org/wiki/Anisotropic_filtering One current limitation of this setup (having the option a user preference) is it makes runtimes more troublesome. Runtimes don't have user preferences set, so for now the blender player defaults to 2x AF. Options will be added later to change this value (probably a command line option). --- .../scripts/startup/bl_ui/space_userpref.py | 2 ++ source/blender/editors/interface/resources.c | 2 ++ source/blender/gpu/GPU_draw.h | 5 ++++ source/blender/gpu/intern/gpu_draw.c | 25 ++++++++++++++++++- source/blender/makesdna/DNA_userdef_types.h | 3 +-- source/blender/makesrna/intern/rna_userdef.c | 21 ++++++++++++++++ .../windowmanager/intern/wm_init_exit.c | 1 + .../gameengine/GamePlayer/ghost/GPG_ghost.cpp | 5 ++++ source/gameengine/Ketsji/BL_Texture.cpp | 6 +++++ 9 files changed, 67 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 2e9448cca27..7804a1a3c93 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -438,6 +438,8 @@ class USERPREF_PT_system(bpy.types.Panel): col.label(text="OpenGL:") col.prop(system, "gl_clip_alpha", slider=True) col.prop(system, "use_mipmaps") + col.label(text="Anisotropic Filtering") + col.prop(system, "anisotropic_filter", text="") col.prop(system, "use_vertex_buffer_objects") #Anti-aliasing is disabled as it breaks broder/lasso select #col.prop(system, "use_antialiasing") diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 6527e0140b8..3f825762d74 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1580,6 +1580,8 @@ void init_userdef_do_versions(void) U.dragthreshold= 5; if (U.widget_unit==0) U.widget_unit= (U.dpi * 20 + 36)/72; + if (U.anisotropic_filter <= 0) + U.anisotropic_filter = 1; /* funny name, but it is GE stuff, moves userdef stuff to engine */ // XXX space_set_commmandline_options(); diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 18a6f1ba73d..d75b8db2c4e 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -112,6 +112,11 @@ void GPU_set_mipmap(int mipmap); void GPU_set_linear_mipmap(int linear); void GPU_paint_set_mipmap(int mipmap); +/* Anisotropic filtering settings + * - these will free textures on changes */ +void GPU_set_anisotropic(float value); +float GPU_get_anisotropic(void); + /* Image updates and free * - these deal with images bound as opengl textures */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7dfbc52819e..87d25ac850a 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -246,8 +246,9 @@ static struct GPUTextureState { int domipmap, linearmipmap; int alphamode; + float anisotropic; MTFace *lasttface; -} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, NULL}; +} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, 1.f, NULL}; /* Mipmap settings */ @@ -292,6 +293,26 @@ static GLenum gpu_get_mipmap_filter(int mag) } } +/* Anisotropic filtering settings */ +void GPU_set_anisotropic(float value) +{ + if (GTS.anisotropic != value) + { + GPU_free_images(); + + /* Clamp value to the maximum value the graphics card supports */ + if (value > GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT) + value = GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; + + GTS.anisotropic = value; + } +} + +float GPU_get_anisotropic() +{ + return GTS.anisotropic; +} + /* Set OpenGL state for an MTFace */ static void gpu_make_repbind(Image *ima) @@ -559,6 +580,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int ima->tpageflag |= IMA_MIPMAP_COMPLETE; } + if (GLEW_EXT_texture_filter_anisotropic) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); /* set to modulate with vertex color */ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 907710ae4cd..ae57cf3f80b 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -375,7 +375,7 @@ typedef struct UserDef { short scrcastwait; /* milliseconds between screencast snapshots */ short widget_unit; /* defaults to 20 for 72 DPI setting */ - short pad[3]; + short anisotropic_filter; char versemaster[160]; char verseuser[160]; @@ -385,7 +385,6 @@ typedef struct UserDef { short autokey_flag; /* flags for autokeying */ short text_render, pad9; /*options for text rendering*/ - float pad10; struct ColorBand coba_weight; /* from texture.h */ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 14af5ed7a3f..cf371fbf9bc 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -117,6 +117,12 @@ static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr rna_userdef_update(bmain, scene, ptr); } +static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + GPU_set_anisotropic(U.anisotropic_filter); + rna_userdef_update(bmain, scene, ptr); +} + static void rna_userdef_gl_texture_limit_update(Main *bmain, Scene *scene, PointerRNA *ptr) { GPU_free_images(); @@ -2346,6 +2352,14 @@ static void rna_def_userdef_system(BlenderRNA *brna) {128, "CLAMP_128", 0, "128", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem anisotropic_items[] ={ + {1, "FILTER_0", 0, "Off", ""}, + {2, "FILTER_2", 0, "2x", ""}, + {4, "FILTER_4", 0, "4x", ""}, + {8, "FILTER_8", 0, "8x", ""}, + {16, "FILTER_16", 0, "16x", ""}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem audio_mixing_samples_items[] = { {256, "SAMPLES_256", 0, "256", "Set audio mixing buffer size to 256 samples"}, {512, "SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"}, @@ -2568,6 +2582,13 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop= RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_AA); RNA_def_property_ui_text(prop, "Anti-aliasing", "Use anti-aliasing for the 3D view (may impact redraw performance)"); + + prop= RNA_def_property(srna, "anisotropic_filter", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "anisotropic_filter"); + RNA_def_property_enum_items(prop, anisotropic_items); + RNA_def_property_enum_default(prop, 1); + RNA_def_property_ui_text(prop, "Anisotropic Filter", "The quality of the anisotropic filtering (values greater than 1.0 enable anisotropic filtering)"); + RNA_def_property_update(prop, 0, "rna_userdef_anisotropic_update"); prop= RNA_def_property(srna, "gl_texture_limit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "glreslimit"); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 2a733bf28a9..c61db1d653e 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -169,6 +169,7 @@ void WM_init(bContext *C, int argc, const char **argv) if (!G.background) { GPU_extensions_init(); GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP)); + GPU_set_anisotropic(U.anisotropic_filter); UI_init(); } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 121f38eef02..31e4b223ff2 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -450,6 +450,9 @@ int main(int argc, char** argv) U.audioformat = 0x24; U.audiochannels = 2; + // XXX this one too + U.anisotropic_filter = 2; + sound_init_once(); /* if running blenderplayer the last argument can't be parsed since it has to be the filename. */ @@ -705,6 +708,8 @@ int main(int argc, char** argv) { GPU_set_mipmap(0); } + + GPU_set_anisotropic(U.anisotropic_filter); // Create the system if (GHOST_ISystem::createSystem() == GHOST_kSuccess) diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index d2438a66367..a306e059442 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -28,6 +28,7 @@ #define spit(x) std::cout << x << std::endl; #include "MEM_guardedalloc.h" +#include "GPU_draw.h" extern "C" { // envmaps @@ -175,6 +176,8 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap) glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix ); } + if (GLEW_EXT_texture_filter_anisotropic) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } @@ -199,6 +202,9 @@ void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_RGBA, GL_UNSIGNED_BYTE, newPixels ); } + + if (GLEW_EXT_texture_filter_anisotropic) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); free(newPixels); } From 1c0a6c646856fca219f44ac3ac89da5da7206fa5 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 15 Jun 2011 23:43:02 +0000 Subject: [PATCH 18/92] Blenderplayer: Setting G.main to NULL after it's freed to avoid issues later with GPU_free_images() --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 31e4b223ff2..14048c70516 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -408,6 +408,7 @@ int main(int argc, char** argv) // We load our own G.main, so free the one that initglobals() gives us free_main(G.main); + G.main = NULL; IMB_init(); From 0575c05eb0294fa25f97da9fe1186b6ad8b2313d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 02:48:07 +0000 Subject: [PATCH 19/92] fix to FindOpenEXR pointed out by Sergey Sharybin, also added check for IlmThread and marked individual library cache variables as advanced. --- build_files/cmake/Modules/FindOpenEXR.cmake | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake index 8ddd3ca344d..a445a906696 100644 --- a/build_files/cmake/Modules/FindOpenEXR.cmake +++ b/build_files/cmake/Modules/FindOpenEXR.cmake @@ -7,6 +7,14 @@ # OPENEXR_ROOT_DIR, The base directory to search for OpenEXR. # This can also be an environment variable. # OPENEXR_FOUND, If false, do not try to use OpenEXR. +# +# For indervidual library access these advanced settings are available +# OPENEXR_HALF_LIBRARY, Path to Half library +# OPENEXR_IEX_LIBRARY, Path to Half library +# OPENEXR_ILMIMF_LIBRARY, Path to Ilmimf library +# OPENEXR_ILMTHREAD_LIBRARY, Path to IlmThread library +# OPENEXR_IMATH_LIBRARY, Path to Imath library +# # also defined, but not for general use are # OPENEXR_LIBRARY, where to find the OpenEXR library. @@ -30,8 +38,9 @@ ENDIF() SET(_openexr_FIND_COMPONENTS Half - IlmImf Iex + IlmImf + IlmThread Imath ) @@ -63,14 +72,15 @@ ENDFOREACH() # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG - ${_openexr_LIBRARIES} OPENEXR_INCLUDE_DIR) + _openexr_LIBRARIES OPENEXR_INCLUDE_DIR) IF(OPENEXR_FOUND) SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES}) SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR}) ENDIF(OPENEXR_FOUND) -MARK_AS_ADVANCED( - ${_openexr_LIBRARIES} - OPENEXR_INCLUDE_DIR -) +MARK_AS_ADVANCED(OPENEXR_INCLUDE_DIR) +FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS}) + STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) + MARK_AS_ADVANCED(OPENEXR_${UPPERCOMPONENT}_LIBRARY) +ENDFOREACH() From 2e8ca6d1965bdcaaab672561aa2deddaf6b8f8b3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 02:55:26 +0000 Subject: [PATCH 20/92] include some extra search paths for cmake openexr --- build_files/cmake/Modules/FindOpenEXR.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake index a445a906696..9a116973348 100644 --- a/build_files/cmake/Modules/FindOpenEXR.cmake +++ b/build_files/cmake/Modules/FindOpenEXR.cmake @@ -1,4 +1,4 @@ -# - Find OpenEXR library (copied from FindTIFF.cmake, v 2.8.5) +# - Find OpenEXR library # Find the native OpenEXR includes and library # This module defines # OPENEXR_INCLUDE_DIRS, where to find ImfXdr.h, etc. Set when @@ -47,7 +47,9 @@ SET(_openexr_FIND_COMPONENTS SET(_openexr_SEARCH_DIRS ${OPENEXR_ROOT_DIR} /usr/local - /opt/csw + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave ) FIND_PATH(OPENEXR_INCLUDE_DIR ImfXdr.h @@ -63,7 +65,7 @@ FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS}) FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY NAMES ${COMPONENT} HINTS ${_openexr_SEARCH_DIRS} - PATH_SUFFIXES lib + PATH_SUFFIXES lib64 lib ) LIST(APPEND _openexr_LIBRARIES "${OPENEXR_${UPPERCOMPONENT}_LIBRARY}") ENDFOREACH() From 051dedeeec50ca317c4ded0e0fe6ba3b18dee377 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 06:00:02 +0000 Subject: [PATCH 21/92] minor speedup for UI draw code, noticed ui_get_but_val() could be called 3-5 times per button draw, for RNA buttons this gets the entire array for each call so its not great to call many times. --- source/blender/editors/interface/interface.c | 80 ++++++++++++-------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 37e4cc7616b..cfbe1074dd3 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -77,6 +77,10 @@ #define PRECISION_FLOAT_MAX 7 #define PRECISION_FLOAT_MAX_POW 10000000 /* pow(10, PRECISION_FLOAT_MAX) */ +/* avoid unneeded calls to ui_get_but_val */ +#define UI_BUT_VALUE_UNSET DBL_MAX +#define UI_GET_BUT_VALUE_INIT(_but, _value) if(_value == DBL_MAX) { (_value)= ui_get_but_val(_but); } + /* * a full doc with API notes can be found in bf-blender/trunk/blender/doc/guides/interface_API.txt * @@ -967,17 +971,16 @@ void uiDrawBlock(const bContext *C, uiBlock *block) /* ************* EVENTS ************* */ -static void ui_is_but_sel(uiBut *but) +static void ui_is_but_sel(uiBut *but, double *value) { - double value; /* only initialized when needed, to avoid calling when not used */ short push=0, true=1; if(ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) true= 0; if( but->bit ) { int lvalue; - value= ui_get_but_val(but); - lvalue= (int)value; + UI_GET_BUT_VALUE_INIT(but, *value) + lvalue= (int)*value; if( BTST(lvalue, (but->bitnr)) ) push= true; else push= !true; } @@ -997,24 +1000,24 @@ static void ui_is_but_sel(uiBut *but) case BUT_TOGDUAL: case ICONTOG: case OPTION: - value= ui_get_but_val(but); - if(value != (double)but->hardmin) push= 1; + + if(*value != (double)but->hardmin) push= 1; break; case ICONTOGN: case TOGN: case OPTIONN: - value= ui_get_but_val(but); - if(value==0.0) push= 1; + UI_GET_BUT_VALUE_INIT(but, *value) + if(*value==0.0) push= 1; break; case ROW: case LISTROW: - value= ui_get_but_val(but); + UI_GET_BUT_VALUE_INIT(but, *value) /* support for rna enum buts */ if(but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) { - if((int)value & (int)but->hardmax) push= 1; + if((int)*value & (int)but->hardmax) push= 1; } else { - if(value == (double)but->hardmax) push= 1; + if(*value == (double)but->hardmax) push= 1; } break; case COL: @@ -1385,6 +1388,10 @@ void ui_set_but_val(uiBut *but, double value) break; } } + + /* we can't be sure what RNA set functions actually do, + * so leave this unset */ + value= UI_BUT_VALUE_UNSET; } else if(but->pointype==0); else if(but->type==HSVSLI ) { @@ -1425,19 +1432,19 @@ void ui_set_but_val(uiBut *but, double value) /* then set value with possible edit override */ if(but->editval) - *but->editval= value; + value= *but->editval= value; else if(but->pointype==CHA) - *((char *)but->poin)= (char)value; + value= *((char *)but->poin)= (char)value; else if(but->pointype==SHO) - *((short *)but->poin)= (short)value; + value= *((short *)but->poin)= (short)value; else if(but->pointype==INT) - *((int *)but->poin)= (int)value; + value= *((int *)but->poin)= (int)value; else if(but->pointype==FLO) - *((float *)but->poin)= (float)value; + value= *((float *)but->poin)= (float)value; } /* update select flag */ - ui_is_but_sel(but); + ui_is_but_sel(but, &value); } int ui_get_but_string_max_length(uiBut *but) @@ -1974,17 +1981,19 @@ void uiBlockSetEmboss(uiBlock *block, char dt) void ui_check_but(uiBut *but) { /* if something changed in the button */ - double value; + double value= UI_BUT_VALUE_UNSET; // float okwidth; // UNUSED // int transopts= ui_translate_buttons(); - ui_is_but_sel(but); + ui_is_but_sel(but, &value); // if(but->type==TEX || but->type==IDPOIN) transopts= 0; /* only update soft range while not editing */ - if(but->rnaprop && !(but->editval || but->editstr || but->editvec)) - ui_set_but_soft_range(but, ui_get_but_val(but)); + if(but->rnaprop && !(but->editval || but->editstr || but->editvec)) { + UI_GET_BUT_VALUE_INIT(but, value) + ui_set_but_soft_range(but, value); + } /* test for min and max, icon sliders, etc */ switch( but->type ) { @@ -1993,17 +2002,20 @@ void ui_check_but(uiBut *but) case SCROLL: case NUMSLI: case HSVSLI: - value= ui_get_but_val(but); + UI_GET_BUT_VALUE_INIT(but, value) if(value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); else if(value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); break; case NUMABS: - value= fabs( ui_get_but_val(but) ); - if(value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); - else if(value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); + { + double value_abs; + UI_GET_BUT_VALUE_INIT(but, value) + value_abs= fabs(value); + if(value_abs < (double)but->hardmin) ui_set_but_val(but, but->hardmin); + else if(value_abs > (double)but->hardmax) ui_set_but_val(but, but->hardmax); break; - + } case ICONTOG: case ICONTOGN: if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { @@ -2014,14 +2026,14 @@ void ui_check_but(uiBut *but) case ICONROW: if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { - value= ui_get_but_val(but); + UI_GET_BUT_VALUE_INIT(but, value) but->iconadd= (int)value- (int)(but->hardmin); } break; case ICONTEXTROW: if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { - value= ui_get_but_val(but); + UI_GET_BUT_VALUE_INIT(but, value) but->iconadd= (int)value- (int)(but->hardmin); } break; @@ -2038,7 +2050,7 @@ void ui_check_but(uiBut *but) case ICONTEXTROW: if(but->x2 - but->x1 > 24) { - value= ui_get_but_val(but); + UI_GET_BUT_VALUE_INIT(but, value) ui_set_name_menu(but, (int)value); } break; @@ -2048,7 +2060,7 @@ void ui_check_but(uiBut *but) case HSVSLI: case NUMABS: - value= ui_get_but_val(but); + UI_GET_BUT_VALUE_INIT(but, value) if(ui_is_but_float(but)) { if(value == (double) FLT_MAX) sprintf(but->drawstr, "%sinf", but->str); @@ -2079,7 +2091,7 @@ void ui_check_but(uiBut *but) case LABEL: if(ui_is_but_float(but)) { int prec; - value= ui_get_but_val(but); + UI_GET_BUT_VALUE_INIT(but, value) prec= ui_but_float_precision(but, value); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value); } @@ -2105,8 +2117,10 @@ void ui_check_but(uiBut *but) strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); if (but->flag & UI_SELECT) { strcat(but->drawstr, "Press a key"); - } else { - strcat(but->drawstr, WM_key_event_string((short) ui_get_but_val(but))); + } + else { + UI_GET_BUT_VALUE_INIT(but, value) + strcat(but->drawstr, WM_key_event_string((short)value)); } break; From 0a998decb66820eae4704220988fdc76adc341d4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 06:47:54 +0000 Subject: [PATCH 22/92] fix [#27673] Value sliders >1 do not represent numerical ratios right the soft limits for array buttons not take into account the min/max of all array elements --- source/blender/editors/interface/interface.c | 44 ++++++++---- source/blender/makesrna/RNA_access.h | 2 + source/blender/makesrna/intern/rna_access.c | 74 ++++++++++++++++++++ 3 files changed, 108 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index cfbe1074dd3..bde5d111501 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1765,50 +1765,70 @@ static double soft_range_round_down(double value, double max) void ui_set_but_soft_range(uiBut *but, double value) { - PropertyType type; - double softmin, softmax /*, step, precision*/; - + /* ideally we would not limit this but practially, its more then + * enough worst case is very long vectors wont use a smart soft-range + * which isnt so bad. */ + if(but->rnaprop) { - type= RNA_property_type(but->rnaprop); + const PropertyType type= RNA_property_type(but->rnaprop); + double softmin, softmax /*, step, precision*/; + double value_min= value; + double value_max= value; /* clamp button range to something reasonable in case * we get -inf/inf from RNA properties */ if(type == PROP_INT) { int imin, imax, istep; + const int array_len= RNA_property_array_length(&but->rnapoin, but->rnaprop); RNA_property_int_ui_range(&but->rnapoin, but->rnaprop, &imin, &imax, &istep); softmin= (imin == INT_MIN)? -1e4: imin; softmax= (imin == INT_MAX)? 1e4: imax; /*step= istep;*/ /*UNUSED*/ /*precision= 1;*/ /*UNUSED*/ + + if(array_len >= 2) { + int value_range[2]; + RNA_property_int_get_array_range(&but->rnapoin, but->rnaprop, value_range); + value_min= (double)value_range[0]; + value_max= (double)value_range[1]; + } } else if(type == PROP_FLOAT) { float fmin, fmax, fstep, fprecision; + const int array_len= RNA_property_array_length(&but->rnapoin, but->rnaprop); RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision); softmin= (fmin == -FLT_MAX)? (float)-1e4: fmin; softmax= (fmax == FLT_MAX)? (float)1e4: fmax; /*step= fstep;*/ /*UNUSED*/ /*precision= fprecision;*/ /*UNUSED*/ + + if(array_len >= 2) { + float value_range[2]; + RNA_property_float_get_array_range(&but->rnapoin, but->rnaprop, value_range); + value_min= (double)value_range[0]; + value_max= (double)value_range[1]; + } } else return; /* if the value goes out of the soft/max range, adapt the range */ - if(value+1e-10 < softmin) { - if(value < 0.0) - softmin= -soft_range_round_up(-value, -softmin); + if(value_min+1e-10 < softmin) { + if(value_min < 0.0) + softmin= -soft_range_round_up(-value_min, -softmin); else - softmin= soft_range_round_down(value, softmin); + softmin= soft_range_round_down(value_min, softmin); if(softmin < (double)but->hardmin) softmin= (double)but->hardmin; } - else if(value-1e-10 > softmax) { - if(value < 0.0) - softmax= -soft_range_round_down(-value, -softmax); + else if(value_max-1e-10 > softmax) { + if(value_max < 0.0) + softmax= -soft_range_round_down(-value_max, -softmax); else - softmax= soft_range_round_up(value, softmax); + softmax= soft_range_round_up(value_max, softmax); if(softmax > (double)but->hardmax) softmax= but->hardmax; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index ca19a86e42c..882fbce9271 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -716,6 +716,7 @@ int RNA_property_boolean_get_default_index(PointerRNA *ptr, PropertyRNA *prop, i int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value); void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values); +void RNA_property_int_get_array_range(PointerRNA *ptr, PropertyRNA *prop, int values[2]); int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index); void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values); void RNA_property_int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value); @@ -726,6 +727,7 @@ int RNA_property_int_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int i float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value); void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values); +void RNA_property_float_get_array_range(PointerRNA *ptr, PropertyRNA *prop, float values[2]); float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index); void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values); void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float value); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index ab11f88e0f6..8fbee8ea740 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1643,6 +1643,43 @@ void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values) memset(values, 0, sizeof(int)*prop->totarraylength); } +void RNA_property_int_get_array_range(PointerRNA *ptr, PropertyRNA *prop, int values[2]) +{ + const int array_len= RNA_property_array_length(ptr, prop); + + if(array_len <= 0) { + values[0]= 0; + values[1]= 0; + } + else if (array_len == 1) { + RNA_property_int_get_array(ptr, prop, values); + values[1]= values[0]; + } + else { + int arr_stack[32]; + int *arr; + int i; + + if(array_len > 32) { + arr= MEM_mallocN(sizeof(int) * array_len, "RNA_property_int_get_array_range"); + } + else { + arr= arr_stack; + } + + RNA_property_int_get_array(ptr, prop, arr); + values[0]= values[1]= arr[0]; + for(i= 1; i < array_len; i++) { + values[0]= MIN2(values[0], arr[i]); + values[1]= MAX2(values[1], arr[i]); + } + + if(arr != arr_stack) { + MEM_freeN(arr); + } + } +} + int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index) { int tmp[RNA_MAX_ARRAY_LENGTH]; @@ -1839,6 +1876,43 @@ void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *val memset(values, 0, sizeof(float)*prop->totarraylength); } +void RNA_property_float_get_array_range(PointerRNA *ptr, PropertyRNA *prop, float values[2]) +{ + const int array_len= RNA_property_array_length(ptr, prop); + + if(array_len <= 0) { + values[0]= 0.0f; + values[1]= 0.0f; + } + else if (array_len == 1) { + RNA_property_float_get_array(ptr, prop, values); + values[1]= values[0]; + } + else { + float arr_stack[32]; + float *arr; + int i; + + if(array_len > 32) { + arr= MEM_mallocN(sizeof(float) * array_len, "RNA_property_float_get_array_range"); + } + else { + arr= arr_stack; + } + + RNA_property_float_get_array(ptr, prop, arr); + values[0]= values[1]= arr[0]; + for(i= 1; i < array_len; i++) { + values[0]= MIN2(values[0], arr[i]); + values[1]= MAX2(values[1], arr[i]); + } + + if(arr != arr_stack) { + MEM_freeN(arr); + } + } +} + float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index) { float tmp[RNA_MAX_ARRAY_LENGTH]; From 4a5a9dc71c181c849e352d534d80144fd190411c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 07:02:33 +0000 Subject: [PATCH 23/92] fix for own error in r37542 --- source/blender/editors/interface/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index bde5d111501..30c0f552b72 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1000,7 +1000,7 @@ static void ui_is_but_sel(uiBut *but, double *value) case BUT_TOGDUAL: case ICONTOG: case OPTION: - + UI_GET_BUT_VALUE_INIT(but, *value) if(*value != (double)but->hardmin) push= 1; break; case ICONTOGN: From 3ede710a3c6b8c5bd10136e468019091110006ac Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 07:48:22 +0000 Subject: [PATCH 24/92] fix for baking actions for objects with no animation data. --- release/scripts/startup/bl_operators/nla.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/nla.py b/release/scripts/startup/bl_operators/nla.py index 6b324111903..7cbdaa3ddbf 100644 --- a/release/scripts/startup/bl_operators/nla.py +++ b/release/scripts/startup/bl_operators/nla.py @@ -118,8 +118,10 @@ def bake(frame_start, # ------------------------------------------------------------------------- # Create action + # incase animation data hassnt been created + atd = obj.animation_data_create() action = bpy.data.actions.new("Action") - obj.animation_data.action = action + atd.action = action if do_pose: pose_items = pose.bones.items() From f227c4a064d96909243b4a60a7f6c544f521817a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 07:59:22 +0000 Subject: [PATCH 25/92] fix [#27675] Bones shift out of place when leaving edit mode - float precision issue, details commented in the source. --- source/blender/blenkernel/intern/armature.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index fd25ebe266f..0b31e51d62e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1343,8 +1343,12 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) cross_v3_v3v3(axis,target,nor); /* was 0.0000000000001, caused bug [#23954], smaller values give unstable - * roll when toggling editmode */ - if (dot_v3v3(axis,axis) > 0.00001f) { + * roll when toggling editmode. + * + * was 0.00001, causes bug [#27675], with 0.00000495, + * so a value inbetween these is needed. + */ + if (dot_v3v3(axis,axis) > 0.000001f) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); From 216ba20942249c96f808d9e5c7ca4cc47c6b77f5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 12:48:25 +0000 Subject: [PATCH 26/92] fix [#27671] Transforming sequencer effects strips crashes --- .../editors/transform/transform_conversions.c | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index bf14b6e99ec..669c3195dfd 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3725,27 +3725,8 @@ void flushTransGraphData(TransInfo *t) * seq->depth must be set before running this function so we know if the strips * are root level or not */ -#define XXX_DURIAN_ANIM_TX_HACK static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count, int *flag) { - -#ifdef XXX_DURIAN_ANIM_TX_HACK - /* hack */ - if((seq->flag & SELECT)==0 && seq->type & SEQ_EFFECT) { - Sequence *seq_t[3]; - int i; - - seq_t[0]= seq->seq1; - seq_t[1]= seq->seq2; - seq_t[2]= seq->seq3; - - for(i=0; i<3; i++) { - if (seq_t[i] && ((seq_t[i])->flag & SELECT) && !(seq_t[i]->flag & SEQ_LOCK) && !(seq_t[i]->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL))) - seq->flag |= SELECT; - } - } -#endif - /* for extend we need to do some tricks */ if (t->mode == TFM_TIME_EXTEND) { @@ -4105,6 +4086,7 @@ static void freeSeqData(TransInfo *t) static void createTransSeqData(bContext *C, TransInfo *t) { +#define XXX_DURIAN_ANIM_TX_HACK View2D *v2d= UI_view2d_fromcontext(C); Scene *scene= t->scene; @@ -4135,6 +4117,24 @@ static void createTransSeqData(bContext *C, TransInfo *t) t->frame_side = 'B'; } +#ifdef XXX_DURIAN_ANIM_TX_HACK + { + Sequence *seq; + for(seq= ed->seqbasep->first; seq; seq= seq->next) { + /* hack */ + if((seq->flag & SELECT)==0 && seq->type & SEQ_EFFECT) { + Sequence *seq_user; + int i; + for(i=0; i<3; i++) { + seq_user= *((&seq->seq1) + i); + if (seq_user && (seq_user->flag & SELECT) && !(seq_user->flag & SEQ_LOCK) && !(seq_user->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL))) { + seq->flag |= SELECT; + } + } + } + } + } +#endif count = SeqTransCount(t, ed->seqbasep, 0); @@ -4154,6 +4154,8 @@ static void createTransSeqData(bContext *C, TransInfo *t) /* loop 2: build transdata array */ SeqToTransData_Recursive(t, ed->seqbasep, td, td2d, tdsq); + +#undef XXX_DURIAN_ANIM_TX_HACK } From fd24c99b5ddd251ee64f95ae227ba76bcf9cb561 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 15:01:22 +0000 Subject: [PATCH 27/92] directory only filesel for operators which don't have a filepath or filename property. --- source/blender/editors/space_file/file_draw.c | 24 ++++++++++-------- source/blender/editors/space_file/file_ops.c | 11 +++++--- source/blender/editors/space_file/filelist.c | 2 ++ source/blender/editors/space_file/filesel.c | 21 +++++++++++++--- source/blender/makesdna/DNA_space_types.h | 25 ++++++++++--------- 5 files changed, 52 insertions(+), 31 deletions(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index a6fee359197..9fecfda7764 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -185,16 +185,18 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiButSetCompleteFunc(but, autocomplete_directory, NULL); uiButSetFlag(but, UI_BUT_NO_UTF8); - but = uiDefBut(block, TEX, B_FS_FILENAME, "", - min_x, line2_y, line2_w-chan_offs, btn_h, - params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, - overwrite_alert ?"File name, overwrite existing." : "File name."); - uiButSetCompleteFunc(but, autocomplete_file, NULL); - uiButSetFlag(but, UI_BUT_NO_UTF8); - - /* check if this overrides a file and if the operator option is used */ - if(overwrite_alert) { - uiButSetFlag(but, UI_BUT_REDALERT); + if((params->flag & FILE_DIRSEL_ONLY) == 0) { + but = uiDefBut(block, TEX, B_FS_FILENAME, "", + min_x, line2_y, line2_w-chan_offs, btn_h, + params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, + overwrite_alert ?"File name, overwrite existing." : "File name."); + uiButSetCompleteFunc(but, autocomplete_file, NULL); + uiButSetFlag(but, UI_BUT_NO_UTF8); + + /* check if this overrides a file and if the operator option is used */ + if(overwrite_alert) { + uiButSetFlag(but, UI_BUT_REDALERT); + } } /* clear func */ @@ -202,7 +204,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) } /* Filename number increment / decrement buttons. */ - if (fnumbuttons) { + if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) { uiBlockBeginAlign(block); but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMOUT, min_x + line2_w + separator - chan_offs, line2_y, diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index a5d516a1417..11e7040d4c9 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -205,9 +205,10 @@ static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, SpaceFile *sfile= CTX_wm_space_file(C); FileSelect retval = FILE_SELECT_NOTHING; FileSelection sel= file_selection_get(C, rect, fill); /* get the selection */ + const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; /* flag the files as selected in the filelist */ - filelist_select(sfile->files, &sel, select, SELECTED_FILE, CHECK_ALL); + filelist_select(sfile->files, &sel, select, SELECTED_FILE, check_type); /* Don't act on multiple selected files */ if (sel.first != sel.last) select = 0; @@ -216,7 +217,7 @@ static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, if ( (sel.last >= 0) && ((select == FILE_SEL_ADD) || (select == FILE_SEL_TOGGLE)) ) { /* Check last selection, if selected, act on the file or dir */ - if (filelist_is_selected(sfile->files, sel.last, CHECK_ALL)) { + if (filelist_is_selected(sfile->files, sel.last, check_type)) { retval = file_select_do(C, sel.last); } } @@ -378,8 +379,10 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) /* select all only if previously no file was selected */ if (is_selected) { filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, SELECTED_FILE, CHECK_ALL); - } else { - filelist_select(sfile->files, &sel, FILE_SEL_ADD, SELECTED_FILE, CHECK_FILES); + } + else { + const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; + filelist_select(sfile->files, &sel, FILE_SEL_ADD, SELECTED_FILE, check_type); } ED_area_tag_redraw(sa); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 32b725e0b1f..6736230e84f 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -915,6 +915,8 @@ void filelist_select_file(struct FileList* filelist, int index, FileSelType sele int check_ok = 0; switch (check) { case CHECK_DIRS: + check_ok = S_ISDIR(file->type); + break; case CHECK_ALL: check_ok = 1; break; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 45193a38ef5..3dbfdc9f7d0 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -121,6 +121,9 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* set the parameters from the operator, if it exists */ if (op) { + short is_filename= FALSE; + short is_dir= FALSE; + BLI_strncpy(params->title, op->type->name, sizeof(params->title)); if(RNA_struct_find_property(op->ptr, "filemode")) @@ -128,7 +131,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) else params->type = FILE_SPECIAL; - if (RNA_struct_find_property(op->ptr, "filepath") && RNA_property_is_set(op->ptr, "filepath")) { + if ((is_dir= is_filename= RNA_struct_find_property(op->ptr, "filepath")!=NULL) && RNA_property_is_set(op->ptr, "filepath")) { char name[FILE_MAX]; RNA_string_get(op->ptr, "filepath", name); if (params->type == FILE_LOADLIB) { @@ -140,12 +143,13 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } else { - if (RNA_struct_find_property(op->ptr, "directory") && RNA_property_is_set(op->ptr, "directory")) { + if ((is_dir= RNA_struct_find_property(op->ptr, "directory")!=NULL) && RNA_property_is_set(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", params->dir); sfile->params->file[0]= '\0'; + is_dir= TRUE; } - if (RNA_struct_find_property(op->ptr, "filename") && RNA_property_is_set(op->ptr, "filename")) { + if ((is_filename= RNA_struct_find_property(op->ptr, "filename")!=NULL) && RNA_property_is_set(op->ptr, "filename")) { RNA_string_get(op->ptr, "filename", params->file); } } @@ -155,6 +159,13 @@ short ED_fileselect_set_params(SpaceFile *sfile) BLI_path_abs(params->dir, G.main->name); } + if(is_dir==TRUE && is_filename==FALSE) { + params->flag |= FILE_DIRSEL_ONLY; + } + else { + params->flag &= ~FILE_DIRSEL_ONLY; + } + params->filter = 0; if(RNA_struct_find_property(op->ptr, "filter_blender")) params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0; @@ -216,10 +227,12 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->display= FILE_SHORTDISPLAY; } - } else { + } + else { /* default values, if no operator */ params->type = FILE_UNIX; params->flag |= FILE_HIDE_DOT; + params->flag &= ~FILE_DIRSEL_ONLY; params->display = FILE_SHORTDISPLAY; params->filter = 0; params->filter_glob[0] = '\0'; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index e120cd14775..2b039060e47 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -696,18 +696,19 @@ enum FileSortTypeE { #define FILE_OPENFILE 0 #define FILE_SAVE 1 -/* sfile->flag and simasel->flag */ -#define FILE_SHOWSHORT 1 -#define FILE_RELPATH 2 /* was FILE_STRINGCODE */ -#define FILE_LINK 4 -#define FILE_HIDE_DOT 8 -#define FILE_AUTOSELECT 16 -#define FILE_ACTIVELAY 32 -#define FILE_ATCURSOR 64 -#define FILE_SYNCPOSE 128 -#define FILE_FILTER 256 -#define FILE_BOOKMARKS 512 -#define FILE_GROUP_INSTANCE 1024 +/* sfile->params->flag and simasel->flag */ +#define FILE_SHOWSHORT (1<<0) +#define FILE_RELPATH (1<<1) /* was FILE_STRINGCODE */ +#define FILE_LINK (1<<2) +#define FILE_HIDE_DOT (1<<3) +#define FILE_AUTOSELECT (1<<4) +#define FILE_ACTIVELAY (1<<5) +#define FILE_ATCURSOR (1<<6) +#define FILE_DIRSEL_ONLY (1<<7) +#define FILE_FILTER (1<<8) +#define FILE_BOOKMARKS (1<<9) +#define FILE_GROUP_INSTANCE (1<<10) + /* files in filesel list: file types */ #define BLENDERFILE (1<<2) From dce577ad85e9c3349000143cf4e7647254c01cb9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 15:28:39 +0000 Subject: [PATCH 28/92] use directory selector for properties defined as PROP_DIRPATH, user preferences 'File' buttons for eg. --- .../editors/interface/interface_layout.c | 5 +++- .../editors/space_buttons/buttons_intern.h | 1 + .../editors/space_buttons/buttons_ops.c | 24 ++++++++++++++++--- .../editors/space_buttons/space_buttons.c | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 55c1488291b..79a90fb9d1d 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -534,7 +534,10 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w-UI_UNIT_X, h); /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */ - but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); + but= uiDefIconButO(block, BUT, subtype==PROP_DIRPATH ? + "BUTTONS_OT_directory_browse" : + "BUTTONS_OT_file_browse", + WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); } else if(flag & UI_ITEM_R_EVENT) { uiDefButR(block, KEYEVT, 0, name, x, y, w, h, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL); diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 925223b43ea..d25bd7940ab 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -71,6 +71,7 @@ extern const char *buttons_context_dir[]; /* doc access */ /* buttons_ops.c */ void BUTTONS_OT_file_browse(struct wmOperatorType *ot); +void BUTTONS_OT_directory_browse(struct wmOperatorType *ot); void BUTTONS_OT_toolbox(struct wmOperatorType *ot); #endif /* ED_BUTTONS_INTERN_H */ diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 9b914df1b3c..99e5c6d693e 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -104,11 +104,12 @@ static int file_browse_exec(bContext *C, wmOperator *op) FileBrowseOp *fbo= op->customdata; ID *id; char *base, *str, path[FILE_MAX]; + const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - if (RNA_property_is_set(op->ptr, "filepath")==0 || fbo==NULL) + if (RNA_property_is_set(op->ptr, path_prop)==0 || fbo==NULL) return OPERATOR_CANCELLED; - str= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); + str= RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); /* add slash for directories, important for some properties */ if(RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { @@ -191,12 +192,13 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } else { + const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"); fbo->ptr= ptr; fbo->prop= prop; op->customdata= fbo; - RNA_string_set(op->ptr, "filepath", str); + RNA_string_set(op->ptr, path_prop, str); MEM_freeN(str); if(RNA_struct_find_property(op->ptr, "relative_path")) { @@ -227,3 +229,19 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); } +/* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */ +void BUTTONS_OT_directory_browse(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Accept"; + ot->description="Open a directory browser, Hold Shift to open the file, Alt to browse containing directory"; + ot->idname= "BUTTONS_OT_directory_browse"; + + /* api callbacks */ + ot->invoke= file_browse_invoke; + ot->exec= file_browse_exec; + ot->cancel= file_browse_cancel; + + /* properties */ + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH); +} diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 16c4df59420..e2d80e9e775 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -187,6 +187,7 @@ static void buttons_operatortypes(void) { WM_operatortype_append(BUTTONS_OT_toolbox); WM_operatortype_append(BUTTONS_OT_file_browse); + WM_operatortype_append(BUTTONS_OT_directory_browse); } static void buttons_keymap(struct wmKeyConfig *keyconf) From 30823cbb8713b7d3f41256f9ec3ef8d24262b998 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 16 Jun 2011 16:13:26 +0000 Subject: [PATCH 29/92] Python Docs: update layout.html to match blender.org development submenu changes. --- doc/python_api/blender-org/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python_api/blender-org/layout.html b/doc/python_api/blender-org/layout.html index a37ed730c22..88db31e1586 100644 --- a/doc/python_api/blender-org/layout.html +++ b/doc/python_api/blender-org/layout.html @@ -8,7 +8,7 @@ {%- macro relbar() %}