-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsock_utils.py
94 lines (73 loc) · 2.48 KB
/
sock_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import bpy
import ctypes
import platform
from mathutils import Vector
weird_offset = 10
reroute_width = 10
class StructBase(ctypes.Structure):
_subclasses = []
__annotations__ = {}
def __init_subclass__(cls):
cls._subclasses.append(cls)
@staticmethod
def _init_structs():
functype = type(lambda: None)
for cls in StructBase._subclasses:
fields = []
for field, value in cls.__annotations__.items():
if isinstance(value, functype):
value = value()
fields.append((field, value))
if fields:
cls._fields_ = fields
cls.__annotations__.clear()
StructBase._subclasses.clear()
@classmethod
def get_fields(cls, tar):
return cls.from_address(tar.as_pointer())
class BNodeSocketRuntimeHandle(StructBase): # \source\blender\makesdna\DNA_node_types.h
if platform.system() == "Windows":
_padding_0: ctypes.c_char * 8
declaration: ctypes.c_void_p
changed_flag: ctypes.c_uint32
total_inputs: ctypes.c_short
_padding_1: ctypes.c_char * 2
location: ctypes.c_float * 2
class BNodeStack(StructBase):
vec: ctypes.c_float * 4
min: ctypes.c_float
max: ctypes.c_float
data: ctypes.c_void_p
hasinput: ctypes.c_short
hasoutput: ctypes.c_short
datatype: ctypes.c_short
sockettype: ctypes.c_short
is_copy: ctypes.c_short
external: ctypes.c_short
_padding_: ctypes.c_char * 4
class BNodeSocket(StructBase):
next: ctypes.c_void_p # lambda: ctypes.POINTER(BNodeSocket)
prev: ctypes.c_void_p # lambda: ctypes.POINTER(BNodeSocket)
prop: ctypes.c_void_p
identifier: ctypes.c_char * 64
name: ctypes.c_char * 64
storage: ctypes.c_void_p
in_out: ctypes.c_short
typeinfo: ctypes.c_void_p
idname: ctypes.c_char * 64
default_value: ctypes.c_void_p
_padding_: ctypes.c_char * 4
label: ctypes.c_char * 64
description: ctypes.c_char * 64
if (bpy.app.version >= (4, 0)) and (bpy.app.version_string != "4.0.0 Alpha"):
short_label: ctypes.c_char * 64
default_attribute_name: ctypes.POINTER(ctypes.c_char)
to_index: ctypes.c_int
link: ctypes.c_void_p
ns: BNodeStack
runtime: ctypes.POINTER(BNodeSocketRuntimeHandle)
def get_socket_location(sk):
if (not sk.enabled) and (sk.hide):
return Vector((0, 0))
return Vector(BNodeSocket.get_fields(sk).runtime.contents.location[:])
StructBase._init_structs()