MCPcopy Create free account
hub / github.com/OpenMW/openmw / getColour

Method getColour

components/fallback/fallback.cpp:74–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 }
73
74 osg::Vec4f Map::getColour(std::string_view fall)
75 {
76 const std::string_view sum = getString(fall);
77
78 if (!sum.empty())
79 {
80 std::vector<std::string> ret;
81 Misc::StringUtils::split(sum, ret, ",");
82
83 if (ret.size() == 3)
84 {
85 const auto r = Misc::StringUtils::toNumeric<float>(ret[0]);
86 const auto g = Misc::StringUtils::toNumeric<float>(ret[1]);
87 const auto b = Misc::StringUtils::toNumeric<float>(ret[2]);
88
89 if (r.has_value() && g.has_value() && b.has_value())
90 {
91 return osg::Vec4f(*r / 255.0f, *g / 255.0f, *b / 255.0f, 1.0f);
92 }
93 }
94
95 Log(Debug::Error) << "Error: '" << fall << "' setting value (" << sum
96 << ") is not a valid color, using middle gray as a fallback";
97 }
98
99 return osg::Vec4f(0.5f, 0.5f, 0.5f, 1.f);
100 }
101}

Callers

nothing calls this directly

Calls 7

splitFunction · 0.85
toNumeric<float>Function · 0.85
Vec4fClass · 0.85
LogClass · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected