18 Commits

Author SHA1 Message Date
0f881fbc7a Enforce pointer alignment for InlinedAllocation
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
AssetReferences stored in inlined allocation needs to be aligned to
pointer sized boundary due to atomic operations having strict
requirements for such. Unaligned access seems to only crash on
Windows on ARM systems when trying to allocate TextRender draw chunks.
2025-10-19 22:13:40 +03:00
0898f3d020 Fix wrong build configuration used in ogg and vorbis for Windows
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
2025-10-19 17:24:10 +03:00
c63e79efa4 Add dependency build script for Visual Studio EnvDTE 2025-10-19 13:47:58 +03:00
d0eb85c04f Add dependency build script for WinPixEventRuntime
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
2025-10-18 04:20:58 +03:00
a7749abdcc Fix compiler error and wrong CPU architecture warnings on WoA 2025-10-18 04:20:58 +03:00
242d24d1a6 Fix building vorbis on Windows 2025-10-18 04:20:58 +03:00
853a7510f6 Check VS2026 toolset before trying to compile PhysX 2025-10-18 04:20:58 +03:00
88bd636cbe Fix building ogg+vorbis on macOS 2025-10-18 04:20:57 +03:00
65df32f5d7 Fix NvCloth compilation on Linux and macOS 2025-10-18 04:20:57 +03:00
4baa7fb7b8 Fix PhysX compilation on Linux and macOS 2025-10-18 04:20:57 +03:00
1644c9c5e0 Fix python tool call on macOS for glslang 2025-10-18 04:20:57 +03:00
e130ac7d80 Fix building PhysX on Linux and macOS 2025-10-18 04:20:56 +03:00
45e1d28ba2 Support building OpenAL from Git repository in other platforms 2025-10-18 04:20:56 +03:00
12f686262c Fix building curl on Linux 2025-10-18 02:33:54 +03:00
c76b9f206f Fix building Assimp on Linux
Versioned clang++ symlinks are not available on Arch
2025-10-18 02:33:44 +03:00
078485892f Add support for building dependencies with specific architecture 2025-10-18 02:33:22 +03:00
44b2db5d5d Fix CMake compatibility errors with dependencies 2025-10-18 02:19:57 +03:00
cc401f0316 Support Visual Studio 2026 as a generator for CMake dependencies 2025-10-18 02:19:57 +03:00
556 changed files with 6768 additions and 15121 deletions

View File

@@ -31,7 +31,7 @@ body:
- '1.10' - '1.10'
- '1.11' - '1.11'
- master branch - master branch
default: 3 default: 2
validations: validations:
required: true required: true
- type: textarea - type: textarea

BIN
Content/Editor/Primitives/Cube.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/ColorGrading.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/GI/GlobalSurfaceAtlas.flax (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
Content/Shaders/MotionBlur.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/SDF.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/VolumetricFog.flax (Stored with Git LFS)

Binary file not shown.

View File

@@ -4,7 +4,7 @@
"Major": 1, "Major": 1,
"Minor": 11, "Minor": 11,
"Revision": 0, "Revision": 0,
"Build": 6805 "Build": 6801
}, },
"Company": "Flax", "Company": "Flax",
"Copyright": "Copyright (c) 2012-2025 Wojciech Figat. All rights reserved.", "Copyright": "Copyright (c) 2012-2025 Wojciech Figat. All rights reserved.",

View File

@@ -15,7 +15,7 @@ if errorlevel 1 goto BuildToolFailed
:: Build bindings for all editor configurations :: Build bindings for all editor configurations
echo Building C# bindings... echo Building C# bindings...
Binaries\Tools\Flax.Build.exe -build -BuildBindingsOnly -arch=x64 -platform=Windows --buildTargets=FlaxEditor,FlaxGame Binaries\Tools\Flax.Build.exe -build -BuildBindingsOnly -arch=x64 -platform=Windows --buildTargets=FlaxEditor
popd popd
echo Done! echo Done!

View File

@@ -49,7 +49,7 @@ Follow the instructions below to compile and run the engine from source.
* Fedora: `sudo dnf install dotnet-sdk-8.0` * Fedora: `sudo dnf install dotnet-sdk-8.0`
* Arch: `sudo pacman -S dotnet-sdk-8.0 dotnet-runtime-8.0 dotnet-targeting-pack-8.0 dotnet-host` * Arch: `sudo pacman -S dotnet-sdk-8.0 dotnet-runtime-8.0 dotnet-targeting-pack-8.0 dotnet-host`
* Install Vulkan SDK ([https://vulkan.lunarg.com/](https://vulkan.lunarg.com/)) * Install Vulkan SDK ([https://vulkan.lunarg.com/](https://vulkan.lunarg.com/))
* Ubuntu: `sudo apt install vulkan-sdk` (deprecated, follow official docs) * Ubuntu: `sudo apt install vulkan-sdk`
* Fedora: `sudo dnf install vulkan-headers vulkan-tools vulkan-validation-layers` * Fedora: `sudo dnf install vulkan-headers vulkan-tools vulkan-validation-layers`
* Arch: `sudo pacman -S vulkan-headers vulkan-tools vulkan-validation-layers` * Arch: `sudo pacman -S vulkan-headers vulkan-tools vulkan-validation-layers`
* Install Git with LFS * Install Git with LFS
@@ -60,7 +60,7 @@ Follow the instructions below to compile and run the engine from source.
* Ubuntu: `sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev zlib1g-dev` * Ubuntu: `sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev zlib1g-dev`
* Fedora: `sudo dnf install libX11-devel libXcursor-devel libXinerama-devel ghc-zlib-devel` * Fedora: `sudo dnf install libX11-devel libXcursor-devel libXinerama-devel ghc-zlib-devel`
* Arch: `sudo pacman -S base-devel libx11 libxcursor libxinerama zlib` * Arch: `sudo pacman -S base-devel libx11 libxcursor libxinerama zlib`
* Install Clang compiler (version 14 or later): * Install Clang compiler (version 6 or later):
* Ubuntu: `sudo apt-get install clang lldb lld` * Ubuntu: `sudo apt-get install clang lldb lld`
* Fedora: `sudo dnf install clang llvm lldb lld` * Fedora: `sudo dnf install clang llvm lldb lld`
* Arch: `sudo pacman -S clang lldb lld` * Arch: `sudo pacman -S clang lldb lld`

View File

@@ -749,7 +749,7 @@ namespace FlaxEditor.Content
} }
// Draw short name // Draw short name
Render2D.PushClip(textRect); Render2D.PushClip(ref textRect);
var scale = 0.95f * view.ViewScale; 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.DrawText(style.FontMedium, ShowFileExtension || view.ShowFileExtensions ? FileName : ShortName, textRect, style.Foreground, nameAlignment, TextAlignment.Center, TextWrapping.WrapWords, 1f, scale);
Render2D.PopClip(); Render2D.PopClip();

View File

@@ -281,13 +281,6 @@ namespace FlaxEditor.Content
private void CacheData() private void CacheData()
{ {
if (!_asset)
{
_parameters = Utils.GetEmptyArray<ScriptMemberInfo>();
_methods = Utils.GetEmptyArray<ScriptMemberInfo>();
_attributes = Utils.GetEmptyArray<Attribute>();
return;
}
if (_parameters != null) if (_parameters != null)
return; return;
if (_asset.WaitForLoaded()) if (_asset.WaitForLoaded())
@@ -351,13 +344,13 @@ namespace FlaxEditor.Content
} }
/// <inheritdoc /> /// <inheritdoc />
public string Name => _asset ? Path.GetFileNameWithoutExtension(_asset.Path) : null; public string Name => Path.GetFileNameWithoutExtension(_asset.Path);
/// <inheritdoc /> /// <inheritdoc />
public string Namespace => string.Empty; public string Namespace => string.Empty;
/// <inheritdoc /> /// <inheritdoc />
public string TypeName => _asset ? JsonSerializer.GetStringID(_asset.ID) : null; public string TypeName => JsonSerializer.GetStringID(_asset.ID);
/// <inheritdoc /> /// <inheritdoc />
public bool IsPublic => true; public bool IsPublic => true;

View File

@@ -130,11 +130,6 @@ namespace FlaxEditor.Content
eyeAdaptation.Mode = EyeAdaptationMode.None; eyeAdaptation.Mode = EyeAdaptationMode.None;
eyeAdaptation.OverrideFlags |= EyeAdaptationSettingsOverride.Mode; eyeAdaptation.OverrideFlags |= EyeAdaptationSettingsOverride.Mode;
preview.PostFxVolume.EyeAdaptation = eyeAdaptation; preview.PostFxVolume.EyeAdaptation = eyeAdaptation;
var antiAliasing = preview.PostFxVolume.AntiAliasing;
antiAliasing.Mode = AntialiasingMode.FastApproximateAntialiasing;
antiAliasing.OverrideFlags |= AntiAliasingSettingsOverride.Mode;
preview.PostFxVolume.AntiAliasing = antiAliasing;
} }
} }
} }

View File

@@ -263,7 +263,7 @@ namespace FlaxEditor.Content.Thumbnails
// Create render task but disabled for now // Create render task but disabled for now
_output = GPUDevice.Instance.CreateTexture("ThumbnailsOutput"); _output = GPUDevice.Instance.CreateTexture("ThumbnailsOutput");
var desc = GPUTextureDescription.New2D(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize, PreviewsCache.AssetIconsAtlasFormat); var desc = GPUTextureDescription.New2D(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize, PreviewsCache.AssetIconsAtlasFormat);
_output.Init(desc); _output.Init(ref desc);
_task = Object.New<RenderTask>(); _task = Object.New<RenderTask>();
_task.Order = 50; // Render this task later _task.Order = 50; // Render this task later
_task.Enabled = false; _task.Enabled = false;

View File

@@ -15,32 +15,26 @@
#include "Editor/ProjectInfo.h" #include "Editor/ProjectInfo.h"
#include "Editor/Utilities/EditorUtilities.h" #include "Editor/Utilities/EditorUtilities.h"
String GetGDK() GDKPlatformTools::GDKPlatformTools()
{ {
String gdk; // Find GDK
Platform::GetEnvironmentVariable(TEXT("GameDKLatest"), gdk); Platform::GetEnvironmentVariable(TEXT("GameDKLatest"), _gdkPath);
if (gdk.IsEmpty() || !FileSystem::DirectoryExists(gdk)) if (_gdkPath.IsEmpty() || !FileSystem::DirectoryExists(_gdkPath))
{ {
gdk.Clear(); _gdkPath.Clear();
Platform::GetEnvironmentVariable(TEXT("GRDKLatest"), gdk); Platform::GetEnvironmentVariable(TEXT("GRDKLatest"), _gdkPath);
if (gdk.IsEmpty() || !FileSystem::DirectoryExists(gdk)) if (_gdkPath.IsEmpty() || !FileSystem::DirectoryExists(_gdkPath))
{ {
gdk.Clear(); _gdkPath.Clear();
} }
else else
{ {
if (gdk.EndsWith(TEXT("GRDK\\"))) if (_gdkPath.EndsWith(TEXT("GRDK\\")))
gdk.Remove(gdk.Length() - 6); _gdkPath.Remove(_gdkPath.Length() - 6);
else if (gdk.EndsWith(TEXT("GRDK"))) else if (_gdkPath.EndsWith(TEXT("GRDK")))
gdk.Remove(gdk.Length() - 5); _gdkPath.Remove(_gdkPath.Length() - 5);
} }
} }
return gdk;
}
GDKPlatformTools::GDKPlatformTools()
{
_gdkPath = GetGDK();
} }
DotNetAOTModes GDKPlatformTools::UseAOT() const DotNetAOTModes GDKPlatformTools::UseAOT() const
@@ -127,7 +121,7 @@ bool GDKPlatformTools::OnPostProcess(CookingData& data, GDKPlatformSettings* pla
validName.Add('\0'); validName.Add('\0');
sb.Append(TEXT("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); sb.Append(TEXT("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"));
sb.Append(TEXT("<Game configVersion=\"1\">\n")); sb.Append(TEXT("<Game configVersion=\"0\">\n"));
sb.AppendFormat(TEXT(" <Identity Name=\"{0}\" Publisher=\"{1}\" Version=\"{2}\"/>\n"), sb.AppendFormat(TEXT(" <Identity Name=\"{0}\" Publisher=\"{1}\" Version=\"{2}\"/>\n"),
validName.Get(), validName.Get(),
platformSettings->PublisherName.HasChars() ? platformSettings->PublisherName : TEXT("CN=") + gameSettings->CompanyName, platformSettings->PublisherName.HasChars() ? platformSettings->PublisherName : TEXT("CN=") + gameSettings->CompanyName,

View File

@@ -10,10 +10,9 @@
#include "Engine/Serialization/JsonTools.h" #include "Engine/Serialization/JsonTools.h"
#include "Engine/Serialization/JsonWriters.h" #include "Engine/Serialization/JsonWriters.h"
#include "Editor/Cooker/PlatformTools.h" #include "Editor/Cooker/PlatformTools.h"
#include "Engine/Engine/Globals.h"
#include "Editor/Editor.h" #include "Editor/Editor.h"
#include "Editor/ProjectInfo.h" #include "Editor/ProjectInfo.h"
#include "Editor/Utilities/EditorUtilities.h" #include "Engine/Engine/Globals.h"
#if PLATFORM_MAC #if PLATFORM_MAC
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
@@ -128,7 +127,7 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
const String dst = dstPath / StringUtils::GetFileName(file); const String dst = dstPath / StringUtils::GetFileName(file);
if (dst == file) if (dst == file)
continue; continue;
if (EditorUtilities::CopyFileIfNewer(dst, file)) if (FileSystem::CopyFile(dst, file))
{ {
data.Error(String::Format(TEXT("Failed to copy file from {0} to {1}."), file, dst)); data.Error(String::Format(TEXT("Failed to copy file from {0} to {1}."), file, dst));
return true; return true;

View File

@@ -526,7 +526,6 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
#if PLATFORM_TOOLS_XBOX_SCARLETT #if PLATFORM_TOOLS_XBOX_SCARLETT
case BuildPlatform::XboxScarlett: case BuildPlatform::XboxScarlett:
{ {
options.Platform = PlatformType::XboxScarlett;
const char* platformDefineName = "PLATFORM_XBOX_SCARLETT"; const char* platformDefineName = "PLATFORM_XBOX_SCARLETT";
COMPILE_PROFILE(DirectX_SM6, SHADER_FILE_CHUNK_INTERNAL_D3D_SM6_CACHE); COMPILE_PROFILE(DirectX_SM6, SHADER_FILE_CHUNK_INTERNAL_D3D_SM6_CACHE);
break; break;
@@ -1368,10 +1367,7 @@ bool CookAssetsStep::Perform(CookingData& data)
{ {
typeName = e.TypeName; typeName = e.TypeName;
} }
if (e.Count == 1) LOG(Info, "{0}: {1:>4} assets of total size {2}", typeName, e.Count, Utilities::BytesToText(e.ContentSize));
LOG(Info, "{0}: 1 asset of total size {1}", typeName, Utilities::BytesToText(e.ContentSize));
else
LOG(Info, "{0}: {1:>4} assets of total size {2}", typeName, e.Count, Utilities::BytesToText(e.ContentSize));
} }
LOG(Info, ""); LOG(Info, "");
} }

View File

@@ -265,7 +265,7 @@ bool DeployDataStep::Perform(CookingData& data)
} }
if (version.IsEmpty()) if (version.IsEmpty())
{ {
data.Error(String::Format(TEXT("Failed to find supported .NET {} version (min {}) for {} platform."), maxVer, minVer, platformName)); data.Error(String::Format(TEXT("Failed to find supported .NET {} version (min {}) for the current host platform."), maxVer, minVer));
return true; return true;
} }
} }

View File

@@ -59,7 +59,6 @@ bool PrecompileAssembliesStep::Perform(CookingData& data)
data.StepProgress(infoMsg, 0); data.StepProgress(infoMsg, 0);
// Override Newtonsoft.Json with AOT-version (one that doesn't use System.Reflection.Emit) // 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")); 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.xml"));
FileSystem::DeleteFile(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.pdb")); FileSystem::DeleteFile(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.pdb"));

View File

@@ -139,7 +139,7 @@ namespace FlaxEditor.CustomEditors
return new GenericEditor(); return new GenericEditor();
} }
[LibraryImport("FlaxEngine", EntryPoint = "CustomEditorsUtilInternal_GetCustomEditor", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "CustomEditorsUtilInternal_GetCustomEditor", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalUsing(typeof(SystemTypeMarshaller))] [return: MarshalUsing(typeof(SystemTypeMarshaller))]
internal static partial Type Internal_GetCustomEditor([MarshalUsing(typeof(SystemTypeMarshaller))] Type targetType); internal static partial Type Internal_GetCustomEditor([MarshalUsing(typeof(SystemTypeMarshaller))] Type targetType);
} }

View File

@@ -60,14 +60,14 @@ namespace FlaxEditor.CustomEditors.Dedicated
if (prefab && !prefab.WaitForLoaded()) if (prefab && !prefab.WaitForLoaded())
{ {
var prefabObjectId = actor.PrefabObjectID; var prefabObjectId = actor.PrefabObjectID;
var prefabInstance = prefab.GetDefaultInstance(prefabObjectId); var prefabInstance = prefab.GetDefaultInstance(ref prefabObjectId);
if (prefabInstance != null) if (prefabInstance != null)
{ {
// Use default prefab instance as a reference for the editor // Use default prefab instance as a reference for the editor
Values.SetReferenceValue(prefabInstance); Values.SetReferenceValue(prefabInstance);
// Display prefab UI (when displaying object inside Prefab Window then display only nested prefabs) // Display prefab UI (when displaying object inside Prefab Window then display only nested prefabs)
prefab.GetNestedObject(prefabObjectId, out var nestedPrefabId, out var nestedPrefabObjectId); prefab.GetNestedObject(ref prefabObjectId, out var nestedPrefabId, out var nestedPrefabObjectId);
var nestedPrefab = FlaxEngine.Content.Load<Prefab>(nestedPrefabId); var nestedPrefab = FlaxEngine.Content.Load<Prefab>(nestedPrefabId);
var panel = layout.UniformGrid(); var panel = layout.UniformGrid();
panel.CustomControl.Height = 20.0f; panel.CustomControl.Height = 20.0f;
@@ -207,7 +207,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
{ {
var actor = (Actor)Values[0]; var actor = (Actor)Values[0];
var prefabObjectId = actor.PrefabObjectID; var prefabObjectId = actor.PrefabObjectID;
var prefabInstance = prefab.GetDefaultInstance(prefabObjectId); var prefabInstance = prefab.GetDefaultInstance(ref prefabObjectId);
if (prefabInstance != null) if (prefabInstance != null)
{ {
Values.SetReferenceValue(prefabInstance); Values.SetReferenceValue(prefabInstance);
@@ -525,7 +525,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
var restored = actor.AddScript(removed.PrefabObject.GetType()); var restored = actor.AddScript(removed.PrefabObject.GetType());
var prefabId = actor.PrefabID; var prefabId = actor.PrefabID;
var prefabObjectId = restored.PrefabObjectID; var prefabObjectId = restored.PrefabObjectID;
Script.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), prefabId, prefabObjectId); Script.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), ref prefabId, ref prefabObjectId);
string data = JsonSerializer.Serialize(removed.PrefabObject); string data = JsonSerializer.Serialize(removed.PrefabObject);
JsonSerializer.Deserialize(restored, data); JsonSerializer.Deserialize(restored, data);
@@ -547,7 +547,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
string data = JsonSerializer.Serialize(removedActor.PrefabObject); string data = JsonSerializer.Serialize(removedActor.PrefabObject);
JsonSerializer.Deserialize(restored, data); JsonSerializer.Deserialize(restored, data);
Presenter.Owner.SceneContext.Spawn(restored, parentActor, removedActor.OrderInParent); Presenter.Owner.SceneContext.Spawn(restored, parentActor, removedActor.OrderInParent);
Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), prefabId, prefabObjectId); Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), ref prefabId, ref prefabObjectId);
return; return;
} }

View File

@@ -1,7 +1,6 @@
// Copyright (c) Wojciech Figat. All rights reserved. // Copyright (c) Wojciech Figat. All rights reserved.
using FlaxEngine; using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Dedicated namespace FlaxEditor.CustomEditors.Dedicated
{ {
@@ -12,7 +11,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
[CustomEditor(typeof(EnvironmentProbe)), DefaultEditor] [CustomEditor(typeof(EnvironmentProbe)), DefaultEditor]
public class EnvironmentProbeEditor : ActorEditor public class EnvironmentProbeEditor : ActorEditor
{ {
private Button _bake; private FlaxEngine.GUI.Button _bake;
/// <inheritdoc /> /// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout) public override void Initialize(LayoutElementsContainer layout)
@@ -21,9 +20,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
if (Values.HasDifferentTypes == false) if (Values.HasDifferentTypes == false)
{ {
var group = layout.Group("Bake"); layout.Space(10);
group.Panel.ItemsMargin = new Margin(Utilities.Constants.UIMargin * 2); _bake = layout.Button("Bake").Button;
_bake = group.Button("Bake").Button;
_bake.Clicked += BakeButtonClicked; _bake.Clicked += BakeButtonClicked;
} }
} }

View File

@@ -164,11 +164,11 @@ namespace FlaxEditor.CustomEditors.Dedicated
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14); var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
// Deselect // Deselect
if (isSelected && button1Rect.Contains(location)) if (isSelected && button1Rect.Contains(ref location))
Value = new ModelInstanceActor.MeshReference { Actor = null, LODIndex = -1, MeshIndex = -1 }; Value = new ModelInstanceActor.MeshReference { Actor = null, LODIndex = -1, MeshIndex = -1 };
// Picker dropdown menu // Picker dropdown menu
if ((isSelected ? button2Rect : button1Rect).Contains(location)) if ((isSelected ? button2Rect : button1Rect).Contains(ref location))
ShowDropDownMenu(); ShowDropDownMenu();
return base.OnMouseUp(location, button); return base.OnMouseUp(location, button);

View File

@@ -40,7 +40,7 @@ public class ModelPrefabEditor : GenericEditor
if (prefab) if (prefab)
{ {
var prefabObjectId = modelPrefab.PrefabObjectID; var prefabObjectId = modelPrefab.PrefabObjectID;
var prefabObject = prefab.GetDefaultInstance(prefabObjectId); var prefabObject = prefab.GetDefaultInstance(ref prefabObjectId);
if (prefabObject.PrefabID == _prefabId) if (prefabObject.PrefabID == _prefabId)
break; break;
_prefabId = prefabObject.PrefabID; _prefabId = prefabObject.PrefabID;

View File

@@ -914,11 +914,9 @@ namespace FlaxEditor.CustomEditors.Dedicated
// Remove drop down arrows and containment lines if no objects in the group // Remove drop down arrows and containment lines if no objects in the group
if (group.Children.Count == 0) if (group.Children.Count == 0)
{ {
group.Panel.Close();
group.Panel.ArrowImageOpened = null; group.Panel.ArrowImageOpened = null;
group.Panel.ArrowImageClosed = null; group.Panel.ArrowImageClosed = null;
group.Panel.EnableContainmentLines = false; group.Panel.EnableContainmentLines = false;
group.Panel.CanOpenClose = false;
} }
// Scripts arrange bar // Scripts arrange bar

View File

@@ -1,7 +1,6 @@
// Copyright (c) Wojciech Figat. All rights reserved. // Copyright (c) Wojciech Figat. All rights reserved.
using FlaxEngine; using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Dedicated namespace FlaxEditor.CustomEditors.Dedicated
{ {
@@ -20,9 +19,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
if (Values.HasDifferentTypes == false) if (Values.HasDifferentTypes == false)
{ {
// Add 'Bake' button // Add 'Bake' button
var group = layout.Group("Bake"); layout.Space(10);
group.Panel.ItemsMargin = new Margin(Utilities.Constants.UIMargin * 2); var button = layout.Button("Bake");
var button = group.Button("Bake");
button.Button.Clicked += BakeButtonClicked; button.Button.Clicked += BakeButtonClicked;
} }
} }

View File

@@ -123,8 +123,6 @@ namespace FlaxEditor.CustomEditors.Editors
{ {
base.Refresh(); base.Refresh();
if (Picker == null)
return;
var differentValues = HasDifferentValues; var differentValues = HasDifferentValues;
Picker.DifferentValues = differentValues; Picker.DifferentValues = differentValues;
if (!differentValues) if (!differentValues)
@@ -192,7 +190,7 @@ namespace FlaxEditor.CustomEditors.Editors
public override bool OnMouseDown(Float2 location, MouseButton button) public override bool OnMouseDown(Float2 location, MouseButton button)
{ {
if (DropdownRect.Contains(location)) if (DropdownRect.Contains(ref location))
{ {
Focus(); Focus();
ShowPicker(); ShowPicker();
@@ -206,7 +204,7 @@ namespace FlaxEditor.CustomEditors.Editors
{ {
base.OnMouseMove(location); base.OnMouseMove(location);
if (DropdownRect.Contains(location)) if (DropdownRect.Contains(ref location))
Cursor = CursorType.Default; Cursor = CursorType.Default;
else else
Cursor = CursorType.IBeam; Cursor = CursorType.IBeam;

View File

@@ -71,7 +71,7 @@ namespace FlaxEditor.CustomEditors.Editors
menu.AddButton("Copy", linkedEditor.Copy); menu.AddButton("Copy", linkedEditor.Copy);
var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index)); var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index));
b.Enabled = !Editor._readOnly && Editor._canResize; b.Enabled = linkedEditor.CanPaste && !Editor._readOnly && Editor._canResize;
b = menu.AddButton("Paste", linkedEditor.Paste); b = menu.AddButton("Paste", linkedEditor.Paste);
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly; b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
@@ -155,7 +155,7 @@ namespace FlaxEditor.CustomEditors.Editors
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button) public override bool OnMouseDown(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location)) if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
{ {
_arrangeButtonInUse = true; _arrangeButtonInUse = true;
Focus(); Focus();
@@ -371,7 +371,7 @@ namespace FlaxEditor.CustomEditors.Editors
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button) public override bool OnMouseDown(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location)) if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
{ {
_arrangeButtonInUse = true; _arrangeButtonInUse = true;
Focus(); Focus();
@@ -407,7 +407,7 @@ namespace FlaxEditor.CustomEditors.Editors
menu.AddButton("Copy", linkedEditor.Copy); menu.AddButton("Copy", linkedEditor.Copy);
var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index)); var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index));
b.Enabled = !Editor._readOnly && Editor._canResize; b.Enabled = linkedEditor.CanPaste && !Editor._readOnly && Editor._canResize;
var paste = menu.AddButton("Paste", linkedEditor.Paste); var paste = menu.AddButton("Paste", linkedEditor.Paste);
paste.Enabled = linkedEditor.CanPaste && !Editor._readOnly; paste.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
@@ -650,7 +650,7 @@ namespace FlaxEditor.CustomEditors.Editors
panel.Panel.Size = new Float2(0, 18); panel.Panel.Size = new Float2(0, 18);
panel.Panel.Margin = new Margin(0, 0, Utilities.Constants.UIMargin, 0); panel.Panel.Margin = new Margin(0, 0, Utilities.Constants.UIMargin, 0);
var removeButton = panel.Button("-", "Remove the last item."); var removeButton = panel.Button("-", "Remove the last item");
removeButton.Button.Size = new Float2(16, 16); removeButton.Button.Size = new Float2(16, 16);
removeButton.Button.Enabled = size > _minCount; removeButton.Button.Enabled = size > _minCount;
removeButton.Button.AnchorPreset = AnchorPresets.TopRight; removeButton.Button.AnchorPreset = AnchorPresets.TopRight;
@@ -661,7 +661,7 @@ namespace FlaxEditor.CustomEditors.Editors
Resize(Count - 1); Resize(Count - 1);
}; };
var addButton = panel.Button("+", "Add a new item."); var addButton = panel.Button("+", "Add a new item");
addButton.Button.Size = new Float2(16, 16); addButton.Button.Size = new Float2(16, 16);
addButton.Button.Enabled = (!NotNullItems || size > 0) && size < _maxCount; addButton.Button.Enabled = (!NotNullItems || size > 0) && size < _maxCount;
addButton.Button.AnchorPreset = AnchorPresets.TopRight; addButton.Button.AnchorPreset = AnchorPresets.TopRight;

View File

@@ -321,11 +321,11 @@ namespace FlaxEditor.CustomEditors.Editors
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14); var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
// Deselect // Deselect
if (_value != null && button1Rect.Contains(location)) if (_value != null && button1Rect.Contains(ref location))
Value = null; Value = null;
// Picker dropdown menu // Picker dropdown menu
if (_supportsPickDropDown && (isSelected ? button2Rect : button1Rect).Contains(location)) if (_supportsPickDropDown && (isSelected ? button2Rect : button1Rect).Contains(ref location))
{ {
ShowDropDownMenu(); ShowDropDownMenu();
return true; return true;

View File

@@ -247,7 +247,7 @@ namespace FlaxEditor.CustomEditors.Editors
/// <returns>The items.</returns> /// <returns>The items.</returns>
protected virtual List<ItemInfo> GetItemsForType(ScriptType type) protected virtual List<ItemInfo> GetItemsForType(ScriptType type)
{ {
return GetItemsForType(type, type.IsClass, true, true); return GetItemsForType(type, type.IsClass, true);
} }
/// <summary> /// <summary>
@@ -273,14 +273,10 @@ namespace FlaxEditor.CustomEditors.Editors
var attributes = p.GetAttributes(true); var attributes = p.GetAttributes(true);
var showInEditor = attributes.Any(x => x is ShowInEditorAttribute); var showInEditor = attributes.Any(x => x is ShowInEditorAttribute);
// Skip properties without getter // Skip properties without getter or setter
if (!p.HasGet || (!p.HasSet && !showInEditor && !usePropertiesWithoutSetter)) if (!p.HasGet || (!p.HasSet && !showInEditor && !usePropertiesWithoutSetter))
continue; 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 // Skip hidden fields, handle special attributes
if ((!p.IsPublic && !showInEditor) || attributes.Any(x => x is HideInEditorAttribute)) if ((!p.IsPublic && !showInEditor) || attributes.Any(x => x is HideInEditorAttribute))
continue; continue;

View File

@@ -104,7 +104,7 @@ namespace FlaxEditor.CustomEditors.Editors
public event Action<TypePickerControl> TypePickerValueChanged; public event Action<TypePickerControl> TypePickerValueChanged;
/// <summary> /// <summary>
/// The custom callback for types validation. Can be used to implement a rule for types to pick. /// The custom callback for types validation. Cane be used to implement a rule for types to pick.
/// </summary> /// </summary>
public Func<ScriptType, bool> CheckValid; public Func<ScriptType, bool> CheckValid;
@@ -219,11 +219,11 @@ namespace FlaxEditor.CustomEditors.Editors
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14); var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
// Deselect // Deselect
if (_value && button1Rect.Contains(location) && _type == ScriptType.Null) if (_value && button1Rect.Contains(ref location) && _type == ScriptType.Null)
Value = ScriptType.Null; Value = ScriptType.Null;
// Picker dropdown menu // Picker dropdown menu
if ((isSelected && _type == ScriptType.Null ? button2Rect : button1Rect).Contains(location)) if ((isSelected && _type == ScriptType.Null ? button2Rect : button1Rect).Contains(ref location))
ShowDropDownMenu(); ShowDropDownMenu();
return base.OnMouseUp(location, button); return base.OnMouseUp(location, button);
@@ -353,13 +353,7 @@ namespace FlaxEditor.CustomEditors.Editors
} }
if (!string.IsNullOrEmpty(typeReference.CheckMethod)) if (!string.IsNullOrEmpty(typeReference.CheckMethod))
{ {
var parentEditor = ParentEditor; var parentType = ParentEditor.Values[0].GetType();
// Find actual parent editor if parent editor is collection editor
while (parentEditor.GetType().IsAssignableTo(typeof(CollectionEditor)))
parentEditor = parentEditor.ParentEditor;
var parentType = parentEditor.Values[0].GetType();
var method = parentType.GetMethod(typeReference.CheckMethod, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); var method = parentType.GetMethod(typeReference.CheckMethod, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (method != null) if (method != null)
{ {

View File

@@ -526,23 +526,6 @@ int32 Editor::LoadProduct()
return 12; return 12;
} }
// Get the last opened project path
String localCachePath;
FileSystem::GetSpecialFolderPath(SpecialFolder::AppData, localCachePath);
String editorConfigPath = localCachePath / TEXT("Flax");
String lastProjectSettingPath = editorConfigPath / TEXT("LastProject.txt");
if (!FileSystem::DirectoryExists(editorConfigPath))
FileSystem::CreateDirectory(editorConfigPath);
String lastProjectPath;
if (FileSystem::FileExists(lastProjectSettingPath))
File::ReadAllText(lastProjectSettingPath, lastProjectPath);
if (!FileSystem::DirectoryExists(lastProjectPath))
lastProjectPath = String::Empty;
// Try to open the last project when requested
if (projectPath.IsEmpty() && CommandLine::Options.LastProject.IsTrue() && !lastProjectPath.IsEmpty())
projectPath = lastProjectPath;
// Missing project case // Missing project case
if (projectPath.IsEmpty()) if (projectPath.IsEmpty())
{ {
@@ -558,7 +541,7 @@ int32 Editor::LoadProduct()
Array<String> files; Array<String> files;
if (FileSystem::ShowOpenFileDialog( if (FileSystem::ShowOpenFileDialog(
nullptr, nullptr,
lastProjectPath, StringView::Empty,
TEXT("Project files (*.flaxproj)\0*.flaxproj\0All files (*.*)\0*.*\0"), TEXT("Project files (*.flaxproj)\0*.flaxproj\0All files (*.*)\0*.*\0"),
false, false,
TEXT("Select project to open in Editor"), TEXT("Select project to open in Editor"),
@@ -642,10 +625,6 @@ int32 Editor::LoadProduct()
} }
} }
// Update the last opened project path
if (lastProjectPath.Compare(Project->ProjectFolderPath) != 0)
File::WriteAllText(lastProjectSettingPath, Project->ProjectFolderPath, Encoding::UTF8);
return 0; return 0;
} }

View File

@@ -69,18 +69,18 @@ namespace FlaxEditor
/// <summary> /// <summary>
/// Gets a value indicating whether this Editor is running a dev instance of the engine. /// Gets a value indicating whether this Editor is running a dev instance of the engine.
/// </summary> /// </summary>
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsDevInstance")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsDevInstance", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool IsDevInstance(); internal static partial bool IsDevInstance();
/// <summary> /// <summary>
/// Gets a value indicating whether this Editor is running as official build (distributed via Flax services). /// Gets a value indicating whether this Editor is running as official build (distributed via Flax services).
/// </summary> /// </summary>
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsOfficialBuild")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsOfficialBuild", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool IsOfficialBuild(); internal static partial bool IsOfficialBuild();
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsPlayMode")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_IsPlayMode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_IsPlayMode(); internal static partial bool Internal_IsPlayMode();
@@ -1056,7 +1056,7 @@ namespace FlaxEditor
if (actor) if (actor)
{ {
Internal_GetEditorBoxWithChildren(FlaxEngine.Object.GetUnmanagedPtr(actor), out var box); Internal_GetEditorBoxWithChildren(FlaxEngine.Object.GetUnmanagedPtr(actor), out var box);
BoundingSphere.FromBox(box, out sphere); BoundingSphere.FromBox(ref box, out sphere);
if (sphere == BoundingSphere.Empty) if (sphere == BoundingSphere.Empty)
sphere = new BoundingSphere(actor.Position, sphere.Radius); sphere = new BoundingSphere(actor.Position, sphere.Radius);
sphere.Radius = Math.Max(sphere.Radius, 15.0f); sphere.Radius = Math.Max(sphere.Radius, 15.0f);
@@ -1390,7 +1390,6 @@ namespace FlaxEditor
public void BuildAllMeshesSDF() public void BuildAllMeshesSDF()
{ {
var models = new List<Model>(); var models = new List<Model>();
var forceRebuild = Input.GetKey(KeyboardKeys.F);
Scene.ExecuteOnGraph(node => Scene.ExecuteOnGraph(node =>
{ {
if (node is StaticModelNode staticModelNode && staticModelNode.Actor is StaticModel staticModel) if (node is StaticModelNode staticModelNode && staticModelNode.Actor is StaticModel staticModel)
@@ -1400,7 +1399,7 @@ namespace FlaxEditor
model != null && model != null &&
!models.Contains(model) && !models.Contains(model) &&
!model.IsVirtual && !model.IsVirtual &&
(forceRebuild || model.SDF.Texture == null)) model.SDF.Texture == null)
{ {
models.Add(model); models.Add(model);
} }
@@ -1413,17 +1412,7 @@ namespace FlaxEditor
{ {
var model = models[i]; var model = models[i];
Log($"[{i}/{models.Count}] Generating SDF for {model}"); Log($"[{i}/{models.Count}] Generating SDF for {model}");
float resolutionScale = 1.0f, backfacesThreshold = 0.6f; if (!model.GenerateSDF())
int lodIndex = 6;
bool useGPU = true;
var sdf = model.SDF;
if (sdf.Texture != null)
{
// Preserve options set on this model
resolutionScale = sdf.ResolutionScale;
lodIndex = sdf.LOD;
}
if (!model.GenerateSDF(resolutionScale, lodIndex, true, backfacesThreshold, useGPU))
model.Save(); model.Save();
} }
}); });
@@ -1598,7 +1587,7 @@ namespace FlaxEditor
if (dockedTo != null && dockedTo.SelectedTab != gameWin && dockedTo.SelectedTab != null) if (dockedTo != null && dockedTo.SelectedTab != gameWin && dockedTo.SelectedTab != null)
result = dockedTo.SelectedTab.Size; result = dockedTo.SelectedTab.Size;
else else
result = gameWin.Viewport.ContentSize; result = gameWin.Viewport.Size;
result *= root.DpiScale; result *= root.DpiScale;
result = Float2.Round(result); result = Float2.Round(result);
@@ -1647,103 +1636,96 @@ namespace FlaxEditor
} }
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ReadOutputLogs", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_ReadOutputLogs", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]
internal static partial int Internal_ReadOutputLogs([MarshalUsing(typeof(FlaxEngine.Interop.NativeArrayMarshaller<string, FlaxEngine.Interop.NativeString>), CountElementName = "outCapacity")] ref string[] outMessages, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)] ref byte[] outLogTypes, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I8, SizeParamIndex = 3)] ref long[] outLogTimes, int outCapacity); internal static partial int Internal_ReadOutputLogs([MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref string[] outMessages, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref byte[] outLogTypes, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "outCapacity")] ref long[] outLogTimes, int outCapacity);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetPlayMode")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetPlayMode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]
internal static partial void Internal_SetPlayMode([MarshalAs(UnmanagedType.U1)] bool value); internal static partial void Internal_SetPlayMode([MarshalAs(UnmanagedType.U1)] bool value);
internal static string Internal_GetProjectPath() [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetProjectPath", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
{ internal static partial string Internal_GetProjectPath();
Internal_GetProjectPath(out string projectPath);
return projectPath;
}
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetProjectPath", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CloneAssetFile", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_GetProjectPath([MarshalUsing(typeof(FlaxEngine.Interop.StringViewMarshaller))] out string projectPath);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CloneAssetFile", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CloneAssetFile(string dstPath, string srcPath, ref Guid dstId); internal static partial bool Internal_CloneAssetFile(string dstPath, string srcPath, ref Guid dstId);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetAudioClipMetadata")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetAudioClipMetadata", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_GetAudioClipMetadata(IntPtr obj, out int originalSize, out int importedSize); internal static partial void Internal_GetAudioClipMetadata(IntPtr obj, out int originalSize, out int importedSize);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SaveJsonAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SaveJsonAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_SaveJsonAsset(string outputPath, string data, string typename); internal static partial bool Internal_SaveJsonAsset(string outputPath, string data, string typename);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CopyCache")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CopyCache", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_CopyCache(ref Guid dstId, ref Guid srcId); internal static partial void Internal_CopyCache(ref Guid dstId, ref Guid srcId);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_BakeLightmaps")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_BakeLightmaps", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_BakeLightmaps([MarshalAs(UnmanagedType.U1)] bool cancel); internal static partial void Internal_BakeLightmaps([MarshalAs(UnmanagedType.U1)] bool cancel);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetShaderAssetSourceCode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetShaderAssetSourceCode", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalUsing(typeof(FlaxEngine.Interop.StringViewMarshaller))]
internal static partial string Internal_GetShaderAssetSourceCode(IntPtr obj); internal static partial string Internal_GetShaderAssetSourceCode(IntPtr obj);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CookMeshCollision", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CookMeshCollision", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CookMeshCollision(string path, CollisionDataType type, IntPtr model, int modelLodIndex, uint materialSlotsMask, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit); internal static partial bool Internal_CookMeshCollision(string path, CollisionDataType type, IntPtr model, int modelLodIndex, uint materialSlotsMask, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetCollisionWires")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetCollisionWires", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_GetCollisionWires(IntPtr collisionData, [MarshalUsing(typeof(FlaxEngine.Interop.NativeArrayMarshaller<,>), CountElementName = "trianglesCount")] out Float3[] triangles, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "indicesCount")] out int[] indices, out int trianglesCount, out int indicesCount); internal static partial void Internal_GetCollisionWires(IntPtr collisionData, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "trianglesCount")] out Float3[] triangles, [MarshalUsing(typeof(FlaxEngine.Interop.ArrayMarshaller<,>), CountElementName = "indicesCount")] out int[] indices, out int trianglesCount, out int indicesCount);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetEditorBoxWithChildren")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetEditorBoxWithChildren", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_GetEditorBoxWithChildren(IntPtr obj, out BoundingBox resultAsRef); internal static partial void Internal_GetEditorBoxWithChildren(IntPtr obj, out BoundingBox resultAsRef);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetOptions")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetOptions", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_SetOptions(ref InternalOptions options); internal static partial void Internal_SetOptions(ref InternalOptions options);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_DrawNavMesh")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_DrawNavMesh", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_DrawNavMesh(); internal static partial void Internal_DrawNavMesh();
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CloseSplashScreen")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CloseSplashScreen", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_CloseSplashScreen(); internal static partial void Internal_CloseSplashScreen();
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CreateVisualScript", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CreateVisualScript", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CreateVisualScript(string outputPath, string baseTypename); internal static partial bool Internal_CreateVisualScript(string outputPath, string baseTypename);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanImport", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanImport", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial string Internal_CanImport(string extension); internal static partial string Internal_CanImport(string extension);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanExport", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanExport", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CanExport(string path); internal static partial bool Internal_CanExport(string path);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_Export", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_Export", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_Export(string inputPath, string outputFolder); internal static partial bool Internal_Export(string inputPath, string outputFolder);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetIsEveryAssemblyLoaded")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetIsEveryAssemblyLoaded", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_GetIsEveryAssemblyLoaded(); internal static partial bool Internal_GetIsEveryAssemblyLoaded();
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetLastProjectOpenedEngineBuild")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetLastProjectOpenedEngineBuild", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial int Internal_GetLastProjectOpenedEngineBuild(); internal static partial int Internal_GetLastProjectOpenedEngineBuild();
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetIsCSGActive")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetIsCSGActive", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_GetIsCSGActive(); internal static partial bool Internal_GetIsCSGActive();
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_RunVisualScriptBreakpointLoopTick")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_RunVisualScriptBreakpointLoopTick", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_RunVisualScriptBreakpointLoopTick(float deltaTime); internal static partial void Internal_RunVisualScriptBreakpointLoopTick(float deltaTime);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_DeserializeSceneObject", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(FlaxEngine.Interop.StringMarshaller))] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_DeserializeSceneObject", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_DeserializeSceneObject(IntPtr sceneObject, string json); internal static partial void Internal_DeserializeSceneObject(IntPtr sceneObject, string json);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_LoadAsset")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_LoadAsset", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_LoadAsset(ref Guid id); internal static partial void Internal_LoadAsset(ref Guid id);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanSetToRoot")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_CanSetToRoot", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
internal static partial bool Internal_CanSetToRoot(IntPtr prefab, IntPtr newRoot); internal static partial bool Internal_CanSetToRoot(IntPtr prefab, IntPtr newRoot);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetAnimationTime")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_GetAnimationTime", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial float Internal_GetAnimationTime(IntPtr animatedModel); internal static partial float Internal_GetAnimationTime(IntPtr animatedModel);
[LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetAnimationTime")] [LibraryImport("FlaxEngine", EntryPoint = "EditorInternal_SetAnimationTime", StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(StringMarshaller))]
internal static partial void Internal_SetAnimationTime(IntPtr animatedModel, float time); internal static partial void Internal_SetAnimationTime(IntPtr animatedModel, float time);
#endregion #endregion

View File

@@ -96,7 +96,7 @@ namespace FlaxEditor.GUI
private void DoDrag() private void DoDrag()
{ {
// Do the drag drop operation if has selected element // Do the drag drop operation if has selected element
if (new Rectangle(Float2.Zero, Size).Contains(_mouseDownPos)) if (new Rectangle(Float2.Zero, Size).Contains(ref _mouseDownPos))
{ {
if (Validator.SelectedAsset != null) if (Validator.SelectedAsset != null)
DoDragDrop(DragAssets.GetDragData(Validator.SelectedAsset)); DoDragDrop(DragAssets.GetDragData(Validator.SelectedAsset));

View File

@@ -62,7 +62,7 @@ namespace FlaxEditor.GUI
for (int i = 0; i < children.Count; i++) for (int i = 0; i < children.Count; i++)
{ {
if (children[i] is KeyframePoint p) if (children[i] is KeyframePoint p)
p.IsSelected = p.Bounds.Intersects(selectionRect); p.IsSelected = p.Bounds.Intersects(ref selectionRect);
} }
_editor.UpdateTangents(); _editor.UpdateTangents();
} }
@@ -85,7 +85,7 @@ namespace FlaxEditor.GUI
internal void OnMove(Float2 location) internal void OnMove(Float2 location)
{ {
// Skip updating keyframes until move actual starts to be meaningful // Skip updating keyframes until move actual starts to be meaningful
if (Float2.Distance(_movingSelectionStartPosLock, location) < 1.5f) if (Float2.Distance(ref _movingSelectionStartPosLock, ref location) < 1.5f)
return; return;
_movingSelectionStartPosLock = Float2.Minimum; _movingSelectionStartPosLock = Float2.Minimum;

View File

@@ -689,8 +689,8 @@ namespace FlaxEditor.GUI
if (selectedOnly && !point.IsSelected) if (selectedOnly && !point.IsSelected)
continue; continue;
var pos = point.Point; var pos = point.Point;
Float2.Min(posMin, pos, out posMin); Float2.Min(ref posMin, ref pos, out posMin);
Float2.Max(posMax, pos, out posMax); Float2.Max(ref posMax, ref pos, out posMax);
} }
// Apply margin around the area // Apply margin around the area
@@ -703,16 +703,16 @@ namespace FlaxEditor.GUI
PointFromKeyframesToContents(ref posMin, ref viewRect); PointFromKeyframesToContents(ref posMin, ref viewRect);
PointFromKeyframesToContents(ref posMax, ref viewRect); PointFromKeyframesToContents(ref posMax, ref viewRect);
var tmp = posMin; var tmp = posMin;
Float2.Min(posMin, posMax, out posMin); Float2.Min(ref posMin, ref posMax, out posMin);
Float2.Max(posMax, tmp, out posMax); Float2.Max(ref posMax, ref tmp, out posMax);
var contentsSize = posMax - posMin; var contentsSize = posMax - posMin;
// Convert from Contents to Main Panel // Convert from Contents to Main Panel
posMin = _contents.PointToParent(posMin); posMin = _contents.PointToParent(posMin);
posMax = _contents.PointToParent(posMax); posMax = _contents.PointToParent(posMax);
tmp = posMin; tmp = posMin;
Float2.Min(posMin, posMax, out posMin); Float2.Min(ref posMin, ref posMax, out posMin);
Float2.Max(posMax, tmp, out posMax); Float2.Max(ref posMax, ref tmp, out posMax);
// Update zoom (leave unchanged when focusing a single point) // Update zoom (leave unchanged when focusing a single point)
var zoomMask = EnableZoom; var zoomMask = EnableZoom;
@@ -941,7 +941,7 @@ namespace FlaxEditor.GUI
{ {
SetupGrid(out var min, out var max, out var pixelRange); SetupGrid(out var min, out var max, out var pixelRange);
Render2D.PushClip(viewRect); Render2D.PushClip(ref viewRect);
if ((ShowAxes & UseMode.Vertical) == UseMode.Vertical) if ((ShowAxes & UseMode.Vertical) == UseMode.Vertical)
DrawAxis(Float2.UnitX, viewRect, min.X, max.X, pixelRange.X); DrawAxis(Float2.UnitX, viewRect, min.X, max.X, pixelRange.X);
@@ -954,7 +954,7 @@ namespace FlaxEditor.GUI
// Draw curve // Draw curve
if (!_showCollapsed) if (!_showCollapsed)
{ {
Render2D.PushClip(rect); Render2D.PushClip(ref rect);
DrawCurve(ref viewRect); DrawCurve(ref viewRect);
Render2D.PopClip(); Render2D.PopClip();
} }

View File

@@ -180,7 +180,7 @@ namespace FlaxEditor.GUI.Input
Focus(); Focus();
float mousePosition = location.X; float mousePosition = location.X;
if (_thumbRect.Contains(location)) if (_thumbRect.Contains(ref location))
{ {
// Start sliding // Start sliding
_isSliding = true; _isSliding = true;

View File

@@ -144,7 +144,7 @@ namespace FlaxEditor.GUI.Timeline
var k = keyframes[i]; var k = keyframes[i];
var sphere = new BoundingSphere(k.Value, KeyframeSize); var sphere = new BoundingSphere(k.Value, KeyframeSize);
if (sphere.Intersects(selectRay)) if (sphere.Intersects(ref selectRay))
{ {
SelectKeyframe(_track, i, 0); SelectKeyframe(_track, i, 0);
return; return;
@@ -154,7 +154,7 @@ namespace FlaxEditor.GUI.Timeline
{ {
var t = k.Value + k.TangentIn; var t = k.Value + k.TangentIn;
var box = BoundingBox.FromSphere(new BoundingSphere(t, TangentSize)); var box = BoundingBox.FromSphere(new BoundingSphere(t, TangentSize));
if (box.Intersects(selectRay)) if (box.Intersects(ref selectRay))
{ {
SelectKeyframe(_track, i, 1); SelectKeyframe(_track, i, 1);
return; return;
@@ -165,7 +165,7 @@ namespace FlaxEditor.GUI.Timeline
{ {
var t = k.Value + k.TangentOut; var t = k.Value + k.TangentOut;
var box = BoundingBox.FromSphere(new BoundingSphere(t, TangentSize)); var box = BoundingBox.FromSphere(new BoundingSphere(t, TangentSize));
if (box.Intersects(selectRay)) if (box.Intersects(ref selectRay))
{ {
SelectKeyframe(_track, i, 2); SelectKeyframe(_track, i, 2);
return; return;

View File

@@ -115,7 +115,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
/// <inheritdoc /> /// <inheritdoc />
public override void OnMouseMove(Float2 location) public override void OnMouseMove(Float2 location)
{ {
if (_isMoving && Float2.DistanceSquared(location, _startMovePos) > 25.0f) if (_isMoving && Float2.DistanceSquared(ref location, ref _startMovePos) > 25.0f)
{ {
_startMovePos = Float2.Minimum; _startMovePos = Float2.Minimum;
var x = PointToParent(location).X; var x = PointToParent(location).X;
@@ -387,7 +387,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
{ {
// Push clipping mask // Push clipping mask
GetDesireClientArea(out var clientArea); GetDesireClientArea(out var clientArea);
Render2D.PushClip(clientArea); Render2D.PushClip(ref clientArea);
var style = Style.Current; var style = Style.Current;
var bounds = new Rectangle(Float2.Zero, Size); var bounds = new Rectangle(Float2.Zero, Size);

View File

@@ -115,7 +115,7 @@ namespace FlaxEditor.GUI
{ {
if (Children[i] is KeyframePoint p) if (Children[i] is KeyframePoint p)
{ {
p.IsSelected = p.Bounds.Intersects(selectionRect); p.IsSelected = p.Bounds.Intersects(ref selectionRect);
} }
} }
} }
@@ -401,7 +401,7 @@ namespace FlaxEditor.GUI
Cursor = CursorType.Default; Cursor = CursorType.Default;
// Check if no move has been made at all // Check if no move has been made at all
if (Float2.Distance(location, _rightMouseDownPos) < 2.0f) if (Float2.Distance(ref location, ref _rightMouseDownPos) < 2.0f)
{ {
var selectionCount = _editor.SelectionCount; var selectionCount = _editor.SelectionCount;
var point = GetChildAt(location) as KeyframePoint; var point = GetChildAt(location) as KeyframePoint;

View File

@@ -50,14 +50,14 @@ namespace FlaxEditor.GUI.Timeline.GUI
var color = (_timeline.IsMovingPositionHandle ? style.SelectionBorder : style.Foreground).AlphaMultiplied(0.6f); var color = (_timeline.IsMovingPositionHandle ? style.SelectionBorder : style.Foreground).AlphaMultiplied(0.6f);
Matrix3x3.RotationZ(Mathf.PiOverTwo, out var m1); Matrix3x3.RotationZ(Mathf.PiOverTwo, out var m1);
var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset); var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset);
Matrix3x3.Multiply(m1, m2, out var m3); Matrix3x3.Multiply(ref m1, ref m2, out var m3);
Render2D.PushTransform(m3); Render2D.PushTransform(ref m3);
// TODO: Convert to its own sprite or 9 slice // 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.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.FillRectangle(new Rectangle(new Float2(-6, -icon.Size.Y * 0.5f + 7), new Float2(timeAxisOverlap, 5)), color);
Render2D.PopTransform(); Render2D.PopTransform();
var textMatrix = Matrix3x3.Translation2D(12, timeAxisHeaderOffset); var textMatrix = Matrix3x3.Translation2D(12, timeAxisHeaderOffset);
Render2D.PushTransform(textMatrix); Render2D.PushTransform(ref textMatrix);
Render2D.DrawText(style.FontSmall, labelText, style.Foreground, new Float2(2, -6)); Render2D.DrawText(style.FontSmall, labelText, style.Foreground, new Float2(2, -6));
Render2D.PopTransform(); Render2D.PopTransform();

View File

@@ -356,7 +356,7 @@ namespace FlaxEditor.GUI.Timeline
{ {
Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, moveColor, moveThickness); Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, moveColor, moveThickness);
} }
else if (IsMouseOver && CanResize && MoveLeftEdgeRect.Contains(_mouseLocation)) else if (IsMouseOver && CanResize && MoveLeftEdgeRect.Contains(ref _mouseLocation))
{ {
Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, Color.Yellow); Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, Color.Yellow);
} }
@@ -364,7 +364,7 @@ namespace FlaxEditor.GUI.Timeline
{ {
Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, moveColor, moveThickness); Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, moveColor, moveThickness);
} }
else if (IsMouseOver && CanResize && MoveRightEdgeRect.Contains(_mouseLocation)) else if (IsMouseOver && CanResize && MoveRightEdgeRect.Contains(ref _mouseLocation))
{ {
Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, Color.Yellow); Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, Color.Yellow);
} }
@@ -384,8 +384,8 @@ namespace FlaxEditor.GUI.Timeline
_startMoveLocation = Root.MousePosition; _startMoveLocation = Root.MousePosition;
_startMoveStartFrame = StartFrame; _startMoveStartFrame = StartFrame;
_startMoveDuration = DurationFrames; _startMoveDuration = DurationFrames;
_startMoveLeftEdge = MoveLeftEdgeRect.Contains(location) && CanResize; _startMoveLeftEdge = MoveLeftEdgeRect.Contains(ref location) && CanResize;
_startMoveRightEdge = MoveRightEdgeRect.Contains(location) && CanResize; _startMoveRightEdge = MoveRightEdgeRect.Contains(ref location) && CanResize;
StartMouseCapture(true); StartMouseCapture(true);
if (_startMoveLeftEdge || _startMoveRightEdge) if (_startMoveLeftEdge || _startMoveRightEdge)
return true; return true;

View File

@@ -337,7 +337,7 @@ namespace FlaxEditor.GUI.Timeline
DebugDraw.DrawSphere(sphere, selected ? Color.Yellow : Color.Red); DebugDraw.DrawSphere(sphere, selected ? Color.Yellow : Color.Red);
sphere.Radius *= 0.95f; sphere.Radius *= 0.95f;
DebugDraw.DrawSphere(sphere, new Color(1, 0, 0, coveredAlpha), 0, false); DebugDraw.DrawSphere(sphere, new Color(1, 0, 0, coveredAlpha), 0, false);
if (select && sphere.Intersects(selectRay)) if (select && sphere.Intersects(ref selectRay))
SelectKeyframeGizmo(curveTrack, i, 0); SelectKeyframeGizmo(curveTrack, i, 0);
if (!k.TangentIn.IsZero) if (!k.TangentIn.IsZero)
@@ -349,7 +349,7 @@ namespace FlaxEditor.GUI.Timeline
var box = BoundingBox.FromSphere(new BoundingSphere(t, EditCurveTrackGizmo.TangentSize)); var box = BoundingBox.FromSphere(new BoundingSphere(t, EditCurveTrackGizmo.TangentSize));
DebugDraw.DrawBox(box, selected ? Color.Yellow : Color.AliceBlue); DebugDraw.DrawBox(box, selected ? Color.Yellow : Color.AliceBlue);
DebugDraw.DrawBox(box, Color.AliceBlue.AlphaMultiplied(coveredAlpha), 0, false); DebugDraw.DrawBox(box, Color.AliceBlue.AlphaMultiplied(coveredAlpha), 0, false);
if (select && box.Intersects(selectRay)) if (select && box.Intersects(ref selectRay))
SelectKeyframeGizmo(curveTrack, i, 2); SelectKeyframeGizmo(curveTrack, i, 2);
} }
@@ -362,7 +362,7 @@ namespace FlaxEditor.GUI.Timeline
var box = BoundingBox.FromSphere(new BoundingSphere(t, EditCurveTrackGizmo.TangentSize)); var box = BoundingBox.FromSphere(new BoundingSphere(t, EditCurveTrackGizmo.TangentSize));
DebugDraw.DrawBox(box, selected ? Color.Yellow : Color.AliceBlue); DebugDraw.DrawBox(box, selected ? Color.Yellow : Color.AliceBlue);
DebugDraw.DrawBox(box, Color.AliceBlue.AlphaMultiplied(coveredAlpha), 0, false); DebugDraw.DrawBox(box, Color.AliceBlue.AlphaMultiplied(coveredAlpha), 0, false);
if (select && box.Intersects(selectRay)) if (select && box.Intersects(ref selectRay))
SelectKeyframeGizmo(curveTrack, i, 2); SelectKeyframeGizmo(curveTrack, i, 2);
} }

View File

@@ -2078,7 +2078,7 @@ namespace FlaxEditor.GUI.Timeline
if (button == MouseButton.Right && _isRightMouseButtonDown) if (button == MouseButton.Right && _isRightMouseButtonDown)
{ {
_isRightMouseButtonDown = false; _isRightMouseButtonDown = false;
if (Float2.Distance(location, _rightMouseButtonDownPos) < 4.0f) if (Float2.Distance(ref location, ref _rightMouseButtonDownPos) < 4.0f)
ShowContextMenu(location); ShowContextMenu(location);
} }
@@ -2243,7 +2243,7 @@ namespace FlaxEditor.GUI.Timeline
foreach (var media in _tracks[i].Media) foreach (var media in _tracks[i].Media)
{ {
if (media.Bounds.Intersects(mediaRect)) if (media.Bounds.Intersects(ref mediaRect))
{ {
SelectedMedia.Add(media); SelectedMedia.Add(media);
selectionChanged = true; selectionChanged = true;

View File

@@ -810,7 +810,7 @@ namespace FlaxEditor.GUI.Timeline
/// <returns>True if hits it.</returns> /// <returns>True if hits it.</returns>
protected virtual bool TestHeaderHit(ref Float2 location) protected virtual bool TestHeaderHit(ref Float2 location)
{ {
return new Rectangle(0, 0, Width, HeaderHeight).Contains(location); return new Rectangle(0, 0, Width, HeaderHeight).Contains(ref location);
} }
/// <summary> /// <summary>

View File

@@ -208,7 +208,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
// Hit-test dot // Hit-test dot
var size = Height - 2.0f; var size = Height - 2.0f;
var rect = new Rectangle(new Float2(size * -0.5f) + Size * 0.5f, new Float2(size)); var rect = new Rectangle(new Float2(size * -0.5f) + Size * 0.5f, new Float2(size));
return rect.Contains(location); return rect.Contains(ref location);
} }
return base.ContainsPoint(ref location, precise); return base.ContainsPoint(ref location, precise);

View File

@@ -527,7 +527,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
{ {
_output = GPUDevice.Instance.CreateTexture("CameraCutMedia.Output"); _output = GPUDevice.Instance.CreateTexture("CameraCutMedia.Output");
var desc = GPUTextureDescription.New2D(Width, Height, PixelFormat.R8G8B8A8_UNorm); var desc = GPUTextureDescription.New2D(Width, Height, PixelFormat.R8G8B8A8_UNorm);
_output.Init(desc); _output.Init(ref desc);
} }
if (_task == null) if (_task == null)
{ {

View File

@@ -258,7 +258,7 @@ namespace FlaxEditor.GUI.Tree
} }
var nodeArea = new Rectangle(pos, child.Size); var nodeArea = new Rectangle(pos, child.Size);
if (child.IsExpanded && range.Intersects(nodeArea)) if (child.IsExpanded && range.Intersects(ref nodeArea))
WalkSelectRangeExpandedTree(selection, child, ref range); WalkSelectRangeExpandedTree(selection, child, ref range);
} }
} }
@@ -447,8 +447,8 @@ namespace FlaxEditor.GUI.Tree
// Select previous parent child // Select previous parent child
var select = nodeParent.GetChild(myIndex - 1) as TreeNode; var select = nodeParent.GetChild(myIndex - 1) as TreeNode;
// Get bottom most child node // Select last child if is valid and expanded and has any children
while (select != null && select.IsExpanded && select.HasAnyVisibleChild) if (select != null && select.IsExpanded && select.HasAnyVisibleChild)
{ {
select = select.GetChild(select.ChildrenCount - 1) as TreeNode; select = select.GetChild(select.ChildrenCount - 1) as TreeNode;
} }

View File

@@ -555,7 +555,7 @@ namespace FlaxEditor.GUI.Tree
/// <returns>True if hits it.</returns> /// <returns>True if hits it.</returns>
protected virtual bool TestHeaderHit(ref Float2 location) protected virtual bool TestHeaderHit(ref Float2 location)
{ {
return _headerRect.Contains(location); return _headerRect.Contains(ref location);
} }
/// <summary> /// <summary>
@@ -864,14 +864,14 @@ namespace FlaxEditor.GUI.Tree
var child = children[i]; var child = children[i];
if (!child.Visible) if (!child.Visible)
continue; continue;
Render2D.PushTransform(child._cachedTransform); Render2D.PushTransform(ref child._cachedTransform);
child.Draw(); child.Draw();
Render2D.PopTransform(); Render2D.PopTransform();
} }
static Rectangle GetChildGlobalRectangle(Control control, ref Matrix3x3 globalTransform) static Rectangle GetChildGlobalRectangle(Control control, ref Matrix3x3 globalTransform)
{ {
Matrix3x3.Multiply(control._cachedTransform, globalTransform, out var globalChildTransform); Matrix3x3.Multiply(ref control._cachedTransform, ref globalTransform, out var globalChildTransform);
return new Rectangle(globalChildTransform.M31, globalChildTransform.M32, control.Width * globalChildTransform.M11, control.Height * globalChildTransform.M22); 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]; var child = children[i];
if (child.Visible) if (child.Visible)
{ {
Render2D.PushTransform(child._cachedTransform); Render2D.PushTransform(ref child._cachedTransform);
child.Draw(); child.Draw();
Render2D.PopTransform(); Render2D.PopTransform();
} }

View File

@@ -24,7 +24,7 @@ namespace FlaxEditor.GUI.Tree
foreach (var child in Addons) foreach (var child in Addons)
{ {
Render2D.PushTransform(child._cachedTransform); Render2D.PushTransform(ref child._cachedTransform);
child.Draw(); child.Draw();
Render2D.PopTransform(); Render2D.PopTransform();
} }

View File

@@ -56,9 +56,9 @@ namespace FlaxEditor.Gizmo
var width = output.Width; var width = output.Width;
var height = output.Height; var height = output.Height;
var desc = GPUTextureDescription.New2D(width, height, format, GPUTextureFlags.RenderTarget | GPUTextureFlags.ShaderResource, 1, 1, msaaLevel); var desc = GPUTextureDescription.New2D(width, height, format, GPUTextureFlags.RenderTarget | GPUTextureFlags.ShaderResource, 1, 1, msaaLevel);
var target = RenderTargetPool.Get(desc); var target = RenderTargetPool.Get(ref desc);
desc = GPUTextureDescription.New2D(width, height, PixelFormat.D24_UNorm_S8_UInt, GPUTextureFlags.DepthStencil, 1, 1, msaaLevel); desc = GPUTextureDescription.New2D(width, height, PixelFormat.D24_UNorm_S8_UInt, GPUTextureFlags.DepthStencil, 1, 1, msaaLevel);
var targetDepth = RenderTargetPool.Get(desc); var targetDepth = RenderTargetPool.Get(ref desc);
// Copy frame and clear depth // Copy frame and clear depth
context.Draw(target, input); context.Draw(target, input);
@@ -81,16 +81,16 @@ namespace FlaxEditor.Gizmo
} }
// Sort draw calls // Sort draw calls
renderList.SortDrawCalls(renderContext, false, DrawCallsListType.GBuffer); renderList.SortDrawCalls(ref renderContext, false, DrawCallsListType.GBuffer);
renderList.SortDrawCalls(renderContext, false, DrawCallsListType.GBufferNoDecals); renderList.SortDrawCalls(ref renderContext, false, DrawCallsListType.GBufferNoDecals);
renderList.SortDrawCalls(renderContext, true, DrawCallsListType.Forward); renderList.SortDrawCalls(ref renderContext, true, DrawCallsListType.Forward);
// Perform the rendering // Perform the rendering
renderContext.View.Pass = DrawPass.GBuffer; renderContext.View.Pass = DrawPass.GBuffer;
renderList.ExecuteDrawCalls(renderContext, DrawCallsListType.GBuffer); renderList.ExecuteDrawCalls(ref renderContext, DrawCallsListType.GBuffer);
renderList.ExecuteDrawCalls(renderContext, DrawCallsListType.GBufferNoDecals); renderList.ExecuteDrawCalls(ref renderContext, DrawCallsListType.GBufferNoDecals);
renderContext.View.Pass = DrawPass.Forward; renderContext.View.Pass = DrawPass.Forward;
renderList.ExecuteDrawCalls(renderContext, DrawCallsListType.Forward); renderList.ExecuteDrawCalls(ref renderContext, DrawCallsListType.Forward);
// Resolve MSAA texture // Resolve MSAA texture
if (enableMsaa) if (enableMsaa)

View File

@@ -70,7 +70,7 @@ namespace FlaxEditor.Gizmo
_vertexBuffer = new GPUBuffer(); _vertexBuffer = new GPUBuffer();
var layout = GPUVertexLayout.Get([new VertexElement(VertexElement.Types.Position, 0, 0, false, PixelFormat.R32G32B32_Float)]); var layout = GPUVertexLayout.Get([new VertexElement(VertexElement.Types.Position, 0, 0, false, PixelFormat.R32G32B32_Float)]);
var desc = GPUBufferDescription.Vertex(layout, sizeof(Float3), 4); var desc = GPUBufferDescription.Vertex(layout, sizeof(Float3), 4);
_vertexBuffer.Init(desc); _vertexBuffer.Init(ref desc);
} }
if (_indexBuffer == null) if (_indexBuffer == null)
{ {
@@ -78,7 +78,7 @@ namespace FlaxEditor.Gizmo
fixed (uint* ptr = _triangles) fixed (uint* ptr = _triangles)
{ {
var desc = GPUBufferDescription.Index(sizeof(uint), _triangles.Length, new IntPtr(ptr)); var desc = GPUBufferDescription.Index(sizeof(uint), _triangles.Length, new IntPtr(ptr));
_indexBuffer.Init(desc); _indexBuffer.Init(ref desc);
} }
} }
if (_psGrid == null) if (_psGrid == null)
@@ -90,7 +90,7 @@ namespace FlaxEditor.Gizmo
desc.VS = _shader.GPU.GetVS("VS_Grid"); desc.VS = _shader.GPU.GetVS("VS_Grid");
desc.PS = _shader.GPU.GetPS("PS_Grid"); desc.PS = _shader.GPU.GetPS("PS_Grid");
desc.DepthWriteEnable = false; desc.DepthWriteEnable = false;
_psGrid.Init(desc); _psGrid.Init(ref desc);
} }
// Update vertices of the plane // Update vertices of the plane
@@ -113,8 +113,8 @@ namespace FlaxEditor.Gizmo
if (cb != IntPtr.Zero) if (cb != IntPtr.Zero)
{ {
var data = new Data(); var data = new Data();
Matrix.Multiply(renderContext.View.View, renderContext.View.Projection, out var viewProjection); Matrix.Multiply(ref renderContext.View.View, ref renderContext.View.Projection, out var viewProjection);
Matrix.Transpose(viewProjection, out data.ViewProjectionMatrix); Matrix.Transpose(ref viewProjection, out data.ViewProjectionMatrix);
data.ViewPos = renderContext.View.WorldPosition; data.ViewPos = renderContext.View.WorldPosition;
data.GridColor = options.Viewport.ViewportGridColor; data.GridColor = options.Viewport.ViewportGridColor;
data.Far = renderContext.View.Far; data.Far = renderContext.View.Far;

View File

@@ -128,7 +128,7 @@ namespace FlaxEditor.Gizmo
// Pick a temporary depth buffer // Pick a temporary depth buffer
var desc = GPUTextureDescription.New2D(input.Width, input.Height, PixelFormat.D32_Float, GPUTextureFlags.DepthStencil | GPUTextureFlags.ShaderResource); var desc = GPUTextureDescription.New2D(input.Width, input.Height, PixelFormat.D32_Float, GPUTextureFlags.DepthStencil | GPUTextureFlags.ShaderResource);
var customDepth = RenderTargetPool.Get(desc); var customDepth = RenderTargetPool.Get(ref desc);
context.ClearDepth(customDepth.View()); context.ClearDepth(customDepth.View());
// Draw objects to depth buffer // Draw objects to depth buffer
@@ -148,7 +148,7 @@ namespace FlaxEditor.Gizmo
_material.SetParameterValue("OutlineColor1", _color1); _material.SetParameterValue("OutlineColor1", _color1);
_material.SetParameterValue("CustomDepth", customDepth); _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)); _material.SetParameterValue("ViewInfo", new Float4(1.0f / projection.M11, 1.0f / projection.M22, far / (far - near), (-far * near) / (far - near) / far));
Renderer.DrawPostFxMaterial(context, renderContext, _material, output, input.View()); Renderer.DrawPostFxMaterial(context, ref renderContext, _material, output, input.View());
// Cleanup // Cleanup
RenderTargetPool.Release(customDepth); RenderTargetPool.Release(customDepth);

View File

@@ -129,7 +129,7 @@ namespace FlaxEditor.Gizmo
if (_selectionParents[i] is ActorNode actorNode) if (_selectionParents[i] is ActorNode actorNode)
{ {
var b = actorNode.Actor.EditorBoxChildren; var b = actorNode.Actor.EditorBoxChildren;
BoundingBox.Merge(editorBounds, b, out editorBounds); BoundingBox.Merge(ref editorBounds, ref b, out editorBounds);
bottomToCenter = Mathf.Min(bottomToCenter, actorNode.Actor.Position.Y - editorBounds.Minimum.Y); bottomToCenter = Mathf.Min(bottomToCenter, actorNode.Actor.Position.Y - editorBounds.Minimum.Y);
} }
} }

View File

@@ -135,7 +135,7 @@ namespace FlaxEditor.Gizmo
Mesh sphereMesh = _modelSphere.LODs[0].Meshes[0]; Mesh sphereMesh = _modelSphere.LODs[0].Meshes[0];
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m3); Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m3);
Matrix.Multiply(m3, world, out m1); Matrix.Multiply(ref m3, ref world, out m1);
mx1 = m1; mx1 = m1;
mx1.M41 += 0.05f; mx1.M41 += 0.05f;
@@ -149,44 +149,44 @@ namespace FlaxEditor.Gizmo
// X axis // X axis
Matrix.RotationY(-Mathf.PiOverTwo, out m2); Matrix.RotationY(-Mathf.PiOverTwo, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance xAxisMaterialTransform = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX; MaterialInstance xAxisMaterialTransform = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
transAxisMesh.Draw(renderContext, xAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); transAxisMesh.Draw(ref renderContext, xAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Y axis // Y axis
Matrix.RotationX(Mathf.PiOverTwo, out m2); Matrix.RotationX(Mathf.PiOverTwo, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance yAxisMaterialTransform = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY; MaterialInstance yAxisMaterialTransform = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
transAxisMesh.Draw(renderContext, yAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); transAxisMesh.Draw(ref renderContext, yAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Z axis // Z axis
Matrix.RotationX(Mathf.Pi, out m2); Matrix.RotationX(Mathf.Pi, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance zAxisMaterialTransform = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ; MaterialInstance zAxisMaterialTransform = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
transAxisMesh.Draw(renderContext, zAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); transAxisMesh.Draw(ref renderContext, zAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// XY plane // XY plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f)); m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f));
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance xyPlaneMaterialTransform = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX; MaterialInstance xyPlaneMaterialTransform = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
cubeMesh.Draw(renderContext, xyPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); cubeMesh.Draw(ref renderContext, xyPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// ZX plane // ZX plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale)); m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale));
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance zxPlaneMaterialTransform = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisY; MaterialInstance zxPlaneMaterialTransform = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
cubeMesh.Draw(renderContext, zxPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); cubeMesh.Draw(ref renderContext, zxPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// YZ plane // YZ plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale)); m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale));
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance yzPlaneMaterialTransform = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisZ; MaterialInstance yzPlaneMaterialTransform = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
cubeMesh.Draw(renderContext, yzPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); cubeMesh.Draw(ref renderContext, yzPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Center sphere // Center sphere
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2); Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); sphereMesh.Draw(ref renderContext, isCenter ? _materialAxisFocus : _materialSphere, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
break; break;
} }
@@ -199,24 +199,24 @@ namespace FlaxEditor.Gizmo
// X axis // X axis
Matrix.RotationZ(Mathf.PiOverTwo, out m2); Matrix.RotationZ(Mathf.PiOverTwo, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX; MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
rotationAxisMesh.Draw(renderContext, xAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); rotationAxisMesh.Draw(ref renderContext, xAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Y axis // Y axis
MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY; MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
rotationAxisMesh.Draw(renderContext, yAxisMaterialRotate, m1, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); rotationAxisMesh.Draw(ref renderContext, yAxisMaterialRotate, ref m1, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Z axis // Z axis
Matrix.RotationX(-Mathf.PiOverTwo, out m2); Matrix.RotationX(-Mathf.PiOverTwo, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ; MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
rotationAxisMesh.Draw(renderContext, zAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); rotationAxisMesh.Draw(ref renderContext, zAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Center box // Center box
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2); Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); sphereMesh.Draw(ref renderContext, isCenter ? _materialAxisFocus : _materialSphere, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
break; break;
} }
@@ -229,44 +229,44 @@ namespace FlaxEditor.Gizmo
// X axis // X axis
Matrix.RotationY(-Mathf.PiOverTwo, out m2); Matrix.RotationY(-Mathf.PiOverTwo, out m2);
Matrix.Multiply(m2, mx1, out m3); Matrix.Multiply(ref m2, ref mx1, out m3);
MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX; MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
scaleAxisMesh.Draw(renderContext, xAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); scaleAxisMesh.Draw(ref renderContext, xAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Y axis // Y axis
Matrix.RotationX(Mathf.PiOverTwo, out m2); Matrix.RotationX(Mathf.PiOverTwo, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY; MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
scaleAxisMesh.Draw(renderContext, yAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); scaleAxisMesh.Draw(ref renderContext, yAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Z axis // Z axis
Matrix.RotationX(Mathf.Pi, out m2); Matrix.RotationX(Mathf.Pi, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ; MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
scaleAxisMesh.Draw(renderContext, zAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); scaleAxisMesh.Draw(ref renderContext, zAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// XY plane // XY plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f)); m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f));
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance xyPlaneMaterialScale = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX; MaterialInstance xyPlaneMaterialScale = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
cubeMesh.Draw(renderContext, xyPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); cubeMesh.Draw(ref renderContext, xyPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// ZX plane // ZX plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale)); m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale));
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance zxPlaneMaterialScale = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisZ; MaterialInstance zxPlaneMaterialScale = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
cubeMesh.Draw(renderContext, zxPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); cubeMesh.Draw(ref renderContext, zxPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// YZ plane // YZ plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale)); m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale));
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
MaterialInstance yzPlaneMaterialScale = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisY; MaterialInstance yzPlaneMaterialScale = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
cubeMesh.Draw(renderContext, yzPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); cubeMesh.Draw(ref renderContext, yzPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Center box // Center box
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2); Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
Matrix.Multiply(m2, m1, out m3); Matrix.Multiply(ref m2, ref m1, out m3);
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); sphereMesh.Draw(ref renderContext, isCenter ? _materialAxisFocus : _materialSphere, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
break; break;
} }
@@ -278,7 +278,7 @@ namespace FlaxEditor.Gizmo
Transform t = _vertexSnapObject?.Transform ?? _vertexSnapObjectTo.Transform; Transform t = _vertexSnapObject?.Transform ?? _vertexSnapObjectTo.Transform;
Vector3 p = t.LocalToWorld(_vertexSnapObject != null ? _vertexSnapPoint : _vertexSnapPointTo); Vector3 p = t.LocalToWorld(_vertexSnapObject != null ? _vertexSnapPoint : _vertexSnapPointTo);
Matrix matrix = new Transform(p, t.Orientation, new Float3(gizmoModelsScale2RealGizmoSize)).GetWorld(); Matrix matrix = new Transform(p, t.Orientation, new Float3(gizmoModelsScale2RealGizmoSize)).GetWorld();
cubeMesh.Draw(renderContext, _materialSphere, matrix, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder); cubeMesh.Draw(ref renderContext, _materialSphere, ref matrix, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
} }
} }
} }

View File

@@ -36,7 +36,7 @@ namespace FlaxEditor.Gizmo
private bool IntersectsRotateCircle(Vector3 normal, ref Ray ray, out Real distance) private bool IntersectsRotateCircle(Vector3 normal, ref Ray ray, out Real distance)
{ {
var plane = new Plane(Vector3.Zero, normal); var plane = new Plane(Vector3.Zero, normal);
if (!plane.Intersects(ray, out distance)) if (!plane.Intersects(ref ray, out distance))
return false; return false;
Vector3 hitPoint = ray.Position + ray.Direction * distance; Vector3 hitPoint = ray.Position + ray.Direction * distance;
Real distanceNormalized = hitPoint.Length / RotateRadiusRaw; Real distanceNormalized = hitPoint.Length / RotateRadiusRaw;
@@ -50,8 +50,8 @@ namespace FlaxEditor.Gizmo
// Transform ray into local space of the gizmo // Transform ray into local space of the gizmo
Ray localRay; Ray localRay;
_gizmoWorld.WorldToLocalVector(ray.Direction, out localRay.Direction); _gizmoWorld.WorldToLocalVector(ref ray.Direction, out localRay.Direction);
_gizmoWorld.WorldToLocal(ray.Position, out localRay.Position); _gizmoWorld.WorldToLocal(ref ray.Position, out localRay.Position);
// Find gizmo collisions with mouse // Find gizmo collisions with mouse
Real closestIntersection = Real.MaxValue; Real closestIntersection = Real.MaxValue;
@@ -62,19 +62,19 @@ namespace FlaxEditor.Gizmo
case Mode.Translate: case Mode.Translate:
{ {
// Axis boxes collision // Axis boxes collision
if (XAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection) if (XAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
{ {
_activeAxis = Axis.X; _activeAxis = Axis.X;
closestIntersection = intersection; closestIntersection = intersection;
} }
if (YAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection) if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
{ {
_activeAxis = Axis.Y; _activeAxis = Axis.Y;
closestIntersection = intersection; closestIntersection = intersection;
} }
if (ZAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection) if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
{ {
_activeAxis = Axis.Z; _activeAxis = Axis.Z;
closestIntersection = intersection; closestIntersection = intersection;
@@ -83,25 +83,25 @@ namespace FlaxEditor.Gizmo
// Quad planes collision // Quad planes collision
if (closestIntersection >= float.MaxValue) if (closestIntersection >= float.MaxValue)
closestIntersection = float.MinValue; closestIntersection = float.MinValue;
if (XYBox.Intersects(localRay, out intersection) && intersection > closestIntersection) if (XYBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
{ {
_activeAxis = Axis.XY; _activeAxis = Axis.XY;
closestIntersection = intersection; closestIntersection = intersection;
} }
if (XZBox.Intersects(localRay, out intersection) && intersection > closestIntersection) if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
{ {
_activeAxis = Axis.ZX; _activeAxis = Axis.ZX;
closestIntersection = intersection; closestIntersection = intersection;
} }
if (YZBox.Intersects(localRay, out intersection) && intersection > closestIntersection) if (YZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
{ {
_activeAxis = Axis.YZ; _activeAxis = Axis.YZ;
closestIntersection = intersection; closestIntersection = intersection;
} }
/*// Center /*// Center
if (CenterBoxRaw.Intersects(localRay, out intersection) && intersection > closestIntersection) if (CenterBoxRaw.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
{ {
_activeAxis = Axis.Center; _activeAxis = Axis.Center;
closestIntersection = intersection; closestIntersection = intersection;
@@ -133,17 +133,17 @@ namespace FlaxEditor.Gizmo
case Mode.Scale: case Mode.Scale:
{ {
// Boxes collision // Boxes collision
if (XAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection) if (XAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
{ {
_activeAxis = Axis.X; _activeAxis = Axis.X;
closestIntersection = intersection; closestIntersection = intersection;
} }
if (YAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection) if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
{ {
_activeAxis = Axis.Y; _activeAxis = Axis.Y;
closestIntersection = intersection; closestIntersection = intersection;
} }
if (ZAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection) if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
{ {
_activeAxis = Axis.Z; _activeAxis = Axis.Z;
closestIntersection = intersection; closestIntersection = intersection;
@@ -153,24 +153,24 @@ namespace FlaxEditor.Gizmo
if (closestIntersection >= float.MaxValue) if (closestIntersection >= float.MaxValue)
closestIntersection = float.MinValue; closestIntersection = float.MinValue;
if (XYBox.Intersects(localRay, out intersection) && intersection > closestIntersection) if (XYBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
{ {
_activeAxis = Axis.XY; _activeAxis = Axis.XY;
closestIntersection = intersection; closestIntersection = intersection;
} }
if (XZBox.Intersects(localRay, out intersection) && intersection > closestIntersection) if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
{ {
_activeAxis = Axis.ZX; _activeAxis = Axis.ZX;
closestIntersection = intersection; closestIntersection = intersection;
} }
if (YZBox.Intersects(localRay, out intersection) && intersection > closestIntersection) if (YZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
{ {
_activeAxis = Axis.YZ; _activeAxis = Axis.YZ;
closestIntersection = intersection; closestIntersection = intersection;
} }
// Center // Center
if (CenterBoxRaw.Intersects(localRay, out intersection) && intersection > closestIntersection) if (CenterBoxRaw.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
{ {
_activeAxis = Axis.Center; _activeAxis = Axis.Center;
closestIntersection = intersection; closestIntersection = intersection;

View File

@@ -212,10 +212,10 @@ namespace FlaxEditor.Gizmo
Vector3 delta = Vector3.Zero; Vector3 delta = Vector3.Zero;
Ray ray = Owner.MouseRay; Ray ray = Owner.MouseRay;
Matrix.RotationQuaternion(_gizmoWorld.Orientation, out var rotationMatrix); Matrix.RotationQuaternion(ref _gizmoWorld.Orientation, out var rotationMatrix);
Matrix.Invert(rotationMatrix, out var invRotationMatrix); Matrix.Invert(ref rotationMatrix, out var invRotationMatrix);
ray.Position = Vector3.Transform(ray.Position, invRotationMatrix); ray.Position = Vector3.Transform(ray.Position, invRotationMatrix);
Vector3.TransformNormal(ray.Direction, invRotationMatrix, out ray.Direction); Vector3.TransformNormal(ref ray.Direction, ref invRotationMatrix, out ray.Direction);
var position = Position; var position = Position;
var planeXY = new Plane(Vector3.Backward, Vector3.Transform(position, invRotationMatrix).Z); var planeXY = new Plane(Vector3.Backward, Vector3.Transform(position, invRotationMatrix).Z);
@@ -232,7 +232,7 @@ namespace FlaxEditor.Gizmo
case Axis.X: case Axis.X:
{ {
var plane = planeDotXY > planeDotZX ? planeXY : planeZX; var plane = planeDotXY > planeDotZX ? planeXY : planeZX;
if (ray.Intersects(plane, out intersection)) if (ray.Intersects(ref plane, out intersection))
{ {
_intersectPosition = ray.GetPoint(intersection); _intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero) if (!_lastIntersectionPosition.IsZero)
@@ -244,7 +244,7 @@ namespace FlaxEditor.Gizmo
case Axis.Y: case Axis.Y:
{ {
var plane = planeDotXY > planeDotYZ ? planeXY : planeYZ; var plane = planeDotXY > planeDotYZ ? planeXY : planeYZ;
if (ray.Intersects(plane, out intersection)) if (ray.Intersects(ref plane, out intersection))
{ {
_intersectPosition = ray.GetPoint(intersection); _intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero) if (!_lastIntersectionPosition.IsZero)
@@ -256,7 +256,7 @@ namespace FlaxEditor.Gizmo
case Axis.Z: case Axis.Z:
{ {
var plane = planeDotZX > planeDotYZ ? planeZX : planeYZ; var plane = planeDotZX > planeDotYZ ? planeZX : planeYZ;
if (ray.Intersects(plane, out intersection)) if (ray.Intersects(ref plane, out intersection))
{ {
_intersectPosition = ray.GetPoint(intersection); _intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero) if (!_lastIntersectionPosition.IsZero)
@@ -267,7 +267,7 @@ namespace FlaxEditor.Gizmo
} }
case Axis.YZ: case Axis.YZ:
{ {
if (ray.Intersects(planeYZ, out intersection)) if (ray.Intersects(ref planeYZ, out intersection))
{ {
_intersectPosition = ray.GetPoint(intersection); _intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero) if (!_lastIntersectionPosition.IsZero)
@@ -288,7 +288,7 @@ namespace FlaxEditor.Gizmo
} }
case Axis.XY: case Axis.XY:
{ {
if (ray.Intersects(planeXY, out intersection)) if (ray.Intersects(ref planeXY, out intersection))
{ {
_intersectPosition = ray.GetPoint(intersection); _intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero) if (!_lastIntersectionPosition.IsZero)
@@ -309,7 +309,7 @@ namespace FlaxEditor.Gizmo
} }
case Axis.ZX: case Axis.ZX:
{ {
if (ray.Intersects(planeZX, out intersection)) if (ray.Intersects(ref planeZX, out intersection))
{ {
_intersectPosition = ray.GetPoint(intersection); _intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero) if (!_lastIntersectionPosition.IsZero)
@@ -332,7 +332,7 @@ namespace FlaxEditor.Gizmo
{ {
var gizmoToView = Position - Owner.ViewPosition; var gizmoToView = Position - Owner.ViewPosition;
var plane = new Plane(-Vector3.Normalize(gizmoToView), gizmoToView.Length); var plane = new Plane(-Vector3.Normalize(gizmoToView), gizmoToView.Length);
if (ray.Intersects(plane, out intersection)) if (ray.Intersects(ref plane, out intersection))
{ {
_intersectPosition = ray.GetPoint(intersection); _intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero) if (!_lastIntersectionPosition.IsZero)
@@ -473,11 +473,11 @@ namespace FlaxEditor.Gizmo
dir = Float3.Forward * _gizmoWorld.Orientation; dir = Float3.Forward * _gizmoWorld.Orientation;
Float3 viewDir = Owner.ViewPosition - Position; Float3 viewDir = Owner.ViewPosition - Position;
Float3.Dot(viewDir, dir, out float dot); Float3.Dot(ref viewDir, ref dir, out float dot);
if (dot < 0.0f) if (dot < 0.0f)
delta *= -1; delta *= -1;
Quaternion.RotationAxis(dir, delta, out _rotationDelta); Quaternion.RotationAxis(ref dir, delta, out _rotationDelta);
break; break;
} }

View File

@@ -240,7 +240,7 @@ namespace FlaxEditor
{ {
foreach (var widget in _widgets) foreach (var widget in _widgets)
{ {
if (widget.Bounds.Contains(location)) if (widget.Bounds.Contains(ref location))
{ {
// Initialize widget movement // Initialize widget movement
_activeWidget = widget; _activeWidget = widget;
@@ -326,7 +326,7 @@ namespace FlaxEditor
{ {
foreach (var widget in _widgets) foreach (var widget in _widgets)
{ {
if (widget.Bounds.Contains(location)) if (widget.Bounds.Contains(ref location))
{ {
Cursor = widget.Cursor; Cursor = widget.Cursor;
cursorChanged = true; cursorChanged = true;
@@ -499,7 +499,7 @@ namespace FlaxEditor
var min = Float2.Min(upperLeft, bottomRight); var min = Float2.Min(upperLeft, bottomRight);
var max = Float2.Max(upperLeft, bottomRight); var max = Float2.Max(upperLeft, bottomRight);
var pixelRange = (max - min) * ViewScale; var pixelRange = (max - min) * ViewScale;
Render2D.PushClip(viewRect); Render2D.PushClip(ref viewRect);
DrawAxis(Float2.UnitX, viewRect, min.X, max.X, pixelRange.X); DrawAxis(Float2.UnitX, viewRect, min.X, max.X, pixelRange.X);
DrawAxis(Float2.UnitY, viewRect, min.Y, max.Y, pixelRange.Y); DrawAxis(Float2.UnitY, viewRect, min.Y, max.Y, pixelRange.Y);
Render2D.PopClip(); Render2D.PopClip();
@@ -605,7 +605,7 @@ namespace FlaxEditor
if (!drawAnySelectedControl) if (!drawAnySelectedControl)
{ {
drawAnySelectedControl = true; drawAnySelectedControl = true;
Render2D.PushTransform(_cachedTransform); Render2D.PushTransform(ref _cachedTransform);
} }
var options = Editor.Instance.Options.Options.Visual; 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 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 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); DrawControlWidget(uiControl, ref br, ref mousePos, ref widgetHandleSize, viewScale, new Float2(1, 1), CursorType.SizeNWSE);
Float2.Lerp(ul, bl, 0.5f, out var el); Float2.Lerp(ref ul, ref bl, 0.5f, out var el);
Float2.Lerp(ur, br, 0.5f, out var er); Float2.Lerp(ref ur, ref br, 0.5f, out var er);
Float2.Lerp(ul, ur, 0.5f, out var eu); Float2.Lerp(ref ul, ref ur, 0.5f, out var eu);
Float2.Lerp(bl, br, 0.5f, out var eb); Float2.Lerp(ref bl, ref br, 0.5f, out var eb);
DrawControlWidget(uiControl, ref el, ref mousePos, ref widgetHandleSize, viewScale, new Float2(-1, 0), CursorType.SizeWE); 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 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); DrawControlWidget(uiControl, ref eu, ref mousePos, ref widgetHandleSize, viewScale, new Float2(0, -1), CursorType.SizeNS);
@@ -749,7 +749,7 @@ namespace FlaxEditor
default: break; default: break;
} }
} }
if (rect.Contains(mousePos)) if (rect.Contains(ref mousePos))
{ {
Render2D.FillRectangle(rect, style.Foreground); Render2D.FillRectangle(rect, style.Foreground);
Render2D.DrawRectangle(rect, style.SelectionBorder); Render2D.DrawRectangle(rect, style.SelectionBorder);

View File

@@ -124,7 +124,7 @@ public sealed class ViewportRubberBandSelector
public void ProjectPoint(Vector3 worldSpaceLocation, out Float2 viewportSpaceLocation) public void ProjectPoint(Vector3 worldSpaceLocation, out Float2 viewportSpaceLocation)
{ {
worldSpaceLocation -= _origin; worldSpaceLocation -= _origin;
_viewport.Project(worldSpaceLocation, _viewProjection, out var projected); _viewport.Project(ref worldSpaceLocation, ref _viewProjection, out var projected);
viewportSpaceLocation = new Float2((float)projected.X, (float)projected.Y); viewportSpaceLocation = new Float2((float)projected.X, (float)projected.Y);
} }
@@ -132,7 +132,7 @@ public sealed class ViewportRubberBandSelector
{ {
bounds.Minimum -= _origin; bounds.Minimum -= _origin;
bounds.Maximum -= _origin; bounds.Maximum -= _origin;
return _frustum.Contains(bounds); return _frustum.Contains(ref bounds);
} }
} }

View File

@@ -58,22 +58,22 @@ void OnLogMessage(LogType type, const StringView& msg)
{ {
ScopeLock lock(CachedLogDataLocker); ScopeLock lock(CachedLogDataLocker);
CachedLogData.EnsureCapacity(sizeof(int32) + sizeof(DateTime) + sizeof(int32) + msg.Length() * sizeof(Char)); CachedLogData.EnsureCapacity(4 + 8 + 4 + msg.Length() * 2);
// Log Type // Log Type
int32 buf = (int32)type; int32 buf = (int32)type;
CachedLogData.Add((byte*)&buf, sizeof(int32)); CachedLogData.Add((byte*)&buf, 4);
// Time // Time
auto time = DateTime::Now(); auto time = DateTime::Now();
CachedLogData.Add((byte*)&time.Ticks, sizeof(DateTime)); CachedLogData.Add((byte*)&time.Ticks, 8);
// Message Length // Message Length
buf = msg.Length(); buf = msg.Length();
CachedLogData.Add((byte*)&buf, sizeof(int32)); CachedLogData.Add((byte*)&buf, 4);
// Message // Message
CachedLogData.Add((byte*)msg.Get(), msg.Length() * sizeof(Char)); CachedLogData.Add((byte*)msg.Get(), msg.Length() * 2);
} }
DEFINE_INTERNAL_CALL(bool) EditorInternal_IsDevInstance() DEFINE_INTERNAL_CALL(bool) EditorInternal_IsDevInstance()
@@ -99,7 +99,7 @@ DEFINE_INTERNAL_CALL(bool) EditorInternal_IsPlayMode()
return Editor::IsPlayMode; return Editor::IsPlayMode;
} }
DEFINE_INTERNAL_CALL(int32) EditorInternal_ReadOutputLogs(NativeArray<String>* outMessages, NativeArray<byte>* outLogTypes, NativeArray<int64>* outLogTimes, int outArraySize) DEFINE_INTERNAL_CALL(int32) EditorInternal_ReadOutputLogs(MArray** outMessages, MArray** outLogTypes, MArray** outLogTimes, int outArraySize)
{ {
ScopeLock lock(CachedLogDataLocker); ScopeLock lock(CachedLogDataLocker);
if (CachedLogData.IsEmpty() || CachedLogData.Get() == nullptr) if (CachedLogData.IsEmpty() || CachedLogData.Get() == nullptr)
@@ -108,30 +108,27 @@ DEFINE_INTERNAL_CALL(int32) EditorInternal_ReadOutputLogs(NativeArray<String>* o
int32 count = 0; int32 count = 0;
const int32 maxCount = outArraySize; const int32 maxCount = outArraySize;
String* messages = &outMessages->data[0];
byte* ptr = CachedLogData.Get(); byte* ptr = CachedLogData.Get();
byte* end = ptr + CachedLogData.Count(); byte* end = ptr + CachedLogData.Count();
byte* outLogTypesPtr = outLogTypes->data; byte* outLogTypesPtr = MCore::Array::GetAddress<byte>(*outLogTypes);
int64* outLogTimesPtr = outLogTimes->data; int64* outLogTimesPtr = MCore::Array::GetAddress<int64>(*outLogTimes);
while (count < maxCount && ptr != end) while (count < maxCount && ptr != end)
{ {
auto type = (byte)*(int32*)ptr; auto type = (byte)*(int32*)ptr;
ptr += sizeof(int32); ptr += 4;
auto time = *(int64*)ptr; auto time = *(int64*)ptr;
ptr += sizeof(int64); ptr += 8;
auto length = *(int32*)ptr; auto length = *(int32*)ptr;
ptr += sizeof(int32); ptr += 4;
auto msg = (Char*)ptr; auto msg = (Char*)ptr;
ptr += length * sizeof(Char); ptr += length * 2;
auto msgObj = String(msg, length); auto msgObj = MUtils::ToString(StringView(msg, length));
String& str = messages[count]; MCore::GC::WriteArrayRef(*outMessages, (MObject*)msgObj, count);
ASSERT(str.Get() == nullptr && str.Length() == 0);
str = msgObj;
outLogTypesPtr[count] = type; outLogTypesPtr[count] = type;
outLogTimesPtr[count] = time; outLogTimesPtr[count] = time;
@@ -150,9 +147,9 @@ DEFINE_INTERNAL_CALL(void) EditorInternal_SetPlayMode(bool value)
Editor::IsPlayMode = value; Editor::IsPlayMode = value;
} }
DEFINE_INTERNAL_CALL(void) EditorInternal_GetProjectPath(StringView* projectPath) DEFINE_INTERNAL_CALL(MString*) EditorInternal_GetProjectPath()
{ {
*projectPath = Editor::Project->ProjectPath; return MUtils::ToString(Editor::Project->ProjectPath);
} }
DEFINE_INTERNAL_CALL(void) EditorInternal_CloseSplashScreen() DEFINE_INTERNAL_CALL(void) EditorInternal_CloseSplashScreen()
@@ -162,7 +159,6 @@ DEFINE_INTERNAL_CALL(void) EditorInternal_CloseSplashScreen()
DEFINE_INTERNAL_CALL(bool) EditorInternal_CloneAssetFile(MString* dstPathObj, MString* srcPathObj, Guid* dstId) DEFINE_INTERNAL_CALL(bool) EditorInternal_CloneAssetFile(MString* dstPathObj, MString* srcPathObj, Guid* dstId)
{ {
PLATFORM_DEBUG_BREAK;
// Get normalized paths // Get normalized paths
String dstPath, srcPath; String dstPath, srcPath;
MUtils::ToString(dstPathObj, dstPath); MUtils::ToString(dstPathObj, dstPath);
@@ -176,7 +172,6 @@ DEFINE_INTERNAL_CALL(bool) EditorInternal_CloneAssetFile(MString* dstPathObj, MS
DEFINE_INTERNAL_CALL(bool) EditorInternal_CreateVisualScript(MString* outputPathObj, MString* baseTypenameObj) DEFINE_INTERNAL_CALL(bool) EditorInternal_CreateVisualScript(MString* outputPathObj, MString* baseTypenameObj)
{ {
PLATFORM_DEBUG_BREAK;
String outputPath; String outputPath;
MUtils::ToString(outputPathObj, outputPath); MUtils::ToString(outputPathObj, outputPath);
FileSystem::NormalizePath(outputPath); FileSystem::NormalizePath(outputPath);
@@ -187,7 +182,6 @@ DEFINE_INTERNAL_CALL(bool) EditorInternal_CreateVisualScript(MString* outputPath
DEFINE_INTERNAL_CALL(MString*) EditorInternal_CanImport(MString* extensionObj) DEFINE_INTERNAL_CALL(MString*) EditorInternal_CanImport(MString* extensionObj)
{ {
PLATFORM_DEBUG_BREAK;
String extension; String extension;
MUtils::ToString(extensionObj, extension); MUtils::ToString(extensionObj, extension);
if (extension.Length() > 0 && extension[0] == '.') if (extension.Length() > 0 && extension[0] == '.')
@@ -205,7 +199,6 @@ DEFINE_INTERNAL_CALL(void) EditorInternal_GetAudioClipMetadata(AudioClip* clip,
DEFINE_INTERNAL_CALL(bool) EditorInternal_SaveJsonAsset(MString* outputPathObj, MString* dataObj, MString* dataTypeNameObj) DEFINE_INTERNAL_CALL(bool) EditorInternal_SaveJsonAsset(MString* outputPathObj, MString* dataObj, MString* dataTypeNameObj)
{ {
PLATFORM_DEBUG_BREAK;
String outputPath; String outputPath;
MUtils::ToString(outputPathObj, outputPath); MUtils::ToString(outputPathObj, outputPath);
FileSystem::NormalizePath(outputPath); FileSystem::NormalizePath(outputPath);
@@ -223,7 +216,6 @@ DEFINE_INTERNAL_CALL(bool) EditorInternal_SaveJsonAsset(MString* outputPathObj,
DEFINE_INTERNAL_CALL(bool) EditorInternal_CanExport(MString* pathObj) DEFINE_INTERNAL_CALL(bool) EditorInternal_CanExport(MString* pathObj)
{ {
PLATFORM_DEBUG_BREAK;
#if COMPILE_WITH_ASSETS_EXPORTER #if COMPILE_WITH_ASSETS_EXPORTER
String path; String path;
MUtils::ToString(pathObj, path); MUtils::ToString(pathObj, path);
@@ -237,7 +229,6 @@ DEFINE_INTERNAL_CALL(bool) EditorInternal_CanExport(MString* pathObj)
DEFINE_INTERNAL_CALL(bool) EditorInternal_Export(MString* inputPathObj, MString* outputFolderObj) DEFINE_INTERNAL_CALL(bool) EditorInternal_Export(MString* inputPathObj, MString* outputFolderObj)
{ {
PLATFORM_DEBUG_BREAK;
#if COMPILE_WITH_ASSETS_EXPORTER #if COMPILE_WITH_ASSETS_EXPORTER
String inputPath; String inputPath;
MUtils::ToString(inputPathObj, inputPath); MUtils::ToString(inputPathObj, inputPath);
@@ -255,7 +246,6 @@ DEFINE_INTERNAL_CALL(bool) EditorInternal_Export(MString* inputPathObj, MString*
DEFINE_INTERNAL_CALL(void) EditorInternal_CopyCache(Guid* dstId, Guid* srcId) DEFINE_INTERNAL_CALL(void) EditorInternal_CopyCache(Guid* dstId, Guid* srcId)
{ {
PLATFORM_DEBUG_BREAK;
ShaderCacheManager::CopyCache(*dstId, *srcId); ShaderCacheManager::CopyCache(*dstId, *srcId);
} }
@@ -270,7 +260,6 @@ DEFINE_INTERNAL_CALL(void) EditorInternal_BakeLightmaps(bool cancel)
DEFINE_INTERNAL_CALL(MString*) EditorInternal_GetShaderAssetSourceCode(BinaryAsset* obj) DEFINE_INTERNAL_CALL(MString*) EditorInternal_GetShaderAssetSourceCode(BinaryAsset* obj)
{ {
PLATFORM_DEBUG_BREAK;
INTERNAL_CALL_CHECK_RETURN(obj, nullptr); INTERNAL_CALL_CHECK_RETURN(obj, nullptr);
if (obj->WaitForLoaded()) if (obj->WaitForLoaded())
DebugLog::ThrowNullReference(); DebugLog::ThrowNullReference();
@@ -298,7 +287,6 @@ DEFINE_INTERNAL_CALL(MString*) EditorInternal_GetShaderAssetSourceCode(BinaryAss
DEFINE_INTERNAL_CALL(bool) EditorInternal_CookMeshCollision(MString* pathObj, CollisionDataType type, ModelBase* modelObj, int32 modelLodIndex, uint32 materialSlotsMask, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit) DEFINE_INTERNAL_CALL(bool) EditorInternal_CookMeshCollision(MString* pathObj, CollisionDataType type, ModelBase* modelObj, int32 modelLodIndex, uint32 materialSlotsMask, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
{ {
PLATFORM_DEBUG_BREAK;
#if COMPILE_WITH_PHYSICS_COOKING #if COMPILE_WITH_PHYSICS_COOKING
CollisionCooking::Argument arg; CollisionCooking::Argument arg;
String path; String path;
@@ -319,7 +307,6 @@ DEFINE_INTERNAL_CALL(bool) EditorInternal_CookMeshCollision(MString* pathObj, Co
DEFINE_INTERNAL_CALL(void) EditorInternal_GetCollisionWires(CollisionData* collisionData, MArray** triangles, MArray** indices, int* trianglesCount, int* indicesCount) DEFINE_INTERNAL_CALL(void) EditorInternal_GetCollisionWires(CollisionData* collisionData, MArray** triangles, MArray** indices, int* trianglesCount, int* indicesCount)
{ {
PLATFORM_DEBUG_BREAK;
if (!collisionData || collisionData->WaitForLoaded() || collisionData->GetOptions().Type == CollisionDataType::None) if (!collisionData || collisionData->WaitForLoaded() || collisionData->GetOptions().Type == CollisionDataType::None)
return; return;
@@ -345,7 +332,6 @@ DEFINE_INTERNAL_CALL(void) EditorInternal_GetCollisionWires(CollisionData* colli
DEFINE_INTERNAL_CALL(void) EditorInternal_GetEditorBoxWithChildren(Actor* obj, BoundingBox* result) DEFINE_INTERNAL_CALL(void) EditorInternal_GetEditorBoxWithChildren(Actor* obj, BoundingBox* result)
{ {
PLATFORM_DEBUG_BREAK;
INTERNAL_CALL_CHECK(obj); INTERNAL_CALL_CHECK(obj);
*result = obj->GetEditorBoxChildren(); *result = obj->GetEditorBoxChildren();
} }
@@ -475,7 +461,6 @@ DEFINE_INTERNAL_CALL(void) EditorInternal_RunVisualScriptBreakpointLoopTick(floa
DEFINE_INTERNAL_CALL(void) EditorInternal_DeserializeSceneObject(SceneObject* sceneObject, MString* jsonObj) DEFINE_INTERNAL_CALL(void) EditorInternal_DeserializeSceneObject(SceneObject* sceneObject, MString* jsonObj)
{ {
PLATFORM_DEBUG_BREAK;
PROFILE_CPU_NAMED("DeserializeSceneObject"); PROFILE_CPU_NAMED("DeserializeSceneObject");
StringAnsi json; StringAnsi json;
@@ -546,9 +531,10 @@ DEFINE_INTERNAL_CALL(MTypeObject*) CustomEditorsUtilInternal_GetCustomEditor(MTy
return CustomEditorsUtil::GetCustomEditor(targetType); return CustomEditorsUtil::GetCustomEditor(targetType);
} }
DEFINE_INTERNAL_CALL(NativeSpan<String>) LayersAndTagsSettingsInternal_GetCurrentLayers() DEFINE_INTERNAL_CALL(MArray*) LayersAndTagsSettingsInternal_GetCurrentLayers(int* layersCount)
{ {
return NativeSpan<String>::AsSpan(Level::Layers, Math::Max(1, Level::GetNonEmptyLayerNamesCount())); *layersCount = Math::Max(1, Level::GetNonEmptyLayerNamesCount());
return MUtils::ToArray(Span<String>(Level::Layers, *layersCount));
} }
DEFINE_INTERNAL_CALL(void) GameSettingsInternal_Apply() DEFINE_INTERNAL_CALL(void) GameSettingsInternal_Apply()

View File

@@ -334,7 +334,7 @@ Window* ManagedEditor::GetMainWindow()
ASSERT(HasManagedInstance()); ASSERT(HasManagedInstance());
const auto method = GetClass()->GetMethod("GetMainWindowPtr"); const auto method = GetClass()->GetMethod("GetMainWindowPtr");
ASSERT(method); ASSERT(method);
return (Window*)MUtils::Unbox<void*>(method->Invoke(GetManagedInstance(), nullptr, nullptr), true); return (Window*)MUtils::Unbox<void*>(method->Invoke(GetManagedInstance(), nullptr, nullptr));
} }
bool ManagedEditor::CanReloadScripts() bool ManagedEditor::CanReloadScripts()
@@ -346,7 +346,7 @@ bool ManagedEditor::CanReloadScripts()
Internal_CanReloadScripts = GetClass()->GetMethod("Internal_CanReloadScripts"); Internal_CanReloadScripts = GetClass()->GetMethod("Internal_CanReloadScripts");
ASSERT(Internal_CanReloadScripts); ASSERT(Internal_CanReloadScripts);
} }
return MUtils::Unbox<bool>(Internal_CanReloadScripts->Invoke(GetManagedInstance(), nullptr, nullptr), true); return MUtils::Unbox<bool>(Internal_CanReloadScripts->Invoke(GetManagedInstance(), nullptr, nullptr));
} }
bool ManagedEditor::CanAutoBuildCSG() bool ManagedEditor::CanAutoBuildCSG()
@@ -365,7 +365,7 @@ bool ManagedEditor::CanAutoBuildCSG()
Internal_CanAutoBuildCSG = GetClass()->GetMethod("Internal_CanAutoBuildCSG"); Internal_CanAutoBuildCSG = GetClass()->GetMethod("Internal_CanAutoBuildCSG");
ASSERT(Internal_CanAutoBuildCSG); ASSERT(Internal_CanAutoBuildCSG);
} }
return MUtils::Unbox<bool>(Internal_CanAutoBuildCSG->Invoke(GetManagedInstance(), nullptr, nullptr), true); return MUtils::Unbox<bool>(Internal_CanAutoBuildCSG->Invoke(GetManagedInstance(), nullptr, nullptr));
} }
bool ManagedEditor::CanAutoBuildNavMesh() bool ManagedEditor::CanAutoBuildNavMesh()
@@ -384,7 +384,7 @@ bool ManagedEditor::CanAutoBuildNavMesh()
Internal_CanAutoBuildNavMesh = GetClass()->GetMethod("Internal_CanAutoBuildNavMesh"); Internal_CanAutoBuildNavMesh = GetClass()->GetMethod("Internal_CanAutoBuildNavMesh");
ASSERT(Internal_CanAutoBuildNavMesh); ASSERT(Internal_CanAutoBuildNavMesh);
} }
return MUtils::Unbox<bool>(Internal_CanAutoBuildNavMesh->Invoke(GetManagedInstance(), nullptr, nullptr), true); return MUtils::Unbox<bool>(Internal_CanAutoBuildNavMesh->Invoke(GetManagedInstance(), nullptr, nullptr));
} }
bool ManagedEditor::HasGameViewportFocus() const bool ManagedEditor::HasGameViewportFocus() const
@@ -397,8 +397,7 @@ bool ManagedEditor::HasGameViewportFocus() const
Internal_HasGameViewportFocus = GetClass()->GetMethod("Internal_HasGameViewportFocus"); Internal_HasGameViewportFocus = GetClass()->GetMethod("Internal_HasGameViewportFocus");
ASSERT(Internal_HasGameViewportFocus); ASSERT(Internal_HasGameViewportFocus);
} }
auto invk = Internal_HasGameViewportFocus->Invoke(GetManagedInstance(), nullptr, nullptr); result = MUtils::Unbox<bool>(Internal_HasGameViewportFocus->Invoke(GetManagedInstance(), nullptr, nullptr));
result = MUtils::Unbox<bool>(invk, true);
} }
return result; return result;
} }
@@ -496,7 +495,7 @@ bool ManagedEditor::OnAppExit()
Internal_OnAppExit = GetClass()->GetMethod("Internal_OnAppExit"); Internal_OnAppExit = GetClass()->GetMethod("Internal_OnAppExit");
ASSERT(Internal_OnAppExit); ASSERT(Internal_OnAppExit);
} }
return MUtils::Unbox<bool>(Internal_OnAppExit->Invoke(GetManagedInstance(), nullptr, nullptr), true); return MUtils::Unbox<bool>(Internal_OnAppExit->Invoke(GetManagedInstance(), nullptr, nullptr));
} }
void ManagedEditor::RequestStartPlayOnEditMode() void ManagedEditor::RequestStartPlayOnEditMode()

View File

@@ -334,9 +334,6 @@ namespace FlaxEditor.Modules.SourceCodeEditing
} }
} }
} }
if (editor == null)
editor = Editor.Instance.CodeEditing.Editors[0];
Editor.Instance.CodeEditing.SelectedEditor = editor; Editor.Instance.CodeEditing.SelectedEditor = editor;
} }

View File

@@ -41,9 +41,9 @@ namespace FlaxEditor.Modules.SourceCodeEditing
var vsCode = codeEditing.GetInBuildEditor(CodeEditorTypes.VSCode); var vsCode = codeEditing.GetInBuildEditor(CodeEditorTypes.VSCode);
var rider = codeEditing.GetInBuildEditor(CodeEditorTypes.Rider); var rider = codeEditing.GetInBuildEditor(CodeEditorTypes.Rider);
#if PLATFORM_WINDOWS #if PLATFORM_WINDOW
// Favor the newest Visual Studio // Favor the newest Visual Studio
for (int i = (int)CodeEditorTypes.VS2026; i >= (int)CodeEditorTypes.VS2008; i--) for (int i = (int)CodeEditorTypes.VS2019; i >= (int)CodeEditorTypes.VS2008; i--)
{ {
var visualStudio = codeEditing.GetInBuildEditor((CodeEditorTypes)i); var visualStudio = codeEditing.GetInBuildEditor((CodeEditorTypes)i);
if (visualStudio != null) if (visualStudio != null)
@@ -74,7 +74,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing
public string Name => "Default"; public string Name => "Default";
/// <inheritdoc /> /// <inheritdoc />
public string GenerateProjectCustomArgs => _currentEditor?.GenerateProjectCustomArgs; public string GenerateProjectCustomArgs => null;
/// <inheritdoc /> /// <inheritdoc />
public void OpenSolution() public void OpenSolution()

View File

@@ -22,14 +22,71 @@ namespace FlaxEditor.Modules.SourceCodeEditing
public InBuildSourceCodeEditor(CodeEditorTypes type) public InBuildSourceCodeEditor(CodeEditorTypes type)
{ {
Type = type; Type = type;
Name = CodeEditingManager.GetName(type); switch (type)
{
case CodeEditorTypes.Custom:
Name = "Custom";
break;
case CodeEditorTypes.SystemDefault:
Name = "System Default";
break;
case CodeEditorTypes.VS2008:
Name = "Visual Studio 2008";
break;
case CodeEditorTypes.VS2010:
Name = "Visual Studio 2010";
break;
case CodeEditorTypes.VS2012:
Name = "Visual Studio 2012";
break;
case CodeEditorTypes.VS2013:
Name = "Visual Studio 2013";
break;
case CodeEditorTypes.VS2015:
Name = "Visual Studio 2015";
break;
case CodeEditorTypes.VS2017:
Name = "Visual Studio 2017";
break;
case CodeEditorTypes.VS2019:
Name = "Visual Studio 2019";
break;
case CodeEditorTypes.VS2022:
Name = "Visual Studio 2022";
break;
case CodeEditorTypes.VS2026:
Name = "Visual Studio 2026";
break;
case CodeEditorTypes.VSCode:
Name = "Visual Studio Code";
break;
case CodeEditorTypes.VSCodeInsiders:
Name = "Visual Studio Code - Insiders";
break;
case CodeEditorTypes.Rider:
Name = "Rider";
break;
default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
}
} }
/// <inheritdoc /> /// <inheritdoc />
public string Name { get; set; } public string Name { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public string GenerateProjectCustomArgs => CodeEditingManager.GetGenerateProjectCustomArgs(Type); public string GenerateProjectCustomArgs
{
get
{
switch (Type)
{
case CodeEditorTypes.VSCodeInsiders:
case CodeEditorTypes.VSCode: return "-vscode -vs2022";
case CodeEditorTypes.Rider: return "-vs2022";
default: return null;
}
}
}
/// <inheritdoc /> /// <inheritdoc />
public void OpenSolution() public void OpenSolution()

View File

@@ -722,7 +722,6 @@ namespace FlaxEditor.Modules
_menuToolsBuildCSGMesh = cm.AddButton("Build CSG mesh", inputOptions.BuildCSG, Editor.BuildCSG); _menuToolsBuildCSGMesh = cm.AddButton("Build CSG mesh", inputOptions.BuildCSG, Editor.BuildCSG);
_menuToolsBuildNavMesh = cm.AddButton("Build Nav Mesh", inputOptions.BuildNav, Editor.BuildNavMesh); _menuToolsBuildNavMesh = cm.AddButton("Build Nav Mesh", inputOptions.BuildNav, Editor.BuildNavMesh);
_menuToolsBuildAllMeshesSDF = cm.AddButton("Build all meshes SDF", inputOptions.BuildSDF, Editor.BuildAllMeshesSDF); _menuToolsBuildAllMeshesSDF = cm.AddButton("Build all meshes SDF", inputOptions.BuildSDF, Editor.BuildAllMeshesSDF);
_menuToolsBuildAllMeshesSDF.LinkTooltip("Generates Sign Distance Field texture for all meshes used in loaded scenes. Use with 'F' key pressed to force rebuild SDF for meshes with existing one.");
cm.AddSeparator(); cm.AddSeparator();
cm.AddButton("Game Cooker", Editor.Windows.GameCookerWin.FocusOrShow); cm.AddButton("Game Cooker", Editor.Windows.GameCookerWin.FocusOrShow);
_menuToolsCancelBuilding = cm.AddButton("Cancel building game", () => GameCooker.Cancel()); _menuToolsCancelBuilding = cm.AddButton("Cancel building game", () => GameCooker.Cancel());

View File

@@ -897,11 +897,9 @@ namespace FlaxEditor.Modules
if (type.IsAssignableTo(typeof(AssetEditorWindow))) if (type.IsAssignableTo(typeof(AssetEditorWindow)))
{ {
var ctor = type.GetConstructor(new Type[] { typeof(Editor), typeof(AssetItem) });
var assetItem = Editor.ContentDatabase.FindAsset(winData.AssetItemID); var assetItem = Editor.ContentDatabase.FindAsset(winData.AssetItemID);
var assetType = assetItem.GetType();
var ctor = type.GetConstructor(new Type[] { typeof(Editor), assetType });
var win = (AssetEditorWindow)ctor.Invoke(new object[] { Editor.Instance, assetItem }); var win = (AssetEditorWindow)ctor.Invoke(new object[] { Editor.Instance, assetItem });
win.Show(winData.DockState, winData.DockState != DockState.Float ? winData.DockedTo : null, winData.SelectOnShow, winData.SplitterValue); win.Show(winData.DockState, winData.DockState != DockState.Float ? winData.DockedTo : null, winData.SelectOnShow, winData.SplitterValue);
if (winData.DockState == DockState.Float) if (winData.DockState == DockState.Float)
{ {

View File

@@ -36,8 +36,8 @@ namespace FlaxEditor.SceneGraph
} }
var center = _actor.Transform.Translation; var center = _actor.Transform.Translation;
ViewportIconsRenderer.GetBounds(center, ray.Ray.Position, out var sphere); ViewportIconsRenderer.GetBounds(ref center, ref ray.Ray.Position, out var sphere);
return CollisionsHelper.RayIntersectsSphere(ray.Ray, sphere, out distance); return CollisionsHelper.RayIntersectsSphere(ref ray.Ray, ref sphere, out distance);
} }
} }
} }

View File

@@ -109,10 +109,10 @@ namespace FlaxEditor.SceneGraph.Actors
// Skin vertex position with the current pose // Skin vertex position with the current pose
var position = positionStream.GetFloat3(j); var position = positionStream.GetFloat3(j);
Float3.Transform(position, skinningMatrices[indices[0]], out Float3 pos0); Float3.Transform(ref position, ref skinningMatrices[indices[0]], out Float3 pos0);
Float3.Transform(position, skinningMatrices[indices[1]], out Float3 pos1); Float3.Transform(ref position, ref skinningMatrices[indices[1]], out Float3 pos1);
Float3.Transform(position, skinningMatrices[indices[2]], out Float3 pos2); Float3.Transform(ref position, ref skinningMatrices[indices[2]], out Float3 pos2);
Float3.Transform(position, skinningMatrices[indices[3]], out Float3 pos3); Float3.Transform(ref position, ref skinningMatrices[indices[3]], out Float3 pos3);
position = pos0 * weights[0] + pos1 * weights[1] + pos2 * weights[2] + pos3 * weights[3]; position = pos0 * weights[0] + pos1 * weights[1] + pos2 * weights[2] + pos3 * weights[3];
// Add vertex to the bone list // Add vertex to the bone list
@@ -269,8 +269,8 @@ namespace FlaxEditor.SceneGraph.Actors
for (int i = 0; i < boneVertices.Count; i++) for (int i = 0; i < boneVertices.Count; i++)
{ {
var pos = boneTransform.WorldToLocal(boneVertices[i]); var pos = boneTransform.WorldToLocal(boneVertices[i]);
Vector3.Min(boneLocalBounds.Minimum, pos, out boneLocalBounds.Minimum); Vector3.Min(ref boneLocalBounds.Minimum, ref pos, out boneLocalBounds.Minimum);
Vector3.Max(boneLocalBounds.Maximum, pos, out boneLocalBounds.Maximum); Vector3.Max(ref boneLocalBounds.Maximum, ref pos, out boneLocalBounds.Maximum);
} }
// Add collision shape // Add collision shape
@@ -415,7 +415,7 @@ namespace FlaxEditor.SceneGraph.Actors
float bkLength = bk.Length; float bkLength = bk.Length;
if (bkLength > 0.0f) if (bkLength > 0.0f)
{ {
Float3.Transform(bk, matrix, out Float3 bkA); Float3.Transform(ref bk, ref matrix, out Float3 bkA);
bk = bkA / bkLength; bk = bkA / bkLength;
} }
} }

View File

@@ -184,7 +184,7 @@ namespace FlaxEditor.SceneGraph.Actors
/// <inheritdoc /> /// <inheritdoc />
public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal) public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal)
{ {
return Brush.Intersects(Index, ray.Ray, out distance, out normal); return Brush.Intersects(Index, ref ray.Ray, out distance, out normal);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -207,7 +207,7 @@ namespace FlaxEditor.SceneGraph.Actors
/// <inheritdoc /> /// <inheritdoc />
public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal) public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal)
{ {
if (((BoxBrush)_actor).OrientedBox.Intersects(ray.Ray)) if (((BoxBrush)_actor).OrientedBox.Intersects(ref ray.Ray))
{ {
for (int i = 0; i < ChildNodes.Count; i++) for (int i = 0; i < ChildNodes.Count; i++)
{ {

View File

@@ -107,7 +107,7 @@ namespace FlaxEditor.SceneGraph.Actors
{ {
normal = Vector3.Up; normal = Vector3.Up;
var sphere = new BoundingSphere(Transform.Translation, 10.0f); var sphere = new BoundingSphere(Transform.Translation, 10.0f);
return sphere.Intersects(ray.Ray, out distance); return sphere.Intersects(ref ray.Ray, out distance);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -56,7 +56,7 @@ namespace FlaxEditor.SceneGraph.Actors
return false; return false;
} }
return Camera.Internal_IntersectsItselfEditor(FlaxEngine.Object.GetUnmanagedPtr(_actor), ray.Ray, out distance); return Camera.Internal_IntersectsItselfEditor(FlaxEngine.Object.GetUnmanagedPtr(_actor), ref ray.Ray, out distance);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -58,7 +58,7 @@ namespace FlaxEditor.SceneGraph.Actors
public override Transform Transform public override Transform Transform
{ {
get => Actor.GetInstance(Index).Transform; get => Actor.GetInstance(Index).Transform;
set => Actor.SetInstanceTransform(Index, value); set => Actor.SetInstanceTransform(Index, ref value);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -63,7 +63,7 @@ namespace FlaxEditor.SceneGraph.Actors
{ {
normal = Vector3.Up; normal = Vector3.Up;
var sphere = new BoundingSphere(Transform.Translation, 10.0f); var sphere = new BoundingSphere(Transform.Translation, 10.0f);
return sphere.Intersects(ray.Ray, out distance); return sphere.Intersects(ref ray.Ray, out distance);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -177,7 +177,7 @@ namespace FlaxEditor.SceneGraph.Actors
var actor = (Spline)_node.Actor; var actor = (Spline)_node.Actor;
var pos = actor.GetSplinePoint(Index); var pos = actor.GetSplinePoint(Index);
var nodeSize = NodeSizeByDistance(Transform.Translation, PointNodeSize, ray.View.Position); var nodeSize = NodeSizeByDistance(Transform.Translation, PointNodeSize, ray.View.Position);
return new BoundingSphere(pos, nodeSize).Intersects(ray.Ray, out distance); return new BoundingSphere(pos, nodeSize).Intersects(ref ray.Ray, out distance);
} }
public override void OnDebugDraw(ViewportDebugDrawData data) public override void OnDebugDraw(ViewportDebugDrawData data)
@@ -264,7 +264,7 @@ namespace FlaxEditor.SceneGraph.Actors
var actor = (Spline)_node.Actor; var actor = (Spline)_node.Actor;
var pos = actor.GetSplineTangent(_index, _isIn).Translation; var pos = actor.GetSplineTangent(_index, _isIn).Translation;
var tangentSize = NodeSizeByDistance(Transform.Translation, TangentNodeSize, ray.View.Position); var tangentSize = NodeSizeByDistance(Transform.Translation, TangentNodeSize, ray.View.Position);
return new BoundingSphere(pos, tangentSize).Intersects(ray.Ray, out distance); return new BoundingSphere(pos, tangentSize).Intersects(ref ray.Ray, out distance);
} }
public override void OnDebugDraw(ViewportDebugDrawData data) public override void OnDebugDraw(ViewportDebugDrawData data)

View File

@@ -37,15 +37,15 @@ namespace FlaxEditor.SceneGraph.Actors
{ {
var up = Float3.Up; var up = Float3.Up;
Float3 translation = transform.Translation; Float3 translation = transform.Translation;
Matrix.Billboard(translation, viewPosition, up, viewDirection, out m2); Matrix.Billboard(ref translation, ref viewPosition, ref up, ref viewDirection, out m2);
Matrix.Multiply(m1, m2, out m3); Matrix.Multiply(ref m1, ref m2, out m3);
Matrix.Scaling(transform.Scale, out m1); Matrix.Scaling(ref transform.Scale, out m1);
Matrix.Multiply(m1, m3, out world); Matrix.Multiply(ref m1, ref m3, out world);
} }
else else
{ {
transform.GetWorld(out m2); transform.GetWorld(out m2);
Matrix.Multiply(m1, m2, out world); Matrix.Multiply(ref m1, ref m2, out world);
} }
OrientedBoundingBox bounds; OrientedBoundingBox bounds;
@@ -53,7 +53,7 @@ namespace FlaxEditor.SceneGraph.Actors
world.Decompose(out bounds.Transformation); world.Decompose(out bounds.Transformation);
normal = -ray.Ray.Direction; normal = -ray.Ray.Direction;
return bounds.Intersects(ray.Ray, out distance); return bounds.Intersects(ref ray.Ray, out distance);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -96,7 +96,7 @@ namespace FlaxEditor.SceneGraph.Actors
for (int i = 0; i < verts.Length; i++) for (int i = 0; i < verts.Length; i++)
{ {
ref var v = ref verts[i]; ref var v = ref verts[i];
var distance = Float3.DistanceSquared(pointLocal, v); var distance = Float3.DistanceSquared(ref pointLocal, ref v);
if (distance <= minDistance) if (distance <= minDistance)
{ {
hit = true; hit = true;

View File

@@ -64,7 +64,7 @@ namespace FlaxEditor.SceneGraph.Actors
normal = Vector3.Up; normal = Vector3.Up;
if (Actor is UICanvas uiCanvas && uiCanvas.Is3D) if (Actor is UICanvas uiCanvas && uiCanvas.Is3D)
return uiCanvas.Bounds.Intersects(ray.Ray, out distance); return uiCanvas.Bounds.Intersects(ref ray.Ray, out distance);
distance = 0; distance = 0;
return false; return false;

View File

@@ -352,7 +352,7 @@ namespace FlaxEditor.SceneGraph
for (int i = 0; i < ChildNodes.Count; i++) for (int i = 0; i < ChildNodes.Count; i++)
{ {
ChildNodes[i].GetEditorSphere(out var childSphere); ChildNodes[i].GetEditorSphere(out var childSphere);
BoundingSphere.Merge(sphere, childSphere, out sphere); BoundingSphere.Merge(ref sphere, ref childSphere, out sphere);
} }
} }

View File

@@ -139,34 +139,6 @@ CodeEditor* CodeEditingManager::GetCodeEditor(CodeEditorTypes editorType)
return nullptr; return nullptr;
} }
String CodeEditingManager::GetName(CodeEditorTypes editorType)
{
const auto editor = GetCodeEditor(editorType);
if (editor)
{
return editor->GetName();
}
else
{
LOG(Warning, "Missing code editor type {0}", (int32)editorType);
return String::Empty;
}
}
String CodeEditingManager::GetGenerateProjectCustomArgs(CodeEditorTypes editorType)
{
const auto editor = GetCodeEditor(editorType);
if (editor)
{
return editor->GetGenerateProjectCustomArgs();
}
else
{
LOG(Warning, "Missing code editor type {0}", (int32)editorType);
return String::Empty;
}
}
void CodeEditingManager::OpenFile(CodeEditorTypes editorType, const String& path, int32 line) void CodeEditingManager::OpenFile(CodeEditorTypes editorType, const String& path, int32 line)
{ {
const auto editor = GetCodeEditor(editorType); const auto editor = GetCodeEditor(editorType);

View File

@@ -109,18 +109,9 @@ public:
/// <summary> /// <summary>
/// Gets the name of the editor. /// Gets the name of the editor.
/// </summary> /// </summary>
/// <returns>The name.</returns> /// <returns>The name</returns>
virtual String GetName() const = 0; virtual String GetName() const = 0;
/// <summary>
/// Gets the custom arguments for the Flax.Build tool to add when generating project files for this code editor.
/// </summary>
/// <returns>The custom arguments to generate project files.</returns>
virtual String GetGenerateProjectCustomArgs() const
{
return String::Empty;
}
/// <summary> /// <summary>
/// Opens the file. /// Opens the file.
/// </summary> /// </summary>
@@ -178,20 +169,6 @@ public:
/// <returns>The editor object or null if not found.</returns> /// <returns>The editor object or null if not found.</returns>
static CodeEditor* GetCodeEditor(CodeEditorTypes editorType); static CodeEditor* GetCodeEditor(CodeEditorTypes editorType);
/// <summary>
/// Gets the name of the editor.
/// </summary>
/// <param name="editorType">The code editor type.</param>
/// <returns>The name.</returns>
API_FUNCTION() static String GetName(CodeEditorTypes editorType);
/// <summary>
/// Gets the custom arguments for the Flax.Build tool to add when generating project files for this code editor.
/// </summary>
/// <param name="editorType">The code editor type.</param>
/// <returns>The custom arguments to generate project files.</returns>
API_FUNCTION() static String GetGenerateProjectCustomArgs(CodeEditorTypes editorType);
/// <summary> /// <summary>
/// Opens the file. Handles async opening. /// Opens the file. Handles async opening.
/// </summary> /// </summary>

View File

@@ -257,17 +257,12 @@ String RiderCodeEditor::GetName() const
return TEXT("Rider"); return TEXT("Rider");
} }
String RiderCodeEditor::GetGenerateProjectCustomArgs() const
{
return TEXT("-vs2022");
}
void RiderCodeEditor::OpenFile(const String& path, int32 line) void RiderCodeEditor::OpenFile(const String& path, int32 line)
{ {
// Generate project files if solution is missing // Generate project files if solution is missing
if (!FileSystem::FileExists(_solutionPath)) if (!FileSystem::FileExists(_solutionPath))
{ {
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs()); ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
} }
// Open file // Open file
@@ -295,7 +290,7 @@ void RiderCodeEditor::OpenSolution()
// Generate project files if solution is missing // Generate project files if solution is missing
if (!FileSystem::FileExists(_solutionPath)) if (!FileSystem::FileExists(_solutionPath))
{ {
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs()); ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
} }
// Open solution // Open solution
@@ -317,5 +312,5 @@ void RiderCodeEditor::OpenSolution()
void RiderCodeEditor::OnFileAdded(const String& path) void RiderCodeEditor::OnFileAdded(const String& path)
{ {
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs()); ScriptsBuilder::GenerateProject();
} }

View File

@@ -35,7 +35,6 @@ public:
// [CodeEditor] // [CodeEditor]
CodeEditorTypes GetType() const override; CodeEditorTypes GetType() const override;
String GetName() const override; String GetName() const override;
String GetGenerateProjectCustomArgs() const override;
void OpenFile(const String& path, int32 line) override; void OpenFile(const String& path, int32 line) override;
void OpenSolution() override; void OpenSolution() override;
void OnFileAdded(const String& path) override; void OnFileAdded(const String& path) override;

View File

@@ -148,17 +148,12 @@ String VisualStudioEditor::GetName() const
return String(ToString(_version)); return String(ToString(_version));
} }
String VisualStudioEditor::GetGenerateProjectCustomArgs() const
{
return String::Format(TEXT("-{0}"), String(ToString(_version)).ToLower());
}
void VisualStudioEditor::OpenFile(const String& path, int32 line) void VisualStudioEditor::OpenFile(const String& path, int32 line)
{ {
// Generate project files if solution is missing // Generate project files if solution is missing
if (!FileSystem::FileExists(_solutionPath)) if (!FileSystem::FileExists(_solutionPath))
{ {
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs()); ScriptsBuilder::GenerateProject();
} }
// Open file // Open file
@@ -177,7 +172,7 @@ void VisualStudioEditor::OpenSolution()
// Generate project files if solution is missing // Generate project files if solution is missing
if (!FileSystem::FileExists(_solutionPath)) if (!FileSystem::FileExists(_solutionPath))
{ {
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs()); ScriptsBuilder::GenerateProject();
} }
// Open solution // Open solution
@@ -192,7 +187,7 @@ void VisualStudioEditor::OpenSolution()
void VisualStudioEditor::OnFileAdded(const String& path) void VisualStudioEditor::OnFileAdded(const String& path)
{ {
// TODO: finish dynamic files adding to the project - for now just regenerate it // TODO: finish dynamic files adding to the project - for now just regenerate it
ScriptsBuilder::GenerateProject(GetGenerateProjectCustomArgs()); ScriptsBuilder::GenerateProject();
return; return;
if (!FileSystem::FileExists(_solutionPath)) if (!FileSystem::FileExists(_solutionPath))
{ {

View File

@@ -56,7 +56,6 @@ public:
// [CodeEditor] // [CodeEditor]
CodeEditorTypes GetType() const override; CodeEditorTypes GetType() const override;
String GetName() const override; String GetName() const override;
String GetGenerateProjectCustomArgs() const override;
void OpenFile(const String& path, int32 line) override; void OpenFile(const String& path, int32 line) override;
void OpenSolution() override; void OpenSolution() override;
void OnFileAdded(const String& path) override; void OnFileAdded(const String& path) override;

View File

@@ -128,11 +128,6 @@ String VisualStudioCodeEditor::GetName() const
return _isInsiders ? TEXT("Visual Studio Code - Insiders") : TEXT("Visual Studio Code"); return _isInsiders ? TEXT("Visual Studio Code - Insiders") : TEXT("Visual Studio Code");
} }
String VisualStudioCodeEditor::GetGenerateProjectCustomArgs() const
{
return TEXT("-vs2022 -vscode");
}
void VisualStudioCodeEditor::OpenFile(const String& path, int32 line) void VisualStudioCodeEditor::OpenFile(const String& path, int32 line)
{ {
// Generate VS solution files for intellisense // Generate VS solution files for intellisense

View File

@@ -37,7 +37,6 @@ public:
// [CodeEditor] // [CodeEditor]
CodeEditorTypes GetType() const override; CodeEditorTypes GetType() const override;
String GetName() const override; String GetName() const override;
String GetGenerateProjectCustomArgs() const override;
void OpenFile(const String& path, int32 line) override; void OpenFile(const String& path, int32 line) override;
void OpenSolution() override; void OpenSolution() override;
bool UseAsyncForOpen() const override; bool UseAsyncForOpen() const override;

View File

@@ -406,8 +406,6 @@ namespace FlaxEngine.Utilities
{ {
if (type == ScriptType.Null) if (type == ScriptType.Null)
return null; return null;
if (type.BaseType == null)
return type.Type;
while (type.Type == null) while (type.Type == null)
type = type.BaseType; type = type.BaseType;
return type.Type; return type.Type;

View File

@@ -479,7 +479,7 @@ namespace FlaxEditor.Surface.Archetypes
// Scale debug pointer when it moves to make it more visible when investigating blending // Scale debug pointer when it moves to make it more visible when investigating blending
const float debugMaxSize = 2.0f; const float debugMaxSize = 2.0f;
float debugScale = Mathf.Saturate(Float2.Distance(_debugPos, prev) / new Float2(_rangeX.Absolute.ValuesSum, _rangeY.Absolute.ValuesSum).Length * 100.0f) * debugMaxSize + 1.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 debugBlendSpeed = _debugScale <= debugScale ? 4.0f : 1.0f; float debugBlendSpeed = _debugScale <= debugScale ? 4.0f : 1.0f;
_debugScale = Mathf.Lerp(_debugScale, debugScale, deltaTime * debugBlendSpeed); _debugScale = Mathf.Lerp(_debugScale, debugScale, deltaTime * debugBlendSpeed);
} }
@@ -1189,9 +1189,9 @@ namespace FlaxEditor.Surface.Archetypes
_triangleColors = new Color[_triangles.Length]; _triangleColors = new Color[_triangles.Length];
for (int i = 0; i < _triangles.Length; i += 3) for (int i = 0; i < _triangles.Length; i += 3)
{ {
var is0 = Float2.NearEqual(_triangles[i + 0], pos); var is0 = Float2.NearEqual(ref _triangles[i + 0], ref pos);
var is1 = Float2.NearEqual(_triangles[i + 1], pos); var is1 = Float2.NearEqual(ref _triangles[i + 1], ref pos);
var is2 = Float2.NearEqual(_triangles[i + 2], pos); var is2 = Float2.NearEqual(ref _triangles[i + 2], ref pos);
if (is0 || is1 || is2) if (is0 || is1 || is2)
{ {
selectedTriangles.Add(_triangles[i + 0]); selectedTriangles.Add(_triangles[i + 0]);
@@ -1233,7 +1233,7 @@ namespace FlaxEditor.Surface.Archetypes
if (point != null) if (point != null)
{ {
var highlightColor = point.IsMouseDown ? style.SelectionBorder : style.BackgroundSelected; var highlightColor = point.IsMouseDown ? style.SelectionBorder : style.BackgroundSelected;
Render2D.PushTint(highlightColor); Render2D.PushTint(ref highlightColor);
Render2D.DrawTriangles(_selectedTriangles, _selectedColors); Render2D.DrawTriangles(_selectedTriangles, _selectedColors);
Render2D.PopTint(); Render2D.PopTint();
} }

View File

@@ -213,7 +213,7 @@ namespace FlaxEditor.Surface.Archetypes
if (base.OnMouseDoubleClick(location, button)) if (base.OnMouseDoubleClick(location, button))
return true; return true;
if (_headerRect.Contains(location)) if (_headerRect.Contains(ref location))
{ {
StartRenaming(); StartRenaming();
return true; return true;
@@ -364,7 +364,7 @@ namespace FlaxEditor.Surface.Archetypes
if (ClipChildren) if (ClipChildren)
{ {
GetDesireClientArea(out var clientArea); GetDesireClientArea(out var clientArea);
Render2D.PushClip(clientArea); Render2D.PushClip(ref clientArea);
} }
DrawChildren(); DrawChildren();
@@ -382,13 +382,13 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override bool CanSelect(ref Float2 location) public override bool CanSelect(ref Float2 location)
{ {
return _dragAreaRect.MakeOffsetted(Location).Contains(location); return _dragAreaRect.MakeOffsetted(Location).Contains(ref location);
} }
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button) public override bool OnMouseDown(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left && !_dragAreaRect.Contains(location)) if (button == MouseButton.Left && !_dragAreaRect.Contains(ref location))
{ {
_isMouseDown = true; _isMouseDown = true;
Cursor = CursorType.Hand; Cursor = CursorType.Hand;
@@ -687,7 +687,7 @@ namespace FlaxEditor.Surface.Archetypes
var upperLeft = bounds.UpperLeft; var upperLeft = bounds.UpperLeft;
var bottomRight = bounds.BottomRight; var bottomRight = bounds.BottomRight;
bounds = Rectangle.FromPoints(PointToParent(ref upperLeft), PointToParent(ref bottomRight)); bounds = Rectangle.FromPoints(PointToParent(ref upperLeft), PointToParent(ref bottomRight));
CollisionsHelper.ClosestPointRectanglePoint(bounds, startPos, out endPos); CollisionsHelper.ClosestPointRectanglePoint(ref bounds, ref startPos, out endPos);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -726,20 +726,20 @@ namespace FlaxEditor.Surface.Archetypes
private void OnSurfaceMouseUp(ref Float2 mouse, MouseButton buttons, ref bool handled) private void OnSurfaceMouseUp(ref Float2 mouse, MouseButton buttons, ref bool handled)
{ {
if (handled || Surface.Context != Context) if (handled)
return; return;
// Check click over the connection // Check click over the connection
var mousePosition = Surface.SurfaceRoot.PointFromParent(ref mouse); var mousePosition = Surface.SurfaceRoot.PointFromParent(ref mouse);
if (!TransitionsRectangle.Contains(mousePosition)) if (!TransitionsRectangle.Contains(ref mousePosition))
return; return;
for (int i = 0; i < Transitions.Count; i++) for (int i = 0; i < Transitions.Count; i++)
{ {
var t = Transitions[i]; var t = Transitions[i];
if (t.Bounds.Contains(mousePosition)) if (t.Bounds.Contains(ref mousePosition))
{ {
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point); CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
if (Float2.DistanceSquared(mousePosition, point) < 25.0f) if (Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f)
{ {
OnTransitionClicked(t, ref mouse, ref mousePosition, buttons); OnTransitionClicked(t, ref mouse, ref mousePosition, buttons);
handled = true; handled = true;
@@ -751,20 +751,20 @@ namespace FlaxEditor.Surface.Archetypes
private void OnSurfaceMouseDoubleClick(ref Float2 mouse, MouseButton buttons, ref bool handled) private void OnSurfaceMouseDoubleClick(ref Float2 mouse, MouseButton buttons, ref bool handled)
{ {
if (handled || Surface.Context != Context) if (handled)
return; return;
// Check double click over the connection // Check double click over the connection
var mousePosition = Surface.SurfaceRoot.PointFromParent(ref mouse); var mousePosition = Surface.SurfaceRoot.PointFromParent(ref mouse);
if (!TransitionsRectangle.Contains(mousePosition)) if (!TransitionsRectangle.Contains(ref mousePosition))
return; return;
for (int i = 0; i < Transitions.Count; i++) for (int i = 0; i < Transitions.Count; i++)
{ {
var t = Transitions[i]; var t = Transitions[i];
if (t.Bounds.Contains(mousePosition)) if (t.Bounds.Contains(ref mousePosition))
{ {
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point); CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
if (Float2.DistanceSquared(mousePosition, point) < 25.0f) if (Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f)
{ {
t.EditRule(); t.EditRule();
handled = true; handled = true;
@@ -1007,7 +1007,7 @@ namespace FlaxEditor.Surface.Archetypes
var offset = diff ? -6.0f : 6.0f; var offset = diff ? -6.0f : 6.0f;
var dir = startPos - endPos; var dir = startPos - endPos;
dir.Normalize(); dir.Normalize();
Float2.Perpendicular(dir, out var nrm); Float2.Perpendicular(ref dir, out var nrm);
nrm *= offset; nrm *= offset;
startPos += nrm; startPos += nrm;
endPos += nrm; endPos += nrm;
@@ -1031,7 +1031,7 @@ namespace FlaxEditor.Surface.Archetypes
t.StartPos = startPos; t.StartPos = startPos;
t.EndPos = endPos; t.EndPos = endPos;
Rectangle.FromPoints(startPos, endPos, out t.Bounds); Rectangle.FromPoints(ref startPos, ref endPos, out t.Bounds);
t.Bounds.Expand(10.0f); t.Bounds.Expand(10.0f);
} }
@@ -1040,7 +1040,7 @@ namespace FlaxEditor.Surface.Archetypes
TransitionsRectangle = Transitions[0].Bounds; TransitionsRectangle = Transitions[0].Bounds;
for (int i = 1; i < Transitions.Count; i++) for (int i = 1; i < Transitions.Count; i++)
{ {
Rectangle.Union(TransitionsRectangle, Transitions[i].Bounds, out TransitionsRectangle); Rectangle.Union(ref TransitionsRectangle, ref Transitions[i].Bounds, out TransitionsRectangle);
} }
} }
else else
@@ -1095,7 +1095,7 @@ namespace FlaxEditor.Surface.Archetypes
if (ClipChildren) if (ClipChildren)
{ {
GetDesireClientArea(out var clientArea); GetDesireClientArea(out var clientArea);
Render2D.PushClip(clientArea); Render2D.PushClip(ref clientArea);
} }
DrawChildren(); DrawChildren();
@@ -1120,7 +1120,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override bool CanSelect(ref Float2 location) public override bool CanSelect(ref Float2 location)
{ {
return _dragAreaRect.MakeOffsetted(Location).Contains(location); return _dragAreaRect.MakeOffsetted(Location).Contains(ref location);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -1129,7 +1129,7 @@ namespace FlaxEditor.Surface.Archetypes
if (base.OnMouseDoubleClick(location, button)) if (base.OnMouseDoubleClick(location, button))
return true; return true;
if (_renameButtonRect.Contains(location) || _closeButtonRect.Contains(location)) if (_renameButtonRect.Contains(ref location) || _closeButtonRect.Contains(ref location))
return true; return true;
return false; return false;
@@ -1138,7 +1138,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button) public override bool OnMouseDown(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left && !_dragAreaRect.Contains(location)) if (button == MouseButton.Left && !_dragAreaRect.Contains(ref location))
{ {
_isMouseDown = true; _isMouseDown = true;
Cursor = CursorType.Hand; Cursor = CursorType.Hand;
@@ -1271,11 +1271,11 @@ namespace FlaxEditor.Surface.Archetypes
for (int i = 0; i < Transitions.Count; i++) for (int i = 0; i < Transitions.Count; i++)
{ {
var t = Transitions[i]; var t = Transitions[i];
var isMouseOver = t.Bounds.Contains(mousePosition); var isMouseOver = t.Bounds.Contains(ref mousePosition);
if (isMouseOver) if (isMouseOver)
{ {
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point); CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
isMouseOver = Float2.DistanceSquared(mousePosition, point) < 25.0f; isMouseOver = Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f;
} }
var color = isMouseOver ? Color.Wheat : t.LineColor; var color = isMouseOver ? Color.Wheat : t.LineColor;
SurfaceStyle.DrawStraightConnection(t.StartPos, t.EndPos, color); SurfaceStyle.DrawStraightConnection(t.StartPos, t.EndPos, color);
@@ -1474,7 +1474,7 @@ namespace FlaxEditor.Surface.Archetypes
return true; return true;
// Rename // Rename
if (_renameButtonRect.Contains(location)) if (_renameButtonRect.Contains(ref location))
{ {
StartRenaming(); StartRenaming();
return true; return true;

View File

@@ -308,7 +308,7 @@ namespace FlaxEditor.Surface.Archetypes
if (base.OnMouseDoubleClick(location, button)) if (base.OnMouseDoubleClick(location, button))
return true; return true;
if (_nameField.Bounds.Contains(location) && Surface.CanEdit) if (_nameField.Bounds.Contains(ref location) && Surface.CanEdit)
{ {
StartRenaming(); StartRenaming();
return true; return true;
@@ -1128,7 +1128,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseDoubleClick(Float2 location, MouseButton button) public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left && _headerRect.Contains(location)) if (button == MouseButton.Left && _headerRect.Contains(ref location))
{ {
// Open function content item if exists // Open function content item if exists
var method = GetMethod(out var scriptType, out _, out _); var method = GetMethod(out var scriptType, out _, out _);
@@ -1759,7 +1759,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseDoubleClick(Float2 location, MouseButton button) public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left && _headerRect.Contains(location)) if (button == MouseButton.Left && _headerRect.Contains(ref location))
{ {
OnEditSignature(); OnEditSignature();
return true; return true;

View File

@@ -347,7 +347,7 @@ namespace FlaxEditor.Surface.Archetypes
public override bool CanSelect(ref Float2 location) public override bool CanSelect(ref Float2 location)
{ {
return base.CanSelect(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(location); return base.CanSelect(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(ref location);
} }
public override void OnSurfaceLoaded(SurfaceNodeActions action) public override void OnSurfaceLoaded(SurfaceNodeActions action)
@@ -414,7 +414,7 @@ namespace FlaxEditor.Surface.Archetypes
if (base.OnMouseDown(location, button)) if (base.OnMouseDown(location, button))
return true; return true;
if (button == MouseButton.Left && _resizeButtonRect.Contains(location) && Surface.CanEdit) if (button == MouseButton.Left && _resizeButtonRect.Contains(ref location) && Surface.CanEdit)
{ {
// Start sliding // Start sliding
_isResizing = true; _isResizing = true;

View File

@@ -182,7 +182,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button) public override bool OnMouseDown(Float2 location, MouseButton button)
{ {
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location)) if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
{ {
_arrangeButtonInUse = true; _arrangeButtonInUse = true;
Focus(); Focus();

View File

@@ -191,7 +191,7 @@ namespace FlaxEditor.Surface.Archetypes
// Header // Header
var headerColor = style.BackgroundHighlighted; var headerColor = style.BackgroundHighlighted;
if (_headerRect.Contains(_mousePosition)) if (_headerRect.Contains(ref _mousePosition))
headerColor *= 1.07f; headerColor *= 1.07f;
Render2D.FillRectangle(_headerRect, headerColor); Render2D.FillRectangle(_headerRect, headerColor);
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center); Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);

View File

@@ -113,7 +113,7 @@ namespace FlaxEditor.Surface.Archetypes
var icons = Editor.Instance.Icons; var icons = Editor.Instance.Icons;
var icon = isSelected ? icons.VisjectArrowClosed32 : icons.VisjectArrowOpen32; var icon = isSelected ? icons.VisjectArrowClosed32 : icons.VisjectArrowOpen32;
Render2D.PushTransform(arrowTransform); Render2D.PushTransform(ref arrowTransform);
Render2D.DrawSprite(icon, arrowRect, color); Render2D.DrawSprite(icon, arrowRect, color);
Render2D.PopTransform(); Render2D.PopTransform();
} }
@@ -169,7 +169,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override void OnMouseMove(Float2 location) public override void OnMouseMove(Float2 location)
{ {
if (_isMoving && Float2.DistanceSquared(location, _startMovePos) > 25.0f) if (_isMoving && Float2.DistanceSquared(ref location, ref _startMovePos) > 25.0f)
{ {
_startMovePos = Float2.Minimum; _startMovePos = Float2.Minimum;
int index = Node._stops.IndexOf(this); int index = Node._stops.IndexOf(this);
@@ -1076,12 +1076,12 @@ namespace FlaxEditor.Surface.Archetypes
} }
/// <inheritdoc /> /// <inheritdoc />
protected override bool ShowTooltip => !string.IsNullOrEmpty(TooltipText) && _localBounds.Contains(_mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened; protected override bool ShowTooltip => !string.IsNullOrEmpty(TooltipText) && _localBounds.Contains(ref _mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
/// <inheritdoc /> /// <inheritdoc />
public override bool OnTestTooltipOverControl(ref Float2 location) public override bool OnTestTooltipOverControl(ref Float2 location)
{ {
return _localBounds.Contains(location) && ShowTooltip; return _localBounds.Contains(ref location) && ShowTooltip;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -1150,7 +1150,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override bool CanSelect(ref Float2 location) public override bool CanSelect(ref Float2 location)
{ {
return new Rectangle(Location, DefaultSize).Contains(location); return new Rectangle(Location, DefaultSize).Contains(ref location);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -1230,7 +1230,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc /> /// <inheritdoc />
public override void OnMouseMove(Float2 location) public override void OnMouseMove(Float2 location)
{ {
_isMouseInConnectingBounds = IsMouseOver && _localBounds.MakeExpanded(ConnectingBounds).Contains(location); // Inner area for connecting, outer area for moving _isMouseInConnectingBounds = IsMouseOver && _localBounds.MakeExpanded(ConnectingBounds).Contains(ref location); // Inner area for connecting, outer area for moving
if (!_isMouseInConnectingBounds && !_isMouseDown) if (!_isMouseInConnectingBounds && !_isMouseDown)
Cursor = CursorType.SizeAll; Cursor = CursorType.SizeAll;
else else

View File

@@ -2,8 +2,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.Loader;
using System.Runtime.Serialization.Formatters.Binary;
using FlaxEditor.CustomEditors; using FlaxEditor.CustomEditors;
using FlaxEditor.CustomEditors.Editors; using FlaxEditor.CustomEditors.Editors;
using FlaxEditor.GUI.ContextMenu; using FlaxEditor.GUI.ContextMenu;
@@ -15,7 +18,6 @@ namespace FlaxEditor.Surface
class AttributesEditor : ContextMenuBase class AttributesEditor : ContextMenuBase
{ {
private CustomEditorPresenter _presenter; private CustomEditorPresenter _presenter;
private Proxy _proxy;
private byte[] _oldData; private byte[] _oldData;
private class Proxy private class Proxy
@@ -70,11 +72,11 @@ namespace FlaxEditor.Surface
/// Initializes a new instance of the <see cref="AttributesEditor"/> class. /// Initializes a new instance of the <see cref="AttributesEditor"/> class.
/// </summary> /// </summary>
/// <param name="attributes">The attributes list to edit.</param> /// <param name="attributes">The attributes list to edit.</param>
/// <param name="attributeTypes">The allowed attribute types to use.</param> /// <param name="attributeType">The allowed attribute types to use.</param>
public AttributesEditor(Attribute[] attributes, IList<Type> attributeTypes) public AttributesEditor(Attribute[] attributes, IList<Type> attributeType)
{ {
// Context menu dimensions // Context menu dimensions
const float width = 375.0f; const float width = 340.0f;
const float height = 370.0f; const float height = 370.0f;
Size = new Float2(width, height); Size = new Float2(width, height);
@@ -86,68 +88,61 @@ namespace FlaxEditor.Surface
Parent = this Parent = this
}; };
// Ok and Cancel Buttons // Buttons
float buttonsWidth = (width - 12.0f) * 0.5f; float buttonsWidth = (width - 16.0f) * 0.5f;
float buttonsHeight = 20.0f; float buttonsHeight = 20.0f;
var okButton = new Button(4.0f, Bottom - 4.0f - buttonsHeight, buttonsWidth, buttonsHeight) var cancelButton = new Button(4.0f, title.Bottom + 4.0f, buttonsWidth, buttonsHeight)
{
Text = "Ok",
Parent = this
};
okButton.Clicked += OnOkButtonClicked;
var cancelButton = new Button(okButton.Right + 4.0f, okButton.Y, buttonsWidth, buttonsHeight)
{ {
Text = "Cancel", Text = "Cancel",
Parent = this Parent = this
}; };
cancelButton.Clicked += Hide; cancelButton.Clicked += Hide;
var okButton = new Button(cancelButton.Right + 4.0f, cancelButton.Y, buttonsWidth, buttonsHeight)
{
Text = "OK",
Parent = this
};
okButton.Clicked += OnOkButtonClicked;
// Actual panel used to display attributes // Actual panel
var panel1 = new Panel(ScrollBars.Vertical) var panel1 = new Panel(ScrollBars.Vertical)
{ {
Bounds = new Rectangle(0, title.Bottom + 4.0f, width, height - buttonsHeight - title.Height - 14.0f), Bounds = new Rectangle(0, okButton.Bottom + 4.0f, width, height - okButton.Bottom - 2.0f),
Parent = this Parent = this
}; };
var editor = new CustomEditorPresenter(null); var editor = new CustomEditorPresenter(null);
editor.Panel.AnchorPreset = AnchorPresets.HorizontalStretchTop; editor.Panel.AnchorPreset = AnchorPresets.HorizontalStretchTop;
editor.Panel.IsScrollable = true; editor.Panel.IsScrollable = true;
editor.Panel.Parent = panel1; editor.Panel.Parent = panel1;
editor.Panel.Tag = attributeTypes; editor.Panel.Tag = attributeType;
_presenter = editor; _presenter = editor;
// Cache 'previous' state to check if attributes were edited after operation // Cache 'previous' state to check if attributes were edited after operation
_oldData = SurfaceMeta.GetAttributesData(attributes); _oldData = SurfaceMeta.GetAttributesData(attributes);
_proxy = new Proxy editor.Select(new Proxy
{ {
Value = attributes, Value = attributes,
}; });
editor.Select(_proxy);
_presenter.Modified += OnPresenterModified;
OnPresenterModified();
}
private void OnPresenterModified()
{
if (_proxy.Value.Length == 0)
{
var label = _presenter.Label("No attributes.\nPress the \"+\" button to add a new one and then select an attribute type using the \"Type\" dropdown.", TextAlignment.Center);
label.Label.Wrapping = TextWrapping.WrapWords;
label.Control.Height = 35f;
label.Label.Margin = new Margin(10f);
label.Label.TextColor = label.Label.TextColorHighlighted = Style.Current.ForegroundGrey;
}
} }
private void OnOkButtonClicked() private void OnOkButtonClicked()
{ {
var newValue = ((Proxy)_presenter.Selection[0]).Value; var newValue = ((Proxy)_presenter.Selection[0]).Value;
newValue = newValue.Where(v => v != null).ToArray(); for (int i = 0; i < newValue.Length; i++)
{
if (newValue[i] == null)
{
MessageBox.Show("One of the attributes is null. Please set it to the valid object.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
var newData = SurfaceMeta.GetAttributesData(newValue); var newData = SurfaceMeta.GetAttributesData(newValue);
if (!_oldData.SequenceEqual(newData)) if (!_oldData.SequenceEqual(newData))
{
Edited?.Invoke(newValue); Edited?.Invoke(newValue);
}
Hide(); Hide();
} }
@@ -188,9 +183,7 @@ namespace FlaxEditor.Surface
{ {
_presenter = null; _presenter = null;
_oldData = null; _oldData = null;
_proxy = null;
Edited = null; Edited = null;
_presenter.Modified -= OnPresenterModified;
base.OnDestroy(); base.OnDestroy();
} }

View File

@@ -156,7 +156,7 @@ namespace FlaxEditor.Surface.Elements
Bezier(ref offsetStart, ref control1, ref control2, ref offsetEnd, t, out p); Bezier(ref offsetStart, ref control1, ref control2, ref offsetEnd, t, out p);
// Maybe it would be reasonable to return the point? // Maybe it would be reasonable to return the point?
CollisionsHelper.ClosestPointPointLine(point, oldp, p, out var result); CollisionsHelper.ClosestPointPointLine(ref point, ref oldp, ref p, out var result);
if (Float2.DistanceSquared(point, result) <= squaredDistance) if (Float2.DistanceSquared(point, result) <= squaredDistance)
{ {
return true; 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) private static void Bezier(ref Float2 p0, ref Float2 p1, ref Float2 p2, ref Float2 p3, float alpha, out Float2 result)
{ {
Float2.Lerp(p0, p1, alpha, out var p01); Float2.Lerp(ref p0, ref p1, alpha, out var p01);
Float2.Lerp(p1, p2, alpha, out var p12); Float2.Lerp(ref p1, ref p2, alpha, out var p12);
Float2.Lerp(p2, p3, alpha, out var p23); Float2.Lerp(ref p2, ref p3, alpha, out var p23);
Float2.Lerp(p01, p12, alpha, out var p012); Float2.Lerp(ref p01, ref p12, alpha, out var p012);
Float2.Lerp(p12, p23, alpha, out var p123); Float2.Lerp(ref p12, ref p23, alpha, out var p123);
Float2.Lerp(p012, p123, alpha, out result); Float2.Lerp(ref p012, ref p123, alpha, out result);
} }
/// <summary> /// <summary>

View File

@@ -146,13 +146,13 @@ namespace FlaxEditor.Surface
/// <inheritdoc /> /// <inheritdoc />
public override bool CanSelect(ref Float2 location) public override bool CanSelect(ref Float2 location)
{ {
return _headerRect.MakeOffsetted(Location).Contains(location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(location); return _headerRect.MakeOffsetted(Location).Contains(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(ref location);
} }
/// <inheritdoc /> /// <inheritdoc />
public override bool IsSelectionIntersecting(ref Rectangle selectionRect) public override bool IsSelectionIntersecting(ref Rectangle selectionRect)
{ {
return _headerRect.MakeOffsetted(Location).Intersects(selectionRect); return _headerRect.MakeOffsetted(Location).Intersects(ref selectionRect);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -214,26 +214,23 @@ namespace FlaxEditor.Surface
if (!_isRenaming) if (!_isRenaming)
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center); Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
if (Surface.CanEdit) // Close button
Render2D.DrawSprite(style.Cross, _closeButtonRect, _closeButtonRect.Contains(_mousePosition) && Surface.CanEdit ? style.Foreground : style.ForegroundGrey);
// Color button
Render2D.DrawSprite(style.Settings, _colorButtonRect, _colorButtonRect.Contains(_mousePosition) && Surface.CanEdit ? style.Foreground : style.ForegroundGrey);
// Check if is resizing
if (_isResizing)
{ {
// Close button // Draw overlay
Render2D.DrawSprite(style.Cross, _closeButtonRect, _closeButtonRect.Contains(_mousePosition) && Surface.CanEdit ? style.Foreground : style.ForegroundGrey); Render2D.FillRectangle(_resizeButtonRect, style.Selection);
Render2D.DrawRectangle(_resizeButtonRect, style.SelectionBorder);
// Color button
Render2D.DrawSprite(style.Settings, _colorButtonRect, _colorButtonRect.Contains(_mousePosition) && Surface.CanEdit ? style.Foreground : style.ForegroundGrey);
// Check if is resizing
if (_isResizing)
{
// Draw overlay
Render2D.FillRectangle(_resizeButtonRect, style.Selection);
Render2D.DrawRectangle(_resizeButtonRect, style.SelectionBorder);
}
// Resize button
Render2D.DrawSprite(style.Scale, _resizeButtonRect, _resizeButtonRect.Contains(_mousePosition) && Surface.CanEdit ? style.Foreground : style.ForegroundGrey);
} }
// Resize button
Render2D.DrawSprite(style.Scale, _resizeButtonRect, _resizeButtonRect.Contains(_mousePosition) && Surface.CanEdit ? style.Foreground : style.ForegroundGrey);
// Selection outline // Selection outline
if (_isSelected) if (_isSelected)
{ {
@@ -287,7 +284,7 @@ namespace FlaxEditor.Surface
/// <inheritdoc /> /// <inheritdoc />
public override bool ContainsPoint(ref Float2 location, bool precise) public override bool ContainsPoint(ref Float2 location, bool precise)
{ {
return _headerRect.Contains(location) || _resizeButtonRect.Contains(location); return _headerRect.Contains(ref location) || _resizeButtonRect.Contains(ref location);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -297,7 +294,7 @@ namespace FlaxEditor.Surface
return true; return true;
// Check if can start resizing // Check if can start resizing
if (button == MouseButton.Left && _resizeButtonRect.Contains(location) && Surface.CanEdit) if (button == MouseButton.Left && _resizeButtonRect.Contains(ref location) && Surface.CanEdit)
{ {
// Start sliding // Start sliding
_isResizing = true; _isResizing = true;
@@ -336,7 +333,7 @@ namespace FlaxEditor.Surface
return true; return true;
// Rename // Rename
if (_headerRect.Contains(location) && Surface.CanEdit) if (_headerRect.Contains(ref location) && Surface.CanEdit)
{ {
StartRenaming(); StartRenaming();
return true; return true;
@@ -404,14 +401,14 @@ namespace FlaxEditor.Surface
return true; return true;
// Close // Close
if (_closeButtonRect.Contains(location) && Surface.CanEdit) if (_closeButtonRect.Contains(ref location) && Surface.CanEdit)
{ {
Surface.Delete(this); Surface.Delete(this);
return true; return true;
} }
// Color // Color
if (_colorButtonRect.Contains(location) && Surface.CanEdit) if (_colorButtonRect.Contains(ref location) && Surface.CanEdit)
{ {
ColorValueBox.ShowPickColorDialog?.Invoke(this, Color, OnColorChanged); ColorValueBox.ShowPickColorDialog?.Invoke(this, Color, OnColorChanged);
return true; return true;

View File

@@ -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> /// <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) public virtual bool IsSelectionIntersecting(ref Rectangle selectionRect)
{ {
return Bounds.Intersects(selectionRect); return Bounds.Intersects(ref selectionRect);
} }
/// <summary> /// <summary>

View File

@@ -431,6 +431,27 @@ namespace FlaxEditor.Surface
/// </summary> /// </summary>
public bool HasIndependentBoxes => Archetype.IndependentBoxes != null; public bool HasIndependentBoxes => Archetype.IndependentBoxes != null;
/// <summary>
/// Gets a value indicating whether this node has dependent boxes with assigned valid types. Otherwise any box has no dependent type assigned.
/// </summary>
public bool HasDependentBoxesSetup
{
get
{
if (Archetype.DependentBoxes == null || Archetype.IndependentBoxes == null)
return true;
for (int i = 0; i < Archetype.DependentBoxes.Length; i++)
{
var b = GetBox(Archetype.DependentBoxes[i]);
if (b != null && b.CurrentType == b.DefaultType)
return false;
}
return true;
}
}
private static readonly List<SurfaceNode> UpdateStack = new List<SurfaceNode>(); private static readonly List<SurfaceNode> UpdateStack = new List<SurfaceNode>();
/// <summary> /// <summary>
@@ -868,7 +889,7 @@ namespace FlaxEditor.Surface
} }
/// <inheritdoc /> /// <inheritdoc />
protected override bool ShowTooltip => base.ShowTooltip && _headerRect.Contains(_mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened; protected override bool ShowTooltip => base.ShowTooltip && _headerRect.Contains(ref _mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
/// <inheritdoc /> /// <inheritdoc />
public override bool OnShowTooltip(out string text, out Float2 location, out Rectangle area) public override bool OnShowTooltip(out string text, out Float2 location, out Rectangle area)
@@ -898,13 +919,13 @@ namespace FlaxEditor.Surface
/// <inheritdoc /> /// <inheritdoc />
public override bool OnTestTooltipOverControl(ref Float2 location) public override bool OnTestTooltipOverControl(ref Float2 location)
{ {
return _headerRect.Contains(location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsSelecting; return _headerRect.Contains(ref location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsSelecting;
} }
/// <inheritdoc /> /// <inheritdoc />
public override bool CanSelect(ref Float2 location) public override bool CanSelect(ref Float2 location)
{ {
return _headerRect.MakeOffsetted(Location).Contains(location); return _headerRect.MakeOffsetted(Location).Contains(ref location);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -1056,7 +1077,7 @@ namespace FlaxEditor.Surface
// Header // Header
var headerColor = style.BackgroundHighlighted; var headerColor = style.BackgroundHighlighted;
if (_headerRect.Contains(_mousePosition) && !Surface.IsConnecting && !Surface.IsSelecting) if (_headerRect.Contains(ref _mousePosition) && !Surface.IsConnecting && !Surface.IsSelecting)
headerColor *= 1.07f; headerColor *= 1.07f;
Render2D.FillRectangle(_headerRect, headerColor); Render2D.FillRectangle(_headerRect, headerColor);
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center); Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
@@ -1099,7 +1120,7 @@ namespace FlaxEditor.Surface
if (base.OnMouseDown(location, button)) if (base.OnMouseDown(location, button))
return true; return true;
if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(location)) if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
return true; return true;
if (button == MouseButton.Right) if (button == MouseButton.Right)
mouseDownMousePosition = Input.Mouse.Position; mouseDownMousePosition = Input.Mouse.Position;
@@ -1115,7 +1136,7 @@ namespace FlaxEditor.Surface
// Close/ delete // Close/ delete
bool canDelete = !Surface.IsConnecting && !Surface.WasSelecting && !Surface.WasMovingSelection; bool canDelete = !Surface.IsConnecting && !Surface.WasSelecting && !Surface.WasMovingSelection;
if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(location)) if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
{ {
Surface.Delete(this); Surface.Delete(this);
return true; return true;

Some files were not shown because too many files have changed in this diff Show More