Merge remote-tracking branch 'origin/master' into 1.2
This commit is contained in:
@@ -654,16 +654,20 @@ namespace FlaxEditor.Viewport
|
||||
task.Begin += OnRenderBegin;
|
||||
}
|
||||
|
||||
private void OrientViewport(ref Quaternion orientation)
|
||||
/// <summary>
|
||||
/// Orients the viewport.
|
||||
/// </summary>
|
||||
/// <param name="orientation">The orientation.</param>
|
||||
protected virtual void OrientViewport(ref Quaternion orientation)
|
||||
{
|
||||
if (Editor.Instance.SceneEditing.HasSthSelected)
|
||||
if (ViewportCamera is FPSCamera fpsCamera)
|
||||
{
|
||||
((FPSCamera)ViewportCamera).ShowActors(Editor.Instance.Windows.EditWin.Viewport.TransformGizmo.SelectedParents, ref orientation);
|
||||
var pos = Vector3.Zero + Vector3.Backward * orientation * 2000.0f;
|
||||
fpsCamera.MoveViewport(pos, orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
var pos = new Vector3(0.0f) + Vector3.Backward * orientation * 2000.0f;
|
||||
((FPSCamera)ViewportCamera).MoveViewport(pos, orientation);
|
||||
ViewportCamera.SetArcBallView(orientation, Vector3.Zero, 2000.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1009,7 +1013,7 @@ namespace FlaxEditor.Viewport
|
||||
|
||||
// Check if update mouse
|
||||
Vector2 size = Size;
|
||||
var options = Editor.Instance.Options.Options.Input;
|
||||
var options = Editor.Instance.Options.Options;
|
||||
if (_isControllingMouse)
|
||||
{
|
||||
var rmbWheel = false;
|
||||
@@ -1033,7 +1037,7 @@ namespace FlaxEditor.Viewport
|
||||
if (rmbWheel)
|
||||
{
|
||||
float step = 4.0f;
|
||||
_wheelMovementChangeDeltaSum += _input.MouseWheelDelta * Editor.Instance.Options.Options.Viewport.MouseWheelSensitivity;
|
||||
_wheelMovementChangeDeltaSum += _input.MouseWheelDelta * options.Viewport.MouseWheelSensitivity;
|
||||
int camValueIndex = -1;
|
||||
for (int i = 0; i < EditorViewportCameraSpeedValues.Length; i++)
|
||||
{
|
||||
@@ -1061,27 +1065,27 @@ namespace FlaxEditor.Viewport
|
||||
|
||||
// Get input movement
|
||||
Vector3 moveDelta = Vector3.Zero;
|
||||
if (win.GetKey(options.Forward.Key))
|
||||
if (win.GetKey(options.Input.Forward.Key))
|
||||
{
|
||||
moveDelta += Vector3.Forward;
|
||||
}
|
||||
if (win.GetKey(options.Backward.Key))
|
||||
if (win.GetKey(options.Input.Backward.Key))
|
||||
{
|
||||
moveDelta += Vector3.Backward;
|
||||
}
|
||||
if (win.GetKey(options.Right.Key))
|
||||
if (win.GetKey(options.Input.Right.Key))
|
||||
{
|
||||
moveDelta += Vector3.Right;
|
||||
}
|
||||
if (win.GetKey(options.Left.Key))
|
||||
if (win.GetKey(options.Input.Left.Key))
|
||||
{
|
||||
moveDelta += Vector3.Left;
|
||||
}
|
||||
if (win.GetKey(options.Up.Key))
|
||||
if (win.GetKey(options.Input.Up.Key))
|
||||
{
|
||||
moveDelta += Vector3.Up;
|
||||
}
|
||||
if (win.GetKey(options.Down.Key))
|
||||
if (win.GetKey(options.Input.Down.Key))
|
||||
{
|
||||
moveDelta += Vector3.Down;
|
||||
}
|
||||
@@ -1152,7 +1156,7 @@ namespace FlaxEditor.Viewport
|
||||
{
|
||||
var scroll = _input.MouseWheelDelta;
|
||||
if (scroll > Mathf.Epsilon || scroll < -Mathf.Epsilon)
|
||||
_orthoSize -= scroll * Editor.Instance.Options.Options.Viewport.MouseWheelSensitivity * 0.2f * _orthoSize;
|
||||
_orthoSize -= scroll * options.Viewport.MouseWheelSensitivity * 0.2f * _orthoSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -9,6 +9,7 @@ using FlaxEditor.GUI.Drag;
|
||||
using FlaxEditor.SceneGraph;
|
||||
using FlaxEditor.SceneGraph.Actors;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEditor.Viewport.Cameras;
|
||||
using FlaxEditor.Viewport.Widgets;
|
||||
using FlaxEditor.Windows;
|
||||
using FlaxEngine;
|
||||
@@ -698,6 +699,17 @@ namespace FlaxEditor.Viewport
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OrientViewport(ref Quaternion orientation)
|
||||
{
|
||||
if (TransformGizmo.SelectedParents.Count != 0)
|
||||
{
|
||||
((FPSCamera)ViewportCamera).ShowActors(TransformGizmo.SelectedParents, ref orientation);
|
||||
}
|
||||
|
||||
base.OrientViewport(ref orientation);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnLeftMouseButtonUp()
|
||||
{
|
||||
|
||||
@@ -849,6 +849,17 @@ namespace FlaxEditor.Viewport
|
||||
Spawn(actor, ref hitLocation);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OrientViewport(ref Quaternion orientation)
|
||||
{
|
||||
if (TransformGizmo.SelectedParents.Count != 0)
|
||||
{
|
||||
((FPSCamera)ViewportCamera).ShowActors(TransformGizmo.SelectedParents, ref orientation);
|
||||
}
|
||||
|
||||
base.OrientViewport(ref orientation);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace FlaxEditor.Viewport.Previews
|
||||
/// Base class for texture previews. Draws a surface in the UI and supports view moving/zooming.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEngine.GUI.ContainerControl" />
|
||||
[HideInEditor]
|
||||
public abstract class TexturePreviewBase : ContainerControl
|
||||
{
|
||||
private Rectangle _textureRect;
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
private readonly CustomEditorPresenter _presenter;
|
||||
private readonly ToolStripButton _saveButton;
|
||||
private object _object;
|
||||
private bool _isRegisteredForScriptsReload;
|
||||
|
||||
/// <inheritdoc />
|
||||
public JsonAssetWindow(Editor editor, AssetItem item)
|
||||
@@ -43,7 +44,6 @@ namespace FlaxEditor.Windows.Assets
|
||||
private void OnScriptsReloadBegin()
|
||||
{
|
||||
Close();
|
||||
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -83,8 +83,11 @@ namespace FlaxEditor.Windows.Assets
|
||||
ClearEditedFlag();
|
||||
|
||||
// Auto-close on scripting reload if json asset is from game scripts (it might be reloaded)
|
||||
if (_object != null && FlaxEngine.Scripting.IsTypeFromGameScripts(_object.GetType()))
|
||||
if (_object != null && FlaxEngine.Scripting.IsTypeFromGameScripts(_object.GetType()) && !_isRegisteredForScriptsReload)
|
||||
{
|
||||
_isRegisteredForScriptsReload = true;
|
||||
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
|
||||
}
|
||||
|
||||
base.OnAssetLoaded();
|
||||
}
|
||||
@@ -98,5 +101,17 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
base.OnItemReimported(item);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnDestroy()
|
||||
{
|
||||
if (_isRegisteredForScriptsReload)
|
||||
{
|
||||
_isRegisteredForScriptsReload = false;
|
||||
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
|
||||
}
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,8 +333,9 @@ namespace FlaxEditor.Windows
|
||||
AutoWidth = true,
|
||||
AutoHeight = true,
|
||||
Margin = new Margin(4),
|
||||
VerticalAlignment = TextAlignment.Near,
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
Offsets = Margin.Zero,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
};
|
||||
|
||||
// Entries panel
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "BinaryAsset.h"
|
||||
#include "Cache/AssetsCache.h"
|
||||
#include "Storage/ContentStorageManager.h"
|
||||
#include "Loading/Tasks/LoadAssetDataTask.h"
|
||||
#include "Engine/ContentImporters/AssetsImportingManager.h"
|
||||
@@ -303,9 +304,13 @@ bool BinaryAsset::SaveAsset(const StringView& path, AssetInitData& data, bool si
|
||||
|
||||
bool BinaryAsset::SaveToAsset(const StringView& path, AssetInitData& data, bool silentMode)
|
||||
{
|
||||
// Ensure path is in a valid format
|
||||
String pathNorm(path);
|
||||
FileSystem::NormalizePath(pathNorm);
|
||||
|
||||
// Find target storage container and the asset
|
||||
auto storage = ContentStorageManager::TryGetStorage(path);
|
||||
auto asset = Content::GetAsset(path);
|
||||
auto storage = ContentStorageManager::TryGetStorage(pathNorm);
|
||||
auto asset = Content::GetAsset(pathNorm);
|
||||
auto binaryAsset = dynamic_cast<BinaryAsset*>(asset);
|
||||
if (asset && !binaryAsset)
|
||||
{
|
||||
@@ -351,8 +356,8 @@ bool BinaryAsset::SaveToAsset(const StringView& path, AssetInitData& data, bool
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(path.HasChars());
|
||||
result = FlaxStorage::Create(path, data, silentMode);
|
||||
ASSERT(pathNorm.HasChars());
|
||||
result = FlaxStorage::Create(pathNorm, data, silentMode);
|
||||
}
|
||||
if (binaryAsset)
|
||||
binaryAsset->_isSaving = false;
|
||||
|
||||
@@ -697,6 +697,27 @@ namespace FlaxEngine
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the orientation from the direction vector.
|
||||
/// </summary>
|
||||
/// <param name="direction">The direction vector (normalized).</param>
|
||||
/// <returns>The orientation.</returns>
|
||||
public static Quaternion FromDirection(Vector3 direction)
|
||||
{
|
||||
Quaternion orientation;
|
||||
if (Vector3.Dot(direction, Vector3.Up) >= 0.999f)
|
||||
{
|
||||
orientation = RotationAxis(Vector3.Left, Mathf.PiOverTwo);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 right = Vector3.Cross(direction, Vector3.Up);
|
||||
Vector3 up = Vector3.Cross(right, direction);
|
||||
orientation = LookRotation(direction, up);
|
||||
}
|
||||
return orientation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a linear interpolation between two quaternions.
|
||||
/// </summary>
|
||||
|
||||
@@ -496,14 +496,8 @@ public:
|
||||
// - load scenes (from temporary files)
|
||||
// Note: we don't want to override original scene files
|
||||
|
||||
// If no scene loaded just reload scripting
|
||||
if (!Level::IsAnySceneLoaded())
|
||||
{
|
||||
// Reload scripting
|
||||
LOG(Info, "No scenes loaded, performing fast scripts reload");
|
||||
Scripting::Reload(false);
|
||||
return false;
|
||||
}
|
||||
LOG(Info, "Scripts reloading start");
|
||||
const auto startTime = DateTime::NowUTC();
|
||||
|
||||
// Cache data
|
||||
struct SceneData
|
||||
@@ -538,8 +532,6 @@ public:
|
||||
scenes[i].Init(Level::Scenes[i]);
|
||||
|
||||
// Fire event
|
||||
LOG(Info, "Scripts reloading start");
|
||||
const auto startTime = DateTime::NowUTC();
|
||||
Level::ScriptsReloadStart();
|
||||
|
||||
// Save scenes (to memory)
|
||||
@@ -566,9 +558,10 @@ public:
|
||||
Scripting::Reload();
|
||||
|
||||
// Restore scenes (from memory)
|
||||
LOG(Info, "Loading temporary scenes");
|
||||
for (int32 i = 0; i < scenesCount; i++)
|
||||
{
|
||||
LOG(Info, "Restoring scene {0}", scenes[i].Name);
|
||||
|
||||
// Parse json
|
||||
const auto& sceneData = scenes[i].Data;
|
||||
ISerializable::SerializeDocument document;
|
||||
@@ -590,8 +583,9 @@ public:
|
||||
scenes.Resize(0);
|
||||
|
||||
// Initialize scenes (will link references and create managed objects using new assembly)
|
||||
LOG(Info, "Prepare scene objects");
|
||||
if (Level::Scenes.HasItems())
|
||||
{
|
||||
LOG(Info, "Prepare scene objects");
|
||||
SceneBeginData beginData;
|
||||
for (int32 i = 0; i < Level::Scenes.Count(); i++)
|
||||
{
|
||||
@@ -601,8 +595,7 @@ public:
|
||||
}
|
||||
|
||||
// Fire event
|
||||
const auto endTime = DateTime::NowUTC();
|
||||
LOG(Info, "Scripts reloading end. Total time: {0}ms", static_cast<int32>((endTime - startTime).GetTotalMilliseconds()));
|
||||
LOG(Info, "Scripts reloading end. Total time: {0}ms", static_cast<int32>((DateTime::NowUTC() - startTime).GetTotalMilliseconds()));
|
||||
Level::ScriptsReloadEnd();
|
||||
|
||||
return false;
|
||||
|
||||
@@ -77,7 +77,19 @@ namespace FlaxEngine.GUI
|
||||
public FontReference Font
|
||||
{
|
||||
get => _font;
|
||||
set => _font = value;
|
||||
set
|
||||
{
|
||||
if (_font != value)
|
||||
{
|
||||
_font = value;
|
||||
|
||||
if (_autoWidth || _autoHeight || _autoFitText)
|
||||
{
|
||||
_textSize = Vector2.Zero;
|
||||
PerformLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -47,7 +47,12 @@ namespace FlaxEngine.GUI
|
||||
public float Bottom;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the margin's total size. Cumulative margin size.
|
||||
/// Gets the margin's location (Left, Top).
|
||||
/// </summary>
|
||||
public Vector2 Location => new Vector2(Left, Top);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the margin's total size. Cumulative margin size (Left + Right, Top + Bottom).
|
||||
/// </summary>
|
||||
public Vector2 Size => new Vector2(Left + Right, Top + Bottom);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace FlaxEngine.GUI
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
Control c = _children[i];
|
||||
if (c.Visible)
|
||||
if (c.Visible && Mathf.IsZero(c.AnchorMin.Y) && Mathf.IsZero(c.AnchorMax.Y))
|
||||
{
|
||||
c.Height = h;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace FlaxEngine.GUI
|
||||
for (int i = 0; i < _children.Count; i++)
|
||||
{
|
||||
Control c = _children[i];
|
||||
if (c.Visible)
|
||||
if (c.Visible && Mathf.IsZero(c.AnchorMin.X) && Mathf.IsZero(c.AnchorMax.X))
|
||||
{
|
||||
c.Width = w;
|
||||
}
|
||||
|
||||
@@ -306,16 +306,13 @@ namespace FlaxEngine
|
||||
{
|
||||
var view = _editorTask.View;
|
||||
var transform = Transform;
|
||||
var cameraPosition = view.Position;
|
||||
var cameraDirection = view.Direction;
|
||||
var up = Vector3.Up;
|
||||
Matrix.Translation(_guiRoot.Width * -0.5f, _guiRoot.Height * -0.5f, 0, out var m1);
|
||||
Matrix.Scaling(ref transform.Scale, out var m2);
|
||||
Matrix.Multiply(ref m1, ref m2, out var m3);
|
||||
Quaternion.Euler(180, 180, 0, out var quat);
|
||||
Matrix.RotationQuaternion(ref quat, out m2);
|
||||
Matrix.Multiply(ref m3, ref m2, out m1);
|
||||
Matrix.Billboard(ref transform.Translation, ref cameraPosition, ref up, ref cameraDirection, out m2);
|
||||
m2 = Matrix.Transformation(Vector3.One, Quaternion.FromDirection(-view.Direction), transform.Translation);
|
||||
Matrix.Multiply(ref m1, ref m2, out world);
|
||||
}
|
||||
else if (_renderMode == CanvasRenderMode.CameraSpace)
|
||||
@@ -358,16 +355,13 @@ namespace FlaxEngine
|
||||
{
|
||||
// In 3D world face camera
|
||||
var transform = Transform;
|
||||
var cameraPosition = camera.Position;
|
||||
var cameraDirection = camera.Direction;
|
||||
var up = Vector3.Up;
|
||||
Matrix.Translation(_guiRoot.Width * -0.5f, _guiRoot.Height * -0.5f, 0, out var m1);
|
||||
Matrix.Scaling(ref transform.Scale, out var m2);
|
||||
Matrix.Multiply(ref m1, ref m2, out var m3);
|
||||
Quaternion.Euler(180, 180, 0, out var quat);
|
||||
Matrix.RotationQuaternion(ref quat, out m2);
|
||||
Matrix.Multiply(ref m3, ref m2, out m1);
|
||||
Matrix.Billboard(ref transform.Translation, ref cameraPosition, ref up, ref cameraDirection, out m2);
|
||||
m2 = Matrix.Transformation(Vector3.One, Quaternion.FromDirection(-camera.Direction), transform.Translation);
|
||||
Matrix.Multiply(ref m1, ref m2, out world);
|
||||
}
|
||||
else if (_renderMode == CanvasRenderMode.CameraSpace && camera)
|
||||
|
||||
Reference in New Issue
Block a user