Fills geom.color and sets geom.has_color when an inline or named color is found; otherwise leaves the LinkGeom defaults.
| 137 | // Fills geom.color and sets geom.has_color when an inline or named color is |
| 138 | // found; otherwise leaves the LinkGeom defaults. |
| 139 | void parseMaterial( |
| 140 | const QDomElement& parent, const std::unordered_map<std::string, glm::vec4>& materials, LinkGeom& geom) { |
| 141 | const QDomElement mat = parent.firstChildElement(QStringLiteral("material")); |
| 142 | if (mat.isNull()) { |
| 143 | return; |
| 144 | } |
| 145 | if (auto rgba = readColorRgba(mat.firstChildElement(QStringLiteral("color")))) { |
| 146 | geom.color = *rgba; |
| 147 | geom.has_color = true; |
| 148 | return; |
| 149 | } |
| 150 | // Named material reference: <material name="Foo"/> with no inline color. |
| 151 | const std::string name = mat.attribute(QStringLiteral("name")).toStdString(); |
| 152 | if (!name.empty()) { |
| 153 | auto it = materials.find(name); |
| 154 | if (it != materials.end()) { |
| 155 | geom.color = it->second; |
| 156 | geom.has_color = true; |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // Parse a single <visual> or <collision> into a LinkGeom. Returns false if it |
| 162 | // has no recognizable geometry. |
no test coverage detected