| 186 | } |
| 187 | |
| 188 | TextureManager::CpuTextureHandle TextureManager::loadTexture( |
| 189 | const std::filesystem::path& path, |
| 190 | bool generateMipLevels, |
| 191 | bool loadAsSRGB, |
| 192 | ResourceBindFlags bindFlags, |
| 193 | bool async, |
| 194 | Bitmap::ImportFlags importFlags, |
| 195 | const AssetResolver* assetResolver, |
| 196 | size_t* loadedTextureCount, |
| 197 | const Object* owner |
| 198 | ) |
| 199 | { |
| 200 | if (path.string().find("<UDIM>") != std::string::npos) |
| 201 | { |
| 202 | CpuTextureHandle handle = |
| 203 | loadUdimTexture(path, generateMipLevels, loadAsSRGB, bindFlags, async, importFlags, assetResolver, loadedTextureCount); |
| 204 | |
| 205 | std::lock_guard<std::mutex> lock(mMutex); |
| 206 | registerOwner(handle, owner); |
| 207 | |
| 208 | return handle; |
| 209 | } |
| 210 | |
| 211 | std::vector<std::filesystem::path> paths; |
| 212 | auto addPath = [&](const std::filesystem::path& p) |
| 213 | { |
| 214 | // Find the full path to the texture. |
| 215 | std::filesystem::path fullPath; |
| 216 | bool found = false; |
| 217 | if (assetResolver) |
| 218 | { |
| 219 | fullPath = assetResolver->resolvePath(p); |
| 220 | found = !fullPath.empty(); |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | fullPath = p; |
| 225 | found = std::filesystem::exists(fullPath); |
| 226 | } |
| 227 | |
| 228 | if (found) |
| 229 | paths.emplace_back(std::move(fullPath)); |
| 230 | |
| 231 | return found; |
| 232 | }; |
| 233 | |
| 234 | // If we find <MIP> in the filename, locate all mip levels |
| 235 | std::string filename = path.filename().string(); |
| 236 | auto mipPos = filename.find("<MIP>"); |
| 237 | if (mipPos != std::string::npos) |
| 238 | { |
| 239 | while (true) |
| 240 | { |
| 241 | std::string basename = std::string(filename).replace(mipPos, 5, "mip" + std::to_string(paths.size())); |
| 242 | std::filesystem::path mip = path.parent_path() / basename; |
| 243 | if (!addPath(mip)) |
| 244 | break; |
| 245 | } |
nothing calls this directly
no test coverage detected