forked from blender/blender
Implement instancing for light objects #35
@ -38,7 +38,6 @@ __all__ = (
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import traceback
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
@ -107,6 +106,9 @@ def export_mtlx(material):
|
|||||||
""" Exports material to .mtlx file. It is called from Blender source code. """
|
""" Exports material to .mtlx file. It is called from Blender source code. """
|
||||||
try:
|
try:
|
||||||
import materialx.utils as mx_utils
|
import materialx.utils as mx_utils
|
||||||
|
except ImportError:
|
||||||
|
print("ERROR: no MaterialX addon available")
|
||||||
|
return ""
|
||||||
|
|
||||||
doc = mx_utils.export(material, None)
|
doc = mx_utils.export(material, None)
|
||||||
if not doc:
|
if not doc:
|
||||||
@ -115,13 +117,3 @@ def export_mtlx(material):
|
|||||||
mtlx_file = mx_utils.get_temp_file(".mtlx", f"mat_{material.as_pointer():016x}")
|
mtlx_file = mx_utils.get_temp_file(".mtlx", f"mat_{material.as_pointer():016x}")
|
||||||
mx_utils.export_to_file(doc, mtlx_file, export_deps=True, copy_deps=False)
|
mx_utils.export_to_file(doc, mtlx_file, export_deps=True, copy_deps=False)
|
||||||
return str(mtlx_file)
|
return str(mtlx_file)
|
||||||
|
|
||||||
except ImportError:
|
|
||||||
print("ERROR: no MaterialX addon available")
|
|
||||||
|
|
||||||
except:
|
|
||||||
# This is a placeholder, this code will be moved to C part later
|
|
||||||
# This code shouldn't raise any exception due to breaking refcounts on RenderEngine
|
|
||||||
traceback.print_exc()
|
|
||||||
|
|
||||||
return ""
|
|
||||||
|
@ -68,8 +68,28 @@ void MaterialData::init()
|
|||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CLOG_ERROR(LOG_RENDER_HYDRA_SCENE, "Export error for %s", id->name);
|
/* Clearing and logging exception data */
|
||||||
PyErr_Print();
|
PyObject *type, *value, *traceback;
|
||||||
|
PyErr_Fetch(&type, &value, &traceback);
|
||||||
|
PyErr_NormalizeException(&type, &value, &traceback);
|
||||||
|
std::string err_str = ((PyTypeObject *)type)->tp_name;
|
||||||
|
if (value) {
|
||||||
|
PyObject *pstr = PyObject_Str(value);
|
||||||
|
err_str += ": ";
|
||||||
|
err_str += PyUnicode_AsUTF8(pstr);
|
||||||
|
Py_DECREF(pstr);
|
||||||
|
}
|
||||||
|
CLOG_ERROR(LOG_RENDER_HYDRA_SCENE,
|
||||||
|
"Export error for %s (%s): %s",
|
||||||
|
prim_id.GetText(),
|
||||||
|
id->name,
|
||||||
|
err_str.c_str());
|
||||||
|
if (traceback) {
|
||||||
|
PyTraceBack_Print(traceback, PySys_GetObject("stderr"));
|
||||||
|
}
|
||||||
|
Py_XDECREF(traceback);
|
||||||
|
Py_XDECREF(value);
|
||||||
|
Py_DECREF(type);
|
||||||
}
|
}
|
||||||
Py_DECREF(module);
|
Py_DECREF(module);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace blender::render::hydra {
|
|||||||
MeshData::MeshData(BlenderSceneDelegate *scene_delegate,
|
MeshData::MeshData(BlenderSceneDelegate *scene_delegate,
|
||||||
Object *object,
|
Object *object,
|
||||||
pxr::SdfPath const &prim_id)
|
pxr::SdfPath const &prim_id)
|
||||||
: ObjectData(scene_delegate, object, prim_id)
|
: ObjectData(scene_delegate, object, prim_id), parent_(object->parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ class MeshData : public ObjectData {
|
|||||||
pxr::VtVec3fArray normals_;
|
pxr::VtVec3fArray normals_;
|
||||||
|
|
||||||
MaterialData *mat_data_ = nullptr;
|
MaterialData *mat_data_ = nullptr;
|
||||||
|
Object *parent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
Loading…
Reference in New Issue
Block a user