Material: Material editor enhancements

Improves compatibility when using the legacy editor.

Corrects a number of issues that prevented saved files from being displayed when using the legacy editor.

Reduces the verbosity of console messages.
This commit is contained in:
David Carter
2024-02-04 10:55:56 -05:00
committed by Chris Hennes
parent 5d729db905
commit e9b43a0f83
7 changed files with 81 additions and 25 deletions

View File

@@ -491,6 +491,19 @@ void Material::clearModels()
_appearance.clear();
}
void Material::clearInherited()
{
_allUuids.clear();
// Rebuild the UUID lists without the inherited UUIDs
for (auto& uuid : _physicalUuids) {
_allUuids << uuid;
}
for (auto& uuid : _appearanceUuids) {
_allUuids << uuid;
}
}
void Material::setName(const QString& name)
{
_name = name;
@@ -599,14 +612,7 @@ void Material::removePhysical(const QString& uuid)
}
// If it's an inherited model, do nothing
bool inherited = true;
for (const auto& it : qAsConst(_physicalUuids)) {
if (it == uuid) {
inherited = false;
break;
}
}
if (inherited) {
if (isInherited(uuid)) {
return;
}
@@ -677,14 +683,7 @@ void Material::removeAppearance(const QString& uuid)
}
// If it's an inherited model, do nothing
bool inherited = true;
for (const auto& it : qAsConst(_appearanceUuids)) {
if (it == uuid) {
inherited = false;
break;
}
}
if (inherited) {
if (isInherited(uuid)) {
return;
}
@@ -988,6 +987,18 @@ bool Material::hasAppearanceProperty(const QString& name) const
return true;
}
bool Material::isInherited(const QString& uuid) const
{
if (_physicalUuids.contains(uuid)) {
return false;
}
if (_appearanceUuids.contains(uuid)) {
return false;
}
return _allUuids.contains(uuid);
}
bool Material::hasModel(const QString& uuid) const
{
return _allUuids.contains(uuid);