From a4969e75241405c55d48e950df7786592aa4cee3 Mon Sep 17 00:00:00 2001 From: Derived Cat Date: Wed, 29 Sep 2021 22:07:26 +0800 Subject: [PATCH 1/5] polish UI --- external/zeno | 2 +- zenoblend/execute_operator.py | 41 +++++++++++++++++++++++++++-------- zenoblend/scenario.py | 21 ++++++++++-------- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/external/zeno b/external/zeno index 4751c4b..d8c7e20 160000 --- a/external/zeno +++ b/external/zeno @@ -1 +1 @@ -Subproject commit 4751c4b4670daf93fb1782ff3653e8af4144051a +Subproject commit d8c7e2014637f6ff351d4012d197a97ab17d5b6a diff --git a/zenoblend/execute_operator.py b/zenoblend/execute_operator.py index cb2a696..5d98339 100644 --- a/zenoblend/execute_operator.py +++ b/zenoblend/execute_operator.py @@ -24,20 +24,35 @@ def execute(self, context): #''' -class ZenoStopOperator(bpy.types.Operator): - """Stop the running Zeno instance""" +class ZenoEnableAllOperator(bpy.types.Operator): + """Enable all node trees""" + bl_idname = "node.zeno_enable_all" + bl_label = "Enable All" + + @classmethod + def poll(cls, context): + return getattr(context.space_data, 'tree_type', 'ZenoNodeTree') == 'ZenoNodeTree' + + def execute(self, context): + for tree in bpy.data.node_groups: + if tree.bl_idname == 'ZenoNodeTree': + tree.zeno_enabled = True + return {'FINISHED'} + +class ZenoDisableAllOperator(bpy.types.Operator): + """Disable all node trees""" bl_idname = "node.zeno_stop" - bl_label = "Stop" + bl_label = "Disable All" @classmethod def poll(cls, context): return getattr(context.space_data, 'tree_type', 'ZenoNodeTree') == 'ZenoNodeTree' def execute(self, context): - if scenario.delete_scene(): - self.report({'INFO'}, 'Node tree stopped') - else: - self.report({'WARNING'}, 'Node tree already stopped!') + scenario.delete_scene() + for tree in bpy.data.node_groups: + if tree.bl_idname == 'ZenoNodeTree': + tree.zeno_enabled = False return {'FINISHED'} @@ -147,6 +162,9 @@ def poll(cls, context): def draw(self, context): layout = self.layout scene = context.scene + row = layout.row() + row.operator('node.zeno_enable_all') + row.operator('node.zeno_stop') col = layout.column() col.template_list("ZENO_UL_TreePropertyList", "", bpy.data, 'node_groups', scene.zeno, "ui_list_selected_tree") @@ -167,12 +185,17 @@ def draw(self, context): col.label(text=f"Cached to frame: {cached_to_frame}") row = layout.row() row.operator('node.zeno_start') - row.operator('node.zeno_stop') + if tree.zeno_cached: + if scene.frame_current != scene.zeno.frame_start: + row.enabled = False # gray out button + elif tree.zeno_realtime_update: + row.enabled = False classes = ( ZenoStartOperator, - ZenoStopOperator, + ZenoEnableAllOperator, + ZenoDisableAllOperator, ZenoReloadOperator, ZenoSceneProperties, ZENO_UL_TreePropertyList, diff --git a/zenoblend/scenario.py b/zenoblend/scenario.py index e2ca182..8031d0a 100644 --- a/zenoblend/scenario.py +++ b/zenoblend/scenario.py @@ -268,7 +268,7 @@ def get_dependencies(graph_name): def update_frame(graph_name): tree = bpy.data.node_groups[graph_name] currFrameId = bpy.context.scene.frame_current - if tree.nextFrameId is None: + if getattr(tree, "nextFrameId", None) is None: tree.nextFrameId = bpy.context.scene.zeno.frame_start if currFrameId > bpy.context.scene.zeno.frame_end: return @@ -279,7 +279,8 @@ def update_frame(graph_name): print('update_frame spent', '{:.4f}s'.format(time.time() - t0)) tree.nextFrameId = currFrameId + 1 - if currFrameId not in tree.frameCache: + + if currFrameId not in getattr(tree, "frameCache", {}): return for objName, meshName in tree.frameCache[currFrameId].items(): if objName not in bpy.data.objects: @@ -382,9 +383,11 @@ def scene_update_callback(scene, depsgraph): finally: nowUpdating = False -#@bpy.app.handlers.persistent -#def load_post_callback(dummy): - #bpy.ops.node.zeno_apply() +@bpy.app.handlers.persistent +def load_post_callback(dummy): + for tree in bpy.data.node_groups: + if tree.bl_idname == 'ZenoNodeTree': + tree.zeno_realtime_update = False def register(): @@ -392,8 +395,8 @@ def register(): bpy.app.handlers.frame_change_post.append(frame_update_callback) if scene_update_callback not in bpy.app.handlers.depsgraph_update_post: bpy.app.handlers.depsgraph_update_post.append(scene_update_callback) - #if load_post_callback not in bpy.app.handlers.load_post: - #bpy.app.handlers.load_post.append(load_post_callback) + if load_post_callback not in bpy.app.handlers.load_post: + bpy.app.handlers.load_post.append(load_post_callback) def unregister(): @@ -402,5 +405,5 @@ def unregister(): bpy.app.handlers.frame_change_post.remove(frame_update_callback) if scene_update_callback in bpy.app.handlers.depsgraph_update_post: bpy.app.handlers.depsgraph_update_post.remove(scene_update_callback) - #if load_post_callback in bpy.app.handlers.load_post: - #bpy.app.handlers.load_post.remove(load_post_callback) + if load_post_callback in bpy.app.handlers.load_post: + bpy.app.handlers.load_post.remove(load_post_callback) From 8ae20c30812cf27a0bf8653a1978f275a827bb79 Mon Sep 17 00:00:00 2001 From: Derived Cat Date: Wed, 29 Sep 2021 22:24:05 +0800 Subject: [PATCH 2/5] Update zeno --- external/zeno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/zeno b/external/zeno index d8c7e20..4751c4b 160000 --- a/external/zeno +++ b/external/zeno @@ -1 +1 @@ -Subproject commit d8c7e2014637f6ff351d4012d197a97ab17d5b6a +Subproject commit 4751c4b4670daf93fb1782ff3653e8af4144051a From 38bdc0265c120378ce2f951c5d310f0947549dee Mon Sep 17 00:00:00 2001 From: Derived Cat Date: Wed, 29 Sep 2021 22:29:57 +0800 Subject: [PATCH 3/5] update submodule --- external/zeno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/zeno b/external/zeno index 4751c4b..7bf90c8 160000 --- a/external/zeno +++ b/external/zeno @@ -1 +1 @@ -Subproject commit 4751c4b4670daf93fb1782ff3653e8af4144051a +Subproject commit 7bf90c891171a2c5398513abc4afd0a0defa3299 From 42ccd31313c162668dc2304ac4db5bd8205d81d7 Mon Sep 17 00:00:00 2001 From: Derived Cat Date: Wed, 29 Sep 2021 22:31:24 +0800 Subject: [PATCH 4/5] Update zeno --- external/zeno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/zeno b/external/zeno index 7bf90c8..4751c4b 160000 --- a/external/zeno +++ b/external/zeno @@ -1 +1 @@ -Subproject commit 7bf90c891171a2c5398513abc4afd0a0defa3299 +Subproject commit 4751c4b4670daf93fb1782ff3653e8af4144051a From 3784123656f27ec2e454d99821b6df8d97bba474 Mon Sep 17 00:00:00 2001 From: Derived Cat Date: Wed, 29 Sep 2021 22:44:32 +0800 Subject: [PATCH 5/5] Update zeno --- external/zeno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/zeno b/external/zeno index 4751c4b..fdf97db 160000 --- a/external/zeno +++ b/external/zeno @@ -1 +1 @@ -Subproject commit 4751c4b4670daf93fb1782ff3653e8af4144051a +Subproject commit fdf97dbadc747c662e8793b18241f5ca90b7895e