[Bf-blender-cvs] [794e165] object_nodes: Fix for mismatching socket type identifiers.

Lukas Tönne noreply at git.blender.org
Mon Dec 7 13:51:22 CET 2015


Commit: 794e16591b713401fc89051ac4159ba26e5d2dc2
Author: Lukas Tönne
Date:   Mon Dec 7 13:49:02 2015 +0100
Branches: object_nodes
https://developer.blender.org/rB794e16591b713401fc89051ac4159ba26e5d2dc2

Fix for mismatching socket type identifiers.

Have to be careful about distinguishing socket type identifiers
and bvm type identifiers.

===================================================================

M	release/scripts/nodes/group_nodes.py
M	release/scripts/nodes/node_compiler.py
M	release/scripts/nodes/socket_types.py

===================================================================

diff --git a/release/scripts/nodes/group_nodes.py b/release/scripts/nodes/group_nodes.py
index d6e07c0..4d456e5 100644
--- a/release/scripts/nodes/group_nodes.py
+++ b/release/scripts/nodes/group_nodes.py
@@ -22,7 +22,7 @@ import bpy
 import nodeitems_utils
 from bpy.types import Operator, Panel, UIList, NodeTree, Node, NodeSocket, ObjectNode, PropertyGroup, BVMTypeDesc
 from bpy.props import *
-from socket_types import socket_type_items, socket_type_to_rna
+from socket_types import socket_type_items, socket_type_to_rna, socket_type_to_bvm_type
 
 ###############################################################################
 # Group Interface
@@ -325,7 +325,7 @@ def make_node_group_types(prefix, treetype, node_base):
         def compile(self, compiler):
             gtree = self.id_data
             for i, item in enumerate(gtree.inputs):
-                proxy = compiler.add_proxy(item.base_type)
+                proxy = compiler.add_proxy(socket_type_to_bvm_type(item.base_type))
                 compiler.map_output(i, proxy.outputs[0])
                 compiler.map_input_external(i, proxy.inputs[0])
 
@@ -343,7 +343,7 @@ def make_node_group_types(prefix, treetype, node_base):
         def compile(self, compiler):
             gtree = self.id_data
             for i, item in enumerate(gtree.outputs):
-                proxy = compiler.add_proxy(item.base_type)
+                proxy = compiler.add_proxy(socket_type_to_bvm_type(item.base_type))
                 compiler.map_input(i, proxy.inputs[0])
                 compiler.map_output_external(i, proxy.outputs[0])
 
diff --git a/release/scripts/nodes/node_compiler.py b/release/scripts/nodes/node_compiler.py
index c3ad44d..2b4b557 100644
--- a/release/scripts/nodes/node_compiler.py
+++ b/release/scripts/nodes/node_compiler.py
@@ -19,7 +19,7 @@
 # <pep8-80 compliant>
 
 from collections import OrderedDict
-from socket_types import socket_to_bvm_type, convert_sockets
+from socket_types import rna_to_bvm_type, convert_sockets
 
 # Utility dict type that works like RNA collections,
 # i.e. accepts both string keys and integer indices
@@ -88,7 +88,7 @@ class NodeCompiler:
         # proxies for inputs/outputs
         bnode_inputs = StringDict()
         for binput in bnode.inputs:
-            proxy = self.add_proxy(socket_to_bvm_type(binput))
+            proxy = self.add_proxy(rna_to_bvm_type(type(binput)))
             bnode_inputs[binput.identifier] = proxy
             input_map[(bnode, binput)] = proxy.inputs[0]
 
@@ -97,7 +97,7 @@ class NodeCompiler:
         
         bnode_outputs = StringDict()
         for boutput in bnode.outputs:
-            proxy = self.add_proxy(socket_to_bvm_type(boutput))
+            proxy = self.add_proxy(rna_to_bvm_type(type(boutput)))
             bnode_outputs[boutput.identifier] = proxy
             output_map[(bnode, boutput)] = proxy.outputs[0]
 
diff --git a/release/scripts/nodes/socket_types.py b/release/scripts/nodes/socket_types.py
index f61a1e3..f703266 100644
--- a/release/scripts/nodes/socket_types.py
+++ b/release/scripts/nodes/socket_types.py
@@ -73,20 +73,23 @@ def socket_type_to_rna(base_type):
         }
     return types.get(base_type, None)
 
-def socket_to_bvm_type(socket):
-    if isinstance(socket, bpy.types.NodeSocketFloat):
+def rna_to_bvm_type(cls):
+    if issubclass(cls, bpy.types.NodeSocketFloat):
         return 'FLOAT'
-    elif isinstance(socket, bpy.types.NodeSocketVector):
+    elif issubclass(cls, bpy.types.NodeSocketVector):
         return 'FLOAT3'
-    elif isinstance(socket, bpy.types.NodeSocketColor):
+    elif issubclass(cls, bpy.types.NodeSocketColor):
         return 'FLOAT4'
-    elif isinstance(socket, bpy.types.NodeSocketInt):
+    elif issubclass(cls, bpy.types.NodeSocketInt):
         return 'INT'
-    elif isinstance(socket, bpy.types.GeometrySocket):
+    elif issubclass(cls, bpy.types.GeometrySocket):
         return 'MESH'
-    elif isinstance(socket, bpy.types.TransformSocket):
+    elif issubclass(cls, bpy.types.TransformSocket):
         return 'MATRIX44'
 
+def socket_type_to_bvm_type(base_type):
+    return rna_to_bvm_type(socket_type_to_rna(base_type))
+
 # determines if a conversion is necessary and possible
 # and returns a new input socket to link
 def convert_sockets(compiler, from_socket, to_socket):




More information about the Bf-blender-cvs mailing list