Add --warmup option to control physics warmup loops

Create a new --warmup argument to specify the number of warmup loops for physics before export. This allows users to control how many times the animation is pre-processed to stabilize physics.
This commit is contained in:
Jay
2025-10-19 04:59:34 -07:00
parent 53a7700798
commit 6a17ec0397

View File

@@ -33,6 +33,7 @@ options:
--speed FLOAT Speed of animation (for video), default 1.0
--color HEX Background color as a hex RGBA color, default 000000ff (opaque black)
--quiet Removes console progress log, default false
--warmup INT Warm Up Physics, default 2 loops before export
";
public static void Main(string[] args)
@@ -57,6 +58,8 @@ options:
float speed = 1;
Color backgroundColor = Color.Black;
bool quiet = false;
bool warmup = false;
int warmUpLoops = 2;
for (int i = 0; i < args.Length; i++)
{
@@ -126,6 +129,10 @@ options:
case "--quiet":
quiet = true;
break;
case "--warmup":
warmUpLoops = int.Parse(args[++i]);
warmup = true;
break;
default:
Console.Error.WriteLine($"Unknown argument: {args[i]}");
Environment.Exit(2);
@@ -172,6 +179,20 @@ options:
}
sp.Update(0);
if (warmup)
{
float delta = 1f / fps;
for (int i = 0; i < warmUpLoops; i++)
{
float t = 0;
while (t < trackEntry.Animation.Duration)
{
sp.Update(delta);
t += delta;
}
}
}
foreach (var slotName in hideSlots)
{
if (!sp.SetSlotVisible(slotName, false))