Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-03-01 11:56:15 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-03-01 11:56:15 +0400
commit2eb29e4788008c1346b3a757cccec503b73c9b90 (patch)
tree8b27a7524ad45b8cfcadff31cfa17d2885a0f18b /source/blender/editors
parent1d5a3886a175da808df1872f161e4eb8848ab358 (diff)
A number of improvements for the file output node(s).
1) Old CMP_NODE_OUTPUT_FILE and CMP_NODE_OUTPUT_MULTI_FILE have been merged, only CMP_NODE_OUTPUT_FILE remains. All functions renamed accordingly. 2) do_versions code for converting single-file output nodes into multi-file output nodes. If a Z buffer input is used, the node is made into a multilayer exr with two inputs. (see below). Also re-identifies multi-file output nodes with the CMP_NODE_OUTPUT_FILE type. 3) "Global" format is stored in node now. By default this overrides any per-socket settings. 4) Multilayer EXR output implemented. When M.EXR format is selected for node format, all socket format details are ignored. Socket names are used for layer names. 5) Input buffer types are used as-is when possible, i.e. stored as B/W, RGB or RGBA. In regular file output the format dictates the number of actual channels, so the CompBuf is typechecked to the right type first. For multilayer EXR the number of channels is more flexible, so an input buffer will store only the channels it actually uses. 6) The editor socket type is updated from linked sockets as an indicator of the actual data written to files. This may not be totally accurate for regular file output though, due to restrictions of format setting.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_node/drawnode.c213
-rw-r--r--source/blender/editors/space_node/node_edit.c42
-rw-r--r--source/blender/editors/space_node/node_intern.h4
-rw-r--r--source/blender/editors/space_node/node_ops.c4
4 files changed, 147 insertions, 116 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index a58e03be237..bc22e668b5a 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -102,24 +102,71 @@ static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block,
uiDefBut(block, LABEL, 0, sock->name, x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
}
+/* draw function for file output node sockets.
+ * XXX a bit ugly use atm, called from datatype button functions,
+ * since all node types and callbacks only use data type without struct_type.
+ */
+static void node_socket_button_output_file(const bContext *C, uiBlock *block,
+ bNodeTree *ntree, bNode *node, bNodeSocket *sock,
+ const char *UNUSED(name), int x, int y, int width)
+{
+ uiLayout *layout, *row;
+ PointerRNA nodeptr, sockptr, imfptr;
+ int imtype;
+ int rx, ry;
+ RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &sockptr);
+
+ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle());
+ row = uiLayoutRow(layout, 0);
+
+ uiItemL(row, sock->name, 0);
+
+ imfptr = RNA_pointer_get(&nodeptr, "format");
+ imtype = RNA_enum_get(&imfptr, "file_format");
+ /* in multilayer format all socket format details are ignored */
+ if (imtype != R_IMF_IMTYPE_MULTILAYER) {
+ PropertyRNA *imtype_prop;
+ const char *imtype_name;
+
+ if (!RNA_boolean_get(&sockptr, "use_node_format"))
+ imfptr = RNA_pointer_get(&sockptr, "format");
+
+ imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
+ RNA_property_enum_name((bContext*)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
+ uiBlockSetEmboss(block, UI_EMBOSSP);
+ uiItemL(row, imtype_name, 0);
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+ }
+
+ uiBlockLayoutResolve(block, &rx, &ry);
+}
static void node_socket_button_default(const bContext *C, uiBlock *block,
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
const char *name, int x, int y, int width)
{
- if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
- node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
- else {
- PointerRNA ptr;
- uiBut *bt;
-
- RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
-
- bt = uiDefButR(block, NUM, B_NODE_EXEC, name,
- x, y+1, width, NODE_DY-2,
- &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
- if (node)
- uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
+ switch (sock->struct_type) {
+ case SOCK_STRUCT_NONE: {
+ if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
+ node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
+ else {
+ PointerRNA ptr;
+ uiBut *bt;
+
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+
+ bt = uiDefButR(block, NUM, B_NODE_EXEC, name,
+ x, y+1, width, NODE_DY-2,
+ &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
+ if (node)
+ uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
+ }
+ break;
+ }
+ case SOCK_STRUCT_OUTPUT_FILE:
+ node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
+ break;
}
}
@@ -149,25 +196,33 @@ static void node_socket_button_components(const bContext *C, uiBlock *block,
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
const char *name, int x, int y, int width)
{
- if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
- node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
- else {
- PointerRNA ptr;
- SocketComponentMenuArgs *args;
-
- RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
-
- args= MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
-
- args->ptr = ptr;
- args->x = x;
- args->y = y;
- args->width = width;
- args->cb = node_sync_cb;
- args->arg1 = CTX_wm_space_node(C);
- args->arg2 = node;
-
- uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, "");
+ switch (sock->struct_type) {
+ case SOCK_STRUCT_NONE: {
+ if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
+ node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
+ else {
+ PointerRNA ptr;
+ SocketComponentMenuArgs *args;
+
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+
+ args= MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
+
+ args->ptr = ptr;
+ args->x = x;
+ args->y = y;
+ args->width = width;
+ args->cb = node_sync_cb;
+ args->arg1 = CTX_wm_space_node(C);
+ args->arg2 = node;
+
+ uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, "");
+ }
+ break;
+ }
+ case SOCK_STRUCT_OUTPUT_FILE:
+ node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
+ break;
}
}
@@ -200,29 +255,10 @@ static void node_socket_button_color(const bContext *C, uiBlock *block,
}
break;
}
- case SOCK_STRUCT_OUTPUT_MULTI_FILE: {
- uiLayout *layout, *row;
- PointerRNA ptr, imfptr;
- PropertyRNA *imtype_prop;
- const char *imtype_name;
- int rx, ry;
- RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
- imfptr = RNA_pointer_get(&ptr, "format");
-
- layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle());
- row = uiLayoutRow(layout, 0);
-
- uiItemL(row, sock->name, 0);
- imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
- RNA_property_enum_name((bContext*)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
- uiBlockSetEmboss(block, UI_EMBOSSP);
- uiItemL(row, imtype_name, 0);
- uiBlockSetEmboss(block, UI_EMBOSSN);
-
- uiBlockLayoutResolve(block, &rx, &ry);
+ case SOCK_STRUCT_OUTPUT_FILE:
+ node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
break;
}
- }
}
/* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
@@ -1699,56 +1735,54 @@ static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), Po
static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
- bNode *node= ptr->data;
- NodeImageFile *nif= node->storage;
- PointerRNA imfptr;
-
- uiLayout *row;
-
- uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE);
-
- RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &nif->im_format, &imfptr);
- uiTemplateImageSettings(layout, &imfptr);
-
- row= uiLayoutRow(layout, 1);
- uiItemR(row, ptr, "frame_start", 0, "Start", ICON_NONE);
- uiItemR(row, ptr, "frame_end", 0, "End", ICON_NONE);
-}
-
-static void node_composit_buts_multi_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
- uiItemL(layout, "Base Path:", 0);
+ PointerRNA imfptr = RNA_pointer_get(ptr, "format");
+ int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
+
+ if (multilayer)
+ uiItemL(layout, "Path:", 0);
+ else
+ uiItemL(layout, "Base Path:", 0);
uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
}
-static void node_composit_buts_multi_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
+static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
+ PointerRNA imfptr = RNA_pointer_get(ptr, "format");
PointerRNA active_input_ptr = RNA_pointer_get(ptr, "active_input");
+ int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
- node_composit_buts_multi_file_output(layout, C, ptr);
+ node_composit_buts_file_output(layout, C, ptr);
+ uiTemplateImageSettings(layout, &imfptr);
+
+ uiItemS(layout);
- uiItemO(layout, "Add Input", ICON_ZOOMIN, "NODE_OT_output_multi_file_add_socket");
+ uiItemO(layout, "Add Input", ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
uiTemplateList(layout, C, ptr, "inputs", ptr, "active_input_index", NULL, 0, 0, 0);
if (active_input_ptr.data) {
- PointerRNA imfptr = RNA_pointer_get(&active_input_ptr, "format");
uiLayout *row, *col;
col = uiLayoutColumn(layout, 1);
- uiItemL(col, "File Path:", 0);
+ if (multilayer)
+ uiItemL(col, "Layer Name:", 0);
+ else
+ uiItemL(col, "File Path:", 0);
row = uiLayoutRow(col, 0);
uiItemR(row, &active_input_ptr, "name", 0, "", 0);
- uiItemFullO(row, "NODE_OT_output_multi_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
-
- uiItemS(layout);
+ uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
- col = uiLayoutColumn(layout, 1);
- uiItemL(col, "Format:", 0);
- uiItemR(col, &active_input_ptr, "use_render_format", 0, NULL, 0);
-
- col= uiLayoutColumn(layout, 0);
- uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_render_format")==0);
- uiTemplateImageSettings(col, &imfptr);
+ /* in multilayer format all socket format details are ignored */
+ if (!multilayer) {
+ imfptr = RNA_pointer_get(&active_input_ptr, "format");
+
+ col = uiLayoutColumn(layout, 1);
+ uiItemL(col, "Format:", 0);
+ uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, 0);
+
+ col= uiLayoutColumn(layout, 0);
+ uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format")==0);
+ uiTemplateImageSettings(col, &imfptr);
+ }
}
}
@@ -1986,10 +2020,7 @@ static void node_composit_set_butfunc(bNodeType *ntype)
break;
case CMP_NODE_OUTPUT_FILE:
ntype->uifunc= node_composit_buts_file_output;
- break;
- case CMP_NODE_OUTPUT_MULTI_FILE:
- ntype->uifunc= node_composit_buts_multi_file_output;
- ntype->uifuncbut= node_composit_buts_multi_file_output_details;
+ ntype->uifuncbut= node_composit_buts_file_output_details;
break;
case CMP_NODE_DIFF_MATTE:
ntype->uifunc=node_composit_buts_diff_matte;
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index c89e91724fb..a6d18b58cca 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -2254,6 +2254,8 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL
}
else
nodeRemLink(snode->edittree, tlink);
+
+ snode->edittree->update |= NTREE_UPDATE_LINKS;
}
}
}
@@ -3515,49 +3517,47 @@ void NODE_OT_new_node_tree(wmOperatorType *ot)
RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME-2, "Name", "");
}
-/* ****************** Multi File Output Add Socket ******************* */
+/* ****************** File Output Add Socket ******************* */
-static int node_output_multi_file_add_socket_exec(bContext *C, wmOperator *UNUSED(op))
+static int node_output_file_add_socket_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
SpaceNode *snode= CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNode *node = nodeGetActive(ntree);
+ char file_path[MAX_NAME];
if (!node)
return OPERATOR_CANCELLED;
- ntreeCompositOutputMultiFileAddSocket(ntree, node, &scene->r.im_format);
+ RNA_string_get(op->ptr, "file_path", file_path);
+ ntreeCompositOutputFileAddSocket(ntree, node, file_path, &scene->r.im_format);
snode_notify(C, snode);
return OPERATOR_FINISHED;
}
-static int node_output_multi_file_add_socket_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
-{
- return node_output_multi_file_add_socket_exec(C, op);
-}
-
-void NODE_OT_output_multi_file_add_socket(wmOperatorType *ot)
+void NODE_OT_output_file_add_socket(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Multi File Node Socket";
- ot->description= "Add a new input to a multi file output node";
- ot->idname= "NODE_OT_output_multi_file_add_socket";
+ ot->name= "Add File Node Socket";
+ ot->description= "Add a new input to a file output node";
+ ot->idname= "NODE_OT_output_file_add_socket";
/* callbacks */
- ot->exec= node_output_multi_file_add_socket_exec;
- ot->invoke= node_output_multi_file_add_socket_invoke;
+ ot->exec= node_output_file_add_socket_exec;
ot->poll= composite_node_active;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_string(ot->srna, "file_path", "Image", MAX_NAME, "File Path", "Sub-path of the output file");
}
/* ****************** Multi File Output Remove Socket ******************* */
-static int node_output_multi_file_remove_active_socket_exec(bContext *C, wmOperator *UNUSED(op))
+static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode= CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
@@ -3566,7 +3566,7 @@ static int node_output_multi_file_remove_active_socket_exec(bContext *C, wmOpera
if (!node)
return OPERATOR_CANCELLED;
- if (!ntreeCompositOutputMultiFileRemoveActiveSocket(ntree, node))
+ if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node))
return OPERATOR_CANCELLED;
snode_notify(C, snode);
@@ -3574,15 +3574,15 @@ static int node_output_multi_file_remove_active_socket_exec(bContext *C, wmOpera
return OPERATOR_FINISHED;
}
-void NODE_OT_output_multi_file_remove_active_socket(wmOperatorType *ot)
+void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove Multi File Node Socket";
- ot->description= "Remove active input from a multi file output node";
- ot->idname= "NODE_OT_output_multi_file_remove_active_socket";
+ ot->name= "Remove File Node Socket";
+ ot->description= "Remove active input from a file output node";
+ ot->idname= "NODE_OT_output_file_remove_active_socket";
/* callbacks */
- ot->exec= node_output_multi_file_remove_active_socket_exec;
+ ot->exec= node_output_file_remove_active_socket_exec;
ot->poll= composite_node_active;
/* flags */
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index f6d52aa9474..2524454d9c0 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -157,8 +157,8 @@ void NODE_OT_add_file(struct wmOperatorType *ot);
void NODE_OT_new_node_tree(struct wmOperatorType *ot);
-void NODE_OT_output_multi_file_add_socket(struct wmOperatorType *ot);
-void NODE_OT_output_multi_file_remove_active_socket(struct wmOperatorType *ot);
+void NODE_OT_output_file_add_socket(struct wmOperatorType *ot);
+void NODE_OT_output_file_remove_active_socket(struct wmOperatorType *ot);
extern const char *node_context_dir[];
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 608c6b51f70..d358556d36a 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -101,8 +101,8 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_new_node_tree);
- WM_operatortype_append(NODE_OT_output_multi_file_add_socket);
- WM_operatortype_append(NODE_OT_output_multi_file_remove_active_socket);
+ WM_operatortype_append(NODE_OT_output_file_add_socket);
+ WM_operatortype_append(NODE_OT_output_file_remove_active_socket);
}
void ED_operatormacros_node(void)