From e87d95381ef651bfde47fdaf09f0681ceb5f13ba Mon Sep 17 00:00:00 2001 From: xLinka Date: Wed, 24 Jan 2024 00:44:51 +0000 Subject: [PATCH 1/2] some nodes --- ProtoFlux/Math/Constants/EpsilonDouble.cs | 13 ++++++++++ ProtoFlux/Math/Constants/EpsilonFloat.cs | 13 ++++++++++ ProtoFlux/Math/Random/FileName.cs | 19 +++++++++++++++ ProtoFlux/Math/Random/RandomBool2.cs | 23 ++++++++++++++++++ ProtoFlux/Math/Random/RandomBool3.cs | 19 +++++++++++++++ ProtoFlux/Math/Random/RandomBool4.cs | 24 +++++++++++++++++++ ProtoFlux/Math/Random/RandomCharacter.cs | 22 +++++++++++++++++ ProtoFlux/Math/Random/RandomDouble.cs | 28 ++++++++++++++++++++++ ProtoFlux/Math/Random/RandomEulerAngles.cs | 27 +++++++++++++++++++++ 9 files changed, 188 insertions(+) create mode 100644 ProtoFlux/Math/Constants/EpsilonDouble.cs create mode 100644 ProtoFlux/Math/Constants/EpsilonFloat.cs create mode 100644 ProtoFlux/Math/Random/FileName.cs create mode 100644 ProtoFlux/Math/Random/RandomBool2.cs create mode 100644 ProtoFlux/Math/Random/RandomBool3.cs create mode 100644 ProtoFlux/Math/Random/RandomBool4.cs create mode 100644 ProtoFlux/Math/Random/RandomCharacter.cs create mode 100644 ProtoFlux/Math/Random/RandomDouble.cs create mode 100644 ProtoFlux/Math/Random/RandomEulerAngles.cs diff --git a/ProtoFlux/Math/Constants/EpsilonDouble.cs b/ProtoFlux/Math/Constants/EpsilonDouble.cs new file mode 100644 index 0000000..073de3f --- /dev/null +++ b/ProtoFlux/Math/Constants/EpsilonDouble.cs @@ -0,0 +1,13 @@ +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +[NodeCategory("LogiX/NeosPlus/Math/Constants")] +[NodeName("Epsilon Double")] +public class EpsilonDouble : ValueFunctionNode +{ + protected override double Compute(ExecutionContext context) + { + return MathX.DOUBLE_EPSILON; + } +} diff --git a/ProtoFlux/Math/Constants/EpsilonFloat.cs b/ProtoFlux/Math/Constants/EpsilonFloat.cs new file mode 100644 index 0000000..9524bc8 --- /dev/null +++ b/ProtoFlux/Math/Constants/EpsilonFloat.cs @@ -0,0 +1,13 @@ +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +[NodeCategory("Protoflux/Obsidian/Math/Constants")] +[NodeName("Epsilon Float")] +public class EpsilonFloat : ValueFunctionNode +{ + protected override float Compute(ExecutionContext context) + { + return MathX.FLOAT_EPSILON; + } +} diff --git a/ProtoFlux/Math/Random/FileName.cs b/ProtoFlux/Math/Random/FileName.cs new file mode 100644 index 0000000..dbd9a77 --- /dev/null +++ b/ProtoFlux/Math/Random/FileName.cs @@ -0,0 +1,19 @@ +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +[NodeName("Random Int2")] +public class RandomInt2 : ValueFunctionNode +{ + public ValueInput Min; + public ValueInput Max; + + protected override int2 Compute(ExecutionContext context) + { + int2 min = Min.Evaluate(context,int2.Zero); + int2 max = Max.Evaluate(context,int2.One); + + return new int2(RandomX.Range(min.x, max.x), RandomX.Range(min.y, max.y)); + } +} diff --git a/ProtoFlux/Math/Random/RandomBool2.cs b/ProtoFlux/Math/Random/RandomBool2.cs new file mode 100644 index 0000000..ce512b9 --- /dev/null +++ b/ProtoFlux/Math/Random/RandomBool2.cs @@ -0,0 +1,23 @@ +using System; +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Actions; + +[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +[ContinuouslyChanging] + +public class RandomBool2 : ObjectFunctionNode +{ + public ValueInput Chance; + + protected override bool2 Compute(ExecutionContext context) + { + float2 chance = Chance.Evaluate(context); + bool2 result = new bool2( + RandomX.Chance(chance.x), + RandomX.Chance(chance.y) + ); + return result; + } +} diff --git a/ProtoFlux/Math/Random/RandomBool3.cs b/ProtoFlux/Math/Random/RandomBool3.cs new file mode 100644 index 0000000..f9ec0a5 --- /dev/null +++ b/ProtoFlux/Math/Random/RandomBool3.cs @@ -0,0 +1,19 @@ +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Actions; +using FrooxEngine; + +[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +[NodeName("Random Bool3")] +[ContinuouslyChanging] +public class RandomBool3 : ValueFunctionNode +{ + public ValueInput Chance; + + protected override bool3 Compute(ExecutionContext context) + { + var chance = Chance.Evaluate(context); + return new bool3(RandomX.Chance(chance.x), RandomX.Chance(chance.y), RandomX.Chance(chance.z)); + } +} \ No newline at end of file diff --git a/ProtoFlux/Math/Random/RandomBool4.cs b/ProtoFlux/Math/Random/RandomBool4.cs new file mode 100644 index 0000000..0926934 --- /dev/null +++ b/ProtoFlux/Math/Random/RandomBool4.cs @@ -0,0 +1,24 @@ +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Actions; +using FrooxEngine; + +[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +[NodeName("Random Bool4")] +[ContinuouslyChanging] +public class RandomBool4 : ValueFunctionNode +{ + public ValueInput Chance; + + protected override bool4 Compute(ExecutionContext context) + { + var chance = Chance.Evaluate(context); + return new bool4( + RandomX.Chance(chance.x), + RandomX.Chance(chance.y), + RandomX.Chance(chance.z), + RandomX.Chance(chance.w) + ); + } +} diff --git a/ProtoFlux/Math/Random/RandomCharacter.cs b/ProtoFlux/Math/Random/RandomCharacter.cs new file mode 100644 index 0000000..e6bd71c --- /dev/null +++ b/ProtoFlux/Math/Random/RandomCharacter.cs @@ -0,0 +1,22 @@ +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Actions; + +[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +[NodeName("Random Character")] +[ContinuouslyChanging] +public class RandomCharacter : ValueFunctionNode +{ + public ValueInput Start; + public ValueInput End; + public ObjectInput String; + + protected override char Compute(ExecutionContext context) + { + var str = String.Evaluate(context); + var start = MathX.Clamp(Start.Evaluate(context), 0, str.Length); + var end = MathX.Clamp(End.Evaluate(context,str.Length), start, str.Length); + return str[RandomX.Range(start, end)]; + } +} diff --git a/ProtoFlux/Math/Random/RandomDouble.cs b/ProtoFlux/Math/Random/RandomDouble.cs new file mode 100644 index 0000000..b5f498f --- /dev/null +++ b/ProtoFlux/Math/Random/RandomDouble.cs @@ -0,0 +1,28 @@ +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Actions; + +[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +[NodeName("Random Double")] +[ContinuouslyChanging] +public class RandomDouble : ValueFunctionNode +{ + public ValueInput Min; + public ValueInput Max; + + protected override double Compute(ExecutionContext context) + { + var min = Min.Evaluate(context); + var max = Max.Evaluate(context); + if (min > max) + { + var num1 = max; + var num2 = min; + min = num1; + max = num2; + } + + return min + RandomX.Double * (max - min); + } +} diff --git a/ProtoFlux/Math/Random/RandomEulerAngles.cs b/ProtoFlux/Math/Random/RandomEulerAngles.cs new file mode 100644 index 0000000..27ebf79 --- /dev/null +++ b/ProtoFlux/Math/Random/RandomEulerAngles.cs @@ -0,0 +1,27 @@ +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +[NodeName("Random Euler Angles")] +[ContinuouslyChanging] + +public class RandomEulerAngles : ValueFunctionNode +{ + public ValueInput minPitch; + public ValueInput maxPitch; + public ValueInput minYaw; + public ValueInput maxYaw; + public ValueInput minRoll; + public ValueInput maxRoll; + + protected override float3 Compute(ExecutionContext context) + { + float pitch = RandomX.Range(minPitch.Evaluate(context), maxPitch.Evaluate(context)); + float yaw = RandomX.Range(minYaw.Evaluate(context), maxYaw.Evaluate(context)); + float roll = RandomX.Range(minRoll.Evaluate(context), maxRoll.Evaluate(context)); + + return new float3(pitch, yaw, roll); + } +} From 29638611bce1070ab3360f4f249003680bb81e30 Mon Sep 17 00:00:00 2001 From: xLinka Date: Wed, 17 Apr 2024 12:56:57 +0100 Subject: [PATCH 2/2] fix name --- ProtoFlux/Math/Random/{FileName.cs => RandomInt2.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ProtoFlux/Math/Random/{FileName.cs => RandomInt2.cs} (100%) diff --git a/ProtoFlux/Math/Random/FileName.cs b/ProtoFlux/Math/Random/RandomInt2.cs similarity index 100% rename from ProtoFlux/Math/Random/FileName.cs rename to ProtoFlux/Math/Random/RandomInt2.cs