Skip to content
Snippets Groups Projects
Commit 41021075 authored by Campbell Barton's avatar Campbell Barton
Browse files

don't overwrite the bake panel, instead prepend.

parent 81ab88ef
No related branches found
No related tags found
No related merge requests found
......@@ -93,12 +93,12 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator):
return {'CANCELLED'}
# make sure we have an absolute path so that copying works for sure
absp = bpy.path.abspath(img.filepath, library=img.library)
img_filepath_abs = bpy.path.abspath(img.filepath, library=img.library)
print("Animated baking for frames " + str(start) + " - " + str(end))
print("Animated baking for frames (%d - %d)" % (start, end))
for cfra in range(start, end+1):
print("Baking frame " + str(cfra))
print("Baking frame %d" % cfra)
# update scene to new frame and bake to template image
scene.frame_set(cfra)
......@@ -108,66 +108,26 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator):
#currently the api doesn't allow img.save_as(), so just save the template image as usual for every frame and copy to a file with frame specific filename
img.save()
shutil.copyfile(absp, self.framefile(absp, cfra))
img_filepath_new = self.framefile(img_filepath_abs, cfra)
shutil.copyfile(img_filepath_abs, img_filepath_new)
print("Saved %r" % img_filepath_new)
print("Saved " + self.framefile(absp, cfra))
print("Baking done!")
return{'FINISHED'}
# modified copy of original bake panel draw function
def draw_animrenderbake(self, context):
def draw(self, context):
layout = self.layout
rd = context.scene.render
scene = context.scene
row = layout.row()
row.operator("object.bake_image", icon='RENDER_STILL')
#----------- beginning of modifications ----------------
row.operator("object.anim_bake_image", text="Animated Bake", icon="RENDER_ANIMATION")
row = layout.row(align=True)
row.prop(context.scene, "animrenderbake_start")
row.prop(context.scene, "animrenderbake_end")
#-------------- end of modifications ---------------------
layout.prop(rd, "bake_type")
multires_bake = False
if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
layout.prop(rd, 'use_bake_multires')
multires_bake = rd.use_bake_multires
if not multires_bake:
if rd.bake_type == 'NORMALS':
layout.prop(rd, "bake_normal_space")
elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
layout.prop(rd, "use_bake_normalize")
# col.prop(rd, "bake_aa_mode")
# col.prop(rd, "use_bake_antialiasing")
layout.separator()
rowsub = row.row(align=True)
rowsub.prop(scene, "animrenderbake_start")
rowsub.prop(scene, "animrenderbake_end")
split = layout.split()
col = split.column()
col.prop(rd, "use_bake_clear")
col.prop(rd, "bake_margin")
col.prop(rd, "bake_quad_split", text="Split")
col = split.column()
col.prop(rd, "use_bake_selected_to_active")
sub = col.column()
sub.active = rd.use_bake_selected_to_active
sub.prop(rd, "bake_distance")
sub.prop(rd, "bake_bias")
else:
if rd.bake_type == 'DISPLACEMENT':
layout.prop(rd, "use_bake_lores_mesh")
layout.prop(rd, "use_bake_clear")
layout.prop(rd, "bake_margin")
def register():
bpy.utils.register_module(__name__)
......@@ -182,19 +142,18 @@ def register():
description="End frame of the animated bake",
default=250)
# replace original panel draw function with modified one
panel = bpy.types.RENDER_PT_bake
panel.old_draw = panel.draw
panel.draw = draw_animrenderbake
bpy.types.RENDER_PT_bake.prepend(draw)
def unregister():
bpy.utils.unregister_module(__name__)
# restore original panel draw function
bpy.types.RENDER_PT_bake.draw = bpy.types.RENDER_PT_bake.old_draw
del bpy.types.RENDER_PT_bake.old_draw
del bpy.types.Scene.animrenderbake_start
del bpy.types.Scene.animrenderbake_end
bpy.types.RENDER_PT_bake.remove(draw)
if __name__ == "__main__":
register()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment