forked from blender/blender
Fix crash when hydra render plugin isn't loaded #60
@ -63,7 +63,6 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
return
|
return
|
||||||
|
|
||||||
_bpy_hydra.engine_free(self.engine_ptr)
|
_bpy_hydra.engine_free(self.engine_ptr)
|
||||||
del self.engine_ptr
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register(cls):
|
def register(cls):
|
||||||
@ -95,6 +94,8 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
def update(self, data, depsgraph):
|
def update(self, data, depsgraph):
|
||||||
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)
|
||||||
|
if not self.engine_ptr:
|
||||||
|
return
|
||||||
|
|
||||||
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)
|
||||||
@ -114,6 +115,8 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
def view_update(self, context, depsgraph):
|
def view_update(self, context, depsgraph):
|
||||||
if not self.engine_ptr:
|
if not self.engine_ptr:
|
||||||
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), 'VIEWPORT', self.delegate_id)
|
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), 'VIEWPORT', self.delegate_id)
|
||||||
|
if not self.engine_ptr:
|
||||||
|
return
|
||||||
|
|
||||||
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)
|
||||||
|
@ -23,7 +23,6 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name)
|
|||||||
pxr::HdRendererPluginRegistry ®istry = pxr::HdRendererPluginRegistry::GetInstance();
|
pxr::HdRendererPluginRegistry ®istry = pxr::HdRendererPluginRegistry::GetInstance();
|
||||||
|
|
||||||
pxr::TF_PY_ALLOW_THREADS_IN_SCOPE();
|
pxr::TF_PY_ALLOW_THREADS_IN_SCOPE();
|
||||||
render_delegate_ = registry.CreateRenderDelegate(pxr::TfToken(render_delegate_name));
|
|
||||||
|
|
||||||
/* USD has limited support for Vulkan. To make it works USD should be built
|
/* USD has limited support for Vulkan. To make it works USD should be built
|
||||||
* with PXR_ENABLE_VULKAN_SUPPORT=TRUE which is not possible now */
|
* with PXR_ENABLE_VULKAN_SUPPORT=TRUE which is not possible now */
|
||||||
@ -39,6 +38,11 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name)
|
|||||||
|
|
||||||
hd_drivers.push_back(&hgi_driver_);
|
hd_drivers.push_back(&hgi_driver_);
|
||||||
}
|
}
|
||||||
|
render_delegate_ = registry.CreateRenderDelegate(pxr::TfToken(render_delegate_name));
|
||||||
|
|
||||||
|
if (!render_delegate_) {
|
||||||
|
throw std::runtime_error("Cannot create render delegate: " + render_delegate_name);
|
||||||
|
}
|
||||||
|
|
||||||
render_index_.reset(pxr::HdRenderIndex::New(render_delegate_.Get(), hd_drivers));
|
render_index_.reset(pxr::HdRenderIndex::New(render_delegate_.Get(), hd_drivers));
|
||||||
free_camera_delegate_ = std::make_unique<pxr::HdxFreeCameraSceneDelegate>(
|
free_camera_delegate_ = std::make_unique<pxr::HdxFreeCameraSceneDelegate>(
|
||||||
|
@ -65,7 +65,8 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
|||||||
|
|
||||||
RenderEngine *bl_engine = (RenderEngine *)PyLong_AsVoidPtr(pyengine);
|
RenderEngine *bl_engine = (RenderEngine *)PyLong_AsVoidPtr(pyengine);
|
||||||
|
|
||||||
Engine *engine;
|
Engine *engine = nullptr;
|
||||||
|
try {
|
||||||
if (STREQ(engine_type, "VIEWPORT")) {
|
if (STREQ(engine_type, "VIEWPORT")) {
|
||||||
engine = new ViewportEngine(bl_engine, render_delegate_id);
|
engine = new ViewportEngine(bl_engine, render_delegate_id);
|
||||||
}
|
}
|
||||||
@ -80,8 +81,14 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
|||||||
engine = new FinalEngine(bl_engine, render_delegate_id);
|
engine = new FinalEngine(bl_engine, render_delegate_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (std::runtime_error &e) {
|
||||||
|
CLOG_ERROR(LOG_RENDER_HYDRA, "%s", e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (engine) {
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %016llx %s", engine, engine_type);
|
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %016llx %s", engine, engine_type);
|
||||||
|
}
|
||||||
return PyLong_FromVoidPtr(engine);
|
return PyLong_FromVoidPtr(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user