MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / eatBox

Method eatBox

Source/Engine/Visject/ShaderGraph.cpp:1007–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1005}
1006
1007ShaderGenerator::Value ShaderGenerator::eatBox(Node* caller, Box* box)
1008{
1009 // Check if graph is looped or is too deep
1010 if (_callStack.Count() >= SHADER_GRAPH_MAX_CALL_STACK)
1011 {
1012 OnError(caller, box, TEXT("Graph is looped or too deep!"));
1013 return Value::Zero;
1014 }
1015
1016 // Check if box is invalid (better way to prevent crashes)
1017 if (box == nullptr)
1018 {
1019 return Value::Zero;
1020 }
1021
1022 // Check if box has cached value
1023 if (box->Cache.IsValid())
1024 {
1025 return box->Cache;
1026 }
1027
1028 // Add to the calling stack
1029 _callStack.Push(caller);
1030
1031 // Call per group custom processing event
1032 Value value;
1033 const auto parentNode = box->GetParent<Node>();
1034 _perGroupProcessCall[parentNode->GroupID](box, parentNode, value);
1035
1036 // Ensure value is valid
1037 if (value.IsInvalid())
1038 {
1039 OnError(parentNode, box, TEXT("Unknown box to resolve."));
1040 }
1041
1042 // Cache value
1043 box->Cache = value;
1044
1045 // Remove from the calling stack
1046 _callStack.Pop();
1047
1048 return value;
1049}
1050
1051ShaderGenerator::Value ShaderGenerator::tryGetValue(Box* box, int32 defaultValueBoxIndex, const Value& defaultValue)
1052{

Callers

nothing calls this directly

Calls 6

OnErrorFunction · 0.85
CountMethod · 0.45
IsValidMethod · 0.45
PushMethod · 0.45
IsInvalidMethod · 0.45
PopMethod · 0.45

Tested by

no test coverage detected