Revision: 39821
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39821
Author:   campbellbarton
Date:     2011-08-31 10:43:22 +0000 (Wed, 31 Aug 2011)
Log Message:
-----------
patch [#28218] During-render callback functionality
from Jesse Kaukonen (gekko) 

--- text from the patch.

Recently Campbell Barton added callback functionality for Python's usage, but 
this only includes pre- and post-render callbacks. There are no callbacks for 
the duration of the render. This patch adds the few lines required for 
executing a callback while Blender Render is working. The callback resides in 
the rendering pipeline stats function, so whenever statistics are printed, the 
callback is executed. This functionality is required if one wants to:

1) Observe what is happening while Blender is rendering via the command line
2) Add custom statistics that Blender prints while the renderer works
3) The user wants to continue executing his Python script without the code 
halting at bpy.ops.render.render()

Personally I'm currently using this for printing out more detailed progress 
reports at Renderfarm.fi (such as CPU time, time spent rendering, total 
progress in regards to the entire rendering process). Tested on Windows, Linux 
and OS X.

Example on how to use the callback:

  def statscall(context): print("Thanks for calling!")
  bpy.app.handlers.render_stats.append(statscall)
  bpy.ops.render.render(animation=False, write_still=True)

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_callbacks.h
    trunk/blender/source/blender/python/intern/bpy_app_handlers.c
    trunk/blender/source/blender/render/intern/source/pipeline.c

Modified: trunk/blender/source/blender/blenlib/BLI_callbacks.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_callbacks.h        2011-08-31 
09:37:14 UTC (rev 39820)
+++ trunk/blender/source/blender/blenlib/BLI_callbacks.h        2011-08-31 
10:43:22 UTC (rev 39821)
@@ -42,6 +42,7 @@
 typedef enum {
        BLI_CB_EVT_RENDER_PRE,
        BLI_CB_EVT_RENDER_POST,
+       BLI_CB_EVT_RENDER_STATS,
        BLI_CB_EVT_LOAD_PRE,
        BLI_CB_EVT_LOAD_POST,
        BLI_CB_EVT_SAVE_PRE,

Modified: trunk/blender/source/blender/python/intern/bpy_app_handlers.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_app_handlers.c       
2011-08-31 09:37:14 UTC (rev 39820)
+++ trunk/blender/source/blender/python/intern/bpy_app_handlers.c       
2011-08-31 10:43:22 UTC (rev 39821)
@@ -42,9 +42,10 @@
 static PyStructSequence_Field app_cb_info_fields[]= {
        {(char *)"render_pre", NULL},
        {(char *)"render_post", NULL},
-    {(char *)"load_pre", NULL},
+       {(char *)"render_stats", NULL},
+       {(char *)"load_pre", NULL},
        {(char *)"load_post", NULL},
-    {(char *)"save_pre", NULL},
+       {(char *)"save_pre", NULL},
        {(char *)"save_post", NULL},
        {NULL}
 };

Modified: trunk/blender/source/blender/render/intern/source/pipeline.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pipeline.c        
2011-08-31 09:37:14 UTC (rev 39820)
+++ trunk/blender/source/blender/render/intern/source/pipeline.c        
2011-08-31 10:43:22 UTC (rev 39821)
@@ -173,6 +173,9 @@
                else
                        fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", 
rs->scenename, rs->totvert, rs->totface, rs->totlamp);
        }
+
+       BLI_exec_cb(rs, (ID *)rs, BLI_CB_EVT_RENDER_STATS);
+
        fputc('\n', stdout);
        fflush(stdout);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to