Fix Random Range nodes in CPU particles/script graphs when using int

#1341
This commit is contained in:
Wojtek Figat
2023-09-11 13:59:10 +02:00
parent fb27606541
commit 9afa98e905

View File

@@ -1279,16 +1279,16 @@ void VisjectExecutor::ProcessGroupParticles(Box* box, Node* node, Value& value)
// Random Float Range // Random Float Range
case 213: case 213:
{ {
auto a = tryGetValue(node->TryGetBox(1), node->Values[0]).AsFloat; auto a = (float)tryGetValue(node->TryGetBox(1), node->Values[0]);
auto b = tryGetValue(node->TryGetBox(2), node->Values[1]).AsFloat; auto b = (float)tryGetValue(node->TryGetBox(2), node->Values[1]);
value = Math::Lerp(a, b, RAND); value = Math::Lerp(a, b, RAND);
break; break;
} }
// Random Vector2 Range // Random Vector2 Range
case 214: case 214:
{ {
auto a = tryGetValue(node->TryGetBox(1), node->Values[0]).AsFloat2(); auto a = (Float2)tryGetValue(node->TryGetBox(1), node->Values[0]);
auto b = tryGetValue(node->TryGetBox(2), node->Values[1]).AsFloat2(); auto b = (Float2)tryGetValue(node->TryGetBox(2), node->Values[1]);
value = Float2( value = Float2(
Math::Lerp(a.X, b.X, RAND), Math::Lerp(a.X, b.X, RAND),
Math::Lerp(a.Y, b.Y, RAND) Math::Lerp(a.Y, b.Y, RAND)
@@ -1298,8 +1298,8 @@ void VisjectExecutor::ProcessGroupParticles(Box* box, Node* node, Value& value)
// Random Vector3 Range // Random Vector3 Range
case 215: case 215:
{ {
auto a = tryGetValue(node->TryGetBox(1), node->Values[0]).AsFloat3(); auto a = (Float3)tryGetValue(node->TryGetBox(1), node->Values[0]);
auto b = tryGetValue(node->TryGetBox(2), node->Values[1]).AsFloat3(); auto b = (Float3)tryGetValue(node->TryGetBox(2), node->Values[1]);
value = Float3( value = Float3(
Math::Lerp(a.X, b.X, RAND), Math::Lerp(a.X, b.X, RAND),
Math::Lerp(a.Y, b.Y, RAND), Math::Lerp(a.Y, b.Y, RAND),
@@ -1310,8 +1310,8 @@ void VisjectExecutor::ProcessGroupParticles(Box* box, Node* node, Value& value)
// Random Vector4 Range // Random Vector4 Range
case 216: case 216:
{ {
auto a = tryGetValue(node->TryGetBox(1), node->Values[0]).AsFloat4(); auto a = (Float4)tryGetValue(node->TryGetBox(1), node->Values[0]);
auto b = tryGetValue(node->TryGetBox(2), node->Values[1]).AsFloat4(); auto b = (Float4)tryGetValue(node->TryGetBox(2), node->Values[1]);
value = Float4( value = Float4(
Math::Lerp(a.X, b.X, RAND), Math::Lerp(a.X, b.X, RAND),
Math::Lerp(a.Y, b.Y, RAND), Math::Lerp(a.Y, b.Y, RAND),