graphics/Material: Fix -Wdeprecated-enum-enum-conversion.

This commit is contained in:
Lubosz Sarnecki 2024-08-03 14:33:23 +02:00
parent 43e80972f6
commit d6546f5c23
2 changed files with 22 additions and 2 deletions

View file

@ -30,6 +30,22 @@ const MaterialKey::OpacityMapMode Material::DEFAULT_OPACITY_MAP_MODE{ MaterialKe
const float Material::DEFAULT_OPACITY_CUTOFF { 0.5f };
const MaterialKey::CullFaceMode Material::DEFAULT_CULL_FACE_MODE { MaterialKey::CULL_BACK };
MaterialKey::FlagBit MaterialKey::getFlagBitForChannel(MapChannel channel) {
// To retrieve the FlagBit from a MapChannel
static const std::map<MapChannel,FlagBit> MapChannelFlagBits = {
{EMISSIVE_MAP, EMISSIVE_MAP_BIT},
{ALBEDO_MAP, ALBEDO_MAP_BIT},
{METALLIC_MAP, METALLIC_MAP_BIT},
{ROUGHNESS_MAP, ROUGHNESS_MAP_BIT},
{NORMAL_MAP, NORMAL_MAP_BIT},
{OCCLUSION_MAP, OCCLUSION_MAP_BIT},
{LIGHT_MAP, LIGHT_MAP_BIT},
{SCATTERING_MAP, SCATTERING_MAP_BIT},
};
return MapChannelFlagBits.at(channel);
}
std::string MaterialKey::getOpacityMapModeName(OpacityMapMode mode) {
const std::string names[3] = { "OPACITY_MAP_OPAQUE", "OPACITY_MAP_MASK", "OPACITY_MAP_BLEND" };
return names[mode];

View file

@ -82,11 +82,15 @@ public:
NUM_MAP_CHANNELS,
};
enum OpacityMapMode {
OPACITY_MAP_OPAQUE = 0,
OPACITY_MAP_MASK,
OPACITY_MAP_BLEND,
};
static FlagBit getFlagBitForChannel(MapChannel channel);
static std::string getOpacityMapModeName(OpacityMapMode mode);
// find the enum value from a string, return true if match found
static bool getOpacityMapModeFromName(const std::string& modeName, OpacityMapMode& mode);
@ -215,8 +219,8 @@ public:
void setScatteringMap(bool value) { _flags.set(SCATTERING_MAP_BIT, value); }
bool isScatteringMap() const { return _flags[SCATTERING_MAP_BIT]; }
void setMapChannel(MapChannel channel, bool value) { _flags.set(EMISSIVE_MAP_BIT + channel, value); }
bool isMapChannel(MapChannel channel) const { return _flags[EMISSIVE_MAP_BIT + channel]; }
void setMapChannel(MapChannel channel, bool value) { _flags.set(getFlagBitForChannel(channel), value); }
bool isMapChannel(MapChannel channel) const { return _flags[getFlagBitForChannel(channel)]; }
// Translucency and Opacity Heuristics are combining several flags: