From d8dd3cc8b0bc380ed7134974238fe614b095d996 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 19 Aug 2017 14:40:15 -0400 Subject: [PATCH] Ensure node trees are upgraded properly --- korman/idprops.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/korman/idprops.py b/korman/idprops.py index f7ea5b2..45a6fab 100644 --- a/korman/idprops.py +++ b/korman/idprops.py @@ -138,3 +138,20 @@ def poll_visregion_objects(self, value): def poll_envmap_textures(self, value): return isinstance(value, bpy.types.EnvironmentMapTexture) + +@bpy.app.handlers.persistent +def _upgrade_node_trees(dummy): + """ + Logic node haxxor incoming! + Logic nodes appear to have issues with silently updating themselves. I expect that Blender is + doing something strange in the UI code that causes our metaprogramming tricks to be bypassed. + Therefore, we will loop through all Plasma node trees and forcibly update them on blend load. + """ + + for tree in bpy.data.node_groups: + if tree.bl_idname != "PlasmaNodeTree": + continue + for node in tree.nodes: + if isinstance(node, IDPropMixin): + assert node._try_upgrade_idprops() +bpy.app.handlers.load_post.append(_upgrade_node_trees)