Materials: Inheritance API

API changes to inherit a material
This commit is contained in:
David Carter
2024-05-30 17:31:35 -04:00
committed by Chris Hennes
parent 2df0f3631d
commit 5bb5c2a9cf
2 changed files with 26 additions and 0 deletions

View File

@@ -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>

View File

@@ -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();