| 118 | } |
| 119 | |
| 120 | void Doom3MapReader::parsePrimitive(parser::DefTokeniser& tok, const scene::INodePtr& parentEntity) |
| 121 | { |
| 122 | _primitiveCount++; |
| 123 | |
| 124 | std::string primitiveKeyword = tok.nextToken(); |
| 125 | |
| 126 | // Get a parser for this keyword |
| 127 | PrimitiveParsers::const_iterator p = _primitiveParsers.find(primitiveKeyword); |
| 128 | |
| 129 | if (p == _primitiveParsers.end()) |
| 130 | { |
| 131 | throw FailureException("Unknown primitive type: " + primitiveKeyword); |
| 132 | } |
| 133 | |
| 134 | const PrimitiveParserPtr& parser = p->second; |
| 135 | |
| 136 | // Try to parse the primitive, throwing exception if failed |
| 137 | try |
| 138 | { |
| 139 | scene::INodePtr primitive = parser->parse(tok); |
| 140 | |
| 141 | if (!primitive) |
| 142 | { |
| 143 | std::string text = fmt::format(_("Primitive #{0:d}: parse error"), _primitiveCount); |
| 144 | throw FailureException(text); |
| 145 | } |
| 146 | |
| 147 | // Now add the primitive as a child of the entity |
| 148 | _importFilter.addPrimitiveToEntity(primitive, parentEntity); |
| 149 | } |
| 150 | catch (parser::ParseException& e) |
| 151 | { |
| 152 | // Translate ParseExceptions to FailureExceptions |
| 153 | std::string text = fmt::format(_("Primitive #{0:d}: parse exception {1}"), _primitiveCount, e.what()); |
| 154 | throw FailureException(text); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | scene::INodePtr Doom3MapReader::createEntity(const EntityKeyValues& keyValues) |
| 159 | { |
nothing calls this directly
no test coverage detected