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.
2 changed files with 2 additions and 40 deletions
Showing only changes of commit fb3ae7d1f8 - Show all commits

View File

@ -19,7 +19,8 @@ class CustomHydraRenderEngine(HydraRenderEngine):
def register(cls): def register(cls):
super().register() super().register()
bpy_hydra.register_plugins(["/path/to/plugin")]) import pxr
pxr.Plug.Registry().RegisterPlugins(["/path/to/plugin")])
def get_sync_settings(self, engine_type): def get_sync_settings(self, engine_type):
return { return {
@ -37,7 +38,6 @@ class CustomHydraRenderEngine(HydraRenderEngine):
__all__ = ( __all__ = (
"HydraRenderEngine", "HydraRenderEngine",
"export_mtlx", "export_mtlx",
"register_plugins",
) )
import os import os
@ -47,8 +47,6 @@ from pathlib import Path
import bpy import bpy
import _bpy_hydra import _bpy_hydra
from _bpy_hydra import register_plugins
class HydraRenderEngine(bpy.types.RenderEngine): class HydraRenderEngine(bpy.types.RenderEngine):
""" Render addon with Hydra render delegate should inherit this class """ """ Render addon with Hydra render delegate should inherit this class """

View File

@ -21,40 +21,6 @@
namespace blender::render::hydra { namespace blender::render::hydra {
static PyObject *register_plugins_func(PyObject * /*self*/, PyObject *args)
{
PyObject *pyplugin_dirs;
if (!PyArg_ParseTuple(args, "O", &pyplugin_dirs)) {
Py_RETURN_NONE;
}
std::vector<std::string> plugin_dirs;
PyObject *pyiter, *pyitem;
pyiter = PyObject_GetIter(pyplugin_dirs);
if (pyiter) {
while ((pyitem = PyIter_Next(pyiter))) {
plugin_dirs.push_back(PyUnicode_AsUTF8(pyitem));
Py_DECREF(pyitem);
}
Py_DECREF(pyiter);
}
pxr::PlugRegistry &registry = pxr::PlugRegistry::GetInstance();
registry.RegisterPlugins(plugin_dirs);
/* logging */
std::stringstream ss;
ss << "plugins=[";
for (auto &s : plugin_dirs) {
ss << s << ", ";
}
ss << "]";
CLOG_INFO(LOG_RENDER_HYDRA, 0, "Register %s", ss.str().c_str());
Py_RETURN_NONE;
}
static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args) static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
{ {
PyObject *pyengine; PyObject *pyengine;
@ -235,8 +201,6 @@ static PyObject *cache_or_get_image_file_func(PyObject * /*self*/, PyObject *arg
} }
static PyMethodDef methods[] = { static PyMethodDef methods[] = {
{"register_plugins", register_plugins_func, METH_VARARGS, ""},
{"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_update", engine_update_func, METH_VARARGS, ""}, {"engine_update", engine_update_func, METH_VARARGS, ""},