-
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
speed up update system #2380
Comments
For making update system more carefully, before updating a node it should be checked was parental nodes changed. For this goal it looks like is better to keep status of sockets. But only output sockets will keep real status. Input sockets will return either status of parental socket ore if such does not exist return False. Changing of the statuses will be happened during updating node groups. class SvSocketCommon:
""" Base class for all Sockets """
output_has_changed = BoolProperty(default=True)
@property
def has_changed(self):
if self.is_output:
# "I'm output"
return self.output_has_changed
if self.is_linked:
# "I'm inpunt and linked" - so its data is equal to root socket
return self.other.output_has_changed
if self.prop_name:
# "I'm input, not linked and I have property" - this also means that socket could not be changed.
return False
else:
# "I'm input, not linked and I have not property" - so it can't be changed
return False
def update_status(self, has_changed=False):
self.output_has_changed = has_changed >>> socket = bpy.data.node_groups['NodeTree'].nodes['A Number'].outputs[0]
>>> socket.has_changed
True
>>> socket.update_status()
>>> socket.has_changed
False
>>> socket.update_status(True)
>>> socket.has_changed
True |
Can be useful: |
Now, with more experience, I'm seeing lacks of my previous attempt:
https://wiki.blender.org/wiki/Source/Nodes/NodeInterfaceFramework |
The idea is to protect us from extra calculations.
For example we have spiral node that generate huge data (700 000 points particularly). There is no need to generate this data each time when update system is calling.
It is very simple to avoid recalculations. All that we have to do is to memorize properties of the spiral node and next time when update system will call to update the node, we will compare current properties and memorized properties, if nothing is changed do nothing.
Next step is do something with this data for example move points somewhere. But if this needs only once there is also no need recalculate this each time.
In this case we should check not only properties of the move node but also was data coming from inputs sockets changed. For this goals I created new property of output sockets that returns True if parent node was recalculated.
I made speed test for old and new update system with next layout:
Spiral node generates 700 thousand points. New update system shows increasing speed to 15-75 times. It looks strange that with the same conditions new update systems shows different increasing speed. And I think it should work even faster.
Old update system:
New update system:
Related theme: #121
The text was updated successfully, but these errors were encountered: