MCPcopy Create free account
hub / github.com/crownengine/crown / parse_nodes

Function parse_nodes

src/resource/mesh_resource.cpp:343–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341 }
342
343 s32 parse_nodes(Mesh &m, const char *sjson, CompileOptions &opts)
344 {
345 TempAllocator4096 ta;
346 JsonObject nodes(ta);
347 RETURN_IF_ERROR(sjson::parse(nodes, sjson));
348
349 auto cur = json_object::begin(nodes);
350 auto end = json_object::end(nodes);
351 for (; cur != end; ++cur) {
352 JSON_OBJECT_SKIP_HOLE(nodes, cur);
353
354 Node node(default_allocator());
355 s32 err = mesh::parse_node(node, cur->second, &m, opts);
356 ENSURE_OR_RETURN(MESH_RESOURCE, err == 0, opts);
357
358 DynamicString node_name(ta);
359 node_name = cur->first;
360 RETURN_IF_FALSE(MESH_RESOURCE, !hash_map::has(m._nodes, node_name)
361 , opts
362 , "Node redefined: '%s'"
363 , node_name.c_str()
364 );
365
366 // For backwards compatibility: originally .mesh resources
367 // enforced (implicitly) a 1:1 relationship between nodes
368 // and geometries.
369 if (node._geometry == "")
370 node._geometry = node_name;
371
372 RETURN_IF_FALSE(MESH_RESOURCE, hash_map::has(m._geometries, node._geometry)
373 , opts
374 , "Node '%s' references unexisting geometry '%s'"
375 , node_name.c_str()
376 , node._geometry.c_str()
377 );
378 hash_map::set(m._nodes, node_name, node);
379 }
380
381 return 0;
382 }
383
384 s32 parse(Mesh &m, Buffer &buf, CompileOptions &opts)
385 {

Callers 2

parse_nodeFunction · 0.70
parseFunction · 0.70

Calls 7

setClass · 0.85
parseFunction · 0.70
parse_nodeFunction · 0.70
beginFunction · 0.50
endFunction · 0.50
hasFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected