Refactor engine to support double-precision vectors
This commit is contained in:
@@ -84,7 +84,7 @@ namespace FlaxEditor.Content.Create
|
||||
_settingsEditor = new CustomEditorPresenter(null);
|
||||
_settingsEditor.Panel.Parent = panel;
|
||||
|
||||
_dialogSize = new Vector2(TotalWidth, panel.Bottom);
|
||||
_dialogSize = new Float2(TotalWidth, panel.Bottom);
|
||||
|
||||
_settingsEditor.Select(_entry.Settings);
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace FlaxEditor.Content.Create
|
||||
{
|
||||
base.SetupWindowSettings(ref settings);
|
||||
|
||||
settings.MinimumSize = new Vector2(300, 400);
|
||||
settings.MinimumSize = new Float2(300, 400);
|
||||
settings.HasSizingFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace FlaxEditor.Content.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
|
||||
{
|
||||
base.OnDragEnter(ref location, data);
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace FlaxEditor.Content.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
|
||||
{
|
||||
base.OnDragMove(ref location, data);
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace FlaxEditor.Content.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
|
||||
{
|
||||
var result = DragDropEffect.None;
|
||||
base.OnDragDrop(ref location, data);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace FlaxEditor.Content.GUI
|
||||
private DragActors _dragActors;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
|
||||
{
|
||||
var result = base.OnDragEnter(ref location, data);
|
||||
if (result != DragDropEffect.None)
|
||||
@@ -50,7 +50,7 @@ namespace FlaxEditor.Content.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
|
||||
{
|
||||
_validDragOver = false;
|
||||
var result = base.OnDragMove(ref location, data);
|
||||
@@ -72,7 +72,7 @@ namespace FlaxEditor.Content.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
|
||||
{
|
||||
var result = base.OnDragDrop(ref location, data);
|
||||
if (result != DragDropEffect.None)
|
||||
|
||||
@@ -594,18 +594,18 @@ namespace FlaxEditor.Content.GUI
|
||||
// Check if drag is over
|
||||
if (IsDragOver && _validDragOver)
|
||||
{
|
||||
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), style.BackgroundSelected * 0.4f);
|
||||
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), style.BackgroundSelected * 0.4f);
|
||||
}
|
||||
|
||||
// Check if it's an empty thing
|
||||
if (_items.Count == 0)
|
||||
{
|
||||
Render2D.DrawText(style.FontSmall, IsSearching ? "No results" : "Empty", new Rectangle(Vector2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
|
||||
Render2D.DrawText(style.FontSmall, IsSearching ? "No results" : "Empty", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
@@ -613,7 +613,7 @@ namespace FlaxEditor.Content.GUI
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseWheel(Vector2 location, float delta)
|
||||
public override bool OnMouseWheel(Float2 location, float delta)
|
||||
{
|
||||
// Check if pressing control key
|
||||
if (Root.GetKey(KeyboardKeys.Control))
|
||||
@@ -655,26 +655,26 @@ namespace FlaxEditor.Content.GUI
|
||||
// Movement with arrows
|
||||
{
|
||||
var root = _selection[0];
|
||||
Vector2 size = root.Size;
|
||||
Vector2 offset = Vector2.Minimum;
|
||||
var size = root.Size;
|
||||
var offset = Float2.Minimum;
|
||||
ContentItem item = null;
|
||||
if (key == KeyboardKeys.ArrowUp)
|
||||
{
|
||||
offset = new Vector2(0, -size.Y);
|
||||
offset = new Float2(0, -size.Y);
|
||||
}
|
||||
else if (key == KeyboardKeys.ArrowDown)
|
||||
{
|
||||
offset = new Vector2(0, size.Y);
|
||||
offset = new Float2(0, size.Y);
|
||||
}
|
||||
else if (key == KeyboardKeys.ArrowRight)
|
||||
{
|
||||
offset = new Vector2(size.X, 0);
|
||||
offset = new Float2(size.X, 0);
|
||||
}
|
||||
else if (key == KeyboardKeys.ArrowLeft)
|
||||
{
|
||||
offset = new Vector2(-size.X, 0);
|
||||
offset = new Float2(-size.X, 0);
|
||||
}
|
||||
if (offset != Vector2.Minimum)
|
||||
if (offset != Float2.Minimum)
|
||||
{
|
||||
item = GetChildAt(root.Location + size / 2 + offset) as ContentItem;
|
||||
}
|
||||
|
||||
@@ -131,10 +131,10 @@ namespace FlaxEditor.Content.Import
|
||||
// Select the first item
|
||||
tree.Select(_rootNode.Children[0] as TreeNode);
|
||||
|
||||
_dialogSize = new Vector2(TotalWidth, EditorHeight + splitPanel.Offsets.Height);
|
||||
_dialogSize = new Float2(TotalWidth, EditorHeight + splitPanel.Offsets.Height);
|
||||
}
|
||||
|
||||
private void OnTreeRightClick(TreeNode node, Vector2 location)
|
||||
private void OnTreeRightClick(TreeNode node, Float2 location)
|
||||
{
|
||||
var menu = new ContextMenu();
|
||||
menu.AddButton("Rename", OnRenameClicked);
|
||||
@@ -183,7 +183,7 @@ namespace FlaxEditor.Content.Import
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool OnMouseDoubleClickHeader(ref Vector2 location, MouseButton button)
|
||||
protected override bool OnMouseDoubleClickHeader(ref Float2 location, MouseButton button)
|
||||
{
|
||||
StartRenaming();
|
||||
return true;
|
||||
@@ -254,7 +254,7 @@ namespace FlaxEditor.Content.Import
|
||||
{
|
||||
base.SetupWindowSettings(ref settings);
|
||||
|
||||
settings.MinimumSize = new Vector2(300, 400);
|
||||
settings.MinimumSize = new Float2(300, 400);
|
||||
settings.HasSizingFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,9 +199,9 @@ namespace FlaxEditor.Content.Import
|
||||
/// <summary>
|
||||
/// Custom import geometry offset.
|
||||
/// </summary>
|
||||
[DefaultValue(typeof(Vector3), "0,0,0")]
|
||||
[DefaultValue(typeof(Float3), "0,0,0")]
|
||||
[EditorOrder(520), EditorDisplay("Transform")]
|
||||
public Vector3 Translation { get; set; } = Vector3.Zero;
|
||||
public Float3 Translation { get; set; } = Float3.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// If checked, the imported geometry will be shifted to the center of mass.
|
||||
@@ -376,7 +376,7 @@ namespace FlaxEditor.Content.Import
|
||||
// Transform
|
||||
public float Scale;
|
||||
public Quaternion Rotation;
|
||||
public Vector3 Translation;
|
||||
public Float3 Translation;
|
||||
public byte CenterGeometry;
|
||||
|
||||
// Animation
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace FlaxEditor.Content
|
||||
Offsets = Margin.Zero;
|
||||
}
|
||||
|
||||
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
return Item.OnMouseDoubleClick(Item.PointFromScreen(PointToScreen(location)), button);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace FlaxEditor.Content
|
||||
|
||||
// Check if drag is over
|
||||
if (IsDragOver && _validDragOver)
|
||||
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), Style.Current.BackgroundSelected * 0.6f);
|
||||
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), Style.Current.BackgroundSelected * 0.6f);
|
||||
}
|
||||
|
||||
private bool ValidateDragItem(ContentItem item)
|
||||
@@ -238,7 +238,7 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)
|
||||
{
|
||||
base.OnDragEnter(ref location, data);
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragMove(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
|
||||
{
|
||||
base.OnDragMove(ref location, data);
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
|
||||
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
|
||||
{
|
||||
var result = base.OnDragDrop(ref location, data);
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace FlaxEditor.Content
|
||||
private ContentFolder _parentFolder;
|
||||
|
||||
private bool _isMouseDown;
|
||||
private Vector2 _mouseDownStartPos;
|
||||
private Float2 _mouseDownStartPos;
|
||||
private readonly List<IContentItemOwner> _references = new List<IContentItemOwner>(4);
|
||||
|
||||
private SpriteHandle _thumbnail;
|
||||
@@ -593,11 +593,11 @@ namespace FlaxEditor.Content
|
||||
protected override bool ShowTooltip => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnShowTooltip(out string text, out Vector2 location, out Rectangle area)
|
||||
public override bool OnShowTooltip(out string text, out Float2 location, out Rectangle area)
|
||||
{
|
||||
UpdateTooltipText();
|
||||
var result = base.OnShowTooltip(out text, out _, out area);
|
||||
location = Size * new Vector2(0.9f, 0.5f);
|
||||
location = Size * new Float2(0.9f, 0.5f);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ namespace FlaxEditor.Content
|
||||
var style = Style.Current;
|
||||
var view = Parent as ContentView;
|
||||
var isSelected = view.IsSelected(this);
|
||||
var clientRect = new Rectangle(Vector2.Zero, size);
|
||||
var clientRect = new Rectangle(Float2.Zero, size);
|
||||
var textRect = TextRectangle;
|
||||
Rectangle thumbnailRect;
|
||||
TextAlignment nameAlignment;
|
||||
@@ -657,7 +657,7 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
Focus();
|
||||
|
||||
@@ -672,7 +672,7 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseUp(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && _isMouseDown)
|
||||
{
|
||||
@@ -687,7 +687,7 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
Focus();
|
||||
|
||||
@@ -707,10 +707,10 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Vector2 location)
|
||||
public override void OnMouseMove(Float2 location)
|
||||
{
|
||||
// Check if start drag and drop
|
||||
if (_isMouseDown && Vector2.Distance(_mouseDownStartPos, location) > 10.0f)
|
||||
if (_isMouseDown && Float2.Distance(_mouseDownStartPos, location) > 10.0f)
|
||||
{
|
||||
// Clear flag
|
||||
_isMouseDown = false;
|
||||
|
||||
@@ -121,7 +121,7 @@ Asset::LoadResult PreviewsCache::load()
|
||||
const float positionOffset = static_cast<float>(ASSETS_ICONS_ATLAS_MARGIN) / ASSETS_ICONS_ATLAS_SIZE;
|
||||
for (int32 i = 0; i < ASSETS_ICONS_PER_ATLAS; i++)
|
||||
{
|
||||
sprite.Area.Location = Vector2(static_cast<float>(i % ASSETS_ICONS_PER_ROW), static_cast<float>(i / ASSETS_ICONS_PER_ROW)) * positionScale + positionOffset;
|
||||
sprite.Area.Location = Float2(static_cast<float>(i % ASSETS_ICONS_PER_ROW), static_cast<float>(i / ASSETS_ICONS_PER_ROW)) * positionScale + positionOffset;
|
||||
sprite.Name = StringUtils::ToString(i);
|
||||
Sprites.Add(sprite);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace FlaxEditor.Content
|
||||
{
|
||||
_preview.Prefab = (Prefab)request.Asset;
|
||||
_preview.Parent = guiRoot;
|
||||
_preview.Scale = Vector2.One;
|
||||
_preview.Scale = Float2.One;
|
||||
_preview.ShowDefaultSceneActors = true;
|
||||
_preview.SyncBackbufferSize();
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace FlaxEditor.Content
|
||||
if (_preview.Instance is UIControl uiControl && uiControl.HasControl)
|
||||
{
|
||||
// Ensure to place UI in a proper way
|
||||
uiControl.Control.Location = Vector2.Zero;
|
||||
uiControl.Control.Location = Float2.Zero;
|
||||
uiControl.Control.Scale *= PreviewsCache.AssetIconSize / uiControl.Control.Size.MaxValue;
|
||||
uiControl.Control.AnchorPreset = AnchorPresets.TopLeft;
|
||||
uiControl.Control.AnchorPreset = AnchorPresets.MiddleCenter;
|
||||
@@ -154,8 +154,8 @@ namespace FlaxEditor.Content
|
||||
// Auto fit actor to camera
|
||||
float targetSize = 30.0f;
|
||||
var bounds = _preview.Instance.EditorBoxChildren;
|
||||
float maxSize = Mathf.Max(0.001f, bounds.Size.MaxValue);
|
||||
_preview.Instance.Scale = new Vector3(targetSize / maxSize);
|
||||
var maxSize = Math.Max(0.001f, (float)bounds.Size.MaxValue);
|
||||
_preview.Instance.Scale = new Float3(targetSize / maxSize);
|
||||
_preview.Instance.Position = Vector3.Zero;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user