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

Method ProcessGroupComparisons

Source/Engine/Visject/ShaderGraph.cpp:950–1005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

948}
949
950void ShaderGenerator::ProcessGroupComparisons(Box* box, Node* node, Value& value)
951{
952 switch (node->TypeID)
953 {
954 // ==, !=, >, <=, >=
955 case 1:
956 case 2:
957 case 3:
958 case 4:
959 case 5:
960 case 6:
961 {
962 // Get A and B values
963 const Value a = tryGetValue(node->GetBox(0), node->Values[0]);
964 const Value b = tryGetValue(node->GetBox(1), node->Values[1]).Cast(a.Type);
965
966 // Perform operation
967 const Char* op;
968 switch (node->TypeID)
969 {
970 case 1:
971 op = TEXT("{0} == {1}");
972 break;
973 case 2:
974 op = TEXT("{0} != {1}");
975 break;
976 case 3:
977 op = TEXT("{0} > {1}");
978 break;
979 case 4:
980 op = TEXT("{0} < {1}");
981 break;
982 case 5:
983 op = TEXT("{0} <= {1}");
984 break;
985 case 6:
986 op = TEXT("{0} >= {1}");
987 break;
988 default:
989 CRASH;
990 return;
991 }
992 value = writeLocal(ValueType::Bool, String::Format(op, a.Value, b.Value), node);
993 break;
994 }
995 // Switch On Bool
996 case 7:
997 {
998 const Value condition = tryGetValue(node->GetBox(0), Value::False).AsBool();
999 const Value onTrue = tryGetValue(node->GetBox(2), 1, Value::Zero);
1000 const Value onFalse = tryGetValue(node->GetBox(1), 0, Value::Zero).Cast(onTrue.Type);
1001 value = writeLocal(onTrue.Type, String::Format(TEXT("{0} ? {1} : {2}"), condition.Value, onTrue.Value, onFalse.Value), node);
1002 break;
1003 }
1004 }
1005}
1006
1007ShaderGenerator::Value ShaderGenerator::eatBox(Node* caller, Box* box)

Callers

nothing calls this directly

Calls 4

AsBoolMethod · 0.80
FormatFunction · 0.50
GetBoxMethod · 0.45
CastMethod · 0.45

Tested by

no test coverage detected