Skip to content
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

Polish UI #15

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion external/zeno
Submodule zeno updated from 4751c4 to fdf97d
41 changes: 32 additions & 9 deletions zenoblend/execute_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}


Expand Down Expand Up @@ -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")
Expand All @@ -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,
Expand Down
21 changes: 12 additions & 9 deletions zenoblend/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -382,18 +383,20 @@ 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():
if frame_update_callback not in bpy.app.handlers.frame_change_post:
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():
Expand All @@ -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)