Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlinka committed Jul 20, 2024
1 parent ba48b7e commit efe7808
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ProjectObsidian/ProtoFlux/Math/Random/RandomFloatQ.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Elements.Core;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using Obsidian;


namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random
{

[NodeCategory("Obsidian/Math/Random")]
[ContinuouslyChanging]
public class RandomFloatQ : ValueFunctionNode<ExecutionContext, floatQ>
{
public readonly ValueInput<floatQ> Min;
public readonly ValueInput<floatQ> Max;

protected override floatQ Compute(ExecutionContext context)
{
floatQ min = Min.Evaluate(context);
floatQ max = Max.Evaluate(context);

return RandomXExtensions.Range(min, max);
}
}
}
23 changes: 23 additions & 0 deletions ProjectObsidian/ProtoFlux/RandomXExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using Elements.Core;

namespace Obsidian
{
public static class RandomXExtensions
{
private static RandomXGenerator r = new RandomXGenerator();

public static floatQ Range(floatQ min, floatQ max)
{
lock (r)
{
return new floatQ(
r.Range(min.x, max.x),
r.Range(min.y, max.y),
r.Range(min.z, max.z),
r.Range(min.w, max.w)
);
}
}
}
}

0 comments on commit efe7808

Please sign in to comment.