forked from blender/blender
Fix review comments #51
@ -38,7 +38,6 @@ __all__ = (
|
|||||||
"HydraRenderEngine",
|
"HydraRenderEngine",
|
||||||
"export_mtlx",
|
"export_mtlx",
|
||||||
"register_plugins",
|
"register_plugins",
|
||||||
"get_render_plugins",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -48,7 +47,7 @@ from pathlib import Path
|
|||||||
import bpy
|
import bpy
|
||||||
import _bpy_hydra
|
import _bpy_hydra
|
||||||
|
|
||||||
from _bpy_hydra import register_plugins, get_render_plugins
|
from _bpy_hydra import register_plugins
|
||||||
|
|
||||||
|
|
||||||
class HydraRenderEngine(bpy.types.RenderEngine):
|
class HydraRenderEngine(bpy.types.RenderEngine):
|
||||||
@ -68,7 +67,6 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register(cls):
|
def register(cls):
|
||||||
_bpy_hydra.init()
|
|
||||||
root_folder = "blender.shared" if platform.system() == 'Windows' else "lib"
|
root_folder = "blender.shared" if platform.system() == 'Windows' else "lib"
|
||||||
os.environ['PXR_MTLX_STDLIB_SEARCH_PATHS'] = os.pathsep.join([
|
os.environ['PXR_MTLX_STDLIB_SEARCH_PATHS'] = os.pathsep.join([
|
||||||
str(Path(bpy.app.binary_path).parent / f"{root_folder}/materialx/libraries"),
|
str(Path(bpy.app.binary_path).parent / f"{root_folder}/materialx/libraries"),
|
||||||
|
@ -17,12 +17,6 @@
|
|||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
static PyObject *init_func(PyObject * /*self*/, PyObject *args)
|
|
||||||
{
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Init");
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *register_plugins_func(PyObject * /*self*/, PyObject *args)
|
static PyObject *register_plugins_func(PyObject * /*self*/, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *pyplugin_dirs;
|
PyObject *pyplugin_dirs;
|
||||||
@ -57,41 +51,6 @@ static PyObject *register_plugins_func(PyObject * /*self*/, PyObject *args)
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *get_render_plugins_func(PyObject * /*self*/, PyObject *args)
|
|
||||||
{
|
|
||||||
pxr::PlugRegistry ®istry = pxr::PlugRegistry::GetInstance();
|
|
||||||
pxr::TfTokenVector plugin_ids = pxr::UsdImagingGLEngine::GetRendererPlugins();
|
|
||||||
PyObject *ret = PyTuple_New(plugin_ids.size());
|
|
||||||
PyObject *val;
|
|
||||||
for (int i = 0; i < plugin_ids.size(); ++i) {
|
|
||||||
PyObject *descr = PyDict_New();
|
|
||||||
|
|
||||||
PyDict_SetItemString(descr, "id", val = PyUnicode_FromString(plugin_ids[i].GetText()));
|
|
||||||
Py_DECREF(val);
|
|
||||||
|
|
||||||
PyDict_SetItemString(
|
|
||||||
descr,
|
|
||||||
"name",
|
|
||||||
val = PyUnicode_FromString(
|
|
||||||
pxr::UsdImagingGLEngine::GetRendererDisplayName(plugin_ids[i]).c_str()));
|
|
||||||
Py_DECREF(val);
|
|
||||||
|
|
||||||
std::string plugin_name = plugin_ids[i];
|
|
||||||
plugin_name = plugin_name.substr(0, plugin_name.size() - 6);
|
|
||||||
plugin_name[0] = tolower(plugin_name[0]);
|
|
||||||
std::string path = "";
|
|
||||||
pxr::PlugPluginPtr plugin = registry.GetPluginWithName(plugin_name);
|
|
||||||
if (plugin) {
|
|
||||||
path = plugin->GetPath();
|
|
||||||
}
|
|
||||||
PyDict_SetItemString(descr, "path", val = PyUnicode_FromString(path.c_str()));
|
|
||||||
Py_DECREF(val);
|
|
||||||
|
|
||||||
PyTuple_SetItem(ret, i, descr);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *pyengine;
|
PyObject *pyengine;
|
||||||
@ -242,9 +201,7 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef methods[] = {
|
static PyMethodDef methods[] = {
|
||||||
{"init", init_func, METH_VARARGS, ""},
|
|
||||||
{"register_plugins", register_plugins_func, METH_VARARGS, ""},
|
{"register_plugins", register_plugins_func, METH_VARARGS, ""},
|
||||||
{"get_render_plugins", get_render_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, ""},
|
||||||
|
Loading…
Reference in New Issue
Block a user