Various Python integration changes #77

Closed
Brecht Van Lommel wants to merge 6 commits from brecht:hydra-python-changes into hydra-render

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 12 additions and 13 deletions
Showing only changes of commit 1f9d54dba1 - Show all commits

View File

@ -91,7 +91,7 @@ class HydraRenderEngine(bpy.types.RenderEngine):
return {}
# final render
def _update(self, depsgraph):
def update(self, data, depsgraph):
"""This function is preferable to override in child classes instead of update()"""
engine_type = 'PREVIEW' if self.is_preview else 'FINAL'
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), engine_type, self.delegate_id)
@ -101,17 +101,9 @@ class HydraRenderEngine(bpy.types.RenderEngine):
for key, val in self.get_sync_settings(engine_type).items():
_bpy_hydra.engine_set_sync_setting(self.engine_ptr, key, val)
_bpy_hydra.engine_sync(self.engine_ptr, depsgraph.as_pointer(), bpy.context.as_pointer())
def update(self, data, depsgraph):
# If bl_use_gpu_context is true, this function is ignored and render() is used
if not self.bl_use_gpu_context:
self._update(depsgraph)
_bpy_hydra.engine_update(self.engine_ptr, depsgraph.as_pointer(), None)
def render(self, depsgraph):
if self.bl_use_gpu_context:
self._update(depsgraph)
if not self.engine_ptr:
return
@ -130,7 +122,7 @@ class HydraRenderEngine(bpy.types.RenderEngine):
for key, val in self.get_sync_settings('VIEWPORT').items():
_bpy_hydra.engine_set_sync_setting(self.engine_ptr, key, val)
_bpy_hydra.engine_sync(self.engine_ptr, depsgraph.as_pointer(), context.as_pointer())
_bpy_hydra.engine_update(self.engine_ptr, depsgraph.as_pointer(), context.as_pointer())
for key, val in self.get_render_settings('VIEWPORT').items():
_bpy_hydra.engine_set_render_setting(self.engine_ptr, key, val)

View File

@ -111,7 +111,7 @@ static PyObject *engine_free_func(PyObject * /*self*/, PyObject *args)
Py_RETURN_NONE;
}
static PyObject *engine_sync_func(PyObject * /*self*/, PyObject *args)
static PyObject *engine_update_func(PyObject * /*self*/, PyObject *args)
{
PyObject *pyengine, *pydepsgraph, *pycontext;
if (!PyArg_ParseTuple(args, "OOO", &pyengine, &pydepsgraph, &pycontext)) {
@ -239,7 +239,7 @@ static PyMethodDef methods[] = {
{"engine_create", engine_create_func, METH_VARARGS, ""},
{"engine_free", engine_free_func, METH_VARARGS, ""},
{"engine_sync", engine_sync_func, METH_VARARGS, ""},
{"engine_update", engine_update_func, METH_VARARGS, ""},
{"engine_render", engine_render_func, METH_VARARGS, ""},
{"engine_view_draw", engine_view_draw_func, METH_VARARGS, ""},
{"engine_set_sync_setting", engine_set_sync_setting_func, METH_VARARGS, ""},

View File

@ -919,9 +919,16 @@ static void engine_render_view_layer(Render *re,
/* Sync data to engine, within draw lock so scene data can be accessed safely. */
if (use_engine) {
const bool use_gpu_context = (engine->type->flag & RE_USE_GPU_CONTEXT);
if (use_gpu_context) {
DRW_render_context_enable(engine->re);
}
if (engine->type->update) {
engine->type->update(engine, re->main, engine->depsgraph);
}
if (use_gpu_context) {
DRW_render_context_disable(engine->re);
}
}
if (re->draw_lock) {