fix(camera): complete retail in-head adjustment behavior
This commit is contained in:
parent
11e68aad82
commit
4d0379744b
2 changed files with 86 additions and 7 deletions
|
|
@ -618,6 +618,60 @@ public class RetailChaseCameraTests
|
|||
Assert.Equal(MathF.Sqrt(0.6f * 0.6f + 0.5f * 0.5f), cam.Distance, 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AdjustingCloserInRetailFirstPerson_RefusesNearWriteAndStaysInHead()
|
||||
{
|
||||
var cam = new RetailChaseCamera();
|
||||
cam.SetRetailFirstPersonView();
|
||||
|
||||
cam.AdjustDistance(-1f);
|
||||
|
||||
Assert.True(cam.IsInHead);
|
||||
Assert.Equal(0.18f, cam.Distance, 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AdjustPitchInRetailFirstPerson_ChangesDirectionWithoutMovingEye()
|
||||
{
|
||||
var cam = new RetailChaseCamera();
|
||||
cam.SetRetailFirstPersonView();
|
||||
|
||||
cam.AdjustPitch(+1f);
|
||||
cam.Update(
|
||||
playerPosition: Vector3.Zero,
|
||||
playerYaw: 0f,
|
||||
playerVelocity: Vector3.Zero,
|
||||
isOnGround: true,
|
||||
contactPlaneNormal: Vector3.UnitZ,
|
||||
dt: 1f / 60f);
|
||||
|
||||
Assert.True(cam.IsInHead);
|
||||
Assert.Equal(new Vector3(0.18f, 0f, 1.5f), cam.Position);
|
||||
Vector3 forward = Vector3.Normalize(new Vector3(
|
||||
-cam.View.M13,
|
||||
-cam.View.M23,
|
||||
-cam.View.M33));
|
||||
Assert.True(forward.Z > 0f);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
cam.AdjustPitch(+1f);
|
||||
cam.Update(
|
||||
playerPosition: Vector3.Zero,
|
||||
playerYaw: 0f,
|
||||
playerVelocity: Vector3.Zero,
|
||||
isOnGround: true,
|
||||
contactPlaneNormal: Vector3.UnitZ,
|
||||
dt: 1f);
|
||||
forward = Vector3.Normalize(new Vector3(
|
||||
-cam.View.M13,
|
||||
-cam.View.M23,
|
||||
-cam.View.M33));
|
||||
Assert.Equal(
|
||||
0.8f / MathF.Sqrt(1f + 0.8f * 0.8f),
|
||||
forward.Z,
|
||||
5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AdjustPitch_UsesRetailEightDegreeRotationAndPreservesLength()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue