MCPcopy Create free account
hub / github.com/beefytech/Beef / ParseMaterialDef

Method ParseMaterialDef

BeefySysLib/gfx/glTF.cpp:360–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358};
359
360bool GLTFReader::ParseMaterialDef(ModelMaterialDef* materialDef, const StringImpl& matText)
361{
362 GLTFPropsParser propsParser(matText);
363
364 while (true)
365 {
366 auto node = propsParser.GetNext();
367 if (node.mKind == GLTFPropsParser::NodeKind_End)
368 break;
369
370 if (node.mKind == GLTFPropsParser::NodeKind_String)
371 {
372 auto key = propsParser.GetStringView(node);
373 if (key == "Parent")
374 {
375 if (propsParser.GetNext().mKind != GLTFPropsParser::NodeKind_Equals)
376 return false;
377
378 auto valueNode = propsParser.GetNext();
379 if (valueNode.mKind != GLTFPropsParser::NodeKind_String)
380 return false;
381
382 StringView prefix;
383 StringView str = propsParser.GetStringView(valueNode, prefix);
384 auto parentMaterialDef = LoadMaterial(str);
385 }
386 else if (key == "TextureParameterValues")
387 {
388 int count = 0;
389 if (!ExpectIndex(propsParser, count))
390 return false;
391 if (!ExpectEquals(propsParser))
392 return false;
393 if (!ExpectOpen(propsParser))
394 return false;
395
396 while (true)
397 {
398 node = propsParser.GetNext();
399 if (node.mKind == GLTFPropsParser::NodeKind_RBrace)
400 break;
401 if (node.mKind != GLTFPropsParser::NodeKind_String)
402 return false;
403
404 StringView prefix;
405 StringView str = propsParser.GetStringView(node, prefix);
406 if (str == "TextureParameterValues")
407 {
408 auto textureParamValue = materialDef->mTextureParameterValues.Alloc();
409
410 int idx = 0;
411 if (!ExpectIndex(propsParser, idx))
412 return false;
413 if (!ExpectEquals(propsParser))
414 return false;
415 if (!ExpectOpen(propsParser))
416 return false;
417

Callers

nothing calls this directly

Calls 11

ExpectIndexFunction · 0.85
ExpectEqualsFunction · 0.85
ExpectOpenFunction · 0.85
ExpectCloseFunction · 0.85
TrySkipValueFunction · 0.85
GetStringViewMethod · 0.80
GetNextStringViewMethod · 0.80
GetNextMethod · 0.45
AllocMethod · 0.45
IndexOfMethod · 0.45
RemoveToEndMethod · 0.45

Tested by

no test coverage detected