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

Method getVector3

components/settings/settings.cpp:299–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297 }
298
299 osg::Vec3f Manager::getVector3(std::string_view setting, std::string_view category)
300 {
301 const std::string& value = getString(setting, category);
302
303 std::vector<std::string> components;
304 Misc::StringUtils::split(value, components);
305
306 if (components.size() == 3)
307 {
308 auto x = Misc::StringUtils::toNumeric<float>(components[0]);
309 auto y = Misc::StringUtils::toNumeric<float>(components[1]);
310 auto z = Misc::StringUtils::toNumeric<float>(components[2]);
311
312 if (x && y && z)
313 {
314 return { x.value(), y.value(), z.value() };
315 }
316 }
317
318 throw std::runtime_error(std::string("Can't parse 3d vector: " + value));
319 }
320
321 void Manager::setString(std::string_view setting, std::string_view category, const std::string& value)
322 {

Callers

nothing calls this directly

Calls 4

splitFunction · 0.85
toNumeric<float>Function · 0.85
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected