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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c88
1 files changed, 50 insertions, 38 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 4460a8c8830..c6115711c1a 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1302,8 +1302,8 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree,
return NULL;
}
- nodeFindNode(ntree, fromsock, &fromnode, NULL);
- nodeFindNode(ntree, tosock, &tonode, NULL);
+ nodeFindNodeTry(ntree, fromsock, &fromnode, NULL);
+ nodeFindNodeTry(ntree, tosock, &tonode, NULL);
/* check validity of the sockets:
* if sockets from different trees are passed in this will fail!
*/
@@ -2417,6 +2417,11 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value)
BKE_animdata_fix_paths_rename_all(NULL, "nodes", oldname, node->name);
}
+static bool allow_changing_sockets(bNode *node)
+{
+ return ELEM(node->type, NODE_CUSTOM, SH_NODE_SCRIPT);
+}
+
static bNodeSocket *rna_Node_inputs_new(ID *id,
bNode *node,
Main *bmain,
@@ -2425,21 +2430,13 @@ static bNodeSocket *rna_Node_inputs_new(ID *id,
const char *name,
const char *identifier)
{
-
- if (ELEM(node->type, NODE_GROUP_INPUT, NODE_FRAME)) {
- BKE_report(reports, RPT_ERROR, "Unable to create socket");
+ if (!allow_changing_sockets(node)) {
+ BKE_report(reports, RPT_ERROR, "Cannot add socket to built-in node");
return NULL;
}
- /* Adding an input to a group node is not working,
- * simpler to add it to its underlying nodetree. */
- if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != NULL) {
- return rna_NodeTree_inputs_new((bNodeTree *)node->id, bmain, reports, type, name);
- }
bNodeTree *ntree = (bNodeTree *)id;
- bNodeSocket *sock;
-
- sock = nodeAddSocket(ntree, node, SOCK_IN, type, identifier, name);
+ bNodeSocket *sock = nodeAddSocket(ntree, node, SOCK_IN, type, identifier, name);
if (sock == NULL) {
BKE_report(reports, RPT_ERROR, "Unable to create socket");
@@ -2460,20 +2457,13 @@ static bNodeSocket *rna_Node_outputs_new(ID *id,
const char *name,
const char *identifier)
{
- if (ELEM(node->type, NODE_GROUP_OUTPUT, NODE_FRAME)) {
- BKE_report(reports, RPT_ERROR, "Unable to create socket");
+ if (!allow_changing_sockets(node)) {
+ BKE_report(reports, RPT_ERROR, "Cannot add socket to built-in node");
return NULL;
}
- /* Adding an output to a group node is not working,
- * simpler to add it to its underlying nodetree. */
- if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != NULL) {
- return rna_NodeTree_outputs_new((bNodeTree *)node->id, bmain, reports, type, name);
- }
bNodeTree *ntree = (bNodeTree *)id;
- bNodeSocket *sock;
-
- sock = nodeAddSocket(ntree, node, SOCK_OUT, type, identifier, name);
+ bNodeSocket *sock = nodeAddSocket(ntree, node, SOCK_OUT, type, identifier, name);
if (sock == NULL) {
BKE_report(reports, RPT_ERROR, "Unable to create socket");
@@ -2489,6 +2479,11 @@ static bNodeSocket *rna_Node_outputs_new(ID *id,
static void rna_Node_socket_remove(
ID *id, bNode *node, Main *bmain, ReportList *reports, bNodeSocket *sock)
{
+ if (!allow_changing_sockets(node)) {
+ BKE_report(reports, RPT_ERROR, "Unable to remove socket from built-in node");
+ return;
+ }
+
bNodeTree *ntree = (bNodeTree *)id;
if (BLI_findindex(&node->inputs, sock) == -1 && BLI_findindex(&node->outputs, sock) == -1) {
@@ -2502,8 +2497,13 @@ static void rna_Node_socket_remove(
}
}
-static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain)
+static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain, ReportList *reports)
{
+ if (!allow_changing_sockets(node)) {
+ BKE_report(reports, RPT_ERROR, "Unable to remove sockets from built-in node");
+ return;
+ }
+
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock, *nextsock;
@@ -2516,8 +2516,13 @@ static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain)
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain)
+static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain, ReportList *reports)
{
+ if (!allow_changing_sockets(node)) {
+ BKE_report(reports, RPT_ERROR, "Unable to remove socket from built-in node");
+ return;
+ }
+
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock, *nextsock;
@@ -2530,8 +2535,14 @@ static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain)
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-static void rna_Node_inputs_move(ID *id, bNode *node, Main *bmain, int from_index, int to_index)
+static void rna_Node_inputs_move(
+ ID *id, bNode *node, Main *bmain, ReportList *reports, int from_index, int to_index)
{
+ if (!allow_changing_sockets(node)) {
+ BKE_report(reports, RPT_ERROR, "Unable to move sockets in built-in node");
+ return;
+ }
+
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
@@ -2562,8 +2573,14 @@ static void rna_Node_inputs_move(ID *id, bNode *node, Main *bmain, int from_inde
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-static void rna_Node_outputs_move(ID *id, bNode *node, Main *bmain, int from_index, int to_index)
+static void rna_Node_outputs_move(
+ ID *id, bNode *node, Main *bmain, ReportList *reports, int from_index, int to_index)
{
+ if (!allow_changing_sockets(node)) {
+ BKE_report(reports, RPT_ERROR, "Unable to move sockets in built-in node");
+ return;
+ }
+
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
@@ -2772,9 +2789,7 @@ static char *rna_NodeSocket_path(const PointerRNA *ptr)
int socketindex;
char name_esc[sizeof(node->name) * 2];
- if (!nodeFindNode(ntree, sock, &node, &socketindex)) {
- return NULL;
- }
+ nodeFindNode(ntree, sock, &node, &socketindex);
BLI_str_escape(name_esc, node->name, sizeof(name_esc));
@@ -4500,11 +4515,8 @@ static void rna_NodeConvertColorSpace_to_color_space_set(struct PointerRNA *ptr,
}
static const EnumPropertyItem *rna_NodeConvertColorSpace_color_space_itemf(
- bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
+ bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
{
- if (C == NULL) {
- return rna_enum_color_space_convert_default_items;
- }
EnumPropertyItem *items = NULL;
int totitem = 0;
@@ -7038,11 +7050,11 @@ static void rna_def_cmp_output_file_slots_api(BlenderRNA *brna,
func = RNA_def_function(srna, "clear", "rna_Node_inputs_clear");
RNA_def_function_ui_description(func, "Remove all file slots from this node");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
func = RNA_def_function(srna, "move", "rna_Node_inputs_move");
RNA_def_function_ui_description(func, "Move a file slot to another position");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
parm = RNA_def_int(
func, "from_index", -1, 0, INT_MAX, "From Index", "Index of the socket to move", 0, 10000);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -12117,11 +12129,11 @@ static void rna_def_node_sockets_api(BlenderRNA *brna, PropertyRNA *cprop, int i
func = RNA_def_function(srna, "clear", clearfunc);
RNA_def_function_ui_description(func, "Remove all sockets from this node");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
func = RNA_def_function(srna, "move", movefunc);
RNA_def_function_ui_description(func, "Move a socket to another position");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
parm = RNA_def_int(
func, "from_index", -1, 0, INT_MAX, "From Index", "Index of the socket to move", 0, 10000);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);