fix Image for non-existing textures in atlas
This commit is contained in:
@@ -34,6 +34,14 @@ const UVRegion& Atlas::get(const std::string& name) const {
|
||||
return regions.at(name);
|
||||
}
|
||||
|
||||
std::optional<UVRegion> Atlas::getIf(const std::string& name) const {
|
||||
const auto& found = regions.find(name);
|
||||
if (found == regions.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return found->second;
|
||||
}
|
||||
|
||||
Texture* Atlas::getTexture() const {
|
||||
return texture.get();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include "../../maths/UVRegion.hpp"
|
||||
#include "../../typedefs.hpp"
|
||||
@@ -31,6 +32,7 @@ public:
|
||||
|
||||
bool has(const std::string& name) const;
|
||||
const UVRegion& get(const std::string& name) const;
|
||||
std::optional<UVRegion> getIf(const std::string& name) const;
|
||||
|
||||
Texture* getTexture() const;
|
||||
ImageData* getImage() const;
|
||||
|
||||
Reference in New Issue
Block a user