forked from bartvdbraak/blender
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)
This commit is contained in:
parent
d0d82c69e9
commit
fde215025e
@ -42,6 +42,7 @@ struct ID;
|
||||
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,
|
||||
|
@ -42,9 +42,10 @@ static PyTypeObject BlenderAppCbType;
|
||||
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}
|
||||
};
|
||||
|
@ -173,6 +173,9 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user