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
Branches
Tags
No related merge requests found
...@@ -93,12 +93,12 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator): ...@@ -93,12 +93,12 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator):
return {'CANCELLED'} return {'CANCELLED'}
# make sure we have an absolute path so that copying works for sure # 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): 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 # update scene to new frame and bake to template image
scene.frame_set(cfra) scene.frame_set(cfra)
...@@ -108,66 +108,26 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator): ...@@ -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 #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() 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!") print("Baking done!")
return{'FINISHED'} return{'FINISHED'}
# modified copy of original bake panel draw function # modified copy of original bake panel draw function
def draw_animrenderbake(self, context): def draw(self, context):
layout = self.layout layout = self.layout
rd = context.scene.render scene = context.scene
row = layout.row() 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.operator("object.anim_bake_image", text="Animated Bake", icon="RENDER_ANIMATION")
row = layout.row(align=True) rowsub = row.row(align=True)
row.prop(context.scene, "animrenderbake_start") rowsub.prop(scene, "animrenderbake_start")
row.prop(context.scene, "animrenderbake_end") rowsub.prop(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()
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(): def register():
bpy.utils.register_module(__name__) bpy.utils.register_module(__name__)
...@@ -182,19 +142,18 @@ def register(): ...@@ -182,19 +142,18 @@ def register():
description="End frame of the animated bake", description="End frame of the animated bake",
default=250) default=250)
# replace original panel draw function with modified one bpy.types.RENDER_PT_bake.prepend(draw)
panel = bpy.types.RENDER_PT_bake
panel.old_draw = panel.draw
panel.draw = draw_animrenderbake
def unregister(): def unregister():
bpy.utils.unregister_module(__name__) bpy.utils.unregister_module(__name__)
# restore original panel draw function # 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_start
del bpy.types.Scene.animrenderbake_end del bpy.types.Scene.animrenderbake_end
bpy.types.RENDER_PT_bake.remove(draw)
if __name__ == "__main__": if __name__ == "__main__":
register() register()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment