-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sockets refactoring #3507
Sockets refactoring #3507
Conversation
this field should be overridden by other sockets which would like to use quick links to nodes which are most often used with them. In this way it will be easier for other developers to understand how to add quick links to their new socket types.
just add `bl_idname` of a node which should be quick linked.
I did not find in `self.node.rna_type` any node properties fad9759
I'm eager to delete this code because sockets should not know about node types. Lines 227 to 231 in c69efa6
Sockets should grant API in general and any (node) which would like to use sockets should use them via API and don't inject their parts of code into sockets classes. It looks like I have a solution which can be useful not only for SNL nodes but most likely it will require MK2 version. I'll have a look what can be done. |
make SNL node to use socket properties instead of its own remove SNL code from socket module
avoiding socket initialization infinite recursion and remove unused parts of code
now it more like node properties are exported fix effected jsons remove unused socket properties
Move out SNL node code from sockets module
and move responsibility of deep coping data into policy classes
and rearrange code a bit
I'd say the next candidate for refactoring should be deprecation of |
I'm usually using cycle from itertools to full fill data. |
For new nodes yes, but fullList is widely used in existing nodes, including list-manipulation nodes... |
default_property, they were more widely used than I thought
Using node properties in socket and its own looks redundant. I think it would be possible to use only socket properties and custom draw feature sometimes. Most likely why Lines 920 to 939 in 979172d
This code will let to put extra arguments to update function for example a name of updated property. class Socket
def prop_update(self, context, prop_name=None):
if hasattr(self.node, update_socket_prop):
self.node.update_socket_prop(self, context, prop_name):
else:
updateNode()
value: bpy.props.FloatProperty(update=update_with_kwargs(prop_update, 'value'))
class Node:
def update_socket_prop(self, socket, context, prop_name):
if prop_name == 'Values':
...
elif prop_name == 'Another prop':
... |
memorizing number of objects into socket field
API of new socket creating will be next after the PR: class Socket:
color = (1,1,1,1) # color of new socket (only mandatory attribute)
quick_link_to_node = 'GenVectorsNode' # id name of a node which will be connected by quick link
default_property: FloatProperty(update=update_from_socket) # if use_prop is True and socket is input and socket is unconnected this property will be shown
default_conversion_name = 'FieldImplicitConversionPolicy' # if sockets need another default conversion
def draw_proerty(): ... # if socket property has advance UI like Vector or Color sockets have now In most cases it will be enough. It is available now to use default property for Strings socket. It supports float and int types but other types can easily be added. class Node:
def sv_init():
sock = self.inputs.new('SvStringsSocket', 'Numbers')
sock.use_prop = True
sock.default_property_type = 'int'
scok.default_int_value = 10 Draw performance is better now it will be noticeable after 100 - 200 nodes in a tree. |
@Durman Please check, didn't this break existing blend files? I have a blend file where values of SvVerticesSocket's "built-in" properties (those with Well, actually i'm already sure. Here is the broken file. |
Yes in did, now I realize it. I think I know how this can be fixed. I will open new PR. |
Addressed problem description
#2772 #3483
Preflight checklist
Put an x letter in each brackets when you're done this item: