Materials: Inheritance API
API changes to inherit a material
This commit is contained in:
committed by
Chris Hennes
parent
2df0f3631d
commit
5bb5c2a9cf
@@ -25,6 +25,11 @@
|
||||
<UserDocu>Get a material object by specifying its path and library name</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="inheritMaterial">
|
||||
<Documentation>
|
||||
<UserDocu>Create a new material object by specifying the UUID of its parent</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="MaterialLibraries" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>List of Material libraries.</UserDocu>
|
||||
|
||||
@@ -111,6 +111,27 @@ PyObject* MaterialManagerPy::getMaterialByPath(PyObject* args)
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* MaterialManagerPy::inheritMaterial(PyObject* args)
|
||||
{
|
||||
char* uuid {};
|
||||
if (!PyArg_ParseTuple(args, "s", &uuid)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
try {
|
||||
auto parent = getMaterialManagerPtr()->getMaterial(QString::fromStdString(uuid));
|
||||
|
||||
// Found the parent. Create a new material with this as parent
|
||||
auto material = new Material();
|
||||
material->setParentUUID(QString::fromLatin1(uuid));
|
||||
return new MaterialPy(material); // Transfers ownership
|
||||
}
|
||||
catch (const MaterialNotFound&) {
|
||||
PyErr_SetString(PyExc_LookupError, "Material not found");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Py::List MaterialManagerPy::getMaterialLibraries() const
|
||||
{
|
||||
auto libraries = getMaterialManagerPtr()->getMaterialLibraries();
|
||||
|
||||
Reference in New Issue
Block a user