Fix ambient flyer cadence and rotating shadows
This commit is contained in:
parent
9cd429dd73
commit
8b7b601b32
5 changed files with 239 additions and 3 deletions
|
|
@ -842,6 +842,53 @@ public sealed class RetailStaticAnimatingObjectSchedulerTests
|
|||
Assert.NotEqual(afterFirst, entity.Rotation);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(30)]
|
||||
[InlineData(60)]
|
||||
[InlineData(180)]
|
||||
public void SetOmegaHook_DatSceneryOrbitIsIndependentOfHostFrameRate(
|
||||
int hostFramesPerSecond)
|
||||
{
|
||||
const float authoredYawPerQuantum = -0.027f;
|
||||
var loader = new Loader();
|
||||
loader.Add(
|
||||
AnimationId,
|
||||
OmegaAnimation(new Vector3(0f, 0f, authoredYawPerQuantum)));
|
||||
var scheduler = new RetailStaticAnimatingObjectScheduler(
|
||||
loader,
|
||||
(_, sequencer) => sequencer.ConsumePendingHooks(),
|
||||
(_, _, _) => { });
|
||||
WorldEntity entity = MakeEntity();
|
||||
scheduler.Register(entity, new ScriptActivationInfo(
|
||||
ScriptId: 0,
|
||||
PartTransforms: entity.IndexedPartTransforms,
|
||||
PartAvailability: entity.IndexedPartAvailable,
|
||||
Setup: MakeSetup(),
|
||||
DefaultAnimationId: AnimationId,
|
||||
UsesStaticAnimationWorkset: true));
|
||||
|
||||
// Bank SetOmega at process_hooks; retail first applies it on the next
|
||||
// static-animation pass. Do not include this installation frame in the
|
||||
// measured one-second orbit interval.
|
||||
scheduler.Tick(1f / 30f);
|
||||
scheduler.ProcessHooks();
|
||||
|
||||
float hostDelta = 1f / hostFramesPerSecond;
|
||||
for (int frame = 0; frame < hostFramesPerSecond; frame++)
|
||||
{
|
||||
scheduler.Tick(hostDelta);
|
||||
scheduler.ProcessHooks();
|
||||
}
|
||||
|
||||
Vector3 actualForward = Vector3.Transform(Vector3.UnitX, entity.Rotation);
|
||||
float expectedYaw = authoredYawPerQuantum * 30f;
|
||||
var expectedForward = new Vector3(
|
||||
MathF.Cos(expectedYaw),
|
||||
MathF.Sin(expectedYaw),
|
||||
0f);
|
||||
Assert.InRange(Vector3.Distance(actualForward, expectedForward), 0f, 0.0001f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithoutASetOmegaHookTheRootNeverTurns()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue