Fix cycles OSL node sockets not preserving values when updating with new code.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 10 Jun 2013 20:47:58 +0000 (20:47 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 10 Jun 2013 20:47:58 +0000 (20:47 +0000)
intern/cycles/blender/blender_python.cpp

index 6c3b137fd52a00c0082546caf07df8375ce89510..9600340a1f3e5ade0add85adfa5375a5508a7d97 100644 (file)
@@ -317,11 +317,6 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
                                b_node.outputs.remove(b_sock);
                                b_sock = BL::NodeSocket(PointerRNA_NULL);
                        }
-                       
-                       if (!b_sock) {
-                               /* create new socket */
-                               b_sock = b_node.outputs.create(socket_type.c_str(), param->name.c_str(), param->name.c_str());
-                       }
                }
                else {
                        b_sock = b_node.inputs[param->name];
@@ -331,15 +326,16 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
                                b_node.inputs.remove(b_sock);
                                b_sock = BL::NodeSocket(PointerRNA_NULL);
                        }
-                       
-                       if (!b_sock) {
-                               /* create new socket */
-                               b_sock = b_node.inputs.create(socket_type.c_str(), param->name.c_str(), param->name.c_str());
-                       }
                }
 
-               /* set default value */
-               if(b_sock) {
+               if(!b_sock) {
+                       /* create new socket */
+                       if(param->isoutput)
+                               b_sock = b_node.outputs.create(socket_type.c_str(), param->name.c_str(), param->name.c_str());
+                       else
+                               b_sock = b_node.inputs.create(socket_type.c_str(), param->name.c_str(), param->name.c_str());
+
+                       /* set default value */
                        if(data_type == BL::NodeSocket::type_VALUE) {
                                set_float(b_sock.ptr, "default_value", default_float);
                        }