Compare commits
24 Commits
0ac3ab2329
...
b23606c5eb
| Author | SHA1 | Date | |
|---|---|---|---|
| b23606c5eb | |||
| 0bb59994b1 | |||
| 4e81749474 | |||
| 5113ebf66d | |||
| fa74b6094e | |||
| 7e75aa53ac | |||
| 0faca0675d | |||
| 2d038e4508 | |||
| 092beb6ae9 | |||
| eb69186271 | |||
|
|
a1999183f2 | ||
|
|
1e3ce48024 | ||
|
|
403d2cedc0 | ||
|
|
c8839b8587 | ||
|
|
cf048c9804 | ||
|
|
bea75f51bd | ||
|
|
92254eefcc | ||
|
|
2a55cda583 | ||
|
|
7c91c03adf | ||
|
|
caa902ea9b | ||
|
|
fb07071e24 | ||
|
|
a1cb7dcbe7 | ||
|
|
032f698c7b | ||
|
|
e2aaef9b88 |
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d2b1dc1523cb2140db7ce5fed6e97b09d7fcebbe6cc19fca7708b5b882267040
|
||||
size 4175
|
||||
oid sha256:d3922811f0eb56cbb515c93cd53d80316740ea78219aa81118d2c9dee4a9d230
|
||||
size 4142
|
||||
|
||||
@@ -15,7 +15,7 @@ if errorlevel 1 goto BuildToolFailed
|
||||
|
||||
:: Build bindings for all editor configurations
|
||||
echo Building C# bindings...
|
||||
Binaries\Tools\Flax.Build.exe -build -BuildBindingsOnly -arch=x64 -platform=Windows --buildTargets=FlaxEditor
|
||||
Binaries\Tools\Flax.Build.exe -build -BuildBindingsOnly -arch=x64 -platform=Windows --buildTargets=FlaxEditor,FlaxGame
|
||||
|
||||
popd
|
||||
echo Done!
|
||||
|
||||
@@ -749,7 +749,7 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
// Draw short name
|
||||
Render2D.PushClip(ref textRect);
|
||||
Render2D.PushClip(textRect);
|
||||
var scale = 0.95f * view.ViewScale;
|
||||
Render2D.DrawText(style.FontMedium, ShowFileExtension || view.ShowFileExtensions ? FileName : ShortName, textRect, style.Foreground, nameAlignment, TextAlignment.Center, TextWrapping.WrapWords, 1f, scale);
|
||||
Render2D.PopClip();
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace FlaxEditor.Content.Thumbnails
|
||||
// Create render task but disabled for now
|
||||
_output = GPUDevice.Instance.CreateTexture("ThumbnailsOutput");
|
||||
var desc = GPUTextureDescription.New2D(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize, PreviewsCache.AssetIconsAtlasFormat);
|
||||
_output.Init(ref desc);
|
||||
_output.Init(desc);
|
||||
_task = Object.New<RenderTask>();
|
||||
_task.Order = 50; // Render this task later
|
||||
_task.Enabled = false;
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
#include "Engine/Serialization/JsonTools.h"
|
||||
#include "Engine/Serialization/JsonWriters.h"
|
||||
#include "Editor/Cooker/PlatformTools.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
#include "Editor/Editor.h"
|
||||
#include "Editor/ProjectInfo.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
#include "Editor/Utilities/EditorUtilities.h"
|
||||
#if PLATFORM_MAC
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
@@ -127,7 +128,7 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
|
||||
const String dst = dstPath / StringUtils::GetFileName(file);
|
||||
if (dst == file)
|
||||
continue;
|
||||
if (FileSystem::CopyFile(dst, file))
|
||||
if (EditorUtilities::CopyFileIfNewer(dst, file))
|
||||
{
|
||||
data.Error(String::Format(TEXT("Failed to copy file from {0} to {1}."), file, dst));
|
||||
return true;
|
||||
|
||||
@@ -59,6 +59,7 @@ bool PrecompileAssembliesStep::Perform(CookingData& data)
|
||||
data.StepProgress(infoMsg, 0);
|
||||
|
||||
// Override Newtonsoft.Json with AOT-version (one that doesn't use System.Reflection.Emit)
|
||||
// TODO: remove it since EngineModule does properly reference AOT lib now
|
||||
EditorUtilities::CopyFileIfNewer(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.dll"), Globals::StartupFolder / TEXT("Source/Platforms/DotNet/AOT/Newtonsoft.Json.dll"));
|
||||
FileSystem::DeleteFile(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.xml"));
|
||||
FileSystem::DeleteFile(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.pdb"));
|
||||
|
||||
@@ -60,14 +60,14 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
if (prefab && !prefab.WaitForLoaded())
|
||||
{
|
||||
var prefabObjectId = actor.PrefabObjectID;
|
||||
var prefabInstance = prefab.GetDefaultInstance(ref prefabObjectId);
|
||||
var prefabInstance = prefab.GetDefaultInstance(prefabObjectId);
|
||||
if (prefabInstance != null)
|
||||
{
|
||||
// Use default prefab instance as a reference for the editor
|
||||
Values.SetReferenceValue(prefabInstance);
|
||||
|
||||
// Display prefab UI (when displaying object inside Prefab Window then display only nested prefabs)
|
||||
prefab.GetNestedObject(ref prefabObjectId, out var nestedPrefabId, out var nestedPrefabObjectId);
|
||||
prefab.GetNestedObject(prefabObjectId, out var nestedPrefabId, out var nestedPrefabObjectId);
|
||||
var nestedPrefab = FlaxEngine.Content.Load<Prefab>(nestedPrefabId);
|
||||
var panel = layout.UniformGrid();
|
||||
panel.CustomControl.Height = 20.0f;
|
||||
@@ -207,7 +207,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
{
|
||||
var actor = (Actor)Values[0];
|
||||
var prefabObjectId = actor.PrefabObjectID;
|
||||
var prefabInstance = prefab.GetDefaultInstance(ref prefabObjectId);
|
||||
var prefabInstance = prefab.GetDefaultInstance(prefabObjectId);
|
||||
if (prefabInstance != null)
|
||||
{
|
||||
Values.SetReferenceValue(prefabInstance);
|
||||
@@ -525,7 +525,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
var restored = actor.AddScript(removed.PrefabObject.GetType());
|
||||
var prefabId = actor.PrefabID;
|
||||
var prefabObjectId = restored.PrefabObjectID;
|
||||
Script.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), ref prefabId, ref prefabObjectId);
|
||||
Script.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), prefabId, prefabObjectId);
|
||||
string data = JsonSerializer.Serialize(removed.PrefabObject);
|
||||
JsonSerializer.Deserialize(restored, data);
|
||||
|
||||
@@ -547,7 +547,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
string data = JsonSerializer.Serialize(removedActor.PrefabObject);
|
||||
JsonSerializer.Deserialize(restored, data);
|
||||
Presenter.Owner.SceneContext.Spawn(restored, parentActor, removedActor.OrderInParent);
|
||||
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), ref prefabId, ref prefabObjectId);
|
||||
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), prefabId, prefabObjectId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,11 +164,11 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
|
||||
|
||||
// Deselect
|
||||
if (isSelected && button1Rect.Contains(ref location))
|
||||
if (isSelected && button1Rect.Contains(location))
|
||||
Value = new ModelInstanceActor.MeshReference { Actor = null, LODIndex = -1, MeshIndex = -1 };
|
||||
|
||||
// Picker dropdown menu
|
||||
if ((isSelected ? button2Rect : button1Rect).Contains(ref location))
|
||||
if ((isSelected ? button2Rect : button1Rect).Contains(location))
|
||||
ShowDropDownMenu();
|
||||
|
||||
return base.OnMouseUp(location, button);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ModelPrefabEditor : GenericEditor
|
||||
if (prefab)
|
||||
{
|
||||
var prefabObjectId = modelPrefab.PrefabObjectID;
|
||||
var prefabObject = prefab.GetDefaultInstance(ref prefabObjectId);
|
||||
var prefabObject = prefab.GetDefaultInstance(prefabObjectId);
|
||||
if (prefabObject.PrefabID == _prefabId)
|
||||
break;
|
||||
_prefabId = prefabObject.PrefabID;
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (DropdownRect.Contains(ref location))
|
||||
if (DropdownRect.Contains(location))
|
||||
{
|
||||
Focus();
|
||||
ShowPicker();
|
||||
@@ -206,7 +206,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
{
|
||||
base.OnMouseMove(location);
|
||||
|
||||
if (DropdownRect.Contains(ref location))
|
||||
if (DropdownRect.Contains(location))
|
||||
Cursor = CursorType.Default;
|
||||
else
|
||||
Cursor = CursorType.IBeam;
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location))
|
||||
{
|
||||
_arrangeButtonInUse = true;
|
||||
Focus();
|
||||
@@ -371,7 +371,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location))
|
||||
{
|
||||
_arrangeButtonInUse = true;
|
||||
Focus();
|
||||
|
||||
@@ -321,11 +321,11 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
|
||||
|
||||
// Deselect
|
||||
if (_value != null && button1Rect.Contains(ref location))
|
||||
if (_value != null && button1Rect.Contains(location))
|
||||
Value = null;
|
||||
|
||||
// Picker dropdown menu
|
||||
if (_supportsPickDropDown && (isSelected ? button2Rect : button1Rect).Contains(ref location))
|
||||
if (_supportsPickDropDown && (isSelected ? button2Rect : button1Rect).Contains(location))
|
||||
{
|
||||
ShowDropDownMenu();
|
||||
return true;
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
/// <returns>The items.</returns>
|
||||
protected virtual List<ItemInfo> GetItemsForType(ScriptType type)
|
||||
{
|
||||
return GetItemsForType(type, type.IsClass, true);
|
||||
return GetItemsForType(type, type.IsClass, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -273,10 +273,14 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
var attributes = p.GetAttributes(true);
|
||||
var showInEditor = attributes.Any(x => x is ShowInEditorAttribute);
|
||||
|
||||
// Skip properties without getter or setter
|
||||
// Skip properties without getter
|
||||
if (!p.HasGet || (!p.HasSet && !showInEditor && !usePropertiesWithoutSetter))
|
||||
continue;
|
||||
|
||||
// Skip getter-only properties declared in built-in types
|
||||
if (!p.HasSet && usePropertiesWithoutSetter && p.Type.DeclaringType.Assembly == typeof(Editor).Assembly)
|
||||
continue;
|
||||
|
||||
// Skip hidden fields, handle special attributes
|
||||
if ((!p.IsPublic && !showInEditor) || attributes.Any(x => x is HideInEditorAttribute))
|
||||
continue;
|
||||
|
||||
@@ -219,11 +219,11 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
|
||||
|
||||
// Deselect
|
||||
if (_value && button1Rect.Contains(ref location) && _type == ScriptType.Null)
|
||||
if (_value && button1Rect.Contains(location) && _type == ScriptType.Null)
|
||||
Value = ScriptType.Null;
|
||||
|
||||
// Picker dropdown menu
|
||||
if ((isSelected && _type == ScriptType.Null ? button2Rect : button1Rect).Contains(ref location))
|
||||
if ((isSelected && _type == ScriptType.Null ? button2Rect : button1Rect).Contains(location))
|
||||
ShowDropDownMenu();
|
||||
|
||||
return base.OnMouseUp(location, button);
|
||||
|
||||
@@ -1056,7 +1056,7 @@ namespace FlaxEditor
|
||||
if (actor)
|
||||
{
|
||||
Internal_GetEditorBoxWithChildren(FlaxEngine.Object.GetUnmanagedPtr(actor), out var box);
|
||||
BoundingSphere.FromBox(ref box, out sphere);
|
||||
BoundingSphere.FromBox(box, out sphere);
|
||||
if (sphere == BoundingSphere.Empty)
|
||||
sphere = new BoundingSphere(actor.Position, sphere.Radius);
|
||||
sphere.Radius = Math.Max(sphere.Radius, 15.0f);
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace FlaxEditor.GUI
|
||||
private void DoDrag()
|
||||
{
|
||||
// Do the drag drop operation if has selected element
|
||||
if (new Rectangle(Float2.Zero, Size).Contains(ref _mouseDownPos))
|
||||
if (new Rectangle(Float2.Zero, Size).Contains(_mouseDownPos))
|
||||
{
|
||||
if (Validator.SelectedAsset != null)
|
||||
DoDragDrop(DragAssets.GetDragData(Validator.SelectedAsset));
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace FlaxEditor.GUI
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
{
|
||||
if (children[i] is KeyframePoint p)
|
||||
p.IsSelected = p.Bounds.Intersects(ref selectionRect);
|
||||
p.IsSelected = p.Bounds.Intersects(selectionRect);
|
||||
}
|
||||
_editor.UpdateTangents();
|
||||
}
|
||||
@@ -85,7 +85,7 @@ namespace FlaxEditor.GUI
|
||||
internal void OnMove(Float2 location)
|
||||
{
|
||||
// Skip updating keyframes until move actual starts to be meaningful
|
||||
if (Float2.Distance(ref _movingSelectionStartPosLock, ref location) < 1.5f)
|
||||
if (Float2.Distance(_movingSelectionStartPosLock, location) < 1.5f)
|
||||
return;
|
||||
_movingSelectionStartPosLock = Float2.Minimum;
|
||||
|
||||
|
||||
@@ -689,8 +689,8 @@ namespace FlaxEditor.GUI
|
||||
if (selectedOnly && !point.IsSelected)
|
||||
continue;
|
||||
var pos = point.Point;
|
||||
Float2.Min(ref posMin, ref pos, out posMin);
|
||||
Float2.Max(ref posMax, ref pos, out posMax);
|
||||
Float2.Min(posMin, pos, out posMin);
|
||||
Float2.Max(posMax, pos, out posMax);
|
||||
}
|
||||
|
||||
// Apply margin around the area
|
||||
@@ -703,16 +703,16 @@ namespace FlaxEditor.GUI
|
||||
PointFromKeyframesToContents(ref posMin, ref viewRect);
|
||||
PointFromKeyframesToContents(ref posMax, ref viewRect);
|
||||
var tmp = posMin;
|
||||
Float2.Min(ref posMin, ref posMax, out posMin);
|
||||
Float2.Max(ref posMax, ref tmp, out posMax);
|
||||
Float2.Min(posMin, posMax, out posMin);
|
||||
Float2.Max(posMax, tmp, out posMax);
|
||||
var contentsSize = posMax - posMin;
|
||||
|
||||
// Convert from Contents to Main Panel
|
||||
posMin = _contents.PointToParent(posMin);
|
||||
posMax = _contents.PointToParent(posMax);
|
||||
tmp = posMin;
|
||||
Float2.Min(ref posMin, ref posMax, out posMin);
|
||||
Float2.Max(ref posMax, ref tmp, out posMax);
|
||||
Float2.Min(posMin, posMax, out posMin);
|
||||
Float2.Max(posMax, tmp, out posMax);
|
||||
|
||||
// Update zoom (leave unchanged when focusing a single point)
|
||||
var zoomMask = EnableZoom;
|
||||
@@ -941,7 +941,7 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
SetupGrid(out var min, out var max, out var pixelRange);
|
||||
|
||||
Render2D.PushClip(ref viewRect);
|
||||
Render2D.PushClip(viewRect);
|
||||
|
||||
if ((ShowAxes & UseMode.Vertical) == UseMode.Vertical)
|
||||
DrawAxis(Float2.UnitX, viewRect, min.X, max.X, pixelRange.X);
|
||||
@@ -954,7 +954,7 @@ namespace FlaxEditor.GUI
|
||||
// Draw curve
|
||||
if (!_showCollapsed)
|
||||
{
|
||||
Render2D.PushClip(ref rect);
|
||||
Render2D.PushClip(rect);
|
||||
DrawCurve(ref viewRect);
|
||||
Render2D.PopClip();
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace FlaxEditor.GUI.Input
|
||||
Focus();
|
||||
float mousePosition = location.X;
|
||||
|
||||
if (_thumbRect.Contains(ref location))
|
||||
if (_thumbRect.Contains(location))
|
||||
{
|
||||
// Start sliding
|
||||
_isSliding = true;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
var k = keyframes[i];
|
||||
|
||||
var sphere = new BoundingSphere(k.Value, KeyframeSize);
|
||||
if (sphere.Intersects(ref selectRay))
|
||||
if (sphere.Intersects(selectRay))
|
||||
{
|
||||
SelectKeyframe(_track, i, 0);
|
||||
return;
|
||||
@@ -154,7 +154,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
{
|
||||
var t = k.Value + k.TangentIn;
|
||||
var box = BoundingBox.FromSphere(new BoundingSphere(t, TangentSize));
|
||||
if (box.Intersects(ref selectRay))
|
||||
if (box.Intersects(selectRay))
|
||||
{
|
||||
SelectKeyframe(_track, i, 1);
|
||||
return;
|
||||
@@ -165,7 +165,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
{
|
||||
var t = k.Value + k.TangentOut;
|
||||
var box = BoundingBox.FromSphere(new BoundingSphere(t, TangentSize));
|
||||
if (box.Intersects(ref selectRay))
|
||||
if (box.Intersects(selectRay))
|
||||
{
|
||||
SelectKeyframe(_track, i, 2);
|
||||
return;
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Float2 location)
|
||||
{
|
||||
if (_isMoving && Float2.DistanceSquared(ref location, ref _startMovePos) > 25.0f)
|
||||
if (_isMoving && Float2.DistanceSquared(location, _startMovePos) > 25.0f)
|
||||
{
|
||||
_startMovePos = Float2.Minimum;
|
||||
var x = PointToParent(location).X;
|
||||
@@ -387,7 +387,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
|
||||
{
|
||||
// Push clipping mask
|
||||
GetDesireClientArea(out var clientArea);
|
||||
Render2D.PushClip(ref clientArea);
|
||||
Render2D.PushClip(clientArea);
|
||||
|
||||
var style = Style.Current;
|
||||
var bounds = new Rectangle(Float2.Zero, Size);
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
if (Children[i] is KeyframePoint p)
|
||||
{
|
||||
p.IsSelected = p.Bounds.Intersects(ref selectionRect);
|
||||
p.IsSelected = p.Bounds.Intersects(selectionRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,7 +401,7 @@ namespace FlaxEditor.GUI
|
||||
Cursor = CursorType.Default;
|
||||
|
||||
// Check if no move has been made at all
|
||||
if (Float2.Distance(ref location, ref _rightMouseDownPos) < 2.0f)
|
||||
if (Float2.Distance(location, _rightMouseDownPos) < 2.0f)
|
||||
{
|
||||
var selectionCount = _editor.SelectionCount;
|
||||
var point = GetChildAt(location) as KeyframePoint;
|
||||
|
||||
@@ -50,14 +50,14 @@ namespace FlaxEditor.GUI.Timeline.GUI
|
||||
var color = (_timeline.IsMovingPositionHandle ? style.SelectionBorder : style.Foreground).AlphaMultiplied(0.6f);
|
||||
Matrix3x3.RotationZ(Mathf.PiOverTwo, out var m1);
|
||||
var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset);
|
||||
Matrix3x3.Multiply(ref m1, ref m2, out var m3);
|
||||
Render2D.PushTransform(ref m3);
|
||||
Matrix3x3.Multiply(m1, m2, out var m3);
|
||||
Render2D.PushTransform(m3);
|
||||
// TODO: Convert to its own sprite or 9 slice
|
||||
Render2D.DrawSprite(icon, new Rectangle(new Float2(10, -icon.Size.X * 0.5f - 1), Size + new Float2(0, 1)), color);
|
||||
Render2D.FillRectangle(new Rectangle(new Float2(-6, -icon.Size.Y * 0.5f + 7), new Float2(timeAxisOverlap, 5)), color);
|
||||
Render2D.PopTransform();
|
||||
var textMatrix = Matrix3x3.Translation2D(12, timeAxisHeaderOffset);
|
||||
Render2D.PushTransform(ref textMatrix);
|
||||
Render2D.PushTransform(textMatrix);
|
||||
Render2D.DrawText(style.FontSmall, labelText, style.Foreground, new Float2(2, -6));
|
||||
Render2D.PopTransform();
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
{
|
||||
Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, moveColor, moveThickness);
|
||||
}
|
||||
else if (IsMouseOver && CanResize && MoveLeftEdgeRect.Contains(ref _mouseLocation))
|
||||
else if (IsMouseOver && CanResize && MoveLeftEdgeRect.Contains(_mouseLocation))
|
||||
{
|
||||
Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, Color.Yellow);
|
||||
}
|
||||
@@ -364,7 +364,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
{
|
||||
Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, moveColor, moveThickness);
|
||||
}
|
||||
else if (IsMouseOver && CanResize && MoveRightEdgeRect.Contains(ref _mouseLocation))
|
||||
else if (IsMouseOver && CanResize && MoveRightEdgeRect.Contains(_mouseLocation))
|
||||
{
|
||||
Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, Color.Yellow);
|
||||
}
|
||||
@@ -384,8 +384,8 @@ namespace FlaxEditor.GUI.Timeline
|
||||
_startMoveLocation = Root.MousePosition;
|
||||
_startMoveStartFrame = StartFrame;
|
||||
_startMoveDuration = DurationFrames;
|
||||
_startMoveLeftEdge = MoveLeftEdgeRect.Contains(ref location) && CanResize;
|
||||
_startMoveRightEdge = MoveRightEdgeRect.Contains(ref location) && CanResize;
|
||||
_startMoveLeftEdge = MoveLeftEdgeRect.Contains(location) && CanResize;
|
||||
_startMoveRightEdge = MoveRightEdgeRect.Contains(location) && CanResize;
|
||||
StartMouseCapture(true);
|
||||
if (_startMoveLeftEdge || _startMoveRightEdge)
|
||||
return true;
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
DebugDraw.DrawSphere(sphere, selected ? Color.Yellow : Color.Red);
|
||||
sphere.Radius *= 0.95f;
|
||||
DebugDraw.DrawSphere(sphere, new Color(1, 0, 0, coveredAlpha), 0, false);
|
||||
if (select && sphere.Intersects(ref selectRay))
|
||||
if (select && sphere.Intersects(selectRay))
|
||||
SelectKeyframeGizmo(curveTrack, i, 0);
|
||||
|
||||
if (!k.TangentIn.IsZero)
|
||||
@@ -349,7 +349,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
var box = BoundingBox.FromSphere(new BoundingSphere(t, EditCurveTrackGizmo.TangentSize));
|
||||
DebugDraw.DrawBox(box, selected ? Color.Yellow : Color.AliceBlue);
|
||||
DebugDraw.DrawBox(box, Color.AliceBlue.AlphaMultiplied(coveredAlpha), 0, false);
|
||||
if (select && box.Intersects(ref selectRay))
|
||||
if (select && box.Intersects(selectRay))
|
||||
SelectKeyframeGizmo(curveTrack, i, 2);
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
var box = BoundingBox.FromSphere(new BoundingSphere(t, EditCurveTrackGizmo.TangentSize));
|
||||
DebugDraw.DrawBox(box, selected ? Color.Yellow : Color.AliceBlue);
|
||||
DebugDraw.DrawBox(box, Color.AliceBlue.AlphaMultiplied(coveredAlpha), 0, false);
|
||||
if (select && box.Intersects(ref selectRay))
|
||||
if (select && box.Intersects(selectRay))
|
||||
SelectKeyframeGizmo(curveTrack, i, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -2078,7 +2078,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
if (button == MouseButton.Right && _isRightMouseButtonDown)
|
||||
{
|
||||
_isRightMouseButtonDown = false;
|
||||
if (Float2.Distance(ref location, ref _rightMouseButtonDownPos) < 4.0f)
|
||||
if (Float2.Distance(location, _rightMouseButtonDownPos) < 4.0f)
|
||||
ShowContextMenu(location);
|
||||
}
|
||||
|
||||
@@ -2243,7 +2243,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
|
||||
foreach (var media in _tracks[i].Media)
|
||||
{
|
||||
if (media.Bounds.Intersects(ref mediaRect))
|
||||
if (media.Bounds.Intersects(mediaRect))
|
||||
{
|
||||
SelectedMedia.Add(media);
|
||||
selectionChanged = true;
|
||||
|
||||
@@ -810,7 +810,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
/// <returns>True if hits it.</returns>
|
||||
protected virtual bool TestHeaderHit(ref Float2 location)
|
||||
{
|
||||
return new Rectangle(0, 0, Width, HeaderHeight).Contains(ref location);
|
||||
return new Rectangle(0, 0, Width, HeaderHeight).Contains(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
// Hit-test dot
|
||||
var size = Height - 2.0f;
|
||||
var rect = new Rectangle(new Float2(size * -0.5f) + Size * 0.5f, new Float2(size));
|
||||
return rect.Contains(ref location);
|
||||
return rect.Contains(location);
|
||||
}
|
||||
|
||||
return base.ContainsPoint(ref location, precise);
|
||||
|
||||
@@ -527,7 +527,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
{
|
||||
_output = GPUDevice.Instance.CreateTexture("CameraCutMedia.Output");
|
||||
var desc = GPUTextureDescription.New2D(Width, Height, PixelFormat.R8G8B8A8_UNorm);
|
||||
_output.Init(ref desc);
|
||||
_output.Init(desc);
|
||||
}
|
||||
if (_task == null)
|
||||
{
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
}
|
||||
|
||||
var nodeArea = new Rectangle(pos, child.Size);
|
||||
if (child.IsExpanded && range.Intersects(ref nodeArea))
|
||||
if (child.IsExpanded && range.Intersects(nodeArea))
|
||||
WalkSelectRangeExpandedTree(selection, child, ref range);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
/// <returns>True if hits it.</returns>
|
||||
protected virtual bool TestHeaderHit(ref Float2 location)
|
||||
{
|
||||
return _headerRect.Contains(ref location);
|
||||
return _headerRect.Contains(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -864,14 +864,14 @@ namespace FlaxEditor.GUI.Tree
|
||||
var child = children[i];
|
||||
if (!child.Visible)
|
||||
continue;
|
||||
Render2D.PushTransform(ref child._cachedTransform);
|
||||
Render2D.PushTransform(child._cachedTransform);
|
||||
child.Draw();
|
||||
Render2D.PopTransform();
|
||||
}
|
||||
|
||||
static Rectangle GetChildGlobalRectangle(Control control, ref Matrix3x3 globalTransform)
|
||||
{
|
||||
Matrix3x3.Multiply(ref control._cachedTransform, ref globalTransform, out var globalChildTransform);
|
||||
Matrix3x3.Multiply(control._cachedTransform, globalTransform, out var globalChildTransform);
|
||||
return new Rectangle(globalChildTransform.M31, globalChildTransform.M32, control.Width * globalChildTransform.M11, control.Height * globalChildTransform.M22);
|
||||
}
|
||||
}
|
||||
@@ -882,7 +882,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
var child = children[i];
|
||||
if (child.Visible)
|
||||
{
|
||||
Render2D.PushTransform(ref child._cachedTransform);
|
||||
Render2D.PushTransform(child._cachedTransform);
|
||||
child.Draw();
|
||||
Render2D.PopTransform();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace FlaxEditor.GUI.Tree
|
||||
|
||||
foreach (var child in Addons)
|
||||
{
|
||||
Render2D.PushTransform(ref child._cachedTransform);
|
||||
Render2D.PushTransform(child._cachedTransform);
|
||||
child.Draw();
|
||||
Render2D.PopTransform();
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ namespace FlaxEditor.Gizmo
|
||||
var width = output.Width;
|
||||
var height = output.Height;
|
||||
var desc = GPUTextureDescription.New2D(width, height, format, GPUTextureFlags.RenderTarget | GPUTextureFlags.ShaderResource, 1, 1, msaaLevel);
|
||||
var target = RenderTargetPool.Get(ref desc);
|
||||
var target = RenderTargetPool.Get(desc);
|
||||
desc = GPUTextureDescription.New2D(width, height, PixelFormat.D24_UNorm_S8_UInt, GPUTextureFlags.DepthStencil, 1, 1, msaaLevel);
|
||||
var targetDepth = RenderTargetPool.Get(ref desc);
|
||||
var targetDepth = RenderTargetPool.Get(desc);
|
||||
|
||||
// Copy frame and clear depth
|
||||
context.Draw(target, input);
|
||||
@@ -81,16 +81,16 @@ namespace FlaxEditor.Gizmo
|
||||
}
|
||||
|
||||
// Sort draw calls
|
||||
renderList.SortDrawCalls(ref renderContext, false, DrawCallsListType.GBuffer);
|
||||
renderList.SortDrawCalls(ref renderContext, false, DrawCallsListType.GBufferNoDecals);
|
||||
renderList.SortDrawCalls(ref renderContext, true, DrawCallsListType.Forward);
|
||||
renderList.SortDrawCalls(renderContext, false, DrawCallsListType.GBuffer);
|
||||
renderList.SortDrawCalls(renderContext, false, DrawCallsListType.GBufferNoDecals);
|
||||
renderList.SortDrawCalls(renderContext, true, DrawCallsListType.Forward);
|
||||
|
||||
// Perform the rendering
|
||||
renderContext.View.Pass = DrawPass.GBuffer;
|
||||
renderList.ExecuteDrawCalls(ref renderContext, DrawCallsListType.GBuffer);
|
||||
renderList.ExecuteDrawCalls(ref renderContext, DrawCallsListType.GBufferNoDecals);
|
||||
renderList.ExecuteDrawCalls(renderContext, DrawCallsListType.GBuffer);
|
||||
renderList.ExecuteDrawCalls(renderContext, DrawCallsListType.GBufferNoDecals);
|
||||
renderContext.View.Pass = DrawPass.Forward;
|
||||
renderList.ExecuteDrawCalls(ref renderContext, DrawCallsListType.Forward);
|
||||
renderList.ExecuteDrawCalls(renderContext, DrawCallsListType.Forward);
|
||||
|
||||
// Resolve MSAA texture
|
||||
if (enableMsaa)
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace FlaxEditor.Gizmo
|
||||
_vertexBuffer = new GPUBuffer();
|
||||
var layout = GPUVertexLayout.Get([new VertexElement(VertexElement.Types.Position, 0, 0, false, PixelFormat.R32G32B32_Float)]);
|
||||
var desc = GPUBufferDescription.Vertex(layout, sizeof(Float3), 4);
|
||||
_vertexBuffer.Init(ref desc);
|
||||
_vertexBuffer.Init(desc);
|
||||
}
|
||||
if (_indexBuffer == null)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ namespace FlaxEditor.Gizmo
|
||||
fixed (uint* ptr = _triangles)
|
||||
{
|
||||
var desc = GPUBufferDescription.Index(sizeof(uint), _triangles.Length, new IntPtr(ptr));
|
||||
_indexBuffer.Init(ref desc);
|
||||
_indexBuffer.Init(desc);
|
||||
}
|
||||
}
|
||||
if (_psGrid == null)
|
||||
@@ -90,7 +90,7 @@ namespace FlaxEditor.Gizmo
|
||||
desc.VS = _shader.GPU.GetVS("VS_Grid");
|
||||
desc.PS = _shader.GPU.GetPS("PS_Grid");
|
||||
desc.DepthWriteEnable = false;
|
||||
_psGrid.Init(ref desc);
|
||||
_psGrid.Init(desc);
|
||||
}
|
||||
|
||||
// Update vertices of the plane
|
||||
@@ -113,8 +113,8 @@ namespace FlaxEditor.Gizmo
|
||||
if (cb != IntPtr.Zero)
|
||||
{
|
||||
var data = new Data();
|
||||
Matrix.Multiply(ref renderContext.View.View, ref renderContext.View.Projection, out var viewProjection);
|
||||
Matrix.Transpose(ref viewProjection, out data.ViewProjectionMatrix);
|
||||
Matrix.Multiply(renderContext.View.View, renderContext.View.Projection, out var viewProjection);
|
||||
Matrix.Transpose(viewProjection, out data.ViewProjectionMatrix);
|
||||
data.ViewPos = renderContext.View.WorldPosition;
|
||||
data.GridColor = options.Viewport.ViewportGridColor;
|
||||
data.Far = renderContext.View.Far;
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace FlaxEditor.Gizmo
|
||||
|
||||
// Pick a temporary depth buffer
|
||||
var desc = GPUTextureDescription.New2D(input.Width, input.Height, PixelFormat.D32_Float, GPUTextureFlags.DepthStencil | GPUTextureFlags.ShaderResource);
|
||||
var customDepth = RenderTargetPool.Get(ref desc);
|
||||
var customDepth = RenderTargetPool.Get(desc);
|
||||
context.ClearDepth(customDepth.View());
|
||||
|
||||
// Draw objects to depth buffer
|
||||
@@ -148,7 +148,7 @@ namespace FlaxEditor.Gizmo
|
||||
_material.SetParameterValue("OutlineColor1", _color1);
|
||||
_material.SetParameterValue("CustomDepth", customDepth);
|
||||
_material.SetParameterValue("ViewInfo", new Float4(1.0f / projection.M11, 1.0f / projection.M22, far / (far - near), (-far * near) / (far - near) / far));
|
||||
Renderer.DrawPostFxMaterial(context, ref renderContext, _material, output, input.View());
|
||||
Renderer.DrawPostFxMaterial(context, renderContext, _material, output, input.View());
|
||||
|
||||
// Cleanup
|
||||
RenderTargetPool.Release(customDepth);
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace FlaxEditor.Gizmo
|
||||
if (_selectionParents[i] is ActorNode actorNode)
|
||||
{
|
||||
var b = actorNode.Actor.EditorBoxChildren;
|
||||
BoundingBox.Merge(ref editorBounds, ref b, out editorBounds);
|
||||
BoundingBox.Merge(editorBounds, b, out editorBounds);
|
||||
bottomToCenter = Mathf.Min(bottomToCenter, actorNode.Actor.Position.Y - editorBounds.Minimum.Y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace FlaxEditor.Gizmo
|
||||
Mesh sphereMesh = _modelSphere.LODs[0].Meshes[0];
|
||||
|
||||
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m3);
|
||||
Matrix.Multiply(ref m3, ref world, out m1);
|
||||
Matrix.Multiply(m3, world, out m1);
|
||||
mx1 = m1;
|
||||
mx1.M41 += 0.05f;
|
||||
|
||||
@@ -149,44 +149,44 @@ namespace FlaxEditor.Gizmo
|
||||
|
||||
// X axis
|
||||
Matrix.RotationY(-Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance xAxisMaterialTransform = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
transAxisMesh.Draw(ref renderContext, xAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
transAxisMesh.Draw(renderContext, xAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Y axis
|
||||
Matrix.RotationX(Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance yAxisMaterialTransform = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
transAxisMesh.Draw(ref renderContext, yAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
transAxisMesh.Draw(renderContext, yAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Z axis
|
||||
Matrix.RotationX(Mathf.Pi, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance zAxisMaterialTransform = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
transAxisMesh.Draw(ref renderContext, zAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
transAxisMesh.Draw(renderContext, zAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// XY plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance xyPlaneMaterialTransform = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
cubeMesh.Draw(ref renderContext, xyPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
cubeMesh.Draw(renderContext, xyPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// ZX plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance zxPlaneMaterialTransform = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
cubeMesh.Draw(ref renderContext, zxPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
cubeMesh.Draw(renderContext, zxPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// YZ plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance yzPlaneMaterialTransform = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
cubeMesh.Draw(ref renderContext, yzPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
cubeMesh.Draw(renderContext, yzPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Center sphere
|
||||
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
sphereMesh.Draw(ref renderContext, isCenter ? _materialAxisFocus : _materialSphere, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -199,24 +199,24 @@ namespace FlaxEditor.Gizmo
|
||||
|
||||
// X axis
|
||||
Matrix.RotationZ(Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
rotationAxisMesh.Draw(ref renderContext, xAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
rotationAxisMesh.Draw(renderContext, xAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Y axis
|
||||
MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
rotationAxisMesh.Draw(ref renderContext, yAxisMaterialRotate, ref m1, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
rotationAxisMesh.Draw(renderContext, yAxisMaterialRotate, m1, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Z axis
|
||||
Matrix.RotationX(-Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
rotationAxisMesh.Draw(ref renderContext, zAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
rotationAxisMesh.Draw(renderContext, zAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Center box
|
||||
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
sphereMesh.Draw(ref renderContext, isCenter ? _materialAxisFocus : _materialSphere, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -229,44 +229,44 @@ namespace FlaxEditor.Gizmo
|
||||
|
||||
// X axis
|
||||
Matrix.RotationY(-Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref mx1, out m3);
|
||||
Matrix.Multiply(m2, mx1, out m3);
|
||||
MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
scaleAxisMesh.Draw(ref renderContext, xAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
scaleAxisMesh.Draw(renderContext, xAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Y axis
|
||||
Matrix.RotationX(Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
scaleAxisMesh.Draw(ref renderContext, yAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
scaleAxisMesh.Draw(renderContext, yAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Z axis
|
||||
Matrix.RotationX(Mathf.Pi, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
scaleAxisMesh.Draw(ref renderContext, zAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
scaleAxisMesh.Draw(renderContext, zAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// XY plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance xyPlaneMaterialScale = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
cubeMesh.Draw(ref renderContext, xyPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
cubeMesh.Draw(renderContext, xyPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// ZX plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance zxPlaneMaterialScale = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
cubeMesh.Draw(ref renderContext, zxPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
cubeMesh.Draw(renderContext, zxPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// YZ plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
MaterialInstance yzPlaneMaterialScale = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
cubeMesh.Draw(ref renderContext, yzPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
cubeMesh.Draw(renderContext, yzPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Center box
|
||||
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
sphereMesh.Draw(ref renderContext, isCenter ? _materialAxisFocus : _materialSphere, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
Matrix.Multiply(m2, m1, out m3);
|
||||
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ namespace FlaxEditor.Gizmo
|
||||
Transform t = _vertexSnapObject?.Transform ?? _vertexSnapObjectTo.Transform;
|
||||
Vector3 p = t.LocalToWorld(_vertexSnapObject != null ? _vertexSnapPoint : _vertexSnapPointTo);
|
||||
Matrix matrix = new Transform(p, t.Orientation, new Float3(gizmoModelsScale2RealGizmoSize)).GetWorld();
|
||||
cubeMesh.Draw(ref renderContext, _materialSphere, ref matrix, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
cubeMesh.Draw(renderContext, _materialSphere, matrix, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace FlaxEditor.Gizmo
|
||||
private bool IntersectsRotateCircle(Vector3 normal, ref Ray ray, out Real distance)
|
||||
{
|
||||
var plane = new Plane(Vector3.Zero, normal);
|
||||
if (!plane.Intersects(ref ray, out distance))
|
||||
if (!plane.Intersects(ray, out distance))
|
||||
return false;
|
||||
Vector3 hitPoint = ray.Position + ray.Direction * distance;
|
||||
Real distanceNormalized = hitPoint.Length / RotateRadiusRaw;
|
||||
@@ -50,8 +50,8 @@ namespace FlaxEditor.Gizmo
|
||||
|
||||
// Transform ray into local space of the gizmo
|
||||
Ray localRay;
|
||||
_gizmoWorld.WorldToLocalVector(ref ray.Direction, out localRay.Direction);
|
||||
_gizmoWorld.WorldToLocal(ref ray.Position, out localRay.Position);
|
||||
_gizmoWorld.WorldToLocalVector(ray.Direction, out localRay.Direction);
|
||||
_gizmoWorld.WorldToLocal(ray.Position, out localRay.Position);
|
||||
|
||||
// Find gizmo collisions with mouse
|
||||
Real closestIntersection = Real.MaxValue;
|
||||
@@ -62,19 +62,19 @@ namespace FlaxEditor.Gizmo
|
||||
case Mode.Translate:
|
||||
{
|
||||
// Axis boxes collision
|
||||
if (XAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
|
||||
if (XAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.X;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
|
||||
if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
|
||||
if (YAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.Y;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
|
||||
if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
|
||||
if (ZAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.Z;
|
||||
closestIntersection = intersection;
|
||||
@@ -83,25 +83,25 @@ namespace FlaxEditor.Gizmo
|
||||
// Quad planes collision
|
||||
if (closestIntersection >= float.MaxValue)
|
||||
closestIntersection = float.MinValue;
|
||||
if (XYBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
|
||||
if (XYBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.XY;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
|
||||
if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
|
||||
if (XZBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.ZX;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
if (YZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
|
||||
if (YZBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.YZ;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
|
||||
/*// Center
|
||||
if (CenterBoxRaw.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
|
||||
if (CenterBoxRaw.Intersects(localRay, out intersection) && intersection > closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.Center;
|
||||
closestIntersection = intersection;
|
||||
@@ -133,17 +133,17 @@ namespace FlaxEditor.Gizmo
|
||||
case Mode.Scale:
|
||||
{
|
||||
// Boxes collision
|
||||
if (XAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
|
||||
if (XAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.X;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
|
||||
if (YAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.Y;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
|
||||
if (ZAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.Z;
|
||||
closestIntersection = intersection;
|
||||
@@ -153,24 +153,24 @@ namespace FlaxEditor.Gizmo
|
||||
if (closestIntersection >= float.MaxValue)
|
||||
closestIntersection = float.MinValue;
|
||||
|
||||
if (XYBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
|
||||
if (XYBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.XY;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
|
||||
if (XZBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.ZX;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
if (YZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
|
||||
if (YZBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.YZ;
|
||||
closestIntersection = intersection;
|
||||
}
|
||||
|
||||
// Center
|
||||
if (CenterBoxRaw.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
|
||||
if (CenterBoxRaw.Intersects(localRay, out intersection) && intersection > closestIntersection)
|
||||
{
|
||||
_activeAxis = Axis.Center;
|
||||
closestIntersection = intersection;
|
||||
|
||||
@@ -212,10 +212,10 @@ namespace FlaxEditor.Gizmo
|
||||
Vector3 delta = Vector3.Zero;
|
||||
Ray ray = Owner.MouseRay;
|
||||
|
||||
Matrix.RotationQuaternion(ref _gizmoWorld.Orientation, out var rotationMatrix);
|
||||
Matrix.Invert(ref rotationMatrix, out var invRotationMatrix);
|
||||
Matrix.RotationQuaternion(_gizmoWorld.Orientation, out var rotationMatrix);
|
||||
Matrix.Invert(rotationMatrix, out var invRotationMatrix);
|
||||
ray.Position = Vector3.Transform(ray.Position, invRotationMatrix);
|
||||
Vector3.TransformNormal(ref ray.Direction, ref invRotationMatrix, out ray.Direction);
|
||||
Vector3.TransformNormal(ray.Direction, invRotationMatrix, out ray.Direction);
|
||||
|
||||
var position = Position;
|
||||
var planeXY = new Plane(Vector3.Backward, Vector3.Transform(position, invRotationMatrix).Z);
|
||||
@@ -232,7 +232,7 @@ namespace FlaxEditor.Gizmo
|
||||
case Axis.X:
|
||||
{
|
||||
var plane = planeDotXY > planeDotZX ? planeXY : planeZX;
|
||||
if (ray.Intersects(ref plane, out intersection))
|
||||
if (ray.Intersects(plane, out intersection))
|
||||
{
|
||||
_intersectPosition = ray.GetPoint(intersection);
|
||||
if (!_lastIntersectionPosition.IsZero)
|
||||
@@ -244,7 +244,7 @@ namespace FlaxEditor.Gizmo
|
||||
case Axis.Y:
|
||||
{
|
||||
var plane = planeDotXY > planeDotYZ ? planeXY : planeYZ;
|
||||
if (ray.Intersects(ref plane, out intersection))
|
||||
if (ray.Intersects(plane, out intersection))
|
||||
{
|
||||
_intersectPosition = ray.GetPoint(intersection);
|
||||
if (!_lastIntersectionPosition.IsZero)
|
||||
@@ -256,7 +256,7 @@ namespace FlaxEditor.Gizmo
|
||||
case Axis.Z:
|
||||
{
|
||||
var plane = planeDotZX > planeDotYZ ? planeZX : planeYZ;
|
||||
if (ray.Intersects(ref plane, out intersection))
|
||||
if (ray.Intersects(plane, out intersection))
|
||||
{
|
||||
_intersectPosition = ray.GetPoint(intersection);
|
||||
if (!_lastIntersectionPosition.IsZero)
|
||||
@@ -267,7 +267,7 @@ namespace FlaxEditor.Gizmo
|
||||
}
|
||||
case Axis.YZ:
|
||||
{
|
||||
if (ray.Intersects(ref planeYZ, out intersection))
|
||||
if (ray.Intersects(planeYZ, out intersection))
|
||||
{
|
||||
_intersectPosition = ray.GetPoint(intersection);
|
||||
if (!_lastIntersectionPosition.IsZero)
|
||||
@@ -288,7 +288,7 @@ namespace FlaxEditor.Gizmo
|
||||
}
|
||||
case Axis.XY:
|
||||
{
|
||||
if (ray.Intersects(ref planeXY, out intersection))
|
||||
if (ray.Intersects(planeXY, out intersection))
|
||||
{
|
||||
_intersectPosition = ray.GetPoint(intersection);
|
||||
if (!_lastIntersectionPosition.IsZero)
|
||||
@@ -309,7 +309,7 @@ namespace FlaxEditor.Gizmo
|
||||
}
|
||||
case Axis.ZX:
|
||||
{
|
||||
if (ray.Intersects(ref planeZX, out intersection))
|
||||
if (ray.Intersects(planeZX, out intersection))
|
||||
{
|
||||
_intersectPosition = ray.GetPoint(intersection);
|
||||
if (!_lastIntersectionPosition.IsZero)
|
||||
@@ -332,7 +332,7 @@ namespace FlaxEditor.Gizmo
|
||||
{
|
||||
var gizmoToView = Position - Owner.ViewPosition;
|
||||
var plane = new Plane(-Vector3.Normalize(gizmoToView), gizmoToView.Length);
|
||||
if (ray.Intersects(ref plane, out intersection))
|
||||
if (ray.Intersects(plane, out intersection))
|
||||
{
|
||||
_intersectPosition = ray.GetPoint(intersection);
|
||||
if (!_lastIntersectionPosition.IsZero)
|
||||
@@ -473,11 +473,11 @@ namespace FlaxEditor.Gizmo
|
||||
dir = Float3.Forward * _gizmoWorld.Orientation;
|
||||
|
||||
Float3 viewDir = Owner.ViewPosition - Position;
|
||||
Float3.Dot(ref viewDir, ref dir, out float dot);
|
||||
Float3.Dot(viewDir, dir, out float dot);
|
||||
if (dot < 0.0f)
|
||||
delta *= -1;
|
||||
|
||||
Quaternion.RotationAxis(ref dir, delta, out _rotationDelta);
|
||||
Quaternion.RotationAxis(dir, delta, out _rotationDelta);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace FlaxEditor
|
||||
{
|
||||
foreach (var widget in _widgets)
|
||||
{
|
||||
if (widget.Bounds.Contains(ref location))
|
||||
if (widget.Bounds.Contains(location))
|
||||
{
|
||||
// Initialize widget movement
|
||||
_activeWidget = widget;
|
||||
@@ -326,7 +326,7 @@ namespace FlaxEditor
|
||||
{
|
||||
foreach (var widget in _widgets)
|
||||
{
|
||||
if (widget.Bounds.Contains(ref location))
|
||||
if (widget.Bounds.Contains(location))
|
||||
{
|
||||
Cursor = widget.Cursor;
|
||||
cursorChanged = true;
|
||||
@@ -499,7 +499,7 @@ namespace FlaxEditor
|
||||
var min = Float2.Min(upperLeft, bottomRight);
|
||||
var max = Float2.Max(upperLeft, bottomRight);
|
||||
var pixelRange = (max - min) * ViewScale;
|
||||
Render2D.PushClip(ref viewRect);
|
||||
Render2D.PushClip(viewRect);
|
||||
DrawAxis(Float2.UnitX, viewRect, min.X, max.X, pixelRange.X);
|
||||
DrawAxis(Float2.UnitY, viewRect, min.Y, max.Y, pixelRange.Y);
|
||||
Render2D.PopClip();
|
||||
@@ -605,7 +605,7 @@ namespace FlaxEditor
|
||||
if (!drawAnySelectedControl)
|
||||
{
|
||||
drawAnySelectedControl = true;
|
||||
Render2D.PushTransform(ref _cachedTransform);
|
||||
Render2D.PushTransform(_cachedTransform);
|
||||
}
|
||||
var options = Editor.Instance.Options.Options.Visual;
|
||||
|
||||
@@ -643,10 +643,10 @@ namespace FlaxEditor
|
||||
DrawControlWidget(uiControl, ref ur, ref mousePos, ref widgetHandleSize, viewScale, new Float2(1, -1), CursorType.SizeNESW);
|
||||
DrawControlWidget(uiControl, ref bl, ref mousePos, ref widgetHandleSize, viewScale, new Float2(-1, 1), CursorType.SizeNESW);
|
||||
DrawControlWidget(uiControl, ref br, ref mousePos, ref widgetHandleSize, viewScale, new Float2(1, 1), CursorType.SizeNWSE);
|
||||
Float2.Lerp(ref ul, ref bl, 0.5f, out var el);
|
||||
Float2.Lerp(ref ur, ref br, 0.5f, out var er);
|
||||
Float2.Lerp(ref ul, ref ur, 0.5f, out var eu);
|
||||
Float2.Lerp(ref bl, ref br, 0.5f, out var eb);
|
||||
Float2.Lerp(ul, bl, 0.5f, out var el);
|
||||
Float2.Lerp(ur, br, 0.5f, out var er);
|
||||
Float2.Lerp(ul, ur, 0.5f, out var eu);
|
||||
Float2.Lerp(bl, br, 0.5f, out var eb);
|
||||
DrawControlWidget(uiControl, ref el, ref mousePos, ref widgetHandleSize, viewScale, new Float2(-1, 0), CursorType.SizeWE);
|
||||
DrawControlWidget(uiControl, ref er, ref mousePos, ref widgetHandleSize, viewScale, new Float2(1, 0), CursorType.SizeWE);
|
||||
DrawControlWidget(uiControl, ref eu, ref mousePos, ref widgetHandleSize, viewScale, new Float2(0, -1), CursorType.SizeNS);
|
||||
@@ -749,7 +749,7 @@ namespace FlaxEditor
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (rect.Contains(ref mousePos))
|
||||
if (rect.Contains(mousePos))
|
||||
{
|
||||
Render2D.FillRectangle(rect, style.Foreground);
|
||||
Render2D.DrawRectangle(rect, style.SelectionBorder);
|
||||
|
||||
@@ -124,7 +124,7 @@ public sealed class ViewportRubberBandSelector
|
||||
public void ProjectPoint(Vector3 worldSpaceLocation, out Float2 viewportSpaceLocation)
|
||||
{
|
||||
worldSpaceLocation -= _origin;
|
||||
_viewport.Project(ref worldSpaceLocation, ref _viewProjection, out var projected);
|
||||
_viewport.Project(worldSpaceLocation, _viewProjection, out var projected);
|
||||
viewportSpaceLocation = new Float2((float)projected.X, (float)projected.Y);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public sealed class ViewportRubberBandSelector
|
||||
{
|
||||
bounds.Minimum -= _origin;
|
||||
bounds.Maximum -= _origin;
|
||||
return _frustum.Contains(ref bounds);
|
||||
return _frustum.Contains(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ Window* ManagedEditor::GetMainWindow()
|
||||
ASSERT(HasManagedInstance());
|
||||
const auto method = GetClass()->GetMethod("GetMainWindowPtr");
|
||||
ASSERT(method);
|
||||
return (Window*)MUtils::Unbox<void*>(method->Invoke(GetManagedInstance(), nullptr, nullptr));
|
||||
return (Window*)MUtils::Unbox<void*>(method->Invoke(GetManagedInstance(), nullptr, nullptr), true);
|
||||
}
|
||||
|
||||
bool ManagedEditor::CanReloadScripts()
|
||||
@@ -346,7 +346,7 @@ bool ManagedEditor::CanReloadScripts()
|
||||
Internal_CanReloadScripts = GetClass()->GetMethod("Internal_CanReloadScripts");
|
||||
ASSERT(Internal_CanReloadScripts);
|
||||
}
|
||||
return MUtils::Unbox<bool>(Internal_CanReloadScripts->Invoke(GetManagedInstance(), nullptr, nullptr));
|
||||
return MUtils::Unbox<bool>(Internal_CanReloadScripts->Invoke(GetManagedInstance(), nullptr, nullptr), true);
|
||||
}
|
||||
|
||||
bool ManagedEditor::CanAutoBuildCSG()
|
||||
@@ -365,7 +365,7 @@ bool ManagedEditor::CanAutoBuildCSG()
|
||||
Internal_CanAutoBuildCSG = GetClass()->GetMethod("Internal_CanAutoBuildCSG");
|
||||
ASSERT(Internal_CanAutoBuildCSG);
|
||||
}
|
||||
return MUtils::Unbox<bool>(Internal_CanAutoBuildCSG->Invoke(GetManagedInstance(), nullptr, nullptr));
|
||||
return MUtils::Unbox<bool>(Internal_CanAutoBuildCSG->Invoke(GetManagedInstance(), nullptr, nullptr), true);
|
||||
}
|
||||
|
||||
bool ManagedEditor::CanAutoBuildNavMesh()
|
||||
@@ -384,7 +384,7 @@ bool ManagedEditor::CanAutoBuildNavMesh()
|
||||
Internal_CanAutoBuildNavMesh = GetClass()->GetMethod("Internal_CanAutoBuildNavMesh");
|
||||
ASSERT(Internal_CanAutoBuildNavMesh);
|
||||
}
|
||||
return MUtils::Unbox<bool>(Internal_CanAutoBuildNavMesh->Invoke(GetManagedInstance(), nullptr, nullptr));
|
||||
return MUtils::Unbox<bool>(Internal_CanAutoBuildNavMesh->Invoke(GetManagedInstance(), nullptr, nullptr), true);
|
||||
}
|
||||
|
||||
bool ManagedEditor::HasGameViewportFocus() const
|
||||
@@ -397,7 +397,7 @@ bool ManagedEditor::HasGameViewportFocus() const
|
||||
Internal_HasGameViewportFocus = GetClass()->GetMethod("Internal_HasGameViewportFocus");
|
||||
ASSERT(Internal_HasGameViewportFocus);
|
||||
}
|
||||
result = MUtils::Unbox<bool>(Internal_HasGameViewportFocus->Invoke(GetManagedInstance(), nullptr, nullptr));
|
||||
result = MUtils::Unbox<bool>(Internal_HasGameViewportFocus->Invoke(GetManagedInstance(), nullptr, nullptr), true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ bool ManagedEditor::OnAppExit()
|
||||
Internal_OnAppExit = GetClass()->GetMethod("Internal_OnAppExit");
|
||||
ASSERT(Internal_OnAppExit);
|
||||
}
|
||||
return MUtils::Unbox<bool>(Internal_OnAppExit->Invoke(GetManagedInstance(), nullptr, nullptr));
|
||||
return MUtils::Unbox<bool>(Internal_OnAppExit->Invoke(GetManagedInstance(), nullptr, nullptr), true);
|
||||
}
|
||||
|
||||
void ManagedEditor::RequestStartPlayOnEditMode()
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace FlaxEditor.SceneGraph
|
||||
}
|
||||
|
||||
var center = _actor.Transform.Translation;
|
||||
ViewportIconsRenderer.GetBounds(ref center, ref ray.Ray.Position, out var sphere);
|
||||
return CollisionsHelper.RayIntersectsSphere(ref ray.Ray, ref sphere, out distance);
|
||||
ViewportIconsRenderer.GetBounds(center, ray.Ray.Position, out var sphere);
|
||||
return CollisionsHelper.RayIntersectsSphere(ray.Ray, sphere, out distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,10 +109,10 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
|
||||
// Skin vertex position with the current pose
|
||||
var position = positionStream.GetFloat3(j);
|
||||
Float3.Transform(ref position, ref skinningMatrices[indices[0]], out Float3 pos0);
|
||||
Float3.Transform(ref position, ref skinningMatrices[indices[1]], out Float3 pos1);
|
||||
Float3.Transform(ref position, ref skinningMatrices[indices[2]], out Float3 pos2);
|
||||
Float3.Transform(ref position, ref skinningMatrices[indices[3]], out Float3 pos3);
|
||||
Float3.Transform(position, skinningMatrices[indices[0]], out Float3 pos0);
|
||||
Float3.Transform(position, skinningMatrices[indices[1]], out Float3 pos1);
|
||||
Float3.Transform(position, skinningMatrices[indices[2]], out Float3 pos2);
|
||||
Float3.Transform(position, skinningMatrices[indices[3]], out Float3 pos3);
|
||||
position = pos0 * weights[0] + pos1 * weights[1] + pos2 * weights[2] + pos3 * weights[3];
|
||||
|
||||
// Add vertex to the bone list
|
||||
@@ -269,8 +269,8 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
for (int i = 0; i < boneVertices.Count; i++)
|
||||
{
|
||||
var pos = boneTransform.WorldToLocal(boneVertices[i]);
|
||||
Vector3.Min(ref boneLocalBounds.Minimum, ref pos, out boneLocalBounds.Minimum);
|
||||
Vector3.Max(ref boneLocalBounds.Maximum, ref pos, out boneLocalBounds.Maximum);
|
||||
Vector3.Min(boneLocalBounds.Minimum, pos, out boneLocalBounds.Minimum);
|
||||
Vector3.Max(boneLocalBounds.Maximum, pos, out boneLocalBounds.Maximum);
|
||||
}
|
||||
|
||||
// Add collision shape
|
||||
@@ -415,7 +415,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
float bkLength = bk.Length;
|
||||
if (bkLength > 0.0f)
|
||||
{
|
||||
Float3.Transform(ref bk, ref matrix, out Float3 bkA);
|
||||
Float3.Transform(bk, matrix, out Float3 bkA);
|
||||
bk = bkA / bkLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
/// <inheritdoc />
|
||||
public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal)
|
||||
{
|
||||
return Brush.Intersects(Index, ref ray.Ray, out distance, out normal);
|
||||
return Brush.Intersects(Index, ray.Ray, out distance, out normal);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -207,7 +207,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
/// <inheritdoc />
|
||||
public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal)
|
||||
{
|
||||
if (((BoxBrush)_actor).OrientedBox.Intersects(ref ray.Ray))
|
||||
if (((BoxBrush)_actor).OrientedBox.Intersects(ray.Ray))
|
||||
{
|
||||
for (int i = 0; i < ChildNodes.Count; i++)
|
||||
{
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
{
|
||||
normal = Vector3.Up;
|
||||
var sphere = new BoundingSphere(Transform.Translation, 10.0f);
|
||||
return sphere.Intersects(ref ray.Ray, out distance);
|
||||
return sphere.Intersects(ray.Ray, out distance);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
return false;
|
||||
}
|
||||
|
||||
return Camera.Internal_IntersectsItselfEditor(FlaxEngine.Object.GetUnmanagedPtr(_actor), ref ray.Ray, out distance);
|
||||
return Camera.Internal_IntersectsItselfEditor(FlaxEngine.Object.GetUnmanagedPtr(_actor), ray.Ray, out distance);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
public override Transform Transform
|
||||
{
|
||||
get => Actor.GetInstance(Index).Transform;
|
||||
set => Actor.SetInstanceTransform(Index, ref value);
|
||||
set => Actor.SetInstanceTransform(Index, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
{
|
||||
normal = Vector3.Up;
|
||||
var sphere = new BoundingSphere(Transform.Translation, 10.0f);
|
||||
return sphere.Intersects(ref ray.Ray, out distance);
|
||||
return sphere.Intersects(ray.Ray, out distance);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
var actor = (Spline)_node.Actor;
|
||||
var pos = actor.GetSplinePoint(Index);
|
||||
var nodeSize = NodeSizeByDistance(Transform.Translation, PointNodeSize, ray.View.Position);
|
||||
return new BoundingSphere(pos, nodeSize).Intersects(ref ray.Ray, out distance);
|
||||
return new BoundingSphere(pos, nodeSize).Intersects(ray.Ray, out distance);
|
||||
}
|
||||
|
||||
public override void OnDebugDraw(ViewportDebugDrawData data)
|
||||
@@ -264,7 +264,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
var actor = (Spline)_node.Actor;
|
||||
var pos = actor.GetSplineTangent(_index, _isIn).Translation;
|
||||
var tangentSize = NodeSizeByDistance(Transform.Translation, TangentNodeSize, ray.View.Position);
|
||||
return new BoundingSphere(pos, tangentSize).Intersects(ref ray.Ray, out distance);
|
||||
return new BoundingSphere(pos, tangentSize).Intersects(ray.Ray, out distance);
|
||||
}
|
||||
|
||||
public override void OnDebugDraw(ViewportDebugDrawData data)
|
||||
|
||||
@@ -37,15 +37,15 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
{
|
||||
var up = Float3.Up;
|
||||
Float3 translation = transform.Translation;
|
||||
Matrix.Billboard(ref translation, ref viewPosition, ref up, ref viewDirection, out m2);
|
||||
Matrix.Multiply(ref m1, ref m2, out m3);
|
||||
Matrix.Scaling(ref transform.Scale, out m1);
|
||||
Matrix.Multiply(ref m1, ref m3, out world);
|
||||
Matrix.Billboard(translation, viewPosition, up, viewDirection, out m2);
|
||||
Matrix.Multiply(m1, m2, out m3);
|
||||
Matrix.Scaling(transform.Scale, out m1);
|
||||
Matrix.Multiply(m1, m3, out world);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.GetWorld(out m2);
|
||||
Matrix.Multiply(ref m1, ref m2, out world);
|
||||
Matrix.Multiply(m1, m2, out world);
|
||||
}
|
||||
|
||||
OrientedBoundingBox bounds;
|
||||
@@ -53,7 +53,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
world.Decompose(out bounds.Transformation);
|
||||
|
||||
normal = -ray.Ray.Direction;
|
||||
return bounds.Intersects(ref ray.Ray, out distance);
|
||||
return bounds.Intersects(ray.Ray, out distance);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
for (int i = 0; i < verts.Length; i++)
|
||||
{
|
||||
ref var v = ref verts[i];
|
||||
var distance = Float3.DistanceSquared(ref pointLocal, ref v);
|
||||
var distance = Float3.DistanceSquared(pointLocal, v);
|
||||
if (distance <= minDistance)
|
||||
{
|
||||
hit = true;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
normal = Vector3.Up;
|
||||
|
||||
if (Actor is UICanvas uiCanvas && uiCanvas.Is3D)
|
||||
return uiCanvas.Bounds.Intersects(ref ray.Ray, out distance);
|
||||
return uiCanvas.Bounds.Intersects(ray.Ray, out distance);
|
||||
|
||||
distance = 0;
|
||||
return false;
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace FlaxEditor.SceneGraph
|
||||
for (int i = 0; i < ChildNodes.Count; i++)
|
||||
{
|
||||
ChildNodes[i].GetEditorSphere(out var childSphere);
|
||||
BoundingSphere.Merge(ref sphere, ref childSphere, out sphere);
|
||||
BoundingSphere.Merge(sphere, childSphere, out sphere);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
// Scale debug pointer when it moves to make it more visible when investigating blending
|
||||
const float debugMaxSize = 2.0f;
|
||||
float debugScale = Mathf.Saturate(Float2.Distance(ref _debugPos, ref prev) / new Float2(_rangeX.Absolute.ValuesSum, _rangeY.Absolute.ValuesSum).Length * 100.0f) * debugMaxSize + 1.0f;
|
||||
float debugScale = Mathf.Saturate(Float2.Distance(_debugPos, prev) / new Float2(_rangeX.Absolute.ValuesSum, _rangeY.Absolute.ValuesSum).Length * 100.0f) * debugMaxSize + 1.0f;
|
||||
float debugBlendSpeed = _debugScale <= debugScale ? 4.0f : 1.0f;
|
||||
_debugScale = Mathf.Lerp(_debugScale, debugScale, deltaTime * debugBlendSpeed);
|
||||
}
|
||||
@@ -1189,9 +1189,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
_triangleColors = new Color[_triangles.Length];
|
||||
for (int i = 0; i < _triangles.Length; i += 3)
|
||||
{
|
||||
var is0 = Float2.NearEqual(ref _triangles[i + 0], ref pos);
|
||||
var is1 = Float2.NearEqual(ref _triangles[i + 1], ref pos);
|
||||
var is2 = Float2.NearEqual(ref _triangles[i + 2], ref pos);
|
||||
var is0 = Float2.NearEqual(_triangles[i + 0], pos);
|
||||
var is1 = Float2.NearEqual(_triangles[i + 1], pos);
|
||||
var is2 = Float2.NearEqual(_triangles[i + 2], pos);
|
||||
if (is0 || is1 || is2)
|
||||
{
|
||||
selectedTriangles.Add(_triangles[i + 0]);
|
||||
@@ -1233,7 +1233,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
if (point != null)
|
||||
{
|
||||
var highlightColor = point.IsMouseDown ? style.SelectionBorder : style.BackgroundSelected;
|
||||
Render2D.PushTint(ref highlightColor);
|
||||
Render2D.PushTint(highlightColor);
|
||||
Render2D.DrawTriangles(_selectedTriangles, _selectedColors);
|
||||
Render2D.PopTint();
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
if (base.OnMouseDoubleClick(location, button))
|
||||
return true;
|
||||
|
||||
if (_headerRect.Contains(ref location))
|
||||
if (_headerRect.Contains(location))
|
||||
{
|
||||
StartRenaming();
|
||||
return true;
|
||||
@@ -364,7 +364,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
if (ClipChildren)
|
||||
{
|
||||
GetDesireClientArea(out var clientArea);
|
||||
Render2D.PushClip(ref clientArea);
|
||||
Render2D.PushClip(clientArea);
|
||||
}
|
||||
|
||||
DrawChildren();
|
||||
@@ -382,13 +382,13 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override bool CanSelect(ref Float2 location)
|
||||
{
|
||||
return _dragAreaRect.MakeOffsetted(Location).Contains(ref location);
|
||||
return _dragAreaRect.MakeOffsetted(Location).Contains(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && !_dragAreaRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && !_dragAreaRect.Contains(location))
|
||||
{
|
||||
_isMouseDown = true;
|
||||
Cursor = CursorType.Hand;
|
||||
@@ -687,7 +687,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
var upperLeft = bounds.UpperLeft;
|
||||
var bottomRight = bounds.BottomRight;
|
||||
bounds = Rectangle.FromPoints(PointToParent(ref upperLeft), PointToParent(ref bottomRight));
|
||||
CollisionsHelper.ClosestPointRectanglePoint(ref bounds, ref startPos, out endPos);
|
||||
CollisionsHelper.ClosestPointRectanglePoint(bounds, startPos, out endPos);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -731,15 +731,15 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
// Check click over the connection
|
||||
var mousePosition = Surface.SurfaceRoot.PointFromParent(ref mouse);
|
||||
if (!TransitionsRectangle.Contains(ref mousePosition))
|
||||
if (!TransitionsRectangle.Contains(mousePosition))
|
||||
return;
|
||||
for (int i = 0; i < Transitions.Count; i++)
|
||||
{
|
||||
var t = Transitions[i];
|
||||
if (t.Bounds.Contains(ref mousePosition))
|
||||
if (t.Bounds.Contains(mousePosition))
|
||||
{
|
||||
CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
|
||||
if (Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f)
|
||||
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point);
|
||||
if (Float2.DistanceSquared(mousePosition, point) < 25.0f)
|
||||
{
|
||||
OnTransitionClicked(t, ref mouse, ref mousePosition, buttons);
|
||||
handled = true;
|
||||
@@ -756,15 +756,15 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
// Check double click over the connection
|
||||
var mousePosition = Surface.SurfaceRoot.PointFromParent(ref mouse);
|
||||
if (!TransitionsRectangle.Contains(ref mousePosition))
|
||||
if (!TransitionsRectangle.Contains(mousePosition))
|
||||
return;
|
||||
for (int i = 0; i < Transitions.Count; i++)
|
||||
{
|
||||
var t = Transitions[i];
|
||||
if (t.Bounds.Contains(ref mousePosition))
|
||||
if (t.Bounds.Contains(mousePosition))
|
||||
{
|
||||
CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
|
||||
if (Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f)
|
||||
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point);
|
||||
if (Float2.DistanceSquared(mousePosition, point) < 25.0f)
|
||||
{
|
||||
t.EditRule();
|
||||
handled = true;
|
||||
@@ -1007,7 +1007,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
var offset = diff ? -6.0f : 6.0f;
|
||||
var dir = startPos - endPos;
|
||||
dir.Normalize();
|
||||
Float2.Perpendicular(ref dir, out var nrm);
|
||||
Float2.Perpendicular(dir, out var nrm);
|
||||
nrm *= offset;
|
||||
startPos += nrm;
|
||||
endPos += nrm;
|
||||
@@ -1031,7 +1031,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
t.StartPos = startPos;
|
||||
t.EndPos = endPos;
|
||||
Rectangle.FromPoints(ref startPos, ref endPos, out t.Bounds);
|
||||
Rectangle.FromPoints(startPos, endPos, out t.Bounds);
|
||||
t.Bounds.Expand(10.0f);
|
||||
}
|
||||
|
||||
@@ -1040,7 +1040,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
TransitionsRectangle = Transitions[0].Bounds;
|
||||
for (int i = 1; i < Transitions.Count; i++)
|
||||
{
|
||||
Rectangle.Union(ref TransitionsRectangle, ref Transitions[i].Bounds, out TransitionsRectangle);
|
||||
Rectangle.Union(TransitionsRectangle, Transitions[i].Bounds, out TransitionsRectangle);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1095,7 +1095,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
if (ClipChildren)
|
||||
{
|
||||
GetDesireClientArea(out var clientArea);
|
||||
Render2D.PushClip(ref clientArea);
|
||||
Render2D.PushClip(clientArea);
|
||||
}
|
||||
|
||||
DrawChildren();
|
||||
@@ -1120,7 +1120,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override bool CanSelect(ref Float2 location)
|
||||
{
|
||||
return _dragAreaRect.MakeOffsetted(Location).Contains(ref location);
|
||||
return _dragAreaRect.MakeOffsetted(Location).Contains(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1129,7 +1129,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
if (base.OnMouseDoubleClick(location, button))
|
||||
return true;
|
||||
|
||||
if (_renameButtonRect.Contains(ref location) || _closeButtonRect.Contains(ref location))
|
||||
if (_renameButtonRect.Contains(location) || _closeButtonRect.Contains(location))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -1138,7 +1138,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && !_dragAreaRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && !_dragAreaRect.Contains(location))
|
||||
{
|
||||
_isMouseDown = true;
|
||||
Cursor = CursorType.Hand;
|
||||
@@ -1271,11 +1271,11 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
for (int i = 0; i < Transitions.Count; i++)
|
||||
{
|
||||
var t = Transitions[i];
|
||||
var isMouseOver = t.Bounds.Contains(ref mousePosition);
|
||||
var isMouseOver = t.Bounds.Contains(mousePosition);
|
||||
if (isMouseOver)
|
||||
{
|
||||
CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
|
||||
isMouseOver = Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f;
|
||||
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point);
|
||||
isMouseOver = Float2.DistanceSquared(mousePosition, point) < 25.0f;
|
||||
}
|
||||
var color = isMouseOver ? Color.Wheat : t.LineColor;
|
||||
SurfaceStyle.DrawStraightConnection(t.StartPos, t.EndPos, color);
|
||||
@@ -1474,7 +1474,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
return true;
|
||||
|
||||
// Rename
|
||||
if (_renameButtonRect.Contains(ref location))
|
||||
if (_renameButtonRect.Contains(location))
|
||||
{
|
||||
StartRenaming();
|
||||
return true;
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
if (base.OnMouseDoubleClick(location, button))
|
||||
return true;
|
||||
|
||||
if (_nameField.Bounds.Contains(ref location) && Surface.CanEdit)
|
||||
if (_nameField.Bounds.Contains(location) && Surface.CanEdit)
|
||||
{
|
||||
StartRenaming();
|
||||
return true;
|
||||
@@ -1128,7 +1128,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && _headerRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && _headerRect.Contains(location))
|
||||
{
|
||||
// Open function content item if exists
|
||||
var method = GetMethod(out var scriptType, out _, out _);
|
||||
@@ -1759,7 +1759,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && _headerRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && _headerRect.Contains(location))
|
||||
{
|
||||
OnEditSignature();
|
||||
return true;
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
public override bool CanSelect(ref Float2 location)
|
||||
{
|
||||
return base.CanSelect(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(ref location);
|
||||
return base.CanSelect(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(location);
|
||||
}
|
||||
|
||||
public override void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||
@@ -414,7 +414,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
|
||||
if (button == MouseButton.Left && _resizeButtonRect.Contains(ref location) && Surface.CanEdit)
|
||||
if (button == MouseButton.Left && _resizeButtonRect.Contains(location) && Surface.CanEdit)
|
||||
{
|
||||
// Start sliding
|
||||
_isResizing = true;
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location))
|
||||
{
|
||||
_arrangeButtonInUse = true;
|
||||
Focus();
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
// Header
|
||||
var headerColor = style.BackgroundHighlighted;
|
||||
if (_headerRect.Contains(ref _mousePosition))
|
||||
if (_headerRect.Contains(_mousePosition))
|
||||
headerColor *= 1.07f;
|
||||
Render2D.FillRectangle(_headerRect, headerColor);
|
||||
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
var icons = Editor.Instance.Icons;
|
||||
var icon = isSelected ? icons.VisjectArrowClosed32 : icons.VisjectArrowOpen32;
|
||||
|
||||
Render2D.PushTransform(ref arrowTransform);
|
||||
Render2D.PushTransform(arrowTransform);
|
||||
Render2D.DrawSprite(icon, arrowRect, color);
|
||||
Render2D.PopTransform();
|
||||
}
|
||||
@@ -169,7 +169,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Float2 location)
|
||||
{
|
||||
if (_isMoving && Float2.DistanceSquared(ref location, ref _startMovePos) > 25.0f)
|
||||
if (_isMoving && Float2.DistanceSquared(location, _startMovePos) > 25.0f)
|
||||
{
|
||||
_startMovePos = Float2.Minimum;
|
||||
int index = Node._stops.IndexOf(this);
|
||||
@@ -1076,12 +1076,12 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool ShowTooltip => !string.IsNullOrEmpty(TooltipText) && _localBounds.Contains(ref _mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
|
||||
protected override bool ShowTooltip => !string.IsNullOrEmpty(TooltipText) && _localBounds.Contains(_mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnTestTooltipOverControl(ref Float2 location)
|
||||
{
|
||||
return _localBounds.Contains(ref location) && ShowTooltip;
|
||||
return _localBounds.Contains(location) && ShowTooltip;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1150,7 +1150,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override bool CanSelect(ref Float2 location)
|
||||
{
|
||||
return new Rectangle(Location, DefaultSize).Contains(ref location);
|
||||
return new Rectangle(Location, DefaultSize).Contains(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1230,7 +1230,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Float2 location)
|
||||
{
|
||||
_isMouseInConnectingBounds = IsMouseOver && _localBounds.MakeExpanded(ConnectingBounds).Contains(ref location); // Inner area for connecting, outer area for moving
|
||||
_isMouseInConnectingBounds = IsMouseOver && _localBounds.MakeExpanded(ConnectingBounds).Contains(location); // Inner area for connecting, outer area for moving
|
||||
if (!_isMouseInConnectingBounds && !_isMouseDown)
|
||||
Cursor = CursorType.SizeAll;
|
||||
else
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace FlaxEditor.Surface.Elements
|
||||
Bezier(ref offsetStart, ref control1, ref control2, ref offsetEnd, t, out p);
|
||||
|
||||
// Maybe it would be reasonable to return the point?
|
||||
CollisionsHelper.ClosestPointPointLine(ref point, ref oldp, ref p, out var result);
|
||||
CollisionsHelper.ClosestPointPointLine(point, oldp, p, out var result);
|
||||
if (Float2.DistanceSquared(point, result) <= squaredDistance)
|
||||
{
|
||||
return true;
|
||||
@@ -167,12 +167,12 @@ namespace FlaxEditor.Surface.Elements
|
||||
|
||||
private static void Bezier(ref Float2 p0, ref Float2 p1, ref Float2 p2, ref Float2 p3, float alpha, out Float2 result)
|
||||
{
|
||||
Float2.Lerp(ref p0, ref p1, alpha, out var p01);
|
||||
Float2.Lerp(ref p1, ref p2, alpha, out var p12);
|
||||
Float2.Lerp(ref p2, ref p3, alpha, out var p23);
|
||||
Float2.Lerp(ref p01, ref p12, alpha, out var p012);
|
||||
Float2.Lerp(ref p12, ref p23, alpha, out var p123);
|
||||
Float2.Lerp(ref p012, ref p123, alpha, out result);
|
||||
Float2.Lerp(p0, p1, alpha, out var p01);
|
||||
Float2.Lerp(p1, p2, alpha, out var p12);
|
||||
Float2.Lerp(p2, p3, alpha, out var p23);
|
||||
Float2.Lerp(p01, p12, alpha, out var p012);
|
||||
Float2.Lerp(p12, p23, alpha, out var p123);
|
||||
Float2.Lerp(p012, p123, alpha, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -146,13 +146,13 @@ namespace FlaxEditor.Surface
|
||||
/// <inheritdoc />
|
||||
public override bool CanSelect(ref Float2 location)
|
||||
{
|
||||
return _headerRect.MakeOffsetted(Location).Contains(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(ref location);
|
||||
return _headerRect.MakeOffsetted(Location).Contains(location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsSelectionIntersecting(ref Rectangle selectionRect)
|
||||
{
|
||||
return _headerRect.MakeOffsetted(Location).Intersects(ref selectionRect);
|
||||
return _headerRect.MakeOffsetted(Location).Intersects(selectionRect);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -287,7 +287,7 @@ namespace FlaxEditor.Surface
|
||||
/// <inheritdoc />
|
||||
public override bool ContainsPoint(ref Float2 location, bool precise)
|
||||
{
|
||||
return _headerRect.Contains(ref location) || _resizeButtonRect.Contains(ref location);
|
||||
return _headerRect.Contains(location) || _resizeButtonRect.Contains(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -297,7 +297,7 @@ namespace FlaxEditor.Surface
|
||||
return true;
|
||||
|
||||
// Check if can start resizing
|
||||
if (button == MouseButton.Left && _resizeButtonRect.Contains(ref location) && Surface.CanEdit)
|
||||
if (button == MouseButton.Left && _resizeButtonRect.Contains(location) && Surface.CanEdit)
|
||||
{
|
||||
// Start sliding
|
||||
_isResizing = true;
|
||||
@@ -336,7 +336,7 @@ namespace FlaxEditor.Surface
|
||||
return true;
|
||||
|
||||
// Rename
|
||||
if (_headerRect.Contains(ref location) && Surface.CanEdit)
|
||||
if (_headerRect.Contains(location) && Surface.CanEdit)
|
||||
{
|
||||
StartRenaming();
|
||||
return true;
|
||||
@@ -404,14 +404,14 @@ namespace FlaxEditor.Surface
|
||||
return true;
|
||||
|
||||
// Close
|
||||
if (_closeButtonRect.Contains(ref location) && Surface.CanEdit)
|
||||
if (_closeButtonRect.Contains(location) && Surface.CanEdit)
|
||||
{
|
||||
Surface.Delete(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Color
|
||||
if (_colorButtonRect.Contains(ref location) && Surface.CanEdit)
|
||||
if (_colorButtonRect.Contains(location) && Surface.CanEdit)
|
||||
{
|
||||
ColorValueBox.ShowPickColorDialog?.Invoke(this, Color, OnColorChanged);
|
||||
return true;
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace FlaxEditor.Surface
|
||||
/// <returns><c>true</c> if the selection rectangle is intersecting with the selectable parts of the control ; otherwise, <c>false</c>.</returns>
|
||||
public virtual bool IsSelectionIntersecting(ref Rectangle selectionRect)
|
||||
{
|
||||
return Bounds.Intersects(ref selectionRect);
|
||||
return Bounds.Intersects(selectionRect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -868,7 +868,7 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool ShowTooltip => base.ShowTooltip && _headerRect.Contains(ref _mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
|
||||
protected override bool ShowTooltip => base.ShowTooltip && _headerRect.Contains(_mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnShowTooltip(out string text, out Float2 location, out Rectangle area)
|
||||
@@ -898,13 +898,13 @@ namespace FlaxEditor.Surface
|
||||
/// <inheritdoc />
|
||||
public override bool OnTestTooltipOverControl(ref Float2 location)
|
||||
{
|
||||
return _headerRect.Contains(ref location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsSelecting;
|
||||
return _headerRect.Contains(location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsSelecting;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanSelect(ref Float2 location)
|
||||
{
|
||||
return _headerRect.MakeOffsetted(Location).Contains(ref location);
|
||||
return _headerRect.MakeOffsetted(Location).Contains(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1056,7 +1056,7 @@ namespace FlaxEditor.Surface
|
||||
|
||||
// Header
|
||||
var headerColor = style.BackgroundHighlighted;
|
||||
if (_headerRect.Contains(ref _mousePosition) && !Surface.IsConnecting && !Surface.IsSelecting)
|
||||
if (_headerRect.Contains(_mousePosition) && !Surface.IsConnecting && !Surface.IsSelecting)
|
||||
headerColor *= 1.07f;
|
||||
Render2D.FillRectangle(_headerRect, headerColor);
|
||||
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
|
||||
@@ -1099,7 +1099,7 @@ namespace FlaxEditor.Surface
|
||||
if (base.OnMouseDown(location, button))
|
||||
return true;
|
||||
|
||||
if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(location))
|
||||
return true;
|
||||
if (button == MouseButton.Right)
|
||||
mouseDownMousePosition = Input.Mouse.Position;
|
||||
@@ -1115,7 +1115,7 @@ namespace FlaxEditor.Surface
|
||||
|
||||
// Close/ delete
|
||||
bool canDelete = !Surface.IsConnecting && !Surface.WasSelecting && !Surface.WasMovingSelection;
|
||||
if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(location))
|
||||
{
|
||||
Surface.Delete(this);
|
||||
return true;
|
||||
|
||||
@@ -32,13 +32,13 @@ namespace FlaxEditor.Surface
|
||||
/// </summary>
|
||||
public virtual void DrawComments()
|
||||
{
|
||||
Render2D.PushTransform(ref _cachedTransform);
|
||||
Render2D.PushTransform(_cachedTransform);
|
||||
|
||||
// Push clipping mask
|
||||
if (ClipChildren)
|
||||
{
|
||||
GetDesireClientArea(out Rectangle clientArea);
|
||||
Render2D.PushClip(ref clientArea);
|
||||
Render2D.PushClip(clientArea);
|
||||
}
|
||||
|
||||
// Draw all visible child comments
|
||||
@@ -48,7 +48,7 @@ namespace FlaxEditor.Surface
|
||||
|
||||
if (child is SurfaceComment && child.Visible)
|
||||
{
|
||||
Render2D.PushTransform(ref child._cachedTransform);
|
||||
Render2D.PushTransform(child._cachedTransform);
|
||||
child.Draw();
|
||||
Render2D.PopTransform();
|
||||
}
|
||||
@@ -74,11 +74,11 @@ namespace FlaxEditor.Surface
|
||||
var child = _children[i];
|
||||
if (!(child is SurfaceComment) && child.Visible)
|
||||
{
|
||||
Matrix3x3.Multiply(ref child._cachedTransform, ref globalTransform, out var globalChildTransform);
|
||||
Matrix3x3.Multiply(child._cachedTransform, globalTransform, out var globalChildTransform);
|
||||
var childGlobalRect = new Rectangle(globalChildTransform.M31, globalChildTransform.M32, child.Width * globalChildTransform.M11, child.Height * globalChildTransform.M22);
|
||||
if (globalClipping.Intersects(ref childGlobalRect))
|
||||
if (globalClipping.Intersects(childGlobalRect))
|
||||
{
|
||||
Render2D.PushTransform(ref child._cachedTransform);
|
||||
Render2D.PushTransform(child._cachedTransform);
|
||||
child.Draw();
|
||||
Render2D.PopTransform();
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ namespace FlaxEditor.Surface
|
||||
Matrix3x3.RotationZ(rotation * Mathf.PiOverTwo) *
|
||||
Matrix3x3.Translation2D(endPos - dir * 8);
|
||||
|
||||
Render2D.PushTransform(ref arrowTransform);
|
||||
Render2D.PushTransform(arrowTransform);
|
||||
Render2D.DrawSprite(sprite, arrowRect, color);
|
||||
Render2D.PopTransform();
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
// Push surface view transform (scale and offset)
|
||||
Render2D.PushTransform(ref _rootControl._cachedTransform);
|
||||
Render2D.PushTransform(_rootControl._cachedTransform);
|
||||
var features = Render2D.Features;
|
||||
Render2D.Features = Render2D.RenderingFeatures.None;
|
||||
|
||||
|
||||
@@ -502,7 +502,7 @@ namespace FlaxEditor.Surface
|
||||
/// <inheritdoc />
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
|
||||
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location))
|
||||
{
|
||||
_arrangeButtonInUse = true;
|
||||
Focus();
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace FlaxEngine.Tools
|
||||
for (int i = 0; i < clothParticles.Length; i++)
|
||||
{
|
||||
var pos = instanceTransform.LocalToWorld(clothParticles[i]);
|
||||
var dst = Vector3.Distance(ref pos, ref brushSphere.Center);
|
||||
var dst = Vector3.Distance(pos, brushSphere.Center);
|
||||
if (dst > brushSphere.Radius)
|
||||
continue;
|
||||
float strength = _gizmoMode.BrushStrength * Mathf.Lerp(1.0f, 1.0f - (float)dst / (float)brushSphere.Radius, _gizmoMode.BrushFalloff);
|
||||
@@ -304,7 +304,7 @@ namespace FlaxEngine.Tools
|
||||
_brushMaterial.SetParameterValue("DepthBuffer", Owner.RenderTask.Buffers.DepthBuffer);
|
||||
Quaternion rotation = RootNode.RaycastNormalRotation(ref _hitNormal);
|
||||
Matrix transform = Matrix.Scaling(_gizmoMode.BrushSize * 0.01f) * Matrix.RotationQuaternion(rotation) * Matrix.Translation(_hitLocation - viewOrigin);
|
||||
_brushModel.Draw(ref renderContext, _brushMaterial, ref transform);
|
||||
_brushModel.Draw(renderContext, _brushMaterial, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace FlaxEditor.Tools.Foliage
|
||||
if (foliage && instanceIndex >= 0 && instanceIndex < foliage.InstancesCount)
|
||||
{
|
||||
var instance = foliage.GetInstance(instanceIndex);
|
||||
BoundingBox.FromSphere(ref instance.Bounds, out bounds);
|
||||
BoundingBox.FromSphere(instance.Bounds, out bounds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ namespace FlaxEditor.Tools.Foliage
|
||||
}
|
||||
else
|
||||
{
|
||||
Matrix.RotationQuaternion(ref trans.Orientation, out var transWorld);
|
||||
Matrix.RotationQuaternion(ref rotationDelta, out var deltaWorld);
|
||||
Matrix.RotationQuaternion(trans.Orientation, out var transWorld);
|
||||
Matrix.RotationQuaternion(rotationDelta, out var deltaWorld);
|
||||
Matrix world = transWorld * Matrix.Translation(pivotOffset) * deltaWorld * Matrix.Translation(-pivotOffset);
|
||||
trans.SetRotation(ref world);
|
||||
trans.Translation += world.TranslationVector;
|
||||
@@ -172,7 +172,7 @@ namespace FlaxEditor.Tools.Foliage
|
||||
|
||||
// Transform foliage instance
|
||||
instance.Transform = foliage.Transform.WorldToLocal(trans);
|
||||
foliage.SetInstanceTransform(instanceIndex, ref instance.Transform);
|
||||
foliage.SetInstanceTransform(instanceIndex, instance.Transform);
|
||||
foliage.RebuildClusters();
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace FlaxEditor.Tools.Foliage
|
||||
|
||||
// Duplicate instance and select it
|
||||
var newIndex = foliage.InstancesCount;
|
||||
foliage.AddInstance(ref instance);
|
||||
foliage.AddInstance(instance);
|
||||
action.RecordEnd();
|
||||
Owner.Undo?.AddAction(new MultiUndoAction(action, new EditSelectedInstanceIndexAction(GizmoMode.SelectedInstanceIndex, newIndex)));
|
||||
GizmoMode.SelectedInstanceIndex = newIndex;
|
||||
@@ -231,7 +231,7 @@ namespace FlaxEditor.Tools.Foliage
|
||||
{
|
||||
var transform = foliage.Transform.LocalToWorld(instance.Transform);
|
||||
renderContext.View.GetWorldMatrix(ref transform, out var world);
|
||||
model.Draw(ref renderContext, _highlightMaterial, ref world, StaticFlags.None, false);
|
||||
model.Draw(renderContext, _highlightMaterial, world, StaticFlags.None, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace FlaxEditor.Tools.Foliage
|
||||
if (!foliage)
|
||||
return;
|
||||
var ray = Owner.MouseRay;
|
||||
foliage.Intersects(ref ray, out _, out _, out var instanceIndex);
|
||||
foliage.Intersects(ray, out _, out _, out var instanceIndex);
|
||||
|
||||
// Change the selection (with undo)
|
||||
if (GizmoMode.SelectedInstanceIndex == instanceIndex)
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace FlaxEditor.Tools.Foliage
|
||||
{
|
||||
if (Foliage != null && InstanceIndex > -1 && InstanceIndex < Foliage.InstancesCount)
|
||||
{
|
||||
Foliage.SetInstanceTransform(InstanceIndex, ref _instance.Transform);
|
||||
Foliage.SetInstanceTransform(InstanceIndex, _instance.Transform);
|
||||
Foliage.RebuildClusters();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace FlaxEditor.Tools.Foliage
|
||||
else
|
||||
rotation = Quaternion.LookRotation(Vector3.Cross(Vector3.Cross(brushNormal, Vector3.Forward), brushNormal), brushNormal);
|
||||
Matrix transform = Matrix.Scaling(Mode.CurrentBrush.Size * 0.01f) * Matrix.RotationQuaternion(rotation) * Matrix.Translation(brushPosition - renderContext.View.Origin);
|
||||
_brushModel.Draw(ref renderContext, brushMaterial, ref transform);
|
||||
_brushModel.Draw(renderContext, brushMaterial, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace FlaxEditor.Tools.Foliage.Undo
|
||||
var foliage = FlaxEngine.Object.Find<FlaxEngine.Foliage>(ref foliageId);
|
||||
|
||||
_index = foliage.InstancesCount;
|
||||
foliage.AddInstance(ref _instance);
|
||||
foliage.AddInstance(_instance);
|
||||
foliage.RebuildClusters();
|
||||
|
||||
Editor.Instance.Scene.MarkSceneEdited(foliage.Scene);
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace FlaxEditor.Tools.Foliage.Undo
|
||||
{
|
||||
var foliageId = _foliageId;
|
||||
var foliage = FlaxEngine.Object.Find<FlaxEngine.Foliage>(ref foliageId);
|
||||
foliage.SetInstanceTransform(_index, ref _after);
|
||||
foliage.SetInstanceTransform(_index, _after);
|
||||
foliage.RebuildClusters();
|
||||
Editor.Instance.Scene.MarkSceneEdited(foliage.Scene);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace FlaxEditor.Tools.Foliage.Undo
|
||||
{
|
||||
var foliageId = _foliageId;
|
||||
var foliage = FlaxEngine.Object.Find<FlaxEngine.Foliage>(ref foliageId);
|
||||
foliage.SetInstanceTransform(_index, ref _before);
|
||||
foliage.SetInstanceTransform(_index, _before);
|
||||
foliage.RebuildClusters();
|
||||
Editor.Instance.Scene.MarkSceneEdited(foliage.Scene);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace FlaxEditor.Tools.Terrain.Brushes
|
||||
/// <inheritdoc />
|
||||
public override float Sample(ref Vector3 brushPosition, ref Vector3 samplePosition)
|
||||
{
|
||||
Vector3.DistanceXZ(ref brushPosition, ref samplePosition, out var distanceXZ);
|
||||
Vector3.DistanceXZ(brushPosition, samplePosition, out var distanceXZ);
|
||||
float distance = (float)distanceXZ;
|
||||
float halfSize = Size * 0.5f;
|
||||
float falloff = halfSize * Falloff;
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
_isDone = false;
|
||||
|
||||
// Call tool to generate the terrain patches from the input data
|
||||
if (TerrainTools.GenerateTerrain(_terrain, ref _options.NumberOfPatches, _options.Heightmap, _options.HeightmapScale, _options.Splatmap1, _options.Splatmap2))
|
||||
if (TerrainTools.GenerateTerrain(_terrain, _options.NumberOfPatches, _options.Heightmap, _options.HeightmapScale, _options.Splatmap1, _options.Splatmap2))
|
||||
{
|
||||
Editor.LogError("Failed to generate terrain. See log for more info.");
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
|
||||
_terrainId = terrain.ID;
|
||||
_patchCoord = patchCoord;
|
||||
_data = TerrainTools.SerializePatch(terrain, ref patchCoord);
|
||||
_data = TerrainTools.SerializePatch(terrain, patchCoord);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -159,8 +159,8 @@ namespace FlaxEditor.Tools.Terrain
|
||||
return;
|
||||
}
|
||||
|
||||
terrain.GetPatchBounds(terrain.GetPatchIndex(ref _patchCoord), out var patchBounds);
|
||||
terrain.RemovePatch(ref _patchCoord);
|
||||
terrain.GetPatchBounds(terrain.GetPatchIndex(_patchCoord), out var patchBounds);
|
||||
terrain.RemovePatch(_patchCoord);
|
||||
OnPatchEdit(terrain, ref patchBounds);
|
||||
}
|
||||
|
||||
@@ -174,9 +174,9 @@ namespace FlaxEditor.Tools.Terrain
|
||||
return;
|
||||
}
|
||||
|
||||
terrain.AddPatch(ref _patchCoord);
|
||||
TerrainTools.DeserializePatch(terrain, ref _patchCoord, _data);
|
||||
terrain.GetPatchBounds(terrain.GetPatchIndex(ref _patchCoord), out var patchBounds);
|
||||
terrain.AddPatch(_patchCoord);
|
||||
TerrainTools.DeserializePatch(terrain, _patchCoord, _data);
|
||||
terrain.GetPatchBounds(terrain.GetPatchIndex(_patchCoord), out var patchBounds);
|
||||
OnPatchEdit(terrain, ref patchBounds);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
return;
|
||||
|
||||
var patchCoord = Gizmo.SelectedPatchCoord;
|
||||
if (!CarveTab.SelectedTerrain.HasPatch(ref patchCoord))
|
||||
if (!CarveTab.SelectedTerrain.HasPatch(patchCoord))
|
||||
return;
|
||||
|
||||
var action = new DeletePatchAction(CarveTab.SelectedTerrain, ref patchCoord);
|
||||
@@ -247,7 +247,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
_terrainId = terrain.ID;
|
||||
_patchCoord = patchCoord;
|
||||
_chunkCoord = chunkCoord;
|
||||
_beforeMaterial = terrain.GetChunkOverrideMaterial(ref patchCoord, ref chunkCoord)?.ID ?? Guid.Empty;
|
||||
_beforeMaterial = terrain.GetChunkOverrideMaterial(patchCoord, chunkCoord)?.ID ?? Guid.Empty;
|
||||
_afterMaterial = toSet?.ID ?? Guid.Empty;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
return;
|
||||
}
|
||||
|
||||
terrain.SetChunkOverrideMaterial(ref _patchCoord, ref _chunkCoord, FlaxEngine.Content.LoadAsync<MaterialBase>(id));
|
||||
terrain.SetChunkOverrideMaterial(_patchCoord, _chunkCoord, FlaxEngine.Content.LoadAsync<MaterialBase>(id));
|
||||
|
||||
Editor.Instance.Scene.MarkSceneEdited(terrain.Scene);
|
||||
}
|
||||
@@ -334,9 +334,9 @@ namespace FlaxEditor.Tools.Terrain
|
||||
_exportTerrainButton.Visible = false;
|
||||
|
||||
_isUpdatingUI = true;
|
||||
if (terrain.HasPatch(ref patchCoord))
|
||||
if (terrain.HasPatch(patchCoord))
|
||||
{
|
||||
_chunkOverrideMaterial.Validator.SelectedAsset = terrain.GetChunkOverrideMaterial(ref patchCoord, ref chunkCoord);
|
||||
_chunkOverrideMaterial.Validator.SelectedAsset = terrain.GetChunkOverrideMaterial(patchCoord, chunkCoord);
|
||||
_chunkOverrideMaterial.Enabled = true;
|
||||
}
|
||||
else
|
||||
@@ -349,7 +349,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
}
|
||||
case EditTerrainGizmoMode.Modes.Add:
|
||||
{
|
||||
if (terrain.HasPatch(ref patchCoord))
|
||||
if (terrain.HasPatch(patchCoord))
|
||||
{
|
||||
_selectionInfoLabel.Text = string.Format(
|
||||
"Selected terrain: {0}\nMove mouse cursor at location without a patch.",
|
||||
|
||||
@@ -74,10 +74,10 @@ namespace FlaxEditor.Tools.Terrain
|
||||
{
|
||||
// Highlight selected chunk
|
||||
var patchCoord = Mode.SelectedPatchCoord;
|
||||
if (terrain.HasPatch(ref patchCoord))
|
||||
if (terrain.HasPatch(patchCoord))
|
||||
{
|
||||
var chunkCoord = Mode.SelectedChunkCoord;
|
||||
terrain.DrawChunk(ref renderContext, ref patchCoord, ref chunkCoord, _highlightTerrainMaterial);
|
||||
terrain.DrawChunk(renderContext, patchCoord, chunkCoord, _highlightTerrainMaterial);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -86,7 +86,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
{
|
||||
// Highlight patch to add location
|
||||
var patchCoord = Mode.SelectedPatchCoord;
|
||||
if (!terrain.HasPatch(ref patchCoord) && _planeModel)
|
||||
if (!terrain.HasPatch(patchCoord) && _planeModel)
|
||||
{
|
||||
var planeSize = 100.0f;
|
||||
var patchSize = terrain.ChunkSize * FlaxEngine.Terrain.UnitsPerVertex * FlaxEngine.Terrain.PatchEdgeChunksCount;
|
||||
@@ -96,7 +96,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
Matrix.Scaling(terrain.Scale) *
|
||||
Matrix.RotationQuaternion(terrain.Orientation) *
|
||||
Matrix.Translation(terrain.Position - renderContext.View.Origin);
|
||||
_planeModel.Draw(ref renderContext, _highlightMaterial, ref world);
|
||||
_planeModel.Draw(renderContext, _highlightMaterial, world);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -105,9 +105,9 @@ namespace FlaxEditor.Tools.Terrain
|
||||
{
|
||||
// Highlight selected patch
|
||||
var patchCoord = Mode.SelectedPatchCoord;
|
||||
if (terrain.HasPatch(ref patchCoord))
|
||||
if (terrain.HasPatch(patchCoord))
|
||||
{
|
||||
terrain.DrawPatch(ref renderContext, ref patchCoord, _highlightTerrainMaterial);
|
||||
terrain.DrawPatch(renderContext, patchCoord, _highlightTerrainMaterial);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -173,12 +173,12 @@ namespace FlaxEditor.Tools.Terrain
|
||||
return;
|
||||
}
|
||||
|
||||
terrain.AddPatch(ref _patchCoord);
|
||||
if (TerrainTools.InitializePatch(terrain, ref _patchCoord))
|
||||
terrain.AddPatch(_patchCoord);
|
||||
if (TerrainTools.InitializePatch(terrain, _patchCoord))
|
||||
{
|
||||
Editor.LogError("Failed to initialize terrain patch.");
|
||||
}
|
||||
terrain.GetPatchBounds(terrain.GetPatchIndex(ref _patchCoord), out var patchBounds);
|
||||
terrain.GetPatchBounds(terrain.GetPatchIndex(_patchCoord), out var patchBounds);
|
||||
OnPatchEdit(terrain, ref patchBounds);
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ namespace FlaxEditor.Tools.Terrain
|
||||
return;
|
||||
}
|
||||
|
||||
terrain.GetPatchBounds(terrain.GetPatchIndex(ref _patchCoord), out var patchBounds);
|
||||
terrain.RemovePatch(ref _patchCoord);
|
||||
terrain.GetPatchBounds(terrain.GetPatchIndex(_patchCoord), out var patchBounds);
|
||||
terrain.RemovePatch(_patchCoord);
|
||||
OnPatchEdit(terrain, ref patchBounds);
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
if (terrain)
|
||||
{
|
||||
var patchCoord = Mode.SelectedPatchCoord;
|
||||
if (!terrain.HasPatch(ref patchCoord))
|
||||
if (!terrain.HasPatch(patchCoord))
|
||||
{
|
||||
// Add a new patch (with undo)
|
||||
var action = new AddPatchAction(terrain, ref patchCoord);
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace FlaxEditor.Tools.Terrain.Paint
|
||||
var brushBounds = gizmo.CursorBrushBounds;
|
||||
terrain.GetLocalToWorldMatrix(out p.TerrainWorld);
|
||||
terrain.GetWorldToLocalMatrix(out var terrainInvWorld);
|
||||
BoundingBox.Transform(ref brushBounds, ref terrainInvWorld, out var brushBoundsLocal);
|
||||
BoundingBox.Transform(brushBounds, terrainInvWorld, out var brushBoundsLocal);
|
||||
|
||||
// TODO: try caching brush weights before apply to reduce complexity and batch brush sampling
|
||||
|
||||
@@ -132,11 +132,11 @@ namespace FlaxEditor.Tools.Terrain.Paint
|
||||
continue;
|
||||
|
||||
// Get the patch data (cached internally by the c++ core in editor)
|
||||
var sourceData = TerrainTools.GetSplatMapData(terrain, ref patch.PatchCoord, splatmapIndex);
|
||||
var sourceData = TerrainTools.GetSplatMapData(terrain, patch.PatchCoord, splatmapIndex);
|
||||
if (sourceData == null)
|
||||
throw new Exception("Cannot modify terrain. Loading splatmap failed. See log for more info.");
|
||||
|
||||
var sourceDataOther = TerrainTools.GetSplatMapData(terrain, ref patch.PatchCoord, splatmapIndexOther);
|
||||
var sourceDataOther = TerrainTools.GetSplatMapData(terrain, patch.PatchCoord, splatmapIndexOther);
|
||||
if (sourceDataOther == null)
|
||||
throw new Exception("Cannot modify terrain. Loading splatmap failed. See log for more info.");
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace FlaxEditor.Tools.Terrain.Paint
|
||||
var src = (Color)p.SourceData[zz * p.HeightmapSize + xx];
|
||||
|
||||
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, 0, zz * FlaxEngine.Terrain.UnitsPerVertex);
|
||||
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
var sample = Mathf.Saturate(p.Brush.Sample(ref brushPosition, ref samplePositionWorld));
|
||||
|
||||
var paintAmount = sample * strength;
|
||||
@@ -115,9 +115,9 @@ namespace FlaxEditor.Tools.Terrain.Paint
|
||||
Profiler.EndEvent();
|
||||
|
||||
// Update terrain patch
|
||||
TerrainTools.ModifySplatMap(p.Terrain, ref p.PatchCoord, p.SplatmapIndex, p.TempBuffer, ref p.ModifiedOffset, ref p.ModifiedSize);
|
||||
TerrainTools.ModifySplatMap(p.Terrain, p.PatchCoord, p.SplatmapIndex, p.TempBuffer, p.ModifiedOffset, p.ModifiedSize);
|
||||
if (otherModified)
|
||||
TerrainTools.ModifySplatMap(p.Terrain, ref p.PatchCoord, p.SplatmapIndexOther, p.TempBufferOther, ref p.ModifiedOffset, ref p.ModifiedSize);
|
||||
TerrainTools.ModifySplatMap(p.Terrain, p.PatchCoord, p.SplatmapIndexOther, p.TempBufferOther, p.ModifiedOffset, p.ModifiedSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
for (int i = 0; i < Mode.ChunksUnderCursor.Count; i++)
|
||||
{
|
||||
var chunk = Mode.ChunksUnderCursor[i];
|
||||
terrain.DrawChunk(ref renderContext, ref chunk.PatchCoord, ref chunk.ChunkCoord, brushMaterial, 0);
|
||||
terrain.DrawChunk(renderContext, chunk.PatchCoord, chunk.ChunkCoord, brushMaterial, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
for (int patchIndex = 0; patchIndex < patchesCount; patchIndex++)
|
||||
{
|
||||
terrain.GetPatchBounds(patchIndex, out BoundingBox tmp);
|
||||
if (!tmp.Intersects(ref brushBounds))
|
||||
if (!tmp.Intersects(brushBounds))
|
||||
continue;
|
||||
|
||||
terrain.GetPatchCoord(patchIndex, out var patchCoord);
|
||||
@@ -323,7 +323,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
for (int chunkIndex = 0; chunkIndex < FlaxEngine.Terrain.PatchChunksCount; chunkIndex++)
|
||||
{
|
||||
terrain.GetChunkBounds(patchIndex, chunkIndex, out tmp);
|
||||
if (!tmp.Intersects(ref brushBounds))
|
||||
if (!tmp.Intersects(brushBounds))
|
||||
continue;
|
||||
|
||||
var chunkCoord = new Int2(chunkIndex % FlaxEngine.Terrain.PatchEdgeChunksCount, chunkIndex / FlaxEngine.Terrain.PatchEdgeChunksCount);
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
var sourceHeight = p.SourceHeightMap[zz * p.HeightmapSize + xx];
|
||||
|
||||
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, sourceHeight, zz * FlaxEngine.Terrain.UnitsPerVertex);
|
||||
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
|
||||
var paintAmount = p.Brush.Sample(ref brushPosition, ref samplePositionWorld) * strength;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
Profiler.EndEvent();
|
||||
|
||||
// Update terrain patch
|
||||
TerrainTools.ModifyHeightMap(p.Terrain, ref p.PatchCoord, p.TempBuffer, ref p.ModifiedOffset, ref p.ModifiedSize);
|
||||
TerrainTools.ModifyHeightMap(p.Terrain, p.PatchCoord, p.TempBuffer, p.ModifiedOffset, p.ModifiedSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
var sourceMask = p.SourceHolesMask[zz * p.HeightmapSize + xx] != 0 ? 1.0f : 0.0f;
|
||||
|
||||
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, 0, zz * FlaxEngine.Terrain.UnitsPerVertex);
|
||||
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
samplePositionWorld.Y = brushPosition.Y;
|
||||
|
||||
var paintAmount = p.Brush.Sample(ref brushPosition, ref samplePositionWorld);
|
||||
@@ -54,7 +54,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
Profiler.EndEvent();
|
||||
|
||||
// Update terrain patch
|
||||
TerrainTools.ModifyHolesMask(p.Terrain, ref p.PatchCoord, tempBuffer, ref p.ModifiedOffset, ref p.ModifiedSize);
|
||||
TerrainTools.ModifyHolesMask(p.Terrain, p.PatchCoord, tempBuffer, p.ModifiedOffset, p.ModifiedSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
var brushBounds = gizmo.CursorBrushBounds;
|
||||
terrain.GetLocalToWorldMatrix(out var terrainWorld);
|
||||
terrain.GetWorldToLocalMatrix(out var terrainInvWorld);
|
||||
BoundingBox.Transform(ref brushBounds, ref terrainInvWorld, out var brushBoundsLocal);
|
||||
BoundingBox.Transform(brushBounds, terrainInvWorld, out var brushBoundsLocal);
|
||||
|
||||
// TODO: try caching brush weights before apply to reduce complexity and batch brush sampling
|
||||
|
||||
@@ -119,8 +119,8 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
continue;
|
||||
|
||||
// Get the patch data (cached internally by the c++ core in editor)
|
||||
float* sourceHeights = EditHoles ? null : TerrainTools.GetHeightmapData(terrain, ref patch.PatchCoord);
|
||||
byte* sourceHoles = EditHoles ? TerrainTools.GetHolesMaskData(terrain, ref patch.PatchCoord) : null;
|
||||
float* sourceHeights = EditHoles ? null : TerrainTools.GetHeightmapData(terrain, patch.PatchCoord);
|
||||
byte* sourceHoles = EditHoles ? TerrainTools.GetHolesMaskData(terrain, patch.PatchCoord) : null;
|
||||
if (sourceHeights == null && sourceHoles == null)
|
||||
throw new Exception("Cannot modify terrain. Loading heightmap failed. See log for more info.");
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
var sourceHeight = p.SourceHeightMap[zz * p.HeightmapSize + xx];
|
||||
|
||||
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, sourceHeight, zz * FlaxEngine.Terrain.UnitsPerVertex);
|
||||
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
|
||||
var noiseSample = noise.Sample(xx + patchOffset.X, zz + patchOffset.Y);
|
||||
var paintAmount = p.Brush.Sample(ref brushPosition, ref samplePositionWorld);
|
||||
@@ -60,7 +60,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
Profiler.EndEvent();
|
||||
|
||||
// Update terrain patch
|
||||
TerrainTools.ModifyHeightMap(p.Terrain, ref p.PatchCoord, p.TempBuffer, ref p.ModifiedOffset, ref p.ModifiedSize);
|
||||
TerrainTools.ModifyHeightMap(p.Terrain, p.PatchCoord, p.TempBuffer, p.ModifiedOffset, p.ModifiedSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
var sourceHeight = p.SourceHeightMap[zz * p.HeightmapSize + xx];
|
||||
|
||||
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, sourceHeight, zz * FlaxEngine.Terrain.UnitsPerVertex);
|
||||
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
|
||||
var paintAmount = p.Brush.Sample(ref brushPosition, ref samplePositionWorld);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
Profiler.EndEvent();
|
||||
|
||||
// Update terrain patch
|
||||
TerrainTools.ModifyHeightMap(p.Terrain, ref p.PatchCoord, p.TempBuffer, ref p.ModifiedOffset, ref p.ModifiedSize);
|
||||
TerrainTools.ModifyHeightMap(p.Terrain, p.PatchCoord, p.TempBuffer, p.ModifiedOffset, p.ModifiedSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
|
||||
// Calculate brush influence at the current position
|
||||
var samplePositionLocal = patch.PatchPositionLocal + new Vector3(localCoordX * FlaxEngine.Terrain.UnitsPerVertex, coordHeight, localCoordY * FlaxEngine.Terrain.UnitsPerVertex);
|
||||
Vector3.Transform(ref samplePositionLocal, ref patch.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
Vector3.Transform(samplePositionLocal, patch.TerrainWorld, out Vector3 samplePositionWorld);
|
||||
var paintAmount = patch.Brush.Sample(ref brushPosition, ref samplePositionWorld) * strength;
|
||||
|
||||
if (paintAmount == 0)
|
||||
@@ -138,7 +138,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
}
|
||||
|
||||
// Update terrain patch
|
||||
TerrainTools.ModifyHeightMap(patch.Terrain, ref patch.PatchCoord, patch.TempBuffer, ref patch.ModifiedOffset, ref patch.ModifiedSize);
|
||||
TerrainTools.ModifyHeightMap(patch.Terrain, patch.PatchCoord, patch.TempBuffer, patch.ModifiedOffset, patch.ModifiedSize);
|
||||
}
|
||||
|
||||
// Auto NavMesh rebuild
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
for (int i = 0; i < Mode.ChunksUnderCursor.Count; i++)
|
||||
{
|
||||
var chunk = Mode.ChunksUnderCursor[i];
|
||||
terrain.DrawChunk(ref renderContext, ref chunk.PatchCoord, ref chunk.ChunkCoord, brushMaterial);
|
||||
terrain.DrawChunk(renderContext, chunk.PatchCoord, chunk.ChunkCoord, brushMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
for (int patchIndex = 0; patchIndex < patchesCount; patchIndex++)
|
||||
{
|
||||
terrain.GetPatchBounds(patchIndex, out BoundingBox tmp);
|
||||
if (!tmp.Intersects(ref brushBounds))
|
||||
if (!tmp.Intersects(brushBounds))
|
||||
continue;
|
||||
|
||||
terrain.GetPatchCoord(patchIndex, out var patchCoord);
|
||||
@@ -342,7 +342,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
for (int chunkIndex = 0; chunkIndex < FlaxEngine.Terrain.PatchChunksCount; chunkIndex++)
|
||||
{
|
||||
terrain.GetChunkBounds(patchIndex, chunkIndex, out tmp);
|
||||
if (!tmp.Intersects(ref brushBounds))
|
||||
if (!tmp.Intersects(brushBounds))
|
||||
continue;
|
||||
|
||||
var chunkCoord = new Int2(chunkIndex % FlaxEngine.Terrain.PatchEdgeChunksCount, chunkIndex / FlaxEngine.Terrain.PatchEdgeChunksCount);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
/// <inheritdoc />
|
||||
protected override IntPtr GetData(ref Int2 patchCoord, object tag)
|
||||
{
|
||||
return new IntPtr(TerrainTools.GetHeightmapData(Terrain, ref patchCoord));
|
||||
return new IntPtr(TerrainTools.GetHeightmapData(Terrain, patchCoord));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -36,7 +36,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
{
|
||||
var offset = Int2.Zero;
|
||||
var size = new Int2((int)Mathf.Sqrt(_heightmapLength));
|
||||
if (TerrainTools.ModifyHeightMap(Terrain, ref patchCoord, (float*)data, ref offset, ref size))
|
||||
if (TerrainTools.ModifyHeightMap(Terrain, patchCoord, (float*)data, offset, size))
|
||||
throw new Exception("Failed to modify the heightmap.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
/// <inheritdoc />
|
||||
protected override IntPtr GetData(ref Int2 patchCoord, object tag)
|
||||
{
|
||||
return new IntPtr(TerrainTools.GetHolesMaskData(Terrain, ref patchCoord));
|
||||
return new IntPtr(TerrainTools.GetHolesMaskData(Terrain, patchCoord));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -36,7 +36,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
{
|
||||
var offset = Int2.Zero;
|
||||
var size = new Int2((int)Mathf.Sqrt(_heightmapLength));
|
||||
if (TerrainTools.ModifyHolesMask(Terrain, ref patchCoord, (byte*)data, ref offset, ref size))
|
||||
if (TerrainTools.ModifyHolesMask(Terrain, patchCoord, (byte*)data, offset, size))
|
||||
throw new Exception("Failed to modify the terrain holes.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
/// <inheritdoc />
|
||||
protected override IntPtr GetData(ref Int2 patchCoord, object tag)
|
||||
{
|
||||
return new IntPtr(TerrainTools.GetSplatMapData(Terrain, ref patchCoord, (int)tag));
|
||||
return new IntPtr(TerrainTools.GetSplatMapData(Terrain, patchCoord, (int)tag));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -36,7 +36,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
{
|
||||
var offset = Int2.Zero;
|
||||
var size = new Int2((int)Mathf.Sqrt(_heightmapLength));
|
||||
if (TerrainTools.ModifySplatMap(Terrain, ref patchCoord, (int)tag, (Color32*)data, ref offset, ref size))
|
||||
if (TerrainTools.ModifySplatMap(Terrain, patchCoord, (int)tag, (Color32*)data, offset, size))
|
||||
throw new Exception("Failed to modify the splatmap.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ namespace FlaxEditor.Tools
|
||||
for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++)
|
||||
{
|
||||
var pos = instanceTransform.LocalToWorld(positionStream.GetFloat3(vertexIndex));
|
||||
var dst = Vector3.Distance(ref pos, ref brushSphere.Center);
|
||||
var dst = Vector3.Distance(pos, brushSphere.Center);
|
||||
if (dst > brushSphere.Radius)
|
||||
continue;
|
||||
float strength = _gizmoMode.BrushStrength * Mathf.Lerp(1.0f, 1.0f - (float)dst / (float)brushSphere.Radius, _gizmoMode.BrushFalloff);
|
||||
@@ -574,7 +574,7 @@ namespace FlaxEditor.Tools
|
||||
_brushMaterial.SetParameterValue("DepthBuffer", Owner.RenderTask.Buffers.DepthBuffer);
|
||||
Quaternion rotation = RootNode.RaycastNormalRotation(ref _hitNormal);
|
||||
Matrix transform = Matrix.Scaling(_gizmoMode.BrushSize * 0.01f) * Matrix.RotationQuaternion(rotation) * Matrix.Translation(_hitLocation - viewOrigin);
|
||||
_brushModel.Draw(ref renderContext, _brushMaterial, ref transform);
|
||||
_brushModel.Draw(renderContext, _brushMaterial, transform);
|
||||
}
|
||||
|
||||
// Draw intersecting vertices
|
||||
@@ -588,7 +588,7 @@ namespace FlaxEditor.Tools
|
||||
var instanceTransform = _selectedModel.Transform;
|
||||
var modelScaleMatrix = Matrix.Scaling(_gizmoMode.PreviewVertexSize * 0.01f);
|
||||
var brushSphere = new BoundingSphere(_hitLocation, _gizmoMode.BrushSize);
|
||||
var lodIndex = _gizmoMode.ModelLOD == -1 ? RenderTools.ComputeModelLOD(_selectedModel.Model, ref renderContext.View.Position, (float)_selectedModel.Sphere.Radius, ref renderContext) : _gizmoMode.ModelLOD;
|
||||
var lodIndex = _gizmoMode.ModelLOD == -1 ? RenderTools.ComputeModelLOD(_selectedModel.Model, renderContext.View.Position, (float)_selectedModel.Sphere.Radius, renderContext) : _gizmoMode.ModelLOD;
|
||||
lodIndex = Mathf.Clamp(lodIndex, 0, meshDatas.Length - 1);
|
||||
var lodData = meshDatas[lodIndex];
|
||||
if (lodData != null)
|
||||
@@ -603,10 +603,10 @@ namespace FlaxEditor.Tools
|
||||
for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++)
|
||||
{
|
||||
var pos = instanceTransform.LocalToWorld(positionStream.GetFloat3(vertexIndex));
|
||||
if (brushSphere.Contains(ref pos) == ContainmentType.Disjoint)
|
||||
if (brushSphere.Contains(pos) == ContainmentType.Disjoint)
|
||||
continue;
|
||||
Matrix transform = modelScaleMatrix * Matrix.Translation(pos - viewOrigin);
|
||||
_brushModel.Draw(ref renderContext, _verticesPreviewMaterial, ref transform);
|
||||
_brushModel.Draw(renderContext, _verticesPreviewMaterial, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace FlaxEditor.Actions
|
||||
script.OrderInParent = _orderInParent;
|
||||
_orderInParent = script.OrderInParent; // Ensure order is correct for script that want to use it later
|
||||
if (_prefabObjectId != Guid.Empty)
|
||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(script), ref _prefabId, ref _prefabObjectId);
|
||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(script), _prefabId, _prefabObjectId);
|
||||
Editor.Instance.Scene.MarkSceneEdited(parentActor.Scene);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace FlaxEditor.Actions
|
||||
nested.ID = ID;
|
||||
var prefab = FlaxEngine.Content.Load<Prefab>(PrefabID);
|
||||
if (prefab != null &&
|
||||
prefab.GetNestedObject(ref PrefabObjectID, out nested.PrefabID, out nested.PrefabObjectID) &&
|
||||
prefab.GetNestedObject(PrefabObjectID, out nested.PrefabID, out nested.PrefabObjectID) &&
|
||||
nested.PrefabID != Guid.Empty &&
|
||||
nested.PrefabObjectID != Guid.Empty)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ namespace FlaxEditor.Actions
|
||||
var item = items[i];
|
||||
var obj = Object.Find<Object>(ref item.ID);
|
||||
if (obj != null)
|
||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), ref item.PrefabID, ref item.PrefabObjectID);
|
||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), item.PrefabID, item.PrefabObjectID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace FlaxEditor.Actions
|
||||
Guid prefabId = _prefabIds[i];
|
||||
if (prefabId != Guid.Empty)
|
||||
{
|
||||
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(actors[i]), ref prefabId, ref _prefabObjectIds[i]);
|
||||
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(actors[i]), prefabId, _prefabObjectIds[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace FlaxEditor.Actions
|
||||
{
|
||||
var obj = Object.Find<SceneObject>(ref _idsForPrefab[i]);
|
||||
if (obj != null && _prefabIds[i] != Guid.Empty)
|
||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), ref _prefabIds[i], ref _prefabObjectIds[i]);
|
||||
SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), _prefabIds[i], _prefabObjectIds[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace FlaxEditor
|
||||
if (!isPlayMode && options.General.AutoRebuildNavMesh && data.Scene != null)
|
||||
{
|
||||
// Handle simple case where objects were moved just a little and use one navmesh build request to improve performance
|
||||
if (data.BeforeBounds.Intersects(ref data.AfterBounds))
|
||||
if (data.BeforeBounds.Intersects(data.AfterBounds))
|
||||
{
|
||||
Navigation.BuildNavMesh(data.Scene, BoundingBox.Merge(data.BeforeBounds, data.AfterBounds), options.General.AutoRebuildNavMeshTimeoutMs);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user