MCPcopy Create free account
hub / github.com/Illation/ETEngine / GetAssetsMatchingQuery

Method GetAssetsMatchingQuery

Engine/source/EtCore/Content/AssetDatabase.cpp:142–186  ·  view source on GitHub ↗

--------------------------------------- AssetDatabase::GetAssetsMatchingQuery finds all assets that are contained in a path - if recursive is enabled assets are also found in subdirectories - if searchTerm isn't an empty string, only assets containing the search term will be returned - if filteredTypes isn't empty, only assets of types contained in filtered types are returned

Source from the content-addressed store, hash-verified

140// - if filteredTypes isn't empty, only assets of types contained in filtered types are returned
141//
142AssetDatabase::T_AssetList AssetDatabase::GetAssetsMatchingQuery(std::string const& path,
143 bool const recursive,
144 std::string const& searchTerm,
145 std::vector<rttr::type> const& filteredTypes)
146{
147 T_AssetList outAssets;
148
149 std::string lowerSearch = searchTerm;
150 std::transform(lowerSearch.begin(), lowerSearch.end(), lowerSearch.begin(), ::tolower);
151
152 // caches for every asset type
153 for (AssetDatabase::AssetCache& cache : caches)
154 {
155 if (filteredTypes.size() > 0u)
156 {
157 rttr::type const cacheType = cache.GetAssetType();
158 if (std::find(filteredTypes.begin(), filteredTypes.end(), cacheType) == filteredTypes.cend())
159 {
160 continue;
161 }
162 }
163
164 // every asset per cache
165 for (I_Asset* asset : cache.cache)
166 {
167 if ((asset->GetPath().rfind(path, 0) == 0) && (recursive || (asset->GetPath().length() == path.length())))
168 {
169 bool matchesSearch = true;
170 if (lowerSearch.length() != 0u)
171 {
172 std::string lowerAsset = asset->GetPath() + asset->GetName();
173 std::transform(lowerAsset.begin(), lowerAsset.end(), lowerAsset.begin(), ::tolower);
174 matchesSearch = (lowerAsset.find(lowerSearch) != std::string::npos);
175 }
176
177 if (matchesSearch)
178 {
179 outAssets.emplace_back(asset);
180 }
181 }
182 }
183 }
184
185 return outAssets;
186}
187
188//---------------------------------
189// AssetDatabase::GetAsset

Callers 1

RebuildAssetListMethod · 0.80

Calls 5

beginMethod · 0.80
endMethod · 0.80
GetAssetTypeMethod · 0.80
GetPathMethod · 0.80
GetNameMethod · 0.80

Tested by

no test coverage detected