Material: Material Preferences
Updates the material preferences including selecting a default material Preferences adds some options for what gets displayed in the Materials editor. The option to use the legacy editor is removed in favour of the new editor. A new preference page has been added that allows the user to select a default material. This will then be assigned to any newly created object. In support of this, a new widget PrefsMaterialTreeWidget has been added as an extension of the MaterialTreeWidget to automatically save and restore the selected material.
This commit is contained in:
committed by
Chris Hennes
parent
6c4f76a8a5
commit
4dcd810ac5
@@ -34,12 +34,15 @@
|
||||
using namespace Materials;
|
||||
|
||||
MaterialFilterOptions::MaterialFilterOptions()
|
||||
: _includeFavorites(true)
|
||||
, _includeRecent(true)
|
||||
, _includeFolders(true)
|
||||
, _includeLibraries(true)
|
||||
, _includeLegacy(false)
|
||||
{}
|
||||
{
|
||||
auto param = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Material/Editor");
|
||||
_includeFavorites = param->GetBool("ShowFavorites", true);
|
||||
_includeRecent = param->GetBool("ShowRecent", true);
|
||||
_includeFolders = param->GetBool("ShowEmptyFolders", false);
|
||||
_includeLibraries = param->GetBool("ShowEmptyLibraries", true);
|
||||
_includeLegacy = param->GetBool("ShowLegacy", false);
|
||||
}
|
||||
|
||||
MaterialFilterTreeWidgetOptions::MaterialFilterTreeWidgetOptions()
|
||||
{
|
||||
|
||||
@@ -79,8 +79,11 @@ void MaterialManager::initLibraries()
|
||||
|
||||
void MaterialManager::cleanup()
|
||||
{
|
||||
QMutexLocker locker(&_mutex);
|
||||
|
||||
if (_libraryList) {
|
||||
_libraryList->clear();
|
||||
_libraryList = nullptr;
|
||||
}
|
||||
|
||||
if (_materialMap) {
|
||||
@@ -89,9 +92,17 @@ void MaterialManager::cleanup()
|
||||
it.second->setLibrary(nullptr);
|
||||
}
|
||||
_materialMap->clear();
|
||||
_materialMap = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialManager::refresh()
|
||||
{
|
||||
// This is very expensive and can be improved using observers?
|
||||
cleanup();
|
||||
initLibraries();
|
||||
}
|
||||
|
||||
void MaterialManager::saveMaterial(const std::shared_ptr<MaterialLibrary>& library,
|
||||
const std::shared_ptr<Material>& material,
|
||||
const QString& path,
|
||||
@@ -166,6 +177,9 @@ std::shared_ptr<Material> MaterialManager::defaultMaterial()
|
||||
long initialShininess = hGrp->GetInt("DefaultShapeShininess", 90);
|
||||
|
||||
auto material = manager.getMaterial(defaultMaterialUUID());
|
||||
if (!material) {
|
||||
material = manager.getMaterial(QLatin1String("7f9fd73b-50c9-41d8-b7b2-575a030c1eeb"));
|
||||
}
|
||||
if (material->hasAppearanceModel(ModelUUIDs::ModelUUID_Rendering_Basic)) {
|
||||
material->getAppearanceProperty(QString::fromLatin1("DiffuseColor"))
|
||||
->setColor(mat.diffuseColor);
|
||||
@@ -187,7 +201,10 @@ std::shared_ptr<Material> MaterialManager::defaultMaterial()
|
||||
QString MaterialManager::defaultMaterialUUID()
|
||||
{
|
||||
// Make this a preference
|
||||
return QString::fromLatin1("7f9fd73b-50c9-41d8-b7b2-575a030c1eeb");
|
||||
auto param = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Material");
|
||||
auto uuid = param->GetASCII("DefaultMaterial", "7f9fd73b-50c9-41d8-b7b2-575a030c1eeb");
|
||||
return QString::fromStdString(uuid);
|
||||
}
|
||||
|
||||
std::shared_ptr<Material> MaterialManager::getMaterial(const QString& uuid) const
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
~MaterialManager() override = default;
|
||||
|
||||
static void cleanup();
|
||||
static void refresh();
|
||||
static std::shared_ptr<Material> defaultMaterial();
|
||||
static QString defaultMaterialUUID();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user