Refactor engine to support double-precision vectors
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
#if USE_LARGE_WORLDS
|
||||
using Real = System.Double;
|
||||
#else
|
||||
using Real = System.Single;
|
||||
#endif
|
||||
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using FlaxEngine;
|
||||
@@ -12,7 +18,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
public class ArcBallCamera : ViewportCamera
|
||||
{
|
||||
private Vector3 _orbitCenter;
|
||||
private float _orbitRadius;
|
||||
private Real _orbitRadius;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the orbit center.
|
||||
@@ -30,7 +36,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
/// <summary>
|
||||
/// Gets or sets the orbit radius.
|
||||
/// </summary>
|
||||
public float OrbitRadius
|
||||
public Real OrbitRadius
|
||||
{
|
||||
get => _orbitRadius;
|
||||
set
|
||||
@@ -95,7 +101,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetArcBallView(Quaternion orientation, Vector3 orbitCenter, float orbitRadius)
|
||||
public override void SetArcBallView(Quaternion orientation, Vector3 orbitCenter, Real orbitRadius)
|
||||
{
|
||||
base.SetArcBallView(orientation, orbitCenter, orbitRadius);
|
||||
|
||||
@@ -104,7 +110,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void UpdateView(float dt, ref Vector3 moveDelta, ref Vector2 mouseDelta, out bool centerMouse)
|
||||
public override void UpdateView(float dt, ref Vector3 moveDelta, ref Float2 mouseDelta, out bool centerMouse)
|
||||
{
|
||||
centerMouse = true;
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
#if USE_LARGE_WORLDS
|
||||
using Real = System.Double;
|
||||
#else
|
||||
using Real = System.Single;
|
||||
#endif
|
||||
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System.Collections.Generic;
|
||||
@@ -164,7 +170,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
if (Viewport.UseOrthographicProjection)
|
||||
{
|
||||
position = sphere.Center + Vector3.Backward * orientation * (sphere.Radius * 5.0f);
|
||||
Viewport.OrthographicScale = Vector3.Distance(position, sphere.Center) / 1000;
|
||||
Viewport.OrthographicScale = (float)Vector3.Distance(position, sphere.Center) / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,7 +181,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetArcBallView(Quaternion orientation, Vector3 orbitCenter, float orbitRadius)
|
||||
public override void SetArcBallView(Quaternion orientation, Vector3 orbitCenter, Real orbitRadius)
|
||||
{
|
||||
base.SetArcBallView(orientation, orbitCenter, orbitRadius);
|
||||
|
||||
@@ -211,7 +217,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void UpdateView(float dt, ref Vector3 moveDelta, ref Vector2 mouseDelta, out bool centerMouse)
|
||||
public override void UpdateView(float dt, ref Vector3 moveDelta, ref Float2 mouseDelta, out bool centerMouse)
|
||||
{
|
||||
centerMouse = true;
|
||||
|
||||
@@ -296,7 +302,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
Viewport.Pitch = pitch;
|
||||
if (input.IsOrbiting)
|
||||
{
|
||||
float orbitRadius = Mathf.Max(Vector3.Distance(ref position, ref TargetPoint), 0.0001f);
|
||||
float orbitRadius = Mathf.Max((float)Vector3.Distance(ref position, ref TargetPoint), 0.0001f);
|
||||
Vector3 localPosition = Viewport.ViewDirection * (-1 * orbitRadius);
|
||||
Viewport.ViewPosition = TargetPoint + localPosition;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
/// <param name="moveDelta">The move delta (scaled).</param>
|
||||
/// <param name="mouseDelta">The mouse delta (scaled).</param>
|
||||
/// <param name="centerMouse">True if center mouse after the update.</param>
|
||||
void UpdateView(float dt, ref Vector3 moveDelta, ref Vector2 mouseDelta, out bool centerMouse);
|
||||
void UpdateView(float dt, ref Vector3 moveDelta, ref Float2 mouseDelta, out bool centerMouse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
#if USE_LARGE_WORLDS
|
||||
using Real = System.Double;
|
||||
#else
|
||||
using Real = System.Single;
|
||||
#endif
|
||||
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using FlaxEngine;
|
||||
@@ -62,7 +68,7 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
/// <param name="orientation">The view rotation.</param>
|
||||
/// <param name="orbitCenter">The orbit center location.</param>
|
||||
/// <param name="orbitRadius">The orbit radius.</param>
|
||||
public virtual void SetArcBallView(Quaternion orientation, Vector3 orbitCenter, float orbitRadius)
|
||||
public virtual void SetArcBallView(Quaternion orientation, Vector3 orbitCenter, Real orbitRadius)
|
||||
{
|
||||
// Rotate
|
||||
Viewport.ViewOrientation = orientation;
|
||||
@@ -78,6 +84,6 @@ namespace FlaxEditor.Viewport.Cameras
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void UpdateView(float dt, ref Vector3 moveDelta, ref Vector2 mouseDelta, out bool centerMouse);
|
||||
public abstract void UpdateView(float dt, ref Vector3 moveDelta, ref Float2 mouseDelta, out bool centerMouse);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user