forked from blender/blender
Various Python integration changes #77
@ -91,7 +91,7 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
# final render
|
# final render
|
||||||
def _update(self, depsgraph):
|
def update(self, data, depsgraph):
|
||||||
"""This function is preferable to override in child classes instead of update()"""
|
"""This function is preferable to override in child classes instead of update()"""
|
||||||
engine_type = 'PREVIEW' if self.is_preview else 'FINAL'
|
engine_type = 'PREVIEW' if self.is_preview else 'FINAL'
|
||||||
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), engine_type, self.delegate_id)
|
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():
|
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_set_sync_setting(self.engine_ptr, key, val)
|
||||||
|
|
||||||
_bpy_hydra.engine_sync(self.engine_ptr, depsgraph.as_pointer(), bpy.context.as_pointer())
|
_bpy_hydra.engine_update(self.engine_ptr, depsgraph.as_pointer(), None)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
def render(self, depsgraph):
|
def render(self, depsgraph):
|
||||||
if self.bl_use_gpu_context:
|
|
||||||
self._update(depsgraph)
|
|
||||||
|
|
||||||
if not self.engine_ptr:
|
if not self.engine_ptr:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -130,7 +122,7 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
for key, val in self.get_sync_settings('VIEWPORT').items():
|
for key, val in self.get_sync_settings('VIEWPORT').items():
|
||||||
_bpy_hydra.engine_set_sync_setting(self.engine_ptr, key, val)
|
_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():
|
for key, val in self.get_render_settings('VIEWPORT').items():
|
||||||
_bpy_hydra.engine_set_render_setting(self.engine_ptr, key, val)
|
_bpy_hydra.engine_set_render_setting(self.engine_ptr, key, val)
|
||||||
|
@ -111,7 +111,7 @@ static PyObject *engine_free_func(PyObject * /*self*/, PyObject *args)
|
|||||||
Py_RETURN_NONE;
|
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;
|
PyObject *pyengine, *pydepsgraph, *pycontext;
|
||||||
if (!PyArg_ParseTuple(args, "OOO", &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_create", engine_create_func, METH_VARARGS, ""},
|
||||||
{"engine_free", engine_free_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_render", engine_render_func, METH_VARARGS, ""},
|
||||||
{"engine_view_draw", engine_view_draw_func, METH_VARARGS, ""},
|
{"engine_view_draw", engine_view_draw_func, METH_VARARGS, ""},
|
||||||
{"engine_set_sync_setting", engine_set_sync_setting_func, METH_VARARGS, ""},
|
{"engine_set_sync_setting", engine_set_sync_setting_func, METH_VARARGS, ""},
|
||||||
|
@ -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. */
|
/* Sync data to engine, within draw lock so scene data can be accessed safely. */
|
||||||
if (use_engine) {
|
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) {
|
if (engine->type->update) {
|
||||||
engine->type->update(engine, re->main, engine->depsgraph);
|
engine->type->update(engine, re->main, engine->depsgraph);
|
||||||
}
|
}
|
||||||
|
if (use_gpu_context) {
|
||||||
|
DRW_render_context_disable(engine->re);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (re->draw_lock) {
|
if (re->draw_lock) {
|
||||||
|
Loading…
Reference in New Issue
Block a user