Materials: Pass by reference instead of pointers
Refactoring topass by reference instead of using existing pointers.
This commit is contained in:
committed by
Chris Hennes
parent
670a85de97
commit
db1b5a8773
@@ -216,27 +216,22 @@ MaterialManagerLocal::libraryMaterials(const QString& libraryName)
|
||||
return materials;
|
||||
}
|
||||
|
||||
bool MaterialManagerLocal::passFilter(const std::shared_ptr<Material>& material,
|
||||
const std::shared_ptr<Materials::MaterialFilter>& filter,
|
||||
bool MaterialManagerLocal::passFilter(const Material& material,
|
||||
const Materials::MaterialFilter& filter,
|
||||
const Materials::MaterialFilterOptions& options) const
|
||||
{
|
||||
if (!filter) {
|
||||
// If there's no filter we always include
|
||||
return true;
|
||||
}
|
||||
|
||||
// filter out old format files
|
||||
if (material->isOldFormat() && !options.includeLegacy()) {
|
||||
if (material.isOldFormat() && !options.includeLegacy()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// filter based on models
|
||||
return filter->modelIncluded(material);
|
||||
return filter.modelIncluded(material);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::vector<LibraryObject>>
|
||||
MaterialManagerLocal::libraryMaterials(const QString& libraryName,
|
||||
const std::shared_ptr<MaterialFilter>& filter,
|
||||
const MaterialFilter& filter,
|
||||
const MaterialFilterOptions& options)
|
||||
{
|
||||
auto materials = std::make_shared<std::vector<LibraryObject>>();
|
||||
@@ -245,7 +240,7 @@ MaterialManagerLocal::libraryMaterials(const QString& libraryName,
|
||||
// This is needed to resolve cyclic dependencies
|
||||
auto library = it.second->getLibrary();
|
||||
if (library->isName(libraryName)) {
|
||||
if (passFilter(it.second, filter, options)) {
|
||||
if (passFilter(*it.second, filter, options)) {
|
||||
materials->push_back(
|
||||
LibraryObject(it.first, it.second->getDirectory(), it.second->getName()));
|
||||
}
|
||||
@@ -386,7 +381,7 @@ bool MaterialManagerLocal::exists(const QString& uuid) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MaterialManagerLocal::exists(const std::shared_ptr<MaterialLibrary>& library,
|
||||
bool MaterialManagerLocal::exists(const MaterialLibrary& library,
|
||||
const QString& uuid) const
|
||||
{
|
||||
try {
|
||||
@@ -395,7 +390,7 @@ bool MaterialManagerLocal::exists(const std::shared_ptr<MaterialLibrary>& librar
|
||||
auto materialLibrary =
|
||||
reinterpret_cast<const std::shared_ptr<Materials::MaterialLibraryLocal>&>(
|
||||
*(material->getLibrary()));
|
||||
return (*materialLibrary == *library);
|
||||
return (*materialLibrary == library);
|
||||
}
|
||||
}
|
||||
catch (const MaterialNotFound&) {
|
||||
|
||||
Reference in New Issue
Block a user