MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / readColorRgba

Function readColorRgba

pj_scene3D/widgets/src/urdf_parser.cpp:124–135  ·  view source on GitHub ↗

Read a element into a vec4. Returns nullopt when the element is null or "rgba" fails to parse; default {0.7,0.7,0.7,1.0} lives here so both callers share the same fallback.

Source from the content-addressed store, hash-verified

122// element is null or "rgba" fails to parse; default {0.7,0.7,0.7,1.0} lives
123// here so both callers share the same fallback.
124std::optional<glm::vec4> readColorRgba(const QDomElement& color_el) {
125 if (color_el.isNull()) {
126 return std::nullopt;
127 }
128 std::array<double, 4> rgba{0.7, 0.7, 0.7, 1.0};
129 if (!parseDoubles(color_el.attribute(QStringLiteral("rgba")), rgba)) {
130 return std::nullopt;
131 }
132 return glm::vec4{
133 static_cast<float>(rgba[0]), static_cast<float>(rgba[1]), static_cast<float>(rgba[2]),
134 static_cast<float>(rgba[3])};
135}
136
137// Fills geom.color and sets geom.has_color when an inline or named color is
138// found; otherwise leaves the LinkGeom defaults.

Callers 2

parseMaterialFunction · 0.85
parseUrdfFunction · 0.85

Calls 2

parseDoublesFunction · 0.85
isNullMethod · 0.45

Tested by

no test coverage detected