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

Method ProcessGroupMath

Source/Engine/Visject/ShaderGraph.cpp:134–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134void ShaderGenerator::ProcessGroupMath(Box* box, Node* node, Value& value)
135{
136 switch (node->TypeID)
137 {
138 // Add, Subtract, Multiply, Divide, Modulo
139 case 1:
140 case 2:
141 case 3:
142 case 4:
143 case 5:
144 {
145 Box* b1 = node->GetBox(0);
146 Box* b2 = node->GetBox(1);
147 Value v1 = tryGetValue(b1, 0, Value::Zero);
148 Value v2 = tryGetValue(b2, 1, Value::Zero);
149 if (SanitizeMathValue(v1, node, b1, &value))
150 break;
151 if (b1->HasConnection())
152 v2 = v2.Cast(v1.Type);
153 else
154 v1 = v1.Cast(v2.Type);
155 Char op = '?';
156 switch (node->TypeID)
157 {
158 case 1:
159 op = '+';
160 break;
161 case 2:
162 op = '-';
163 break;
164 case 3:
165 op = '*';
166 break;
167 case 4:
168 op = '%';
169 break;
170 case 5:
171 {
172 op = '/';
173 if (v2.IsZero())
174 {
175 OnError(node, b2, TEXT("Cannot divide by zero!"));
176 v2 = Value::One;
177 }
178 break;
179 }
180 default:
181 break;
182 }
183 value = writeOperation2(node, v1, v2, op);
184 break;
185 }
186 // Absolute Value, Ceil, Cosine, Floor, Normalize, Round, Saturate, Sine, Sqrt, Tangent
187 case 7:
188 case 8:
189 case 9:
190 case 10:
191 case 12:

Callers

nothing calls this directly

Calls 15

OnErrorFunction · 0.85
ValueEnum · 0.85
AsFloat2Method · 0.80
AsFloat3Method · 0.80
AsFloatMethod · 0.80
AsBoolMethod · 0.80
FormatFunction · 0.50
StringClass · 0.50
CastFunction · 0.50
GetBoxMethod · 0.45
HasConnectionMethod · 0.45
CastMethod · 0.45

Tested by

no test coverage detected