[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4166] trunk/py/scripts/addons/ object_animrenderbake.py: don't overwrite the bake panel, instead prepend.

Campbell Barton ideasman42 at gmail.com
Tue Jan 15 05:14:26 CET 2013


Revision: 4166
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4166
Author:   campbellbarton
Date:     2013-01-15 04:14:18 +0000 (Tue, 15 Jan 2013)
Log Message:
-----------
don't overwrite the bake panel, instead prepend.

Modified Paths:
--------------
    trunk/py/scripts/addons/object_animrenderbake.py

Modified: trunk/py/scripts/addons/object_animrenderbake.py
===================================================================
--- trunk/py/scripts/addons/object_animrenderbake.py	2013-01-14 20:11:42 UTC (rev 4165)
+++ trunk/py/scripts/addons/object_animrenderbake.py	2013-01-15 04:14:18 UTC (rev 4166)
@@ -93,12 +93,12 @@
             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,67 +108,27 @@
 
             #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 ---------------------
+    rowsub = row.row(align=True)
+    rowsub.prop(scene, "animrenderbake_start")
+    rowsub.prop(scene, "animrenderbake_end")
 
-    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():
     bpy.utils.register_module(__name__)
 
@@ -182,19 +142,18 @@
         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()



More information about the Bf-extensions-cvs mailing list