forked from blender/blender
Various Python integration changes #77
@ -1286,14 +1286,14 @@ class HydraRenderEngine(RenderEngine):
|
||||
|
||||
engine_type = 'PREVIEW' if self.is_preview else 'FINAL'
|
||||
if not self.engine_ptr:
|
||||
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), engine_type, self.bl_delegate_id)
|
||||
self.engine_ptr = _bpy_hydra.engine_create(self, engine_type, self.bl_delegate_id)
|
||||
if not self.engine_ptr:
|
||||
return
|
||||
|
||||
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_update(self.engine_ptr, depsgraph.as_pointer(), 0)
|
||||
_bpy_hydra.engine_update(self.engine_ptr, depsgraph, 0)
|
||||
|
||||
for key, val in self.get_render_settings('PREVIEW' if self.is_preview else 'FINAL').items():
|
||||
_bpy_hydra.engine_set_render_setting(self.engine_ptr, key, val)
|
||||
@ -1303,20 +1303,20 @@ class HydraRenderEngine(RenderEngine):
|
||||
return
|
||||
|
||||
import _bpy_hydra
|
||||
_bpy_hydra.engine_render(self.engine_ptr, depsgraph.as_pointer())
|
||||
_bpy_hydra.engine_render(self.engine_ptr, depsgraph)
|
||||
|
||||
# Viewport render.
|
||||
def view_update(self, context, depsgraph):
|
||||
import _bpy_hydra
|
||||
if not self.engine_ptr:
|
||||
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), 'VIEWPORT', self.bl_delegate_id)
|
||||
self.engine_ptr = _bpy_hydra.engine_create(self, 'VIEWPORT', self.bl_delegate_id)
|
||||
if not self.engine_ptr:
|
||||
return
|
||||
|
||||
for key, val in self.get_sync_settings('VIEWPORT').items():
|
||||
_bpy_hydra.engine_set_sync_setting(self.engine_ptr, key, val)
|
||||
|
||||
_bpy_hydra.engine_update(self.engine_ptr, depsgraph.as_pointer(), context.as_pointer())
|
||||
_bpy_hydra.engine_update(self.engine_ptr, depsgraph, context)
|
||||
|
||||
for key, val in self.get_render_settings('VIEWPORT').items():
|
||||
_bpy_hydra.engine_set_render_setting(self.engine_ptr, key, val)
|
||||
@ -1326,4 +1326,4 @@ class HydraRenderEngine(RenderEngine):
|
||||
return
|
||||
|
||||
import _bpy_hydra
|
||||
_bpy_hydra.engine_view_draw(self.engine_ptr, depsgraph.as_pointer(), context.as_pointer())
|
||||
_bpy_hydra.engine_view_draw(self.engine_ptr, depsgraph, context)
|
||||
|
@ -46,6 +46,8 @@ set(INC
|
||||
../../gpu
|
||||
../../gpu/intern
|
||||
../../python/intern
|
||||
# RNA_prototypes.h
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
..
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna/intern
|
||||
)
|
||||
@ -124,4 +126,5 @@ set(SRC
|
||||
|
||||
blender_add_lib(bf_render_hydra "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
# RNA_prototypes.h
|
||||
add_dependencies(bf_render_hydra bf_rna)
|
||||
|
@ -3,24 +3,28 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <boost/python/extract.hpp>
|
||||
#include "RE_engine.h"
|
||||
|
||||
#include <pxr/base/plug/plugin.h>
|
||||
#include <pxr/base/plug/registry.h>
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
#include <pxr/usdImaging/usdImagingGL/engine.h>
|
||||
#include "bpy_rna.h"
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
#include "scene_delegate/image.h"
|
||||
|
||||
#include "final_engine.h"
|
||||
#include "preview_engine.h"
|
||||
#include "scene_delegate/image.h"
|
||||
#include "viewport_engine.h"
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
template<typename T> T *pyrna_to_pointer(PyObject *pyobject, const StructRNA *rnatype)
|
||||
{
|
||||
const PointerRNA *ptr = pyrna_struct_as_ptr_or_null(pyobject, rnatype);
|
||||
return (ptr) ? static_cast<T *>(ptr->data) : nullptr;
|
||||
}
|
||||
|
||||
static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
PyObject *pyengine;
|
||||
@ -29,7 +33,7 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
RenderEngine *bl_engine = (RenderEngine *)PyLong_AsVoidPtr(pyengine);
|
||||
RenderEngine *bl_engine = pyrna_to_pointer<RenderEngine>(pyengine, &RNA_RenderEngine);
|
||||
|
||||
Engine *engine = nullptr;
|
||||
try {
|
||||
@ -84,9 +88,9 @@ static PyObject *engine_update_func(PyObject * /*self*/, PyObject *args)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
||||
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
||||
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
||||
Engine *engine = static_cast<Engine *>(PyLong_AsVoidPtr(pyengine));
|
||||
Depsgraph *depsgraph = pyrna_to_pointer<Depsgraph>(pydepsgraph, &RNA_Depsgraph);
|
||||
bContext *context = pyrna_to_pointer<bContext>(pycontext, &RNA_Context);
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine);
|
||||
engine->sync(depsgraph, context);
|
||||
@ -102,8 +106,8 @@ static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
||||
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
||||
Engine *engine = static_cast<Engine *>(PyLong_AsVoidPtr(pyengine));
|
||||
Depsgraph *depsgraph = pyrna_to_pointer<Depsgraph>(pydepsgraph, &RNA_Depsgraph);
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine);
|
||||
|
||||
@ -122,9 +126,9 @@ static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
ViewportEngine *engine = (ViewportEngine *)PyLong_AsVoidPtr(pyengine);
|
||||
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
||||
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
||||
ViewportEngine *engine = static_cast<ViewportEngine *>(PyLong_AsVoidPtr(pyengine));
|
||||
Depsgraph *depsgraph = pyrna_to_pointer<Depsgraph>(pydepsgraph, &RNA_Depsgraph);
|
||||
bContext *context = pyrna_to_pointer<bContext>(pycontext, &RNA_Context);
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p", engine);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user