feat: integrate render swarm companion app

This commit is contained in:
2026-06-22 00:18:25 +02:00
parent 64c2eb275e
commit e230da1002
3 changed files with 54 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ classes = (
properties.SceneRendererSettings,
operators.SCENERENDERER_OT_render_all,
operators.SCENERENDERER_OT_cancel_batch,
operators.SCENERENDERER_OT_launch_swarm,
panel.SCENERENDERER_PT_panel,
)

View File

@@ -180,6 +180,53 @@ class SCENERENDERER_OT_cancel_batch(bpy.types.Operator):
return {'FINISHED'}
class SCENERENDERER_OT_launch_swarm(bpy.types.Operator):
bl_idname = "scenerenderer.launch_swarm"
bl_label = "Launch Render Swarm"
bl_description = "Start the Render Swarm Companion App as Host"
def execute(self, context):
# Ensure file is saved
if not bpy.data.is_saved:
self.report({'ERROR'}, "Please save your .blend file first!")
return {'CANCELLED'}
bpy.ops.wm.save_mainfile()
filepath = bpy.data.filepath
render_dir = bpy.path.abspath("//renders")
os.makedirs(render_dir, exist_ok=True)
# Determine path to swarm app
swarm_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "scene-renderer-swarm"))
if not os.path.exists(swarm_dir):
self.report({'ERROR'}, f"Swarm App not found at {swarm_dir}")
return {'CANCELLED'}
import platform
if platform.system() == "Windows":
script = os.path.join(swarm_dir, "run.bat")
else:
script = os.path.join(swarm_dir, "run.sh")
cmd = [
script,
"--blend", filepath,
"--out", render_dir,
"--start", str(context.scene.frame_start),
"--end", str(context.scene.frame_end)
]
try:
# We use Popen so we don't block Blender
subprocess.Popen(cmd, cwd=swarm_dir)
self.report({'INFO'}, "Render Swarm Host launched!")
except Exception as e:
self.report({'ERROR'}, f"Failed to launch Swarm: {e}")
return {'FINISHED'}
_FORMAT_TO_EXT = {
'PNG': '.png',
'JPEG': '.jpg',

View File

@@ -120,4 +120,9 @@ class SCENERENDERER_PT_panel(bpy.types.Panel):
op1 = row.operator("scenerenderer.render_all", text="Current Scene", icon='RENDER_STILL')
op1.render_only_current = True
op2 = row.operator("scenerenderer.render_all", text="All Scenes", icon='RENDER_ANIMATION')
op2.render_only_current = False
op2.render_only_current = False
layout.separator()
row = layout.row(align=True)
row.scale_y = 2.0
row.operator("scenerenderer.launch_swarm", text="Start Render Swarm (Network)", icon='NODETREE')