Skip to content
Permalink
Browse files

[Editor] Re-order code execution

  • Loading branch information
Eideren authored and xen2 committed Jun 5, 2019
1 parent 268a7ed commit 0c0ed336b59d558380005b055be85db479f78772
@@ -184,10 +184,19 @@ protected void UpdateCameraBase(ref float yaw, ref float pitch, ref Vector3 posi
// Compute translation speed according to framerate and modifiers
float baseSpeed = MoveSpeed * SceneUnit * (input.isShiftDown ? 10 : 1) * (1f/60f);

var rotation = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);

float zoomDelta = 0f;

// Update yaw and pitch first to keep dependencies on 'rotation' up to date with current frame changes
if (input.isMoving || input.isRotating || input.isOrbiting)
{
var rotationSpeed = RotationSpeed * (input.isOrbiting ? 2 : 1); // we want to rotate faster when rotating around an object.
yaw -= 1.333f * Game.Input.MouseDelta.X * rotationSpeed; // we want to rotate faster Horizontally and Vertically
if (input.isRotating || input.isOrbiting)
pitch = MathUtil.Clamp(pitch - Game.Input.MouseDelta.Y * rotationSpeed, -MathUtil.PiOverTwo, MathUtil.PiOverTwo);
}

var rotation = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);

// If scene has changed since last time
if (asOrthographic && Game?.ContentScene?.Entities != null)
{
@@ -262,17 +271,6 @@ protected void UpdateCameraBase(ref float yaw, ref float pitch, ref Vector3 posi
}
}

// Rotate
if (input.isMoving || input.isRotating || input.isOrbiting)
{
var rotationSpeed = RotationSpeed * (input.isOrbiting ? 2 : 1); // we want to rotate faster when rotating around an object.
yaw -= 1.333f * Game.Input.MouseDelta.X * rotationSpeed; // we want to rotate faster Horizontally and Vertically
if (input.isRotating || input.isOrbiting)
pitch = MathUtil.Clamp(pitch - Game.Input.MouseDelta.Y * rotationSpeed, -MathUtil.PiOverTwo, MathUtil.PiOverTwo);
// Yaw & Pitch modified, update quaternion rotation
rotation = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);
}

// Forward/backward
if (input.isZooming)
{

0 comments on commit 0c0ed33

Please sign in to comment.
You can’t perform that action at this time.