[Bf-blender-cvs] [bd3334feaae] functions: allow more advanced socket declarations
Jacques Lucke
noreply at git.blender.org
Tue Mar 12 18:29:38 CET 2019
Commit: bd3334feaaeb39edccd568f17a22321d028b8f7a
Author: Jacques Lucke
Date: Tue Mar 12 16:30:41 2019 +0100
Branches: functions
https://developer.blender.org/rBbd3334feaaeb39edccd568f17a22321d028b8f7a
allow more advanced socket declarations
===================================================================
M release/scripts/startup/function_nodes/base.py
M release/scripts/startup/function_nodes/nodes/append_to_list.py
M release/scripts/startup/function_nodes/nodes/clamp.py
M release/scripts/startup/function_nodes/nodes/combine_lists.py
M release/scripts/startup/function_nodes/nodes/combine_vector.py
M release/scripts/startup/function_nodes/nodes/float_math.py
M release/scripts/startup/function_nodes/nodes/get_list_element.py
M release/scripts/startup/function_nodes/nodes/map_range.py
M release/scripts/startup/function_nodes/nodes/object_transforms.py
M release/scripts/startup/function_nodes/nodes/random_number.py
M release/scripts/startup/function_nodes/nodes/separate_vector.py
M release/scripts/startup/function_nodes/nodes/vector_distance.py
A release/scripts/startup/function_nodes/socket_decl.py
M release/scripts/startup/function_nodes/sockets.py
===================================================================
diff --git a/release/scripts/startup/function_nodes/base.py b/release/scripts/startup/function_nodes/base.py
index c9cc9b8f94a..f8da8f4dbf5 100644
--- a/release/scripts/startup/function_nodes/base.py
+++ b/release/scripts/startup/function_nodes/base.py
@@ -31,7 +31,7 @@ class BaseNode:
def iter_final_subclasses(cls):
yield from filter(lambda x: issubclass(x, bpy.types.Node), iter_subclasses_recursive(cls))
-class BaseSocket:
+class BaseSocketDecl:
color = (0, 0, 0, 0)
def draw_color(self, context, node):
@@ -46,15 +46,15 @@ class BaseSocket:
class FunctionNode(BaseNode):
def init(self, context):
inputs, outputs = self.get_sockets()
- for idname, name in inputs:
- self.inputs.new(idname, name)
- for idname, name in outputs:
- self.outputs.new(idname, name)
+ for socket_decl in inputs:
+ socket_decl.generate(self, self.inputs)
+ for socket_decl in outputs:
+ socket_decl.generate(self, self.outputs)
def get_sockets():
return [], []
-class DataSocket(BaseSocket):
+class DataSocket(BaseSocketDecl):
def draw_self(self, layout, node, text):
if not (self.is_linked or self.is_output) and hasattr(self, "draw_property"):
self.draw_property(layout, node, text)
diff --git a/release/scripts/startup/function_nodes/nodes/append_to_list.py b/release/scripts/startup/function_nodes/nodes/append_to_list.py
index 8a8031d755c..390acb68dfb 100644
--- a/release/scripts/startup/function_nodes/nodes/append_to_list.py
+++ b/release/scripts/startup/function_nodes/nodes/append_to_list.py
@@ -1,14 +1,17 @@
import bpy
from .. base import FunctionNode
+from .. socket_decl import BaseSocketDecl, ListSocketDecl
class AppendToListNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_AppendToListNode"
bl_label = "Append to List"
+ active_type: BaseSocketDecl.Property()
+
def get_sockets(self):
return [
- ("fn_FloatListSocket", "List"),
- ("fn_FloatSocket", "Value"),
+ ListSocketDecl("List", "active_type"),
+ BaseSocketDecl("Value", "active_type"),
], [
- ("fn_FloatListSocket", "List"),
+ ListSocketDecl("List", "active_type"),
]
\ No newline at end of file
diff --git a/release/scripts/startup/function_nodes/nodes/clamp.py b/release/scripts/startup/function_nodes/nodes/clamp.py
index 5f8cead91b2..3c94de53688 100644
--- a/release/scripts/startup/function_nodes/nodes/clamp.py
+++ b/release/scripts/startup/function_nodes/nodes/clamp.py
@@ -1,5 +1,6 @@
import bpy
from .. base import FunctionNode
+from .. socket_decl import FixedSocketDecl
class ClampNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_ClampNode"
@@ -7,9 +8,9 @@ class ClampNode(bpy.types.Node, FunctionNode):
def get_sockets(self):
return [
- ("fn_FloatSocket", "Value"),
- ("fn_FloatSocket", "Min"),
- ("fn_FloatSocket", "Max"),
+ FixedSocketDecl("Value", "Float"),
+ FixedSocketDecl("Min", "Float"),
+ FixedSocketDecl("Max", "Float"),
], [
- ("fn_FloatSocket", "Result"),
+ FixedSocketDecl("Result", "Float"),
]
\ No newline at end of file
diff --git a/release/scripts/startup/function_nodes/nodes/combine_lists.py b/release/scripts/startup/function_nodes/nodes/combine_lists.py
index 6d651c3cd39..d5db51e1bb8 100644
--- a/release/scripts/startup/function_nodes/nodes/combine_lists.py
+++ b/release/scripts/startup/function_nodes/nodes/combine_lists.py
@@ -1,14 +1,17 @@
import bpy
from .. base import FunctionNode
+from .. socket_decl import ListSocketDecl
class CombineListsNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_CombineListsNode"
bl_label = "Combine Lists"
+ active_type: ListSocketDecl.Property()
+
def get_sockets(self):
return [
- ("fn_FloatListSocket", "List 1"),
- ("fn_FloatListSocket", "List 2"),
+ ListSocketDecl("List 1", "active_type"),
+ ListSocketDecl("List 2", "active_type"),
], [
- ("fn_FloatListSocket", "List"),
+ ListSocketDecl("List", "active_type"),
]
\ No newline at end of file
diff --git a/release/scripts/startup/function_nodes/nodes/combine_vector.py b/release/scripts/startup/function_nodes/nodes/combine_vector.py
index 055491b9b86..aa9d074fa8f 100644
--- a/release/scripts/startup/function_nodes/nodes/combine_vector.py
+++ b/release/scripts/startup/function_nodes/nodes/combine_vector.py
@@ -1,5 +1,6 @@
import bpy
from .. base import FunctionNode
+from .. socket_decl import FixedSocketDecl
class CombineVectorNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_CombineVectorNode"
@@ -7,9 +8,9 @@ class CombineVectorNode(bpy.types.Node, FunctionNode):
def get_sockets(self):
return [
- ("fn_FloatSocket", "X"),
- ("fn_FloatSocket", "Y"),
- ("fn_FloatSocket", "Z"),
+ FixedSocketDecl("X", "Float"),
+ FixedSocketDecl("Y", "Float"),
+ FixedSocketDecl("Z", "Float"),
], [
- ("fn_VectorSocket", "Result"),
+ FixedSocketDecl("Result", "Vector"),
]
\ No newline at end of file
diff --git a/release/scripts/startup/function_nodes/nodes/float_math.py b/release/scripts/startup/function_nodes/nodes/float_math.py
index 7951925e496..9b25b054362 100644
--- a/release/scripts/startup/function_nodes/nodes/float_math.py
+++ b/release/scripts/startup/function_nodes/nodes/float_math.py
@@ -1,6 +1,7 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
+from .. socket_decl import FixedSocketDecl
operation_items = [
("ADD", "Add", "", "", 1),
@@ -20,10 +21,10 @@ class FloatMathNode(bpy.types.Node, FunctionNode):
def get_sockets(self):
return [
- ("fn_FloatSocket", "A"),
- ("fn_FloatSocket", "B"),
+ FixedSocketDecl("A", "Float"),
+ FixedSocketDecl("B", "Float"),
], [
- ("fn_FloatSocket", "Result"),
+ FixedSocketDecl("Result", "Float"),
]
def draw(self, layout):
diff --git a/release/scripts/startup/function_nodes/nodes/get_list_element.py b/release/scripts/startup/function_nodes/nodes/get_list_element.py
index ea64a6e7792..7bfc16fb204 100644
--- a/release/scripts/startup/function_nodes/nodes/get_list_element.py
+++ b/release/scripts/startup/function_nodes/nodes/get_list_element.py
@@ -1,15 +1,18 @@
import bpy
from .. base import FunctionNode
+from .. socket_decl import FixedSocketDecl, BaseSocketDecl, ListSocketDecl
class GetListElementNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_GetListElementNode"
bl_label = "Get List Element"
+ active_type: BaseSocketDecl.Property()
+
def get_sockets(self):
return [
- ("fn_FloatListSocket", "List"),
- ("fn_IntegerSocket", "Index"),
- ("fn_FloatSocket", "Fallback"),
+ ListSocketDecl("List", "active_type"),
+ FixedSocketDecl("Index", "Integer"),
+ BaseSocketDecl("Fallback", "active_type"),
], [
- ("fn_FloatSocket", "Value"),
+ BaseSocketDecl("Value", "active_type"),
]
\ No newline at end of file
diff --git a/release/scripts/startup/function_nodes/nodes/map_range.py b/release/scripts/startup/function_nodes/nodes/map_range.py
index a8b971dfeeb..1fc09e05b68 100644
--- a/release/scripts/startup/function_nodes/nodes/map_range.py
+++ b/release/scripts/startup/function_nodes/nodes/map_range.py
@@ -1,6 +1,7 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
+from .. socket_decl import FixedSocketDecl
class MapRangeNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_MapRangeNode"
@@ -8,11 +9,11 @@ class MapRangeNode(bpy.types.Node, FunctionNode):
def get_sockets(self):
return [
- ("fn_FloatSocket", "Value"),
- ("fn_FloatSocket", "From Min"),
- ("fn_FloatSocket", "From Max"),
- ("fn_FloatSocket", "To Min"),
- ("fn_FloatSocket", "To Max"),
+ FixedSocketDecl("Value", "Float"),
+ FixedSocketDecl("From Min", "Float"),
+ FixedSocketDecl("From Max", "Float"),
+ FixedSocketDecl("To Min", "Float"),
+ FixedSocketDecl("To Max", "Float"),
], [
- ("fn_FloatSocket", "Value"),
+ FixedSocketDecl("Value", "Float"),
]
\ No newline at end of file
diff --git a/release/scripts/startup/function_nodes/nodes/object_transforms.py b/release/scripts/startup/function_nodes/nodes/object_transforms.py
index 5fae78e493c..73d826e35ae 100644
--- a/release/scripts/startup/function_nodes/nodes/object_transforms.py
+++ b/release/scripts/startup/function_nodes/nodes/object_transforms.py
@@ -1,6 +1,7 @@
import bpy
from bpy.props import *
from .. base import FunctionNode
+from .. socket_decl import FixedSocketDecl
class ObjectTransformsNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_ObjectTransformsNode"
@@ -13,7 +14,7 @@ class ObjectTransformsNode(bpy.types.Node, FunctionNode):
def get_sockets(self):
return [], [
- ("fn_VectorSocket", "Location"),
+ FixedSocketDecl("Location", "Vector"),
]
def draw(self, layout):
diff --git a/release/scripts/startup/function_nodes/nodes/random_number.py b/release/scripts/startup/function_nodes/nodes/random_number.py
index 7e5ac2c9b6a..eb2df6d5228 100644
--- a/release/scripts/startup/function_nodes/nodes/random_number.py
+++ b/release/scripts/startup/function_nodes/nodes/random_number.py
@@ -1,5 +1,6 @@
import bpy
from .. base import FunctionNode
+from .. socket_decl import FixedSocketDecl
class RandomNumberNode(bpy.types.Node, FunctionNode):
bl_idname = "fn_RandomNumberNode"
@@ -7,9 +8,9 @@ class RandomNumberNode(bpy.types.Node, FunctionNode):
def get_sockets(self):
return [
- ("fn_IntegerSocket", "Seed"),
- ("fn_FloatSocket", "Min"),
- ("fn_FloatSocket", "Max"),
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list