Overriding Blender update events.
Created by: Durman
Problem statement
- During coding of nodes you should take in account update system of Blender.
- Blender
update
events does not suit well to the Sverchok requiredupdate
events. - It is cheaper to spend some calculation to make update smarter and save time on nodes recalculations.
Possible solution
First of all such system should get all signals from Blender. It is possible to do by placing function in update methods. For example:
class SverchCustomTree:
def update(self):
tree_update(self)
After getting signals the system can call appropriate methods.
def tree_update(node_tree):
for node in node_tree:
if hasattr(node, 'sv_update'):
node.sv_update()
It is simpler to make update smarter.
def tree_update(node_tree):
type_update = get_type_update()
if type_update == 'new_links_creation`:
new_links = get_new_links()
fro link in new_links:
update_node_ui(link.from_node)
update_node_ui(link.to_node)