Merge branch 'random-range-visject' of https://github.com/Tryibion/FlaxEngine into Tryibion-random-range-visject

This commit is contained in:
Wojtek Figat
2023-05-05 16:22:46 +02:00
3 changed files with 28 additions and 56 deletions

View File

@@ -730,12 +730,8 @@ namespace FlaxEditor.Surface.Archetypes
Elements = new[]
{
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(float), 0),
NodeElementArchetype.Factory.Text(0, 0, "Min", 30.0f, 18.0f),
NodeElementArchetype.Factory.Float(30, 0, 0),
NodeElementArchetype.Factory.Text(0, Surface.Constants.LayoutOffsetY, "Max", 30.0f, 18.0f),
NodeElementArchetype.Factory.Float(30, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Input(0, "Min", true, typeof(float), 1, 0),
NodeElementArchetype.Factory.Input(1, "Max", true, typeof(float), 2, 1),
}
},
new NodeArchetype
@@ -753,14 +749,8 @@ namespace FlaxEditor.Surface.Archetypes
Elements = new[]
{
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(Float2), 0),
NodeElementArchetype.Factory.Text(0, 0, "Min", 30.0f, 18.0f),
NodeElementArchetype.Factory.Vector_X(30, 0, 0),
NodeElementArchetype.Factory.Vector_Y(83, 0, 0),
NodeElementArchetype.Factory.Text(0, Surface.Constants.LayoutOffsetY, "Max", 30.0f, 18.0f),
NodeElementArchetype.Factory.Vector_X(30, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Vector_Y(83, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Input(0, "Min", true, typeof(Float2), 1, 0),
NodeElementArchetype.Factory.Input(1, "Max", true, typeof(Float2), 2, 1),
}
},
new NodeArchetype
@@ -778,16 +768,8 @@ namespace FlaxEditor.Surface.Archetypes
Elements = new[]
{
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(Float3), 0),
NodeElementArchetype.Factory.Text(0, 0, "Min", 30.0f, 18.0f),
NodeElementArchetype.Factory.Vector_X(30, 0, 0),
NodeElementArchetype.Factory.Vector_Y(83, 0, 0),
NodeElementArchetype.Factory.Vector_Z(136, 0, 0),
NodeElementArchetype.Factory.Text(0, Surface.Constants.LayoutOffsetY, "Max", 30.0f, 18.0f),
NodeElementArchetype.Factory.Vector_X(30, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Vector_Y(83, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Vector_Z(136, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Input(0, "Min", true, typeof(Float3), 1, 0),
NodeElementArchetype.Factory.Input(1, "Max", true, typeof(Float3), 2, 1),
}
},
new NodeArchetype
@@ -805,18 +787,8 @@ namespace FlaxEditor.Surface.Archetypes
Elements = new[]
{
NodeElementArchetype.Factory.Output(0, string.Empty, typeof(Float4), 0),
NodeElementArchetype.Factory.Text(0, 0, "Min", 30.0f, 18.0f),
NodeElementArchetype.Factory.Vector_X(30, 0, 0),
NodeElementArchetype.Factory.Vector_Y(83, 0, 0),
NodeElementArchetype.Factory.Vector_Z(136, 0, 0),
NodeElementArchetype.Factory.Vector_W(189, 0, 0),
NodeElementArchetype.Factory.Text(0, Surface.Constants.LayoutOffsetY, "Max", 30.0f, 18.0f),
NodeElementArchetype.Factory.Vector_X(30, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Vector_Y(83, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Vector_Z(136, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Vector_W(189, Surface.Constants.LayoutOffsetY, 1),
NodeElementArchetype.Factory.Input(0, "Min", true, typeof(Float4), 1, 0),
NodeElementArchetype.Factory.Input(1, "Max", true, typeof(Float4), 2, 1),
}
},

View File

@@ -388,33 +388,33 @@ void ParticleEmitterGPUGenerator::ProcessGroupParticles(Box* box, Node* node, Va
// Random Float Range
case 213:
{
auto& a = node->Values[0].AsFloat;
auto& b = node->Values[1].AsFloat;
value = writeLocal(VariantType::Float, String::Format(TEXT("lerp({0}, {1}, RAND)"), a, b), node);
auto a = tryGetValue(node->TryGetBox(1), node->Values[0]).AsFloat();
auto b = tryGetValue(node->TryGetBox(2), node->Values[1]).AsFloat();
value = writeLocal(VariantType::Float, String::Format(TEXT("lerp({0}, {1}, RAND)"), a.Value, b.Value), node);
break;
}
// Random Vector2 Range
case 214:
{
auto& a = node->Values[0].AsFloat2();
auto& b = node->Values[1].AsFloat2();
value = writeLocal(VariantType::Float2, String::Format(TEXT("float2(lerp({0}, {1}, RAND), lerp({2}, {3}, RAND))"), a.X, b.X, a.Y, b.Y), node);
auto a = tryGetValue(node->TryGetBox(1), node->Values[0]).AsFloat2();
auto b = tryGetValue(node->TryGetBox(2), node->Values[1]).AsFloat2();
value = writeLocal(VariantType::Float2, String::Format(TEXT("float2(lerp({0}.x, {1}.x, RAND), lerp({0}.y, {1}.y, RAND))"), a.Value, b.Value), node);
break;
}
// Random Vector3 Range
case 215:
{
auto& a = node->Values[0].AsFloat3();
auto& b = node->Values[1].AsFloat3();
value = writeLocal(VariantType::Float3, String::Format(TEXT("float3(lerp({0}, {1}, RAND), lerp({2}, {3}, RAND), lerp({4}, {5}, RAND))"), a.X, b.X, a.Y, b.Y, a.Z, b.Z), node);
auto a = tryGetValue(node->TryGetBox(1), node->Values[0]).AsFloat3();
auto b = tryGetValue(node->TryGetBox(2), node->Values[1]).AsFloat3();
value = writeLocal(VariantType::Float3, String::Format(TEXT("float3(lerp({0}.x, {1}.x, RAND), lerp({0}.y, {1}.y, RAND), lerp({0}.z, {1}.z, RAND))"), a.Value, b.Value), node);
break;
}
// Random Vector4 Range
case 216:
{
auto& a = node->Values[0].AsFloat4();
auto& b = node->Values[1].AsFloat4();
value = writeLocal(VariantType::Float4, String::Format(TEXT("float4(lerp({0}, {1}, RAND), lerp({2}, {3}, RAND), lerp({4}, {5}, RAND), lerp({6}, {7}, RAND))"), a.X, b.X, a.Y, b.Y, a.Z, b.Z, a.W, b.W), node);
auto a = tryGetValue(node->TryGetBox(1), node->Values[0]).AsFloat4();
auto b = tryGetValue(node->TryGetBox(2), node->Values[1]).AsFloat4();
value = writeLocal(VariantType::Float4, String::Format(TEXT("float4(lerp({0}.x, {1}.x, RAND), lerp({0}.y, {1}.y, RAND), lerp({0}.z, {1}.z, RAND), lerp({0}.w, {1}.w, RAND))"), a.Value, b.Value), node);
break;
}
// Particle Emitter Function

View File

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