Revision: 58763
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58763
Author: lukastoenne
Date: 2013-07-31 12:26:01 +0000 (Wed, 31 Jul 2013)
Log Message:
-----------
Fix #36267, part 1 of 2: fix for reroute node type updates. The reroute nodes
change their socket type based on what they are connected to, to work as
pass-through nodes with as little conversion as
necessary.
Problem was/is that the nodes can set the 'type' property, but in order to
actually change the data type they would also need to update the typeinfo
pointer (and idname), which is strongly discouraged.
Solution is to just replace the input/output sockets of the reroute node with
new sockets of the desired type and port all links over.
Modified Paths:
--------------
trunk/blender/source/blender/nodes/intern/node_common.c
Modified: trunk/blender/source/blender/nodes/intern/node_common.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/node_common.c 2013-07-31
11:12:07 UTC (rev 58762)
+++ trunk/blender/source/blender/nodes/intern/node_common.c 2013-07-31
12:26:01 UTC (rev 58763)
@@ -267,6 +267,7 @@
bNodeSocket *output = node->outputs.first;
bNodeLink *link;
int type = SOCK_FLOAT;
+ const char *type_idname = nodeStaticSocketType(type, PROP_NONE);
/* XXX it would be a little bit more efficient to restrict actual
updates
* to rerout nodes connected to an updated node, but there's no
reliable flag
@@ -292,21 +293,37 @@
}
/* determine socket type from unambiguous input/output connection if
possible */
- if (input->limit == 1 && input->link)
+ if (input->limit == 1 && input->link) {
type = input->link->fromsock->type;
- else if (output->limit == 1 && output->link)
+ type_idname = nodeStaticSocketType(type, PROP_NONE);
+ }
+ else if (output->limit == 1 && output->link) {
type = output->link->tosock->type;
+ type_idname = nodeStaticSocketType(type, PROP_NONE);
+ }
- /* arbitrary, could also test output->type, both are the same */
if (input->type != type) {
- PointerRNA input_ptr, output_ptr;
- /* same type for input/output */
- RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, input,
&input_ptr);
- RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, output,
&output_ptr);
-
- RNA_enum_set(&input_ptr, "type", type);
- RNA_enum_set(&output_ptr, "type", type);
+ bNodeSocket *ninput = nodeAddSocket(ntree, node, SOCK_IN,
type_idname, "input", "Input");
+ for (link = ntree->links.first; link; link = link->next) {
+ if (link->tosock == input) {
+ link->tosock = ninput;
+ ninput->link = link;
+ }
+ }
+ nodeRemoveSocket(ntree, node, input);
}
+
+ if (output->type != type) {
+ bNodeSocket *noutput = nodeAddSocket(ntree, node, SOCK_OUT,
type_idname, "output", "Output");
+ for (link = ntree->links.first; link; link = link->next) {
+ if (link->fromsock == output) {
+ link->fromsock = noutput;
+ }
+ }
+ nodeRemoveSocket(ntree, node, output);
+ }
+
+ nodeUpdateInternalLinks(ntree, node);
}
/* Global update function for Reroute node types.
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs