From 48eded1a9b7d3b80d10ba7177ca36ce3e9b0af3e Mon Sep 17 00:00:00 2001 From: Swann Date: Fri, 21 Jan 2022 09:06:56 +0100 Subject: [PATCH] feat: update replay --- multi_user/operators.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/multi_user/operators.py b/multi_user/operators.py index 4d78046..23b51c5 100644 --- a/multi_user/operators.py +++ b/multi_user/operators.py @@ -69,7 +69,7 @@ stop_modal_executor = False CLEARED_DATABLOCKS = ['actions', 'armatures', 'cache_files', 'cameras', - 'collections', 'curves', 'filepath', 'fonts', + 'collections', 'curves', 'fonts', 'grease_pencils', 'images', 'lattices', 'libraries', 'lightprobes', 'lights', 'linestyles', 'masks', 'materials', 'meshes', 'metaballs', 'movieclips', @@ -113,7 +113,6 @@ def draw_user(username, metadata, radius=0.01, intensity=10.0): scene = metadata.get('scene_current', bpy.context.scene.name) user_collection = bpy.data.collections.new(username) - # User Color user_mat = bpy.data.materials.new(username) user_mat.use_nodes = True @@ -155,7 +154,7 @@ def draw_user(username, metadata, radius=0.01, intensity=10.0): camera_obj.modifiers.new("wireframe", "SKIN") camera_obj.data.skin_vertices[0].data[0].use_root = True - for v in camera_mesh.skin_vertices[0].data: + for v in camera_obj.data.skin_vertices[0].data: v.radius = [radius, radius] camera_mesh.materials.append(user_mat) @@ -1032,12 +1031,12 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper): user_skin_radius: bpy.props.FloatProperty( name="Wireframe radius", description="Wireframe radius", - default=0.005, + default=0.01, ) user_color_intensity: bpy.props.FloatProperty( name="Shading intensity", description="Shading intensity", - default=10.0, + default=1.0, ) files: bpy.props.CollectionProperty( @@ -1431,6 +1430,26 @@ def menu_func_import(self, context): def menu_func_export(self, context): self.layout.operator(SessionSaveBackupOperator.bl_idname, text='Multi-user session snapshot (.db)') +class SessionRenderReplay(bpy.types.Operator): + bl_idname = "session.render_replay" + bl_label = "Render Replay" + bl_description = "Render Replay" + + @classmethod + def poll(cls, context): + return context.window_manager.session.replay_files + + def execute(self, context): + base_path = str(context.scene.render.filepath) + for frame in range(0,context.scene.frame_end): + logging.info(f"Rendering frame {frame} to {base_path}_{frame}.png") + context.scene.frame_current = frame + filename = Path(bpy.context.window_manager.session.replay_files[context.scene.active_replay_file].name) + context.scene.render.filepath = f"{base_path}{frame}_{filename.stem}" + bpy.ops.render.render(write_still=True) + + context.scene.render.filepath = base_path + return {'FINISHED'} classes = ( SessionConnectOperator, @@ -1457,6 +1476,7 @@ classes = ( RefreshServerStatus, GetDoc, FirstLaunch, + SessionRenderReplay, )