Decorators for node tree updation delay

When we create a field on the add-on interface panel, the value of which changes something in the node tree, each time the user changes the field value the node tree recompiles. If the user changes the value in that field by holding and moving the mouse, too frequent node tree recompilation will cause Blender to hangs.

This problem can be solved using decorators for deferred updating of the node tree.

Code by Skarn.

Decorators definition:

The code uses the third-party “Boltons” library, which needs to be included to the add-on for proper work.

This code defines two decorators: “delay_execution” – to delay execution by time, and “on_release” – to delay until the user releases the held mouse button.

In the add-on we can use these decorators:

Here the “sun_direction” node property will update only when the user releases the held mouse button.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments