MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / parsePrimitive

Method parsePrimitive

radiantcore/map/format/Doom3MapReader.cpp:120–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void 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
158scene::INodePtr Doom3MapReader::createEntity(const EntityKeyValues& keyValues)
159{

Callers

nothing calls this directly

Calls 9

whatMethod · 0.80
FailureExceptionClass · 0.50
formatFunction · 0.50
_Function · 0.50
nextTokenMethod · 0.45
findMethod · 0.45
endMethod · 0.45
parseMethod · 0.45
addPrimitiveToEntityMethod · 0.45

Tested by

no test coverage detected