Skip to content

Commit

Permalink
Create Factorial Node Reference #1688
Browse files Browse the repository at this point in the history
Yellow-Dog-Man/Resonite-Issues#1688

Adding factorial node as a basis for ticket 1688 on main github
  • Loading branch information
Xlinka committed Jun 25, 2024
1 parent dcf5e3e commit a5c335b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ProjectObsidian/ProtoFlux/Math/Factorial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using Elements.Core;
using ProtoFlux.Core;
using ProtoFlux.Runtimes.Execution;
using FrooxEngine.ProtoFlux;

namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math
{
[NodeCategory("Obsidian/Math")]
[NodeName("Factorial")]
public class FactorialNode : ValueFunctionNode<FrooxEngineContext, int>
{
public ValueInput<int> Input;

protected override int Compute(FrooxEngineContext context)
{
var input = Input.Evaluate(context);
var fact = 1;
var loop = MathX.Clamp(input, 0, 16);
for (var i = 1; i <= loop; i++) fact *= i;
return fact;
}
}
}

0 comments on commit a5c335b

Please sign in to comment.