diff --git a/Content/Shaders/BakeLightmap.flax b/Content/Shaders/BakeLightmap.flax index 6e813205f..fac992469 100644 --- a/Content/Shaders/BakeLightmap.flax +++ b/Content/Shaders/BakeLightmap.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:17295767d488dc2b64a1794ceda8b4d68f20dd2c5f1a8fdbe6f7940a070f9724 +oid sha256:cc4b141137661d995ff571191150c5997fa6f6576572b5c2281c395a12772d7c size 16095 diff --git a/Content/Shaders/BitonicSort.flax b/Content/Shaders/BitonicSort.flax index c8a9e901c..d5964fca9 100644 --- a/Content/Shaders/BitonicSort.flax +++ b/Content/Shaders/BitonicSort.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c8371a1f4e0631e69f6dc6dbb8e11c8618351a7083293078270d60599f739e9f -size 6725 +oid sha256:df704c63770ee2b641f000726a3ec93c189685ffa149e484e961c9dba522baaf +size 6721 diff --git a/Source/Editor/Content/Import/ModelImportEntry.cs b/Source/Editor/Content/Import/ModelImportEntry.cs index e7cbe96ea..37525e6d3 100644 --- a/Source/Editor/Content/Import/ModelImportEntry.cs +++ b/Source/Editor/Content/Import/ModelImportEntry.cs @@ -262,9 +262,9 @@ namespace FlaxEditor.Content.Import public int BaseLOD { get; set; } = 0; /// - /// The amount of LODs to include in the model (all reaming ones starting from Base LOD will be generated). + /// The amount of LODs to include in the model (all remaining ones starting from Base LOD will be generated). /// - [EditorOrder(1120), DefaultValue(4), Limit(1, Model.MaxLODs), EditorDisplay("Level Of Detail", "LOD Count"), Tooltip("The amount of LODs to include in the model (all reaming ones starting from Base LOD will be generated).")] + [EditorOrder(1120), DefaultValue(4), Limit(1, Model.MaxLODs), EditorDisplay("Level Of Detail", "LOD Count"), Tooltip("The amount of LODs to include in the model (all remaining ones starting from Base LOD will be generated).")] public int LODCount { get; set; } = 4; /// diff --git a/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp b/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp index b687e5a2b..6a42450d5 100644 --- a/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp @@ -146,7 +146,7 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data) const auto c = packageName[i]; if (c != '_' && c != '.' && !StringUtils::IsAlnum(c)) { - LOG(Error, "Android Package Name \'{0}\' contains invalid chaarcter. Only letters, numbers, dots and underscore characters are allowed.", packageName); + LOG(Error, "Android Package Name \'{0}\' contains invalid character. Only letters, numbers, dots and underscore characters are allowed.", packageName); return true; } } diff --git a/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp b/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp index 7f7851941..c8f9e45a7 100644 --- a/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp @@ -28,7 +28,7 @@ bool UWPPlatformTools::OnScriptsStepDone(CookingData& data) const String assembliesPath = data.OutputPath; if (FileSystem::CopyFile(assembliesPath / TEXT("Newtonsoft.Json.dll"), customBinPath)) { - data.Error(TEXT("Failed to copy deloy custom assembly.")); + data.Error(TEXT("Failed to copy deploy custom assembly.")); return true; } FileSystem::DeleteFile(assembliesPath / TEXT("Newtonsoft.Json.pdb")); diff --git a/Source/Editor/Cooker/PlatformTools.h b/Source/Editor/Cooker/PlatformTools.h index 28f6346ca..c98c008bc 100644 --- a/Source/Editor/Cooker/PlatformTools.h +++ b/Source/Editor/Cooker/PlatformTools.h @@ -48,7 +48,7 @@ public: /// /// Gets the value indicating whenever platform requires AOT. /// - /// True if platform uses AOT and needs C# assemblies to be be precompiled, otherwise false. + /// True if platform uses AOT and needs C# assemblies to be precompiled, otherwise false. virtual bool UseAOT() const { return false; diff --git a/Source/Editor/Cooker/Steps/ValidateStep.cpp b/Source/Editor/Cooker/Steps/ValidateStep.cpp index 625957fae..915f7839d 100644 --- a/Source/Editor/Cooker/Steps/ValidateStep.cpp +++ b/Source/Editor/Cooker/Steps/ValidateStep.cpp @@ -65,7 +65,7 @@ bool ValidateStep::Perform(CookingData& data) AssetInfo info; if (!Content::GetAssetInfo(gameSettings->FirstScene, info)) { - data.Error(TEXT("Missing first scene.")); + data.Error(TEXT("Missing first scene. Set it in the game settings.")); return true; } } diff --git a/Source/Editor/Editor.h b/Source/Editor/Editor.h index 761e4b059..8c56043d9 100644 --- a/Source/Editor/Editor.h +++ b/Source/Editor/Editor.h @@ -43,7 +43,7 @@ public: public: /// - /// The flag used to determine if a project was used with the older engine version last time it was opened. Some cached data should be regenerated to prevent version difference issues. The version number comparision is based on major and minor part of the version. Build number is ignored. + /// The flag used to determine if a project was used with the older engine version last time it was opened. Some cached data should be regenerated to prevent version difference issues. The version number comparison is based on major and minor part of the version. Build number is ignored. /// static bool IsOldProjectOpened; diff --git a/Source/Editor/GUI/CurveEditor.cs b/Source/Editor/GUI/CurveEditor.cs index 3e37b591c..3819b5758 100644 --- a/Source/Editor/GUI/CurveEditor.cs +++ b/Source/Editor/GUI/CurveEditor.cs @@ -222,7 +222,7 @@ namespace FlaxEditor.GUI } /// - /// Filters teh given value using the the . + /// Filters the given value using the . /// /// The mode. /// The value to process. diff --git a/Source/Editor/GUI/Dialogs/Dialog.cs b/Source/Editor/GUI/Dialogs/Dialog.cs index b8897b2e1..173dd9128 100644 --- a/Source/Editor/GUI/Dialogs/Dialog.cs +++ b/Source/Editor/GUI/Dialogs/Dialog.cs @@ -186,7 +186,7 @@ namespace FlaxEditor.GUI.Dialogs // Clean up _window = null; - // Check if any thead is blocked during ShowDialog, then wait for it + // Check if any thread is blocked during ShowDialog, then wait for it bool wait = true; while (wait) { diff --git a/Source/Editor/GUI/Docking/MasterDockPanel.cs b/Source/Editor/GUI/Docking/MasterDockPanel.cs index f7acdbed4..a560de195 100644 --- a/Source/Editor/GUI/Docking/MasterDockPanel.cs +++ b/Source/Editor/GUI/Docking/MasterDockPanel.cs @@ -64,7 +64,7 @@ namespace FlaxEditor.GUI.Docking for (int i = 0; i < childPanels.Length; i++) childPanels[i].Dispose(); - // Delete reaming controls (except tabs proxy) + // Delete remaining controls (except tabs proxy) if (TabsProxy != null) TabsProxy.Parent = null; DisposeChildren(); diff --git a/Source/Editor/GUI/Input/SliderControl.cs b/Source/Editor/GUI/Input/SliderControl.cs index 90288cfd0..77e8a5da8 100644 --- a/Source/Editor/GUI/Input/SliderControl.cs +++ b/Source/Editor/GUI/Input/SliderControl.cs @@ -168,6 +168,7 @@ namespace FlaxEditor.GUI.Input { if (button == MouseButton.Left) { + Focus(); float mousePosition = location.X; if (_thumbRect.Contains(ref location)) @@ -208,7 +209,6 @@ namespace FlaxEditor.GUI.Input { if (button == MouseButton.Left && _isSliding) { - // End sliding EndSliding(); return true; } diff --git a/Source/Editor/GUI/Table.cs b/Source/Editor/GUI/Table.cs index e070cba17..cca26cadc 100644 --- a/Source/Editor/GUI/Table.cs +++ b/Source/Editor/GUI/Table.cs @@ -120,7 +120,7 @@ namespace FlaxEditor.GUI /// /// Draws the column. /// - /// The the header area rectangle. + /// The header area rectangle. /// The zero-based index of the column. protected virtual void DrawColumn(ref Rectangle rect, int columnIndex) { diff --git a/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs b/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs index 2e26b9045..25f6ffb0a 100644 --- a/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs +++ b/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs @@ -402,7 +402,7 @@ namespace FlaxEditor.GUI } /// - /// Converts the input point from editor editor contents control space into the keyframes time/value coordinates. + /// Converts the input point from editor contents control space into the keyframes time/value coordinates. /// /// The point. /// The keyframes contents area bounds. diff --git a/Source/Editor/GUI/Timeline/Tracks/MemberTrack.cs b/Source/Editor/GUI/Timeline/Tracks/MemberTrack.cs index 57de46ee4..250fb73c3 100644 --- a/Source/Editor/GUI/Timeline/Tracks/MemberTrack.cs +++ b/Source/Editor/GUI/Timeline/Tracks/MemberTrack.cs @@ -179,7 +179,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks } /// - /// Evaluates the member value value at the specified time. + /// Evaluates the member value at the specified time. /// /// The time to evaluate the member at. /// The member value at provided time. diff --git a/Source/Editor/Gizmo/GizmosCollection.cs b/Source/Editor/Gizmo/GizmosCollection.cs index a246aeeb0..5530a41a3 100644 --- a/Source/Editor/Gizmo/GizmosCollection.cs +++ b/Source/Editor/Gizmo/GizmosCollection.cs @@ -7,7 +7,7 @@ using FlaxEngine; namespace FlaxEditor.Gizmo { /// - /// Represents collection of Gizmo tools where one is active and in use. + /// Represents collection of gizmo tools where one is active and in use. /// /// [HideInEditor] diff --git a/Source/Editor/Gizmo/TransformGizmoBase.Draw.cs b/Source/Editor/Gizmo/TransformGizmoBase.Draw.cs index 8f871c635..0a11ecd77 100644 --- a/Source/Editor/Gizmo/TransformGizmoBase.Draw.cs +++ b/Source/Editor/Gizmo/TransformGizmoBase.Draw.cs @@ -45,7 +45,7 @@ namespace FlaxEditor.Gizmo ) { // Error - Platform.Fatal("Failed to load Transform Gizmo resources."); + Platform.Fatal("Failed to load transform gizmo resources."); } } diff --git a/Source/Editor/Gizmo/TransformGizmoBase.Settings.cs b/Source/Editor/Gizmo/TransformGizmoBase.Settings.cs index 786e001e6..2955fe6d7 100644 --- a/Source/Editor/Gizmo/TransformGizmoBase.Settings.cs +++ b/Source/Editor/Gizmo/TransformGizmoBase.Settings.cs @@ -104,7 +104,7 @@ namespace FlaxEditor.Gizmo public Axis ActiveAxis => _activeAxis; /// - /// Gets or sts the current gizmo mode. + /// Gets or sets the current gizmo mode. /// public Mode ActiveMode { diff --git a/Source/Editor/Gizmo/TransformGizmoBase.cs b/Source/Editor/Gizmo/TransformGizmoBase.cs index 87dcb6fa8..93dbeddaa 100644 --- a/Source/Editor/Gizmo/TransformGizmoBase.cs +++ b/Source/Editor/Gizmo/TransformGizmoBase.cs @@ -151,7 +151,7 @@ namespace FlaxEditor.Gizmo // Set positions of the gizmo UpdateGizmoPosition(); - // Scale Gizmo to fit on-screen + // Scale gizmo to fit on-screen Vector3 vLength = Owner.ViewPosition - Position; float gizmoSize = Editor.Instance.Options.Options.Visual.GizmoSize; _screenScale = vLength.Length / GizmoScaleFactor * gizmoSize; @@ -318,7 +318,7 @@ namespace FlaxEditor.Gizmo } else if (_activeMode == Mode.Scale) { - // Apply Scale + // Apply scale _scaleDelta = delta; } } diff --git a/Source/Editor/History/HistoryStack.cs b/Source/Editor/History/HistoryStack.cs index c7a63efc4..e2d828ce9 100644 --- a/Source/Editor/History/HistoryStack.cs +++ b/Source/Editor/History/HistoryStack.cs @@ -74,7 +74,7 @@ namespace FlaxEditor.History _reverseActions.PushBack(reverse[i]); } - // Cleanup reaming actions + // Cleanup remaining actions for (int i = _historyActionsLimit; i < history.Length; i++) { history[i].Dispose(); diff --git a/Source/Editor/Modules/ContentFindingModule.cs b/Source/Editor/Modules/ContentFindingModule.cs index 88b5832af..9be15e0d1 100644 --- a/Source/Editor/Modules/ContentFindingModule.cs +++ b/Source/Editor/Modules/ContentFindingModule.cs @@ -108,7 +108,7 @@ namespace FlaxEditor.Modules /// /// Removes a quick action by name. /// - /// Thr action's name. + /// The action's name. /// True when it succeed, false if there is no Quick Action with this name. public bool RemoveQuickAction(string name) { diff --git a/Source/Editor/Modules/ContentImportingModule.cs b/Source/Editor/Modules/ContentImportingModule.cs index 03f434b9c..0c934f130 100644 --- a/Source/Editor/Modules/ContentImportingModule.cs +++ b/Source/Editor/Modules/ContentImportingModule.cs @@ -410,7 +410,7 @@ namespace FlaxEditor.Modules { if (request.Settings != null && entry.TryOverrideSettings(request.Settings)) { - // Use overriden settings + // Use overridden settings } else if (!request.SkipSettingsDialog) { diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index 9b80b664c..a8058b9d8 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -276,8 +276,8 @@ namespace FlaxEditor.Modules // Get metadata int version = int.Parse(root.Attributes["Version"].Value, CultureInfo.InvariantCulture); var virtualDesktopBounds = Platform.VirtualDesktopBounds; - var virtualDesktopSafeLeftCorner = virtualDesktopBounds.Location + new Vector2(0, 23); // 23 is a window strip size - var virtualDesktopSafeRightCorner = virtualDesktopBounds.BottomRight - new Vector2(50, 50); // apply some safe area + var virtualDesktopSafeLeftCorner = virtualDesktopBounds.Location; + var virtualDesktopSafeRightCorner = virtualDesktopBounds.BottomRight; switch (version) { @@ -971,7 +971,7 @@ namespace FlaxEditor.Modules } #region Window Events - + private void OnEditorStateChanged() { for (int i = 0; i < Windows.Count; i++) diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index 7c0cd11da..3c501de85 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -41,7 +41,7 @@ namespace FlaxEditor.Options private readonly Dictionary _customSettings = new Dictionary(); /// - /// Gets the custom settings factories. Each entry defines the custom settings type identified by teh given key name. The value si a factory function that returns the default options fpr a given type. + /// Gets the custom settings factories. Each entry defines the custom settings type identified by the given key name. The value is a factory function that returns the default options for a given type. /// public IReadOnlyDictionary CustomSettings => _customSettings; diff --git a/Source/Editor/Progress/ProgressHandler.cs b/Source/Editor/Progress/ProgressHandler.cs index f008a5a03..c83258091 100644 --- a/Source/Editor/Progress/ProgressHandler.cs +++ b/Source/Editor/Progress/ProgressHandler.cs @@ -80,7 +80,7 @@ namespace FlaxEditor.Progress } /// - /// Called when progress action gets updated (changed nfo text or progress value). + /// Called when progress action gets updated (changed info text or progress value). /// /// The progress (normalized to range [0;1]). /// The information text. diff --git a/Source/Editor/ProjectInfo.cpp b/Source/Editor/ProjectInfo.cpp index 0f916241e..47782ab9d 100644 --- a/Source/Editor/ProjectInfo.cpp +++ b/Source/Editor/ProjectInfo.cpp @@ -204,7 +204,7 @@ bool ProjectInfo::LoadProject(const String& projectPath) reference.Project = Load(referencePath); if (reference.Project == nullptr) { - LOG(Error, "Faield to load referenced project ({0}, from {1})", reference.Name, referencePath); + LOG(Error, "Failed to load referenced project ({0}, from {1})", reference.Name, referencePath); return true; } } @@ -277,7 +277,7 @@ bool ProjectInfo::LoadOldProject(const String& projectPath) flaxReference.Project = Load(Globals::StartupFolder / TEXT("Flax.flaxproj")); if (!flaxReference.Project) { - ShowProjectLoadError(TEXT("Failed to load Flax Engien project."), projectPath); + ShowProjectLoadError(TEXT("Failed to load Flax Engine project."), projectPath); return true; } diff --git a/Source/Editor/Scripting/CodeEditors/VisualStudio/VisualStudioConnection.cpp b/Source/Editor/Scripting/CodeEditors/VisualStudio/VisualStudioConnection.cpp index d73c5279a..54ba119f2 100644 --- a/Source/Editor/Scripting/CodeEditors/VisualStudio/VisualStudioConnection.cpp +++ b/Source/Editor/Scripting/CodeEditors/VisualStudio/VisualStudioConnection.cpp @@ -49,7 +49,7 @@ public: { if (dwRejectType == SERVERCALL_RETRYLATER) { - // Retry immediatey + // Retry immediately return 99; } diff --git a/Source/Editor/Scripting/ScriptsBuilder.cpp b/Source/Editor/Scripting/ScriptsBuilder.cpp index 7d581fa8a..7cced3e36 100644 --- a/Source/Editor/Scripting/ScriptsBuilder.cpp +++ b/Source/Editor/Scripting/ScriptsBuilder.cpp @@ -567,7 +567,7 @@ bool ScriptsBuilderService::Init() LOG(Warning, "Missing EditorTarget property in opened project, using deducted target name {0}", Editor::Project->EditorTarget); } - // Remove any reaming files from previous Editor run hot-reloads + // Remove any remaining files from previous Editor run hot-reloads const Char *target, *platform, *architecture, *configuration; ScriptsBuilder::GetBinariesConfiguration(target, platform, architecture, configuration); if (target) diff --git a/Source/Editor/Surface/AnimGraphSurface.cs b/Source/Editor/Surface/AnimGraphSurface.cs index 8621ed257..abffc4432 100644 --- a/Source/Editor/Surface/AnimGraphSurface.cs +++ b/Source/Editor/Surface/AnimGraphSurface.cs @@ -65,8 +65,8 @@ namespace FlaxEditor.Surface NodeElementArchetype.Factory.Output(0, "Length", typeof(float), 0), NodeElementArchetype.Factory.Output(1, "Time", typeof(float), 1), NodeElementArchetype.Factory.Output(2, "Normalized Time", typeof(float), 2), - NodeElementArchetype.Factory.Output(3, "Reaming Time", typeof(float), 3), - NodeElementArchetype.Factory.Output(4, "Reaming Normalized Time", typeof(float), 4), + NodeElementArchetype.Factory.Output(3, "Remaining Time", typeof(float), 3), + NodeElementArchetype.Factory.Output(4, "Remaining Normalized Time", typeof(float), 4), } }, } diff --git a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs index 9f9e21f4f..2faa9feef 100644 --- a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs +++ b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs @@ -1046,7 +1046,7 @@ namespace FlaxEditor.Surface.Archetypes startPos += nrm; endPos += nrm; - // Swap fo the other arrow + // Swap to the other arrow if (!diff) { var tmp = startPos; diff --git a/Source/Editor/Surface/Archetypes/Animation.cs b/Source/Editor/Surface/Archetypes/Animation.cs index b27fb9bd6..2ec196e13 100644 --- a/Source/Editor/Surface/Archetypes/Animation.cs +++ b/Source/Editor/Surface/Archetypes/Animation.cs @@ -764,8 +764,8 @@ namespace FlaxEditor.Surface.Archetypes NodeElementArchetype.Factory.Output(0, "Length", typeof(float), 0), NodeElementArchetype.Factory.Output(1, "Time", typeof(float), 1), NodeElementArchetype.Factory.Output(2, "Normalized Time", typeof(float), 2), - NodeElementArchetype.Factory.Output(3, "Reaming Time", typeof(float), 3), - NodeElementArchetype.Factory.Output(4, "Reaming Normalized Time", typeof(float), 4), + NodeElementArchetype.Factory.Output(3, "Remaining Time", typeof(float), 3), + NodeElementArchetype.Factory.Output(4, "Remaining Normalized Time", typeof(float), 4), } }, new NodeArchetype diff --git a/Source/Editor/Surface/Archetypes/Function.cs b/Source/Editor/Surface/Archetypes/Function.cs index 340d234ab..80b3d07b9 100644 --- a/Source/Editor/Surface/Archetypes/Function.cs +++ b/Source/Editor/Surface/Archetypes/Function.cs @@ -1177,7 +1177,7 @@ namespace FlaxEditor.Surface.Archetypes [EditorOrder(0), Tooltip("The name of the parameter."), ExpandGroups] public string Name; - [EditorOrder(1), Tooltip("The type fo the parameter value.")] + [EditorOrder(1), Tooltip("The type for the parameter value.")] [TypeReference(typeof(object), nameof(IsTypeValid))] public ScriptType Type; @@ -1564,7 +1564,7 @@ namespace FlaxEditor.Surface.Archetypes // Check if return type has been changed if (_signature.ReturnType != prevReturnType) { - // Update all return nodes used by this function to match teh new type + // Update all return nodes used by this function to match the new type var usedNodes = DepthFirstTraversal(false); var hasAnyReturnNode = false; foreach (var node in usedNodes) diff --git a/Source/Editor/Surface/Archetypes/Parameters.cs b/Source/Editor/Surface/Archetypes/Parameters.cs index 43048d19d..5332b3475 100644 --- a/Source/Editor/Surface/Archetypes/Parameters.cs +++ b/Source/Editor/Surface/Archetypes/Parameters.cs @@ -32,7 +32,7 @@ namespace FlaxEditor.Surface.Archetypes public Dictionary Prototypes = DefaultPrototypes; /// - /// The default prototypes for thr node elements to use for the given parameter type. + /// The default prototypes for the node elements to use for the given parameter type. /// public static readonly Dictionary DefaultPrototypes = new Dictionary { diff --git a/Source/Editor/Surface/VisjectSurface.DragDrop.cs b/Source/Editor/Surface/VisjectSurface.DragDrop.cs index 323ef8510..422198f5b 100644 --- a/Source/Editor/Surface/VisjectSurface.DragDrop.cs +++ b/Source/Editor/Surface/VisjectSurface.DragDrop.cs @@ -107,7 +107,7 @@ namespace FlaxEditor.Surface /// Validates the parameter drag operation. /// /// Name of the parameter. - /// Tre if can drag that parameter, otherwise false. + /// True if can drag that parameter, otherwise false. protected virtual bool ValidateDragParameter(string parameterName) { return GetParameter(parameterName) != null; diff --git a/Source/Editor/Surface/VisualScriptSurface.cs b/Source/Editor/Surface/VisualScriptSurface.cs index 335860c52..b919c7c37 100644 --- a/Source/Editor/Surface/VisualScriptSurface.cs +++ b/Source/Editor/Surface/VisualScriptSurface.cs @@ -76,7 +76,7 @@ namespace FlaxEditor.Surface // Check if has cached groups if (_cache.Count != 0) { - // Check if context menu doesn;t have the recent cached groups + // Check if context menu doesn't have the recent cached groups if (!contextMenu.Groups.Any(g => g.Archetype.Tag is int asInt && asInt == _version)) { var groups = contextMenu.Groups.Where(g => g.Archetype.Tag is int).ToArray(); diff --git a/Source/Editor/Tools/Foliage/FoliageTab.cs b/Source/Editor/Tools/Foliage/FoliageTab.cs index 9dbb17e88..fe4120035 100644 --- a/Source/Editor/Tools/Foliage/FoliageTab.cs +++ b/Source/Editor/Tools/Foliage/FoliageTab.cs @@ -21,6 +21,7 @@ namespace FlaxEditor.Tools.Foliage private readonly Tabs _modes; private readonly ContainerControl _noFoliagePanel; private int _selectedFoliageTypeIndex = -1; + private Button _createNewFoliage; /// /// The editor instance. @@ -99,6 +100,7 @@ namespace FlaxEditor.Tools.Foliage public FoliageTab(SpriteHandle icon, Editor editor) : base(string.Empty, icon) { + Level.SceneLoaded += OnSceneLoaded; Editor = editor; Editor.SceneEditing.SelectionChanged += OnSelectionChanged; @@ -135,14 +137,31 @@ namespace FlaxEditor.Tools.Foliage Offsets = Margin.Zero, Parent = _noFoliagePanel }; - var noFoliageButton = new Button + _createNewFoliage = new Button { Text = "Create new foliage", AnchorPreset = AnchorPresets.MiddleCenter, Offsets = new Margin(-60, 120, -12, 24), Parent = _noFoliagePanel, + Enabled = false }; - noFoliageButton.Clicked += OnCreateNewFoliageClicked; + _createNewFoliage.Clicked += OnCreateNewFoliageClicked; + } + + private void OnSceneLoaded(Scene arg1, Guid arg2) + { + _createNewFoliage.Enabled = true; + + Level.SceneUnloaded += OnSceneUnloaded; + Level.SceneLoaded -= OnSceneLoaded; + } + + private void OnSceneUnloaded(Scene arg1, Guid arg2) + { + _createNewFoliage.Enabled = false; + + Level.SceneLoaded += OnSceneLoaded; + Level.SceneUnloaded -= OnSceneUnloaded; } private void OnSelected(Tab tab) @@ -248,5 +267,16 @@ namespace FlaxEditor.Tools.Foliage { SelectedFoliageTypesChanged?.Invoke(); } + + /// + public override void OnDestroy() + { + if (_createNewFoliage.Enabled) + Level.SceneUnloaded -= OnSceneUnloaded; + else + Level.SceneLoaded -= OnSceneLoaded; + + base.OnDestroy(); + } } } diff --git a/Source/Editor/Tools/Terrain/CarveTab.cs b/Source/Editor/Tools/Terrain/CarveTab.cs index a3a65c52a..e7b880414 100644 --- a/Source/Editor/Tools/Terrain/CarveTab.cs +++ b/Source/Editor/Tools/Terrain/CarveTab.cs @@ -18,6 +18,7 @@ namespace FlaxEditor.Tools.Terrain { private readonly Tabs _modes; private readonly ContainerControl _noTerrainPanel; + private readonly Button _createTerrainButton; /// /// The editor instance. @@ -57,6 +58,7 @@ namespace FlaxEditor.Tools.Terrain public CarveTab(SpriteHandle icon, Editor editor) : base(string.Empty, icon) { + Level.SceneLoaded += OnSceneLoaded; Editor = editor; Editor.SceneEditing.SelectionChanged += OnSelectionChanged; @@ -93,14 +95,31 @@ namespace FlaxEditor.Tools.Terrain Offsets = Margin.Zero, Parent = _noTerrainPanel }; - var noTerrainButton = new Button + _createTerrainButton = new Button { Text = "Create new terrain", AnchorPreset = AnchorPresets.MiddleCenter, Offsets = new Margin(-60, 120, -12, 24), - Parent = _noTerrainPanel + Parent = _noTerrainPanel, + Enabled = false }; - noTerrainButton.Clicked += OnCreateNewTerrainClicked; + _createTerrainButton.Clicked += OnCreateNewTerrainClicked; + } + + private void OnSceneLoaded(Scene arg1, Guid arg2) + { + _createTerrainButton.Enabled = true; + + Level.SceneUnloaded += OnSceneUnloaded; + Level.SceneLoaded -= OnSceneLoaded; + } + + private void OnSceneUnloaded(Scene arg1, Guid arg2) + { + _createTerrainButton.Enabled = false; + + Level.SceneLoaded += OnSceneLoaded; + Level.SceneUnloaded -= OnSceneUnloaded; } private void OnSelected(Tab tab) @@ -183,5 +202,16 @@ namespace FlaxEditor.Tools.Terrain default: throw new IndexOutOfRangeException("Invalid carve tab mode."); } } + + /// + public override void OnDestroy() + { + if (_createTerrainButton.Enabled) + Level.SceneUnloaded -= OnSceneUnloaded; + else + Level.SceneLoaded -= OnSceneLoaded; + + base.OnDestroy(); + } } } diff --git a/Source/Editor/Tools/Terrain/Paint/Mode.cs b/Source/Editor/Tools/Terrain/Paint/Mode.cs index 1a1373d05..e53071aa3 100644 --- a/Source/Editor/Tools/Terrain/Paint/Mode.cs +++ b/Source/Editor/Tools/Terrain/Paint/Mode.cs @@ -33,7 +33,7 @@ namespace FlaxEditor.Tools.Terrain.Paint } /// - /// The tool strength (normalized to range 0-1). Defines the intensity of the paint operation to make it stronger or mre subtle. + /// The tool strength (normalized to range 0-1). Defines the intensity of the paint operation to make it stronger or more subtle. /// [EditorOrder(0), Limit(0, 10, 0.01f), Tooltip("The tool strength (normalized to range 0-1). Defines the intensity of the paint operation to make it stronger or more subtle.")] public float Strength = 1.0f; diff --git a/Source/Editor/Tools/Terrain/Sculpt/Mode.cs b/Source/Editor/Tools/Terrain/Sculpt/Mode.cs index 14fbe0175..eb32b3934 100644 --- a/Source/Editor/Tools/Terrain/Sculpt/Mode.cs +++ b/Source/Editor/Tools/Terrain/Sculpt/Mode.cs @@ -33,7 +33,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt } /// - /// The tool strength (normalized to range 0-1). Defines the intensity of the sculpt operation to make it stronger or mre subtle. + /// The tool strength (normalized to range 0-1). Defines the intensity of the sculpt operation to make it stronger or more subtle. /// [EditorOrder(0), Limit(0, 6, 0.01f), Tooltip("The tool strength (normalized to range 0-1). Defines the intensity of the sculpt operation to make it stronger or more subtle.")] public float Strength = 1.2f; diff --git a/Source/Editor/Tools/Terrain/TerrainTools.cpp b/Source/Editor/Tools/Terrain/TerrainTools.cpp index 6bf4f8fd4..e89b5e3e9 100644 --- a/Source/Editor/Tools/Terrain/TerrainTools.cpp +++ b/Source/Editor/Tools/Terrain/TerrainTools.cpp @@ -2,7 +2,7 @@ #include "TerrainTools.h" #include "Engine/Core/Cache.h" -#include "Engine/Core/Math/VectorInt.h" +#include "Engine/Core/Math/Int2.h" #include "Engine/Core/Math/Color32.h" #include "Engine/Core/Collections/CollectionPoolCache.h" #include "Engine/Terrain/TerrainPatch.h" diff --git a/Source/Editor/Tools/VertexPainting.cs b/Source/Editor/Tools/VertexPainting.cs index c130370e7..29d9daedc 100644 --- a/Source/Editor/Tools/VertexPainting.cs +++ b/Source/Editor/Tools/VertexPainting.cs @@ -49,7 +49,7 @@ namespace FlaxEditor.Tools set => Tab._gizmoMode.BrushStrength = value; } - [EditorOrder(20), EditorDisplay("Brush"), Limit(0.0f, 1.0f, 0.01f), Tooltip("The falloff parameter fo the brush. Adjusts the paint strength for the vertices that are far from the brush center. Use lower values to make painting smoother and softer.")] + [EditorOrder(20), EditorDisplay("Brush"), Limit(0.0f, 1.0f, 0.01f), Tooltip("The falloff parameter for the brush. Adjusts the paint strength for the vertices that are far from the brush center. Use lower values to make painting smoother and softer.")] public float BrushFalloff { get => Tab._gizmoMode.BrushFalloff; diff --git a/Source/Editor/Utilities/EditorUtilities.cpp b/Source/Editor/Utilities/EditorUtilities.cpp index 541c8892a..451fc09a0 100644 --- a/Source/Editor/Utilities/EditorUtilities.cpp +++ b/Source/Editor/Utilities/EditorUtilities.cpp @@ -6,10 +6,8 @@ #include "Engine/Core/Log.h" #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Graphics/PixelFormatExtensions.h" -#include "Engine/Serialization/FileReadStream.h" #include "Engine/Tools/TextureTool/TextureTool.h" #include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/VectorInt.h" #include "Engine/Core/Config/GameSettings.h" #include "Engine/Content/Content.h" #include "Engine/Content/AssetReference.h" @@ -247,7 +245,7 @@ void UpdateIconData(uint8* iconData, const TextureData* icon) iconTexSize = Math::RoundUpToPowerOf2(width); } - // Try to pick a proper mip (requrie the same size) + // Try to pick a proper mip (require the same size) const TextureMipData* srcPixels = nullptr; int32 mipLevels = icon->GetMipLevels(); for (int32 mipIndex = 0; mipIndex < mipLevels; mipIndex++) diff --git a/Source/Editor/Utilities/ObjectSnapshot.cs b/Source/Editor/Utilities/ObjectSnapshot.cs index a64ddf306..8f29d1145 100644 --- a/Source/Editor/Utilities/ObjectSnapshot.cs +++ b/Source/Editor/Utilities/ObjectSnapshot.cs @@ -251,7 +251,7 @@ namespace FlaxEditor.Utilities var list = new List(); #if DEBUG_OBJECT_SNAPSHOT_COMPARISION - Debug.Logger.LogHandler.LogWrite(LogType.Warning, "-------------- Comparision --------------"); + Debug.Logger.LogHandler.LogWrite(LogType.Warning, "-------------- Comparison --------------"); #endif for (int i = _members.Count - 1; i >= 0; i--) { diff --git a/Source/Editor/Utilities/ShuntingYardParser.cs b/Source/Editor/Utilities/ShuntingYardParser.cs index dfd83b1f8..100c5c3d7 100644 --- a/Source/Editor/Utilities/ShuntingYardParser.cs +++ b/Source/Editor/Utilities/ShuntingYardParser.cs @@ -126,7 +126,7 @@ namespace FlaxEditor.Utilities /// /// The first operator. /// The second operator. - /// The comparision result. + /// The comparison result. private static bool CompareOperators(string oper1, string oper2) { var op1 = Operators[oper1]; diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index cd9935da3..9a5a3079a 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -743,6 +743,7 @@ namespace FlaxEditor.Utilities case VariantType.Array: return new ScriptType(typeof(object[])); case VariantType.Dictionary: return new ScriptType(typeof(Dictionary)); case VariantType.ManagedObject: return new ScriptType(typeof(object)); + case VariantType.Blob: return new ScriptType(typeof(byte[])); default: throw new ArgumentOutOfRangeException($"Unknown Variant Type {variantType} without typename."); } } @@ -806,6 +807,7 @@ namespace FlaxEditor.Utilities case VariantType.Array: return typeof(object[]); case VariantType.Dictionary: return typeof(Dictionary); case VariantType.ManagedObject: return typeof(object); + case VariantType.Blob: return typeof(byte[]); default: throw new ArgumentOutOfRangeException($"Unknown Variant Type {variantType} without typename."); } } diff --git a/Source/Editor/Viewport/Cameras/FPSCamera.cs b/Source/Editor/Viewport/Cameras/FPSCamera.cs index c9e65d6e4..8ed219449 100644 --- a/Source/Editor/Viewport/Cameras/FPSCamera.cs +++ b/Source/Editor/Viewport/Cameras/FPSCamera.cs @@ -24,7 +24,7 @@ namespace FlaxEditor.Viewport.Cameras public bool IsAnimatingMove => _moveStartTime > Mathf.Epsilon; /// - /// The target point location. It's used to orbit around it whe user clicks Alt+LMB. + /// The target point location. It's used to orbit around it when user clicks Alt+LMB. /// public Vector3 TargetPoint = new Vector3(-200); diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index 02696f743..0b810e891 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -528,6 +528,18 @@ namespace FlaxEditor.Viewport ViewWidgetButtonMenu.VisibleChanged += control => orthoValue.Checked = _isOrtho; } + // Cara Orientation + { + var cameraView = ViewWidgetButtonMenu.AddChildMenu("Orientation").ContextMenu; + for (int i = 0; i < EditorViewportCameraOrientationValues.Length; i++) + { + var co = EditorViewportCameraOrientationValues[i]; + var button = cameraView.AddButton(co.Name); + button.Tag = co.Orientation; + } + cameraView.ButtonClicked += button => ViewOrientation = Quaternion.Euler((Vector3)button.Tag); + } + // Field of View { var fov = ViewWidgetButtonMenu.AddButton("Field Of View"); @@ -1193,6 +1205,28 @@ namespace FlaxEditor.Viewport base.OnDestroy(); } + private struct CameraOrientation + { + public readonly string Name; + public readonly Vector3 Orientation; + + public CameraOrientation(string name, Vector3 orientation) + { + Name = name; + Orientation = orientation; + } + } + + private readonly CameraOrientation[] EditorViewportCameraOrientationValues = + { + new CameraOrientation("Front", new Vector3(0, 0, 0)), + new CameraOrientation("Back", new Vector3(0, 180, 0)), + new CameraOrientation("Left", new Vector3(0, 90, 0)), + new CameraOrientation("Right", new Vector3(0, -90, 0)), + new CameraOrientation("Top", new Vector3(-90, 0, 0)), + new CameraOrientation("Bottom", new Vector3(90, 0, 0)) + }; + private readonly float[] EditorViewportCameraSpeedValues = { 0.1f, diff --git a/Source/Editor/Windows/AboutDialog.cs b/Source/Editor/Windows/AboutDialog.cs index 03e60f43c..bb320fb87 100644 --- a/Source/Editor/Windows/AboutDialog.cs +++ b/Source/Editor/Windows/AboutDialog.cs @@ -115,7 +115,7 @@ namespace FlaxEditor.Windows { var thirdPartyPanel = new Panel(ScrollBars.Vertical) { - Bounds = new Rectangle(0, topParentControl.Bottom + 4, Width, Height - topParentControl.Bottom - 24), + Bounds = new Rectangle(4, topParentControl.Bottom + 4, Width - 8, Height - topParentControl.Bottom - 24), Parent = this }; var thirdPartyEntries = new[] diff --git a/Source/Editor/Windows/Assets/AssetEditorWindow.cs b/Source/Editor/Windows/Assets/AssetEditorWindow.cs index 756adbe05..92c697b88 100644 --- a/Source/Editor/Windows/Assets/AssetEditorWindow.cs +++ b/Source/Editor/Windows/Assets/AssetEditorWindow.cs @@ -288,7 +288,7 @@ namespace FlaxEditor.Windows.Assets public abstract class AssetEditorWindowBase : AssetEditorWindow where T : Asset { /// - /// Flag set to true if window is is waiting for asset to be loaded (to send or events). + /// Flag set to true if window is waiting for asset to be loaded (to send or events). /// protected bool _isWaitingForLoaded; diff --git a/Source/Editor/Windows/Assets/SceneAnimationWindow.cs b/Source/Editor/Windows/Assets/SceneAnimationWindow.cs index cbed724bc..95421585d 100644 --- a/Source/Editor/Windows/Assets/SceneAnimationWindow.cs +++ b/Source/Editor/Windows/Assets/SceneAnimationWindow.cs @@ -490,7 +490,7 @@ namespace FlaxEditor.Windows.Assets } if (_player.IsStopped || _player.Time >= _options.EndTime) { - // End rendering but perform reaming copies of the staging textures so all data is captured (from GPU to CPU) + // End rendering but perform remaining copies of the staging textures so all data is captured (from GPU to CPU) _state = States.Staging; break; } diff --git a/Source/Editor/Windows/GameWindow.cs b/Source/Editor/Windows/GameWindow.cs index a29869825..35bc91bbe 100644 --- a/Source/Editor/Windows/GameWindow.cs +++ b/Source/Editor/Windows/GameWindow.cs @@ -222,7 +222,7 @@ namespace FlaxEditor.Windows private void PlayingStateOnSceneDuplicating() { - // Remove reaming GUI controls so loaded scene can add own GUI + // Remove remaining GUI controls so loaded scene can add own GUI //_guiRoot.DisposeChildren(); // Show GUI @@ -231,7 +231,7 @@ namespace FlaxEditor.Windows private void PlayingStateOnSceneRestored() { - // Remove reaming GUI controls so loaded scene can add own GUI + // Remove remaining GUI controls so loaded scene can add own GUI //_guiRoot.DisposeChildren(); // Hide GUI diff --git a/Source/Editor/Windows/SplashScreen.cpp b/Source/Editor/Windows/SplashScreen.cpp index 98578950f..b05c73761 100644 --- a/Source/Editor/Windows/SplashScreen.cpp +++ b/Source/Editor/Windows/SplashScreen.cpp @@ -110,6 +110,11 @@ const Char* SplashScreenQuotes[] = TEXT("You have my bow.\nAnd my axe!"), TEXT("To the bridge of Khazad-dum."), TEXT("One ring to rule them all.\nOne ring to find them."), + TEXT("Ladies and gentelman, we got him"), + TEXT("Cyberpunk of game engines"), + TEXT("That's what she said"), + TEXT("Compiling Shaders (93,788)"), + TEXT("Hi There"), }; SplashScreen::~SplashScreen() diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index 8f43506d2..1a26318a1 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -1489,11 +1489,11 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu case 2: value = transitionsData.Position / transitionsData.Length; break; - // Reaming Time + // Remaining Time case 3: value = transitionsData.Length - transitionsData.Position; break; - // Reaming Normalized Time + // Remaining Normalized Time case 4: value = 1.0f - (transitionsData.Position / transitionsData.Length); break; diff --git a/Source/Engine/Audio/AudioSource.h b/Source/Engine/Audio/AudioSource.h index ac15b5a4b..2b5b7e9d8 100644 --- a/Source/Engine/Audio/AudioSource.h +++ b/Source/Engine/Audio/AudioSource.h @@ -199,7 +199,7 @@ public: /// Gets the current state of the audio playback (playing/paused/stopped). /// /// The value. - API_PROPERTY() FORCE_INLINE States GetState() const + API_PROPERTY() FORCE_INLINE AudioSource::States GetState() const { return _state; } diff --git a/Source/Engine/CSG/CSGMesh.Triangulate.cpp b/Source/Engine/CSG/CSGMesh.Triangulate.cpp index bb814653b..8a64f4042 100644 --- a/Source/Engine/CSG/CSGMesh.Triangulate.cpp +++ b/Source/Engine/CSG/CSGMesh.Triangulate.cpp @@ -22,7 +22,7 @@ bool CSG::Mesh::Triangulate(RawData& data, Array& cacheVB) const Array surfaceCacheVB(32); // Cache submeshes by material to lay them down - // key- brush index, value- direcotry for surafecs (key: surface index, value: list with start vertex per triangle) + // key- brush index, value- direcotry for surfaces (key: surface index, value: list with start vertex per triangle) Dictionary>> polygonsPerBrush(64); // Build index buffer @@ -115,8 +115,8 @@ bool CSG::Mesh::Triangulate(RawData& data, Array& cacheVB) const tangent.Normalize(); // Gram-Schmidt orthogonalize - Vector3 newTangentUnormalized = tangent - normal * Vector3::Dot(normal, tangent); - const float length = newTangentUnormalized.Length(); + Vector3 newTangentUnnormalized = tangent - normal * Vector3::Dot(normal, tangent); + const float length = newTangentUnnormalized.Length(); // Workaround to handle degenerated case if (Math::IsZero(length)) @@ -129,7 +129,7 @@ bool CSG::Mesh::Triangulate(RawData& data, Array& cacheVB) const } else { - tangent = newTangentUnormalized / length; + tangent = newTangentUnnormalized / length; bitangent.Normalize(); } @@ -217,12 +217,12 @@ bool CSG::Mesh::Triangulate(RawData& data, Array& cacheVB) const auto& vertex = cacheVB[triangleStartVertex + k]; Vector3 projected = Vector3::Project(vertex.Position, 0, 0, 1000, 1000, 0, 1, vp); - Vector2 projectecXY = Vector2(projected); + Vector2 projectedXY = Vector2(projected); - min = Vector2::Min(projectecXY, min); - max = Vector2::Max(projectecXY, max); + min = Vector2::Min(projectedXY, min); + max = Vector2::Max(projectedXY, max); - pointsCache.Add(projectecXY); + pointsCache.Add(projectedXY); } } diff --git a/Source/Engine/CSG/CSGMesh.cpp b/Source/Engine/CSG/CSGMesh.cpp index cc4897d3a..9a885a35d 100644 --- a/Source/Engine/CSG/CSGMesh.cpp +++ b/Source/Engine/CSG/CSGMesh.cpp @@ -38,7 +38,7 @@ void CSG::Mesh::PerformOperation(Mesh* other) { case Mode::Additive: { - // Check if both meshes do not intesect + // Check if both meshes do not intersect if (AABB::IsOutside(_bounds, other->GetBounds())) // TODO: test every sub bounds not whole _bounds { // Add vertices to the mesh without any additional calculations @@ -57,7 +57,7 @@ void CSG::Mesh::PerformOperation(Mesh* other) case Mode::Subtractive: { - // Check if both meshes do not intesect + // Check if both meshes do not intersect if (AABB::IsOutside(_bounds, other->GetBounds())) // TODO: test every sub bounds not whole _bounds { // Do nothing @@ -141,7 +141,7 @@ void CSG::Mesh::intersect(const Mesh* other, PolygonOperation insideOp, PolygonO // insideOp - operation for polygons being inside the other brush // outsideOp - operation for polygons being outside the other brush - // Prevent from redudant action + // Prevent from redundant action if (insideOp == Keep && outsideOp == Keep) return; @@ -180,7 +180,7 @@ void CSG::Mesh::intersectSubMesh(const Mesh* other, int32 subMeshIndex, PolygonO int32 startBrushSurface = brushMeta.StartSurfaceIndex; int32 endBrushSurface = startBrushSurface + brushMeta.SurfacesCount; - // Check every polygon (itereate fron end since we can ass new polygons and we don't want to process them) + // Check every polygon (iterate from end since we can ass new polygons and we don't want to process them) for (int32 i = _polygons.Count() - 1; i >= 0; i--) { auto& polygon = _polygons[i]; diff --git a/Source/Engine/Content/Assets/ModelBase.h b/Source/Engine/Content/Assets/ModelBase.h index ebf05570d..89805f3c0 100644 --- a/Source/Engine/Content/Assets/ModelBase.h +++ b/Source/Engine/Content/Assets/ModelBase.h @@ -53,7 +53,7 @@ public: ScopeLock lock(Locker); const int32 prevCount = MaterialSlots.Count(); - MaterialSlots.Resize(slotsCount); + MaterialSlots.Resize(slotsCount, false); // Initialize slot names for (int32 i = prevCount; i < slotsCount; i++) diff --git a/Source/Engine/Content/Loading/ContentLoadingManager.cpp b/Source/Engine/Content/Loading/ContentLoadingManager.cpp index ac2dd8257..6e6ff7a65 100644 --- a/Source/Engine/Content/Loading/ContentLoadingManager.cpp +++ b/Source/Engine/Content/Loading/ContentLoadingManager.cpp @@ -208,7 +208,7 @@ void ContentLoadingManagerService::Dispose() MainThread = nullptr; ThisThread = nullptr; - // Cancel all reaming tasks (no chance to execute them) + // Cancel all remaining tasks (no chance to execute them) Tasks.CancelAll(); } diff --git a/Source/Engine/Content/Utilities/IESLoader.cpp b/Source/Engine/Content/Utilities/IESLoader.cpp index 0ef7c320a..271ab3d5e 100644 --- a/Source/Engine/Content/Utilities/IESLoader.cpp +++ b/Source/Engine/Content/Utilities/IESLoader.cpp @@ -240,7 +240,7 @@ float IESLoader::ExtractInR16(Array& output) float result = 0.0f; for (uint32 i = 0; i < hAnglesCount; i++) result += InterpolateBilinear(static_cast(i), v); - *out++ = ConvertFloatToHalf(invMaxValue * result / (float)hAnglesCount); + *out++ = Float16Compressor::Compress(invMaxValue * result / (float)hAnglesCount); } } diff --git a/Source/Engine/ContentExporters/ExportModel.cpp b/Source/Engine/ContentExporters/ExportModel.cpp index efc13419b..7fdd011f9 100644 --- a/Source/Engine/ContentExporters/ExportModel.cpp +++ b/Source/Engine/ContentExporters/ExportModel.cpp @@ -76,7 +76,7 @@ ExportAssetResult AssetExporters::ExportModel(ExportAssetContext& context) for (uint32 i = 0; i < vertices; i++) { auto v = vb1[i].TexCoord; - output->WriteTextFormatted("vt {0} {1}\n", ConvertHalfToFloat(v.X), ConvertHalfToFloat(v.Y)); + output->WriteTextFormatted("vt {0} {1}\n", Float16Compressor::Decompress(v.X), Float16Compressor::Decompress(v.Y)); } output->WriteChar('\n'); @@ -181,7 +181,7 @@ ExportAssetResult AssetExporters::ExportSkinnedModel(ExportAssetContext& context for (uint32 i = 0; i < vertices; i++) { auto v = vb0[i].TexCoord; - output->WriteTextFormatted("vt {0} {1}\n", ConvertHalfToFloat(v.X), ConvertHalfToFloat(v.Y)); + output->WriteTextFormatted("vt {0} {1}\n", Float16Compressor::Decompress(v.X), Float16Compressor::Decompress(v.Y)); } output->WriteChar('\n'); diff --git a/Source/Engine/Core/Log.cpp b/Source/Engine/Core/Log.cpp index 2213672c9..cb73a79e1 100644 --- a/Source/Engine/Core/Log.cpp +++ b/Source/Engine/Core/Log.cpp @@ -51,18 +51,18 @@ bool Log::Logger::Init() { // Check if there are any files to delete const int32 maxLogFiles = 20; - int32 reaming = oldLogs.Count() - maxLogFiles + 1; - if (reaming > 0) + int32 remaining = oldLogs.Count() - maxLogFiles + 1; + if (remaining > 0) { Sorting::QuickSort(oldLogs.Get(), oldLogs.Count()); // Delete the oldest logs int32 i = 0; - while (reaming > 0) + while (remaining > 0) { FileSystem::DeleteFile(oldLogs[i++]); filesDeleted++; - reaming--; + remaining--; } } } diff --git a/Source/Engine/Core/Math/AABB.h b/Source/Engine/Core/Math/AABB.h index 39e8a5bf6..5853d6597 100644 --- a/Source/Engine/Core/Math/AABB.h +++ b/Source/Engine/Core/Math/AABB.h @@ -8,7 +8,7 @@ /// /// Integer axis aligned bounding box /// -struct AABB +struct FLAXENGINE_API AABB { public: diff --git a/Source/Engine/Core/Math/BoundingFrustum.h b/Source/Engine/Core/Math/BoundingFrustum.h index b8b16c412..9052521fc 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.h +++ b/Source/Engine/Core/Math/BoundingFrustum.h @@ -10,7 +10,7 @@ /// /// Defines a frustum which can be used in frustum culling, zoom to Extents (zoom to fit) operations, (matrix, frustum, camera) interchange, and many kind of intersection testing. /// -API_STRUCT(InBuild) struct BoundingFrustum +API_STRUCT(InBuild) struct FLAXENGINE_API BoundingFrustum { private: diff --git a/Source/Engine/Core/Math/Color.cs b/Source/Engine/Core/Math/Color.cs index a98f35126..96376092e 100644 --- a/Source/Engine/Core/Math/Color.cs +++ b/Source/Engine/Core/Math/Color.cs @@ -280,7 +280,7 @@ namespace FlaxEngine /// /// The hexadecimal string. /// Output value. - /// True if value has benn parsed, otherwise false. + /// True if value has been parsed, otherwise false. public static bool TryParseHex(string hexString, out Color value) { value = Black; diff --git a/Source/Engine/Core/Math/Half.cpp b/Source/Engine/Core/Math/Half.cpp index 47bf66802..0de29c030 100644 --- a/Source/Engine/Core/Math/Half.cpp +++ b/Source/Engine/Core/Math/Half.cpp @@ -18,81 +18,81 @@ Half4 Half4::Zero(0, 0, 0, 0); Half2::Half2(const Vector2& v) { - X = ConvertFloatToHalf(v.X); - Y = ConvertFloatToHalf(v.Y); + X = Float16Compressor::Compress(v.X); + Y = Float16Compressor::Compress(v.Y); } Vector2 Half2::ToVector2() const { return Vector2( - ConvertHalfToFloat(X), - ConvertHalfToFloat(Y) + Float16Compressor::Decompress(X), + Float16Compressor::Decompress(Y) ); } Half3::Half3(const Vector3& v) { - X = ConvertFloatToHalf(v.X); - Y = ConvertFloatToHalf(v.Y); - Z = ConvertFloatToHalf(v.Z); + X = Float16Compressor::Compress(v.X); + Y = Float16Compressor::Compress(v.Y); + Z = Float16Compressor::Compress(v.Z); } Vector3 Half3::ToVector3() const { return Vector3( - ConvertHalfToFloat(X), - ConvertHalfToFloat(Y), - ConvertHalfToFloat(Z) + Float16Compressor::Decompress(X), + Float16Compressor::Decompress(Y), + Float16Compressor::Decompress(Z) ); } Half4::Half4(const Vector4& v) { - X = ConvertFloatToHalf(v.X); - Y = ConvertFloatToHalf(v.Y); - Z = ConvertFloatToHalf(v.Z); - W = ConvertFloatToHalf(v.W); + X = Float16Compressor::Compress(v.X); + Y = Float16Compressor::Compress(v.Y); + Z = Float16Compressor::Compress(v.Z); + W = Float16Compressor::Compress(v.W); } Half4::Half4(const Color& c) { - X = ConvertFloatToHalf(c.R); - Y = ConvertFloatToHalf(c.G); - Z = ConvertFloatToHalf(c.B); - W = ConvertFloatToHalf(c.A); + X = Float16Compressor::Compress(c.R); + Y = Float16Compressor::Compress(c.G); + Z = Float16Compressor::Compress(c.B); + W = Float16Compressor::Compress(c.A); } Half4::Half4(const Rectangle& rect) { - X = ConvertFloatToHalf(rect.Location.X); - Y = ConvertFloatToHalf(rect.Location.Y); - Z = ConvertFloatToHalf(rect.Size.X); - W = ConvertFloatToHalf(rect.Size.Y); + X = Float16Compressor::Compress(rect.Location.X); + Y = Float16Compressor::Compress(rect.Location.Y); + Z = Float16Compressor::Compress(rect.Size.X); + W = Float16Compressor::Compress(rect.Size.Y); } Vector2 Half4::ToVector2() const { return Vector2( - ConvertHalfToFloat(X), - ConvertHalfToFloat(Y) + Float16Compressor::Decompress(X), + Float16Compressor::Decompress(Y) ); } Vector3 Half4::ToVector3() const { return Vector3( - ConvertHalfToFloat(X), - ConvertHalfToFloat(Y), - ConvertHalfToFloat(Z) + Float16Compressor::Decompress(X), + Float16Compressor::Decompress(Y), + Float16Compressor::Decompress(Z) ); } Vector4 Half4::ToVector4() const { return Vector4( - ConvertHalfToFloat(X), - ConvertHalfToFloat(Y), - ConvertHalfToFloat(Z), - ConvertHalfToFloat(W) + Float16Compressor::Decompress(X), + Float16Compressor::Decompress(Y), + Float16Compressor::Decompress(Z), + Float16Compressor::Decompress(W) ); } diff --git a/Source/Engine/Core/Math/Half.h b/Source/Engine/Core/Math/Half.h index 19059ad0c..e0773b1d4 100644 --- a/Source/Engine/Core/Math/Half.h +++ b/Source/Engine/Core/Math/Half.h @@ -11,8 +11,14 @@ typedef uint16 Half; #define USE_SSE_HALF_CONVERSION 0 -class Float16Compressor +/// +/// Utility for packing/unpacking floating point value from single precision (32 bit) to half precision (16 bit). +/// +class FLAXENGINE_API Float16Compressor { + // Reference: + // http://www.cs.cmu.edu/~jinlianw/third_party/float16_compressor.hpp + union Bits { float f; @@ -22,24 +28,19 @@ class Float16Compressor static const int shift = 13; static const int shiftSign = 16; - static const int32 infN = 0x7F800000; // flt32 infinity static const int32 maxN = 0x477FE000; // max flt16 normal as a flt32 static const int32 minN = 0x38800000; // min flt16 normal as a flt32 static const int32 signN = 0x80000000; // flt32 sign bit - static const int32 infC = infN >> shift; static const int32 nanN = (infC + 1) << shift; // minimum flt16 nan as a flt32 static const int32 maxC = maxN >> shift; static const int32 minC = minN >> shift; static const int32 signC = signN >> shiftSign; // flt16 sign bit - static const int32 mulN = 0x52000000; // (1 << 23) / minN static const int32 mulC = 0x33800000; // minN / (1 << (23 - shift)) - static const int32 subC = 0x003FF; // max flt32 subnormal down shifted static const int32 norC = 0x00400; // min flt32 normal down shifted - static const int32 maxD = infC - maxC - 1; static const int32 minD = minC - subC - 1; @@ -48,9 +49,9 @@ public: static Half Compress(const float value) { #if USE_SSE_HALF_CONVERSION - __m128 V1 = _mm_set_ss(value); - __m128i V2 = _mm_cvtps_ph(V1, 0); - return static_cast(_mm_cvtsi128_si32(V2)); + __m128 value1 = _mm_set_ss(value); + __m128i value2 = _mm_cvtps_ph(value1, 0); + return static_cast(_mm_cvtsi128_si32(value2)); #else Bits v, s; v.f = value; @@ -72,9 +73,9 @@ public: static float Decompress(const Half value) { #if USE_SSE_HALF_CONVERSION - __m128i V1 = _mm_cvtsi32_si128(static_cast(value)); - __m128 V2 = _mm_cvtph_ps(V1); - return _mm_cvtss_f32(V2); + __m128i value1 = _mm_cvtsi32_si128(static_cast(value)); + __m128 value2 = _mm_cvtph_ps(value1); + return _mm_cvtss_f32(value2); #else Bits v; v.ui = value; @@ -95,20 +96,10 @@ public: } }; -inline float ConvertHalfToFloat(const Half value) -{ - return Float16Compressor::Decompress(value); -} - -inline Half ConvertFloatToHalf(const float value) -{ - return Float16Compressor::Compress(value); -} - /// /// Defines a two component vector, using half precision floating point coordinates. /// -struct Half2 +struct FLAXENGINE_API Half2 { public: @@ -145,8 +136,8 @@ public: /// Y component Half2(float x, float y) { - X = ConvertFloatToHalf(x); - Y = ConvertFloatToHalf(y); + X = Float16Compressor::Compress(x); + Y = Float16Compressor::Compress(y); } /// @@ -167,7 +158,7 @@ public: /// /// Defines a three component vector, using half precision floating point coordinates. /// -struct Half3 +struct FLAXENGINE_API Half3 { public: @@ -201,9 +192,9 @@ public: Half3(const float x, const float y, const float z) { - X = ConvertFloatToHalf(x); - Y = ConvertFloatToHalf(y); - Z = ConvertFloatToHalf(z); + X = Float16Compressor::Compress(x); + Y = Float16Compressor::Compress(y); + Z = Float16Compressor::Compress(z); } Half3(const Vector3& v); @@ -216,7 +207,7 @@ public: /// /// Defines a four component vector, using half precision floating point coordinates. /// -struct Half4 +struct FLAXENGINE_API Half4 { public: @@ -255,31 +246,27 @@ public: Half4(const float x, const float y, const float z) { - X = ConvertFloatToHalf(x); - Y = ConvertFloatToHalf(y); - Z = ConvertFloatToHalf(z); + X = Float16Compressor::Compress(x); + Y = Float16Compressor::Compress(y); + Z = Float16Compressor::Compress(z); W = 0; } Half4(const float x, const float y, const float z, const float w) { - X = ConvertFloatToHalf(x); - Y = ConvertFloatToHalf(y); - Z = ConvertFloatToHalf(z); - W = ConvertFloatToHalf(w); + X = Float16Compressor::Compress(x); + Y = Float16Compressor::Compress(y); + Z = Float16Compressor::Compress(z); + W = Float16Compressor::Compress(w); } explicit Half4(const Vector4& v); - explicit Half4(const Color& c); - explicit Half4(const Rectangle& rect); public: Vector2 ToVector2() const; - Vector3 ToVector3() const; - Vector4 ToVector4() const; }; diff --git a/Source/Engine/Core/Math/Int2.h b/Source/Engine/Core/Math/Int2.h new file mode 100644 index 000000000..a6038d1b0 --- /dev/null +++ b/Source/Engine/Core/Math/Int2.h @@ -0,0 +1,279 @@ +// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. + +#pragma once + +#include "Math.h" +#include "Engine/Core/Formatting.h" +#include "Engine/Core/Templates.h" + +struct Vector2; +struct Vector3; +struct Vector4; + +/// +/// Two-components vector (32 bit integer type). +/// +API_STRUCT(InBuild) struct FLAXENGINE_API Int2 +{ +public: + + union + { + struct + { + // X component + int32 X; + + // Y component + int32 Y; + }; + + // Raw values + int32 Raw[2]; + }; + +public: + + // Vector with all components equal 0 + static const Int2 Zero; + + // Vector with all components equal 1 + static const Int2 One; + +public: + + /// + /// Empty constructor. + /// + Int2() + { + } + + // Init + // @param xy Value to assign to the all components + Int2(int32 xy) + : X(xy) + , Y(xy) + { + } + + // Init + // @param x X component value + // @param y Y component value + Int2(int32 x, int32 y) + : X(x) + , Y(y) + { + } + + // Init + // @param v Vector to use X and Y components + explicit Int2(const Vector2& v); + +public: + + String ToString() const; + +public: + + // Arithmetic operators with Int2 + + Int2 operator+(const Int2& b) const + { + return Add(*this, b); + } + + Int2 operator-(const Int2& b) const + { + return Subtract(*this, b); + } + + Int2 operator*(const Int2& b) const + { + return Multiply(*this, b); + } + + Int2 operator/(const Int2& b) const + { + return Divide(*this, b); + } + + Int2 operator-() const + { + return Int2(-X, -Y); + } + + // op= operators with Int2 + + Int2& operator+=(const Int2& b) + { + *this = Add(*this, b); + return *this; + } + + Int2& operator-=(const Int2& b) + { + *this = Subtract(*this, b); + return *this; + } + + Int2& operator*=(const Int2& b) + { + *this = Multiply(*this, b); + return *this; + } + + Int2& operator/=(const Int2& b) + { + *this = Divide(*this, b); + return *this; + } + + // Arithmetic operators with int32 + + Int2 operator+(int32 b) const + { + return Add(*this, b); + } + + Int2 operator-(int32 b) const + { + return Subtract(*this, b); + } + + Int2 operator*(int32 b) const + { + return Multiply(*this, b); + } + + Int2 operator/(int32 b) const + { + return Divide(*this, b); + } + + // op= operators with int32 + + Int2& operator+=(int32 b) + { + *this = Add(*this, b); + return *this; + } + + Int2& operator-=(int32 b) + { + *this = Subtract(*this, b); + return *this; + } + + Int2& operator*=(int32 b) + { + *this = Multiply(*this, b); + return *this; + } + + Int2& operator/=(int32 b) + { + *this = Divide(*this, b); + return *this; + } + + // Comparison operators + + bool operator==(const Int2& b) const + { + return X == b.X && Y == b.Y; + } + + bool operator!=(const Int2& b) const + { + return X != b.X || Y != b.Y; + } + + bool operator>(const Int2& b) const + { + return X > b.X && Y > b.Y; + } + + bool operator>=(const Int2& b) const + { + return X >= b.X && Y >= b.Y; + } + + bool operator<(const Int2& b) const + { + return X < b.X && Y < b.Y; + } + + bool operator<=(const Int2& b) const + { + return X <= b.X && Y <= b.Y; + } + +public: + + static void Add(const Int2& a, const Int2& b, Int2* result) + { + result->X = a.X + b.X; + result->Y = a.Y + b.Y; + } + + static Int2 Add(const Int2& a, const Int2& b) + { + Int2 result; + Add(a, b, &result); + return result; + } + + static void Subtract(const Int2& a, const Int2& b, Int2* result) + { + result->X = a.X - b.X; + result->Y = a.Y - b.Y; + } + + static Int2 Subtract(const Int2& a, const Int2& b) + { + Int2 result; + Subtract(a, b, &result); + return result; + } + + static Int2 Multiply(const Int2& a, const Int2& b) + { + return Int2(a.X * b.X, a.Y * b.Y); + } + + static Int2 Multiply(const Int2& a, int32 b) + { + return Int2(a.X * b, a.Y * b); + } + + static Int2 Divide(const Int2& a, const Int2& b) + { + return Int2(a.X / b.X, a.Y / b.Y); + } + + static Int2 Divide(const Int2& a, int32 b) + { + return Int2(a.X / b, a.Y / b); + } + + // Creates vector from minimum components of two vectors + static Int2 Min(const Int2& a, const Int2& b) + { + return Int2(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y); + } + + // Creates vector from maximum components of two vectors + static Int2 Max(const Int2& a, const Int2& b) + { + return Int2(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y); + } +}; + +template<> +struct TIsPODType +{ + enum { Value = true }; +}; + +DEFINE_DEFAULT_FORMATTING(Int2, "X:{0} Y:{1}", v.X, v.Y); diff --git a/Source/Engine/Core/Math/Int3.h b/Source/Engine/Core/Math/Int3.h new file mode 100644 index 000000000..6886acc6b --- /dev/null +++ b/Source/Engine/Core/Math/Int3.h @@ -0,0 +1,128 @@ +// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. + +#pragma once + +#include "Math.h" +#include "Engine/Core/Formatting.h" +#include "Engine/Core/Templates.h" + +struct Vector2; +struct Vector3; +struct Vector4; + +/// +/// Three-components vector (32 bit integer type). +/// +API_STRUCT(InBuild) struct FLAXENGINE_API Int3 +{ +public: + + union + { + struct + { + // X component + int32 X; + + // Y component + int32 Y; + + // Y component + int32 Z; + }; + + // Raw values + int32 Raw[3]; + }; + +public: + + // Vector with all components equal 0 + static const Int3 Zero; + + // Vector with all components equal 1 + static const Int3 One; + +public: + + /// + /// Empty constructor. + /// + Int3() + { + } + + // Init + // @param xy Value to assign to the all components + Int3(int32 xyz) + : X(xyz) + , Y(xyz) + , Z(xyz) + { + } + + // Init + // @param x X component value + // @param y Y component value + // @param z Z component value + Int3(int32 x, int32 y, int32 z) + : X(x) + , Y(y) + , Z(z) + { + } + + // Init + // @param v Vector to use X, Y and Z components + explicit Int3(const Vector3& v); + +public: + + String ToString() const; + +public: + + // Returns a vector containing the largest components of the specified vectors + // @param a The first source vector + // @param b The second source vector + // @param result When the method completes, contains an new vector composed of the largest components of the source vectors + static Int3 Max(const Int3& a, const Int3& b) + { + return Int3(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y, a.Z > b.Z ? a.Z : b.Z); + } + + // Returns a vector containing the smallest components of the specified vectors + // @param a The first source vector + // @param b The second source vector + // @param result When the method completes, contains an new vector composed of the smallest components of the source vectors + static Int3 Min(const Int3& a, const Int3& b) + { + return Int3(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y, a.Z < b.Z ? a.Z : b.Z); + } + + // Returns a vector containing the largest components of the specified vectors + // @param a The first source vector + // @param b The second source vector + // @param result When the method completes, contains an new vector composed of the largest components of the source vectors + static void Max(const Int3& a, const Int3& b, Int3* result) + { + *result = Int3(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y, a.Z > b.Z ? a.Z : b.Z); + } + + // Returns a vector containing the smallest components of the specified vectors + // @param a The first source vector + // @param b The second source vector + // @param result When the method completes, contains an new vector composed of the smallest components of the source vectors + static void Min(const Int3& a, const Int3& b, Int3* result) + { + *result = Int3(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y, a.Z < b.Z ? a.Z : b.Z); + } +}; + +template<> +struct TIsPODType +{ + enum { Value = true }; +}; + +DEFINE_DEFAULT_FORMATTING(Int3, "X:{0} Y:{1} Z:{2}", v.X, v.Y, v.Z); diff --git a/Source/Engine/Core/Math/Int4.h b/Source/Engine/Core/Math/Int4.h new file mode 100644 index 000000000..c8e9eebd8 --- /dev/null +++ b/Source/Engine/Core/Math/Int4.h @@ -0,0 +1,134 @@ +// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. + +#pragma once + +#include "Math.h" +#include "Engine/Core/Formatting.h" +#include "Engine/Core/Templates.h" + +struct Vector2; +struct Vector3; +struct Vector4; + +/// +/// Four-components vector (32 bit integer type). +/// +API_STRUCT(InBuild) struct FLAXENGINE_API Int4 +{ +public: + + union + { + struct + { + // X component + int32 X; + + // Y component + int32 Y; + + // Z component + int32 Z; + + // W component + int32 W; + }; + + // Raw values + int32 Raw[4]; + }; + +public: + + // Vector with all components equal 0 + static const Int4 Zero; + + // Vector with all components equal 1 + static const Int4 One; + +public: + + /// + /// Empty constructor. + /// + Int4() + { + } + + // Init + // @param xy Value to assign to the all components + Int4(int32 xyzw) + : X(xyzw) + , Y(xyzw) + , Z(xyzw) + , W(xyzw) + { + } + + // Init + // @param x X component value + // @param y Y component value + // @param z Z component value + // @param w W component value + Int4(int32 x, int32 y, int32 z, int32 w) + : X(x) + , Y(y) + , Z(z) + , W(w) + { + } + + // Init + // @param v Vector to use X, Y, Z and W components + explicit Int4(const Vector4& v); + +public: + + String ToString() const; + +public: + + /// + /// Returns average arithmetic of all the components + /// + /// Average arithmetic of all the components + float AverageArithmetic() const + { + return (X + Y + Z + W) * 0.25f; + } + + /// + /// Gets sum of all vector components values + /// + /// Sum of X, Y, Z and W + int32 SumValues() const + { + return X + Y + Z + W; + } + + /// + /// Returns minimum value of all the components + /// + /// Minimum value + int32 MinValue() const + { + return Math::Min(X, Y, Z, W); + } + + /// + /// Returns maximum value of all the components + /// + /// Maximum value + int32 MaxValue() const + { + return Math::Max(X, Y, Z, W); + } +}; + +template<> +struct TIsPODType +{ + enum { Value = true }; +}; + +DEFINE_DEFAULT_FORMATTING(Int4, "X:{0} Y:{1} Z:{2} W:{3}", v.X, v.Y, v.Z, v.W); diff --git a/Source/Engine/Core/Math/Mathf.cs b/Source/Engine/Core/Math/Mathf.cs index 7286573bf..529bd6ab0 100644 --- a/Source/Engine/Core/Math/Mathf.cs +++ b/Source/Engine/Core/Math/Mathf.cs @@ -36,6 +36,11 @@ namespace FlaxEngine /// public const float PiOverFour = (float)(Math.PI / 4); + /// + /// A value specifying the golden mean + /// + public const float GoldenRatio = 1.6180339887f; + /// /// Returns the absolute value of f. /// diff --git a/Source/Engine/Core/Math/Matrix3x3.h b/Source/Engine/Core/Math/Matrix3x3.h index 3cf690259..b28be5437 100644 --- a/Source/Engine/Core/Math/Matrix3x3.h +++ b/Source/Engine/Core/Math/Matrix3x3.h @@ -9,7 +9,7 @@ /// /// Represents a 3x3 mathematical matrix. /// -API_STRUCT(InBuild) struct Matrix3x3 +API_STRUCT(InBuild) struct FLAXENGINE_API Matrix3x3 { public: diff --git a/Source/Engine/Core/Math/OrientedBoundingBox.h b/Source/Engine/Core/Math/OrientedBoundingBox.h index 03256633d..d19108f84 100644 --- a/Source/Engine/Core/Math/OrientedBoundingBox.h +++ b/Source/Engine/Core/Math/OrientedBoundingBox.h @@ -8,7 +8,7 @@ #include "CollisionsHelper.h" // Oriented Bounding Box (OBB) is a rectangular block, much like an AABB (Bounding Box) but with an arbitrary orientation in 3D space. -API_STRUCT(InBuild) struct OrientedBoundingBox +API_STRUCT(InBuild) struct FLAXENGINE_API OrientedBoundingBox { public: diff --git a/Source/Engine/Core/Math/Packed.h b/Source/Engine/Core/Math/Packed.h index ec666bf61..4f41dac9c 100644 --- a/Source/Engine/Core/Math/Packed.h +++ b/Source/Engine/Core/Math/Packed.h @@ -13,7 +13,7 @@ typedef Half Float16; /// /// Packed vector, layout: R:10 bytes, G:10 bytes, B:10 bytes, A:2 bytes, all values are stored as floats in range [0;1]. /// -struct Float1010102 +struct FLAXENGINE_API Float1010102 { union { @@ -64,7 +64,7 @@ public: }; // The 3D vector is packed into 32 bits with 11/11/10 bits per floating-point component. -struct FloatR11G11B10 +struct FLAXENGINE_API FloatR11G11B10 { union { @@ -118,7 +118,7 @@ public: Vector3 ToVector3() const; }; -struct RG16UNorm +struct FLAXENGINE_API RG16UNorm { uint16 X, Y; @@ -131,7 +131,7 @@ struct RG16UNorm Vector2 ToVector2() const; }; -struct RGBA16UNorm +struct FLAXENGINE_API RGBA16UNorm { uint16 X, Y, Z, W; diff --git a/Source/Engine/Core/Math/Plane.h b/Source/Engine/Core/Math/Plane.h index 2ca34258f..2fbe7438c 100644 --- a/Source/Engine/Core/Math/Plane.h +++ b/Source/Engine/Core/Math/Plane.h @@ -8,7 +8,7 @@ /// /// Represents a plane in three dimensional space. /// -API_STRUCT() struct Plane +API_STRUCT() struct FLAXENGINE_API Plane { DECLARE_SCRIPTING_TYPE_MINIMAL(Plane); public: diff --git a/Source/Engine/Core/Math/Ray.h b/Source/Engine/Core/Math/Ray.h index 56d06a21e..f125cba97 100644 --- a/Source/Engine/Core/Math/Ray.h +++ b/Source/Engine/Core/Math/Ray.h @@ -11,7 +11,7 @@ struct Viewport; /// /// Represents a three dimensional line based on a point in space and a direction. /// -API_STRUCT() struct Ray +API_STRUCT() struct FLAXENGINE_API Ray { DECLARE_SCRIPTING_TYPE_MINIMAL(Ray); public: diff --git a/Source/Engine/Core/Math/Rectangle.h b/Source/Engine/Core/Math/Rectangle.h index 305ae70e1..f2dcbd20a 100644 --- a/Source/Engine/Core/Math/Rectangle.h +++ b/Source/Engine/Core/Math/Rectangle.h @@ -10,7 +10,6 @@ API_STRUCT() struct FLAXENGINE_API Rectangle { DECLARE_SCRIPTING_TYPE_MINIMAL(Rectangle); -public: /// /// The empty rectangle. diff --git a/Source/Engine/Core/Math/Transform.h b/Source/Engine/Core/Math/Transform.h index 3b8cf71b7..ed19efeae 100644 --- a/Source/Engine/Core/Math/Transform.h +++ b/Source/Engine/Core/Math/Transform.h @@ -11,10 +11,9 @@ struct Matrix; /// /// Describes transformation in a 3D space. /// -API_STRUCT() struct Transform +API_STRUCT() struct FLAXENGINE_API Transform { DECLARE_SCRIPTING_TYPE_MINIMAL(Transform); -public: /// /// The translation vector of the transform. diff --git a/Source/Engine/Core/Math/Triangle.h b/Source/Engine/Core/Math/Triangle.h index 03f91ece3..b0f7ea09d 100644 --- a/Source/Engine/Core/Math/Triangle.h +++ b/Source/Engine/Core/Math/Triangle.h @@ -8,7 +8,7 @@ /// /// Represents a three dimensional triangle. /// -struct Triangle +struct FLAXENGINE_API Triangle { public: diff --git a/Source/Engine/Core/Math/Vector2.cpp b/Source/Engine/Core/Math/Vector2.cpp index 6a0468033..c23e79d19 100644 --- a/Source/Engine/Core/Math/Vector2.cpp +++ b/Source/Engine/Core/Math/Vector2.cpp @@ -4,8 +4,8 @@ #include "Vector3.h" #include "Vector4.h" #include "Color.h" +#include "Int2.h" #include "../Types/String.h" -#include "VectorInt.h" static_assert(sizeof(Vector2) == 8, "Invalid Vector2 type size."); diff --git a/Source/Engine/Core/Math/Vector3.cpp b/Source/Engine/Core/Math/Vector3.cpp index e3ff349ba..f66bbcbbd 100644 --- a/Source/Engine/Core/Math/Vector3.cpp +++ b/Source/Engine/Core/Math/Vector3.cpp @@ -6,7 +6,7 @@ #include "Color.h" #include "Quaternion.h" #include "Matrix.h" -#include "VectorInt.h" +#include "Int3.h" #include "../Types/String.h" static_assert(sizeof(Vector3) == 12, "Invalid Vector3 type size."); diff --git a/Source/Engine/Core/Math/Vector4.cpp b/Source/Engine/Core/Math/Vector4.cpp index 3caaab985..34fa27aac 100644 --- a/Source/Engine/Core/Math/Vector4.cpp +++ b/Source/Engine/Core/Math/Vector4.cpp @@ -6,7 +6,7 @@ #include "Color.h" #include "Matrix.h" #include "Rectangle.h" -#include "VectorInt.h" +#include "Int4.h" #include "../Types/String.h" static_assert(sizeof(Vector4) == 16, "Invalid Vector4 type size."); diff --git a/Source/Engine/Core/Math/VectorInt.h b/Source/Engine/Core/Math/VectorInt.h index 80804c39a..d9611d615 100644 --- a/Source/Engine/Core/Math/VectorInt.h +++ b/Source/Engine/Core/Math/VectorInt.h @@ -2,518 +2,6 @@ #pragma once -#include "Math.h" -#include "Engine/Core/Formatting.h" -#include "Engine/Core/Templates.h" - -struct Vector2; -struct Vector3; -struct Vector4; - -/// -/// Two-components vector (32 bit integer type). -/// -API_STRUCT(InBuild) struct Int2 -{ -public: - - union - { - struct - { - // X component - int32 X; - - // Y component - int32 Y; - }; - - // Raw values - int32 Raw[2]; - }; - -public: - - // Vector with all components equal 0 - static const Int2 Zero; - - // Vector with all components equal 1 - static const Int2 One; - -public: - - /// - /// Empty constructor. - /// - Int2() - { - } - - // Init - // @param xy Value to assign to the all components - Int2(int32 xy) - : X(xy) - , Y(xy) - { - } - - // Init - // @param x X component value - // @param y Y component value - Int2(int32 x, int32 y) - : X(x) - , Y(y) - { - } - - // Init - // @param v Vector to use X and Y components - explicit Int2(const Vector2& v); - -public: - - String ToString() const; - -public: - - // Arithmetic operators with Int2 - - Int2 operator+(const Int2& b) const - { - return Add(*this, b); - } - - Int2 operator-(const Int2& b) const - { - return Subtract(*this, b); - } - - Int2 operator*(const Int2& b) const - { - return Multiply(*this, b); - } - - Int2 operator/(const Int2& b) const - { - return Divide(*this, b); - } - - Int2 operator-() const - { - return Int2(-X, -Y); - } - - // op= operators with Int2 - - Int2& operator+=(const Int2& b) - { - *this = Add(*this, b); - return *this; - } - - Int2& operator-=(const Int2& b) - { - *this = Subtract(*this, b); - return *this; - } - - Int2& operator*=(const Int2& b) - { - *this = Multiply(*this, b); - return *this; - } - - Int2& operator/=(const Int2& b) - { - *this = Divide(*this, b); - return *this; - } - - // Arithmetic operators with int32 - - Int2 operator+(int32 b) const - { - return Add(*this, b); - } - - Int2 operator-(int32 b) const - { - return Subtract(*this, b); - } - - Int2 operator*(int32 b) const - { - return Multiply(*this, b); - } - - Int2 operator/(int32 b) const - { - return Divide(*this, b); - } - - // op= operators with int32 - - Int2& operator+=(int32 b) - { - *this = Add(*this, b); - return *this; - } - - Int2& operator-=(int32 b) - { - *this = Subtract(*this, b); - return *this; - } - - Int2& operator*=(int32 b) - { - *this = Multiply(*this, b); - return *this; - } - - Int2& operator/=(int32 b) - { - *this = Divide(*this, b); - return *this; - } - - // Comparison operators - - bool operator==(const Int2& b) const - { - return X == b.X && Y == b.Y; - } - - bool operator!=(const Int2& b) const - { - return X != b.X || Y != b.Y; - } - - bool operator>(const Int2& b) const - { - return X > b.X && Y > b.Y; - } - - bool operator>=(const Int2& b) const - { - return X >= b.X && Y >= b.Y; - } - - bool operator<(const Int2& b) const - { - return X < b.X && Y < b.Y; - } - - bool operator<=(const Int2& b) const - { - return X <= b.X && Y <= b.Y; - } - -public: - - static void Add(const Int2& a, const Int2& b, Int2* result) - { - result->X = a.X + b.X; - result->Y = a.Y + b.Y; - } - - static Int2 Add(const Int2& a, const Int2& b) - { - Int2 result; - Add(a, b, &result); - return result; - } - - static void Subtract(const Int2& a, const Int2& b, Int2* result) - { - result->X = a.X - b.X; - result->Y = a.Y - b.Y; - } - - static Int2 Subtract(const Int2& a, const Int2& b) - { - Int2 result; - Subtract(a, b, &result); - return result; - } - - static Int2 Multiply(const Int2& a, const Int2& b) - { - return Int2(a.X * b.X, a.Y * b.Y); - } - - static Int2 Multiply(const Int2& a, int32 b) - { - return Int2(a.X * b, a.Y * b); - } - - static Int2 Divide(const Int2& a, const Int2& b) - { - return Int2(a.X / b.X, a.Y / b.Y); - } - - static Int2 Divide(const Int2& a, int32 b) - { - return Int2(a.X / b, a.Y / b); - } - - // Creates vector from minimum components of two vectors - static Int2 Min(const Int2& a, const Int2& b) - { - return Int2(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y); - } - - // Creates vector from maximum components of two vectors - static Int2 Max(const Int2& a, const Int2& b) - { - return Int2(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y); - } -}; - -/// -/// Three-components vector (32 bit integer type). -/// -API_STRUCT(InBuild) struct Int3 -{ -public: - - union - { - struct - { - // X component - int32 X; - - // Y component - int32 Y; - - // Y component - int32 Z; - }; - - // Raw values - int32 Raw[3]; - }; - -public: - - // Vector with all components equal 0 - static const Int3 Zero; - - // Vector with all components equal 1 - static const Int3 One; - -public: - - /// - /// Empty constructor. - /// - Int3() - { - } - - // Init - // @param xy Value to assign to the all components - Int3(int32 xyz) - : X(xyz) - , Y(xyz) - , Z(xyz) - { - } - - // Init - // @param x X component value - // @param y Y component value - // @param z Z component value - Int3(int32 x, int32 y, int32 z) - : X(x) - , Y(y) - , Z(z) - { - } - - // Init - // @param v Vector to use X, Y and Z components - explicit Int3(const Vector3& v); - -public: - - String ToString() const; - -public: - - // Returns a vector containing the largest components of the specified vectors - // @param a The first source vector - // @param b The second source vector - // @param result When the method completes, contains an new vector composed of the largest components of the source vectors - static Int3 Max(const Int3& a, const Int3& b) - { - return Int3(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y, a.Z > b.Z ? a.Z : b.Z); - } - - // Returns a vector containing the smallest components of the specified vectors - // @param a The first source vector - // @param b The second source vector - // @param result When the method completes, contains an new vector composed of the smallest components of the source vectors - static Int3 Min(const Int3& a, const Int3& b) - { - return Int3(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y, a.Z < b.Z ? a.Z : b.Z); - } - - // Returns a vector containing the largest components of the specified vectors - // @param a The first source vector - // @param b The second source vector - // @param result When the method completes, contains an new vector composed of the largest components of the source vectors - static void Max(const Int3& a, const Int3& b, Int3* result) - { - *result = Int3(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y, a.Z > b.Z ? a.Z : b.Z); - } - - // Returns a vector containing the smallest components of the specified vectors - // @param a The first source vector - // @param b The second source vector - // @param result When the method completes, contains an new vector composed of the smallest components of the source vectors - static void Min(const Int3& a, const Int3& b, Int3* result) - { - *result = Int3(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y, a.Z < b.Z ? a.Z : b.Z); - } -}; - -/// -/// Four-components vector (32 bit integer type). -/// -API_STRUCT(InBuild) struct Int4 -{ -public: - - union - { - struct - { - // X component - int32 X; - - // Y component - int32 Y; - - // Z component - int32 Z; - - // W component - int32 W; - }; - - // Raw values - int32 Raw[4]; - }; - -public: - - // Vector with all components equal 0 - static const Int4 Zero; - - // Vector with all components equal 1 - static const Int4 One; - -public: - - /// - /// Empty constructor. - /// - Int4() - { - } - - // Init - // @param xy Value to assign to the all components - Int4(int32 xyzw) - : X(xyzw) - , Y(xyzw) - , Z(xyzw) - , W(xyzw) - { - } - - // Init - // @param x X component value - // @param y Y component value - // @param z Z component value - // @param w W component value - Int4(int32 x, int32 y, int32 z, int32 w) - : X(x) - , Y(y) - , Z(z) - , W(w) - { - } - - // Init - // @param v Vector to use X, Y, Z and W components - explicit Int4(const Vector4& v); - -public: - - String ToString() const; - -public: - - /// - /// Returns average arithmetic of all the components - /// - /// Average arithmetic of all the components - float AverageArithmetic() const - { - return (X + Y + Z + W) * 0.25f; - } - - /// - /// Gets sum of all vector components values - /// - /// Sum of X, Y, Z and W - int32 SumValues() const - { - return X + Y + Z + W; - } - - /// - /// Returns minimum value of all the components - /// - /// Minimum value - int32 MinValue() const - { - return Math::Min(X, Y, Z, W); - } - - /// - /// Returns maximum value of all the components - /// - /// Maximum value - int32 MaxValue() const - { - return Math::Max(X, Y, Z, W); - } -}; - -template<> -struct TIsPODType -{ - enum { Value = true }; -}; - -template<> -struct TIsPODType -{ - enum { Value = true }; -}; - -template<> -struct TIsPODType -{ - enum { Value = true }; -}; - -DEFINE_DEFAULT_FORMATTING(Int2, "X:{0} Y:{1}", v.X, v.Y); - -DEFINE_DEFAULT_FORMATTING(Int3, "X:{0} Y:{1} Z:{2}", v.X, v.Y, v.Z); - -DEFINE_DEFAULT_FORMATTING(Int4, "X:{0} Y:{1} Z:{2} W:{3}", v.X, v.Y, v.Z, v.W); +#include "Int2.h" +#include "Int3.h" +#include "Int4.h" diff --git a/Source/Engine/Core/Math/Viewport.h b/Source/Engine/Core/Math/Viewport.h index 0b5871f2e..e30d085d3 100644 --- a/Source/Engine/Core/Math/Viewport.h +++ b/Source/Engine/Core/Math/Viewport.h @@ -10,7 +10,7 @@ struct Matrix; struct Rectangle; // Describes the viewport dimensions. -API_STRUCT(InBuild) struct Viewport +API_STRUCT(InBuild) struct FLAXENGINE_API Viewport { public: diff --git a/Source/Engine/Core/ObjectsRemovalService.cpp b/Source/Engine/Core/ObjectsRemovalService.cpp index a36265646..f9d26f808 100644 --- a/Source/Engine/Core/ObjectsRemovalService.cpp +++ b/Source/Engine/Core/ObjectsRemovalService.cpp @@ -193,7 +193,7 @@ void ObjectsRemovalServiceService::Dispose() // Collect new objects ObjectsRemovalService::Flush(); - // Delete all reaming objects + // Delete all remaining objects { ScopeLock lock(PoolLocker); for (auto i = Pool.Begin(); i.IsNotEnd(); ++i) diff --git a/Source/Engine/Core/Types/Variant.cpp b/Source/Engine/Core/Types/Variant.cpp index 62c791875..db71c2f77 100644 --- a/Source/Engine/Core/Types/Variant.cpp +++ b/Source/Engine/Core/Types/Variant.cpp @@ -2612,7 +2612,8 @@ Variant Variant::Lerp(const Variant& a, const Variant& b, float alpha) void Variant::AllocStructure() { - const ScriptingTypeHandle typeHandle = Scripting::FindScriptingType(StringAnsiView(Type.TypeName)); + const StringAnsiView typeName(Type.TypeName); + const ScriptingTypeHandle typeHandle = Scripting::FindScriptingType(typeName); if (typeHandle) { const ScriptingType& type = typeHandle.GetType(); @@ -2620,8 +2621,26 @@ void Variant::AllocStructure() AsBlob.Data = Allocator::Allocate(AsBlob.Length); type.Struct.Ctor(AsBlob.Data); } + else if (typeName == "System.Byte") + { + // Hack for byte + AsBlob.Length = 1; + AsBlob.Data = Allocator::Allocate(AsBlob.Length); + *((byte*)AsBlob.Data) = 0; + } + else if (typeName == "System.Int16" || typeName == "System.UInt16") + { + // Hack for 16bit int + AsBlob.Length = 2; + AsBlob.Data = Allocator::Allocate(AsBlob.Length); + *((int16*)AsBlob.Data) = 0; + } else { + if (typeName.Length() != 0) + { + LOG(Warning, "Missing scripting type \'{0}\'", String(typeName.Get())); + } AsBlob.Data = nullptr; AsBlob.Length = 0; } @@ -2637,6 +2656,10 @@ void Variant::CopyStructure(void* src) auto& type = typeHandle.GetType(); type.Struct.Copy(AsBlob.Data, src); } + else + { + Platform::MemoryCopy(AsBlob.Data, src, AsBlob.Length); + } } } diff --git a/Source/Engine/Debug/Exception.h b/Source/Engine/Debug/Exception.h index 481c78589..5bef7aa55 100644 --- a/Source/Engine/Debug/Exception.h +++ b/Source/Engine/Debug/Exception.h @@ -36,7 +36,7 @@ namespace Log /// /// Additional information that help describe error Exception(const String& additionalInfo) - : Exception(TEXT("An exception has occured."), additionalInfo) + : Exception(TEXT("An exception has occurred."), additionalInfo) { } diff --git a/Source/Engine/Engine/Engine.cpp b/Source/Engine/Engine/Engine.cpp index f9313b1b4..2518d5916 100644 --- a/Source/Engine/Engine/Engine.cpp +++ b/Source/Engine/Engine/Engine.cpp @@ -468,7 +468,7 @@ void Engine::OnExit() LOG_FLUSH(); - // Kill all reaming threads + // Kill all remaining threads ThreadRegistry::KillEmAll(); // Cleanup diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 20836b300..8aa88756a 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -985,7 +985,7 @@ API_ENUM() enum class TessellationMethod enum class ShaderFlags : uint32 { /// - /// The default set fo flags. + /// The default set for flags. /// Default = 0, diff --git a/Source/Engine/Graphics/GPUBuffer.h b/Source/Engine/Graphics/GPUBuffer.h index 84611419e..97be261a4 100644 --- a/Source/Engine/Graphics/GPUBuffer.h +++ b/Source/Engine/Graphics/GPUBuffer.h @@ -215,7 +215,7 @@ public: /// Gets a CPU pointer to the resource by mapping its contents. Denies the GPU access to that resource. /// /// The map operation mode. - /// The pointer ot the mapped CPU buffer with resource data or null if failed. + /// The pointer of the mapped CPU buffer with resource data or null if failed. API_FUNCTION() virtual void* Map(GPUResourceMapMode mode) = 0; /// diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index a5195ff50..47ec6d3a6 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -239,7 +239,7 @@ void GPUDevice::preDispose() SAFE_DELETE_GPU_RESOURCE(_res->FullscreenTriangleVB); // Release GPU resources memory and unlink from device - // Note: after that noe GPU resources should be used/created, only deleted + // Note: after that no GPU resources should be used/created, only deleted Resources.OnDeviceDispose(); } diff --git a/Source/Engine/Graphics/GPULimits.h b/Source/Engine/Graphics/GPULimits.h index 485f5d866..b50714fcd 100644 --- a/Source/Engine/Graphics/GPULimits.h +++ b/Source/Engine/Graphics/GPULimits.h @@ -174,10 +174,10 @@ API_ENUM(Attributes="Flags") enum class FormatSupport : int32 DECLARE_ENUM_OPERATORS(FormatSupport); // Helper macro to check if given format does not support a given set of feature flags -#define FORMAT_FEATURES_ARE_NOT_SUPPORTED(formatSupport, formatSupportFlags) ((formatSupport & formatSupportFlags) != static_cast(formatSupportFlags)) +#define FORMAT_FEATURES_ARE_NOT_SUPPORTED(formatSupport, formatSupportFlags) ((formatSupport & (formatSupportFlags)) != static_cast(formatSupportFlags)) // Helper macro to check if given format does support a given set of feature flags -#define FORMAT_FEATURES_ARE_SUPPORTED(formatSupport, formatSupportFlags) ((formatSupport & formatSupportFlags) == static_cast(formatSupportFlags)) +#define FORMAT_FEATURES_ARE_SUPPORTED(formatSupport, formatSupportFlags) ((formatSupport & (formatSupportFlags)) == static_cast(formatSupportFlags)) /// /// The features exposed for a particular format. diff --git a/Source/Engine/Graphics/GPUSwapChain.cpp b/Source/Engine/Graphics/GPUSwapChain.cpp index 347fa6e46..68b1486ad 100644 --- a/Source/Engine/Graphics/GPUSwapChain.cpp +++ b/Source/Engine/Graphics/GPUSwapChain.cpp @@ -39,7 +39,7 @@ Task* GPUSwapChain::DownloadDataAsync(TextureData& result) { if (_downloadTask) { - LOG(Warning, "Can download window backuffer data ony once at the time."); + LOG(Warning, "Can download window backuffer data only once at the time."); return nullptr; } diff --git a/Source/Engine/Graphics/Graphics.cpp b/Source/Engine/Graphics/Graphics.cpp index 21b506ef1..69170dca0 100644 --- a/Source/Engine/Graphics/Graphics.cpp +++ b/Source/Engine/Graphics/Graphics.cpp @@ -49,6 +49,9 @@ GraphicsService GraphicsServiceInstance; void Graphics::DisposeDevice() { + // Clean any danging pointer to last task (might stay if engine is disposing after crash) + GPUDevice::Instance->CurrentTask = nullptr; + if (GPUDevice::Instance) { GPUDevice::Instance->Dispose(); diff --git a/Source/Engine/Graphics/Materials/IMaterial.h b/Source/Engine/Graphics/Materials/IMaterial.h index 8d5590354..09796c04b 100644 --- a/Source/Engine/Graphics/Materials/IMaterial.h +++ b/Source/Engine/Graphics/Materials/IMaterial.h @@ -108,7 +108,7 @@ public: /// /// Gets the mask of render passes supported by this material. /// - /// The drw passes supported by this material. + /// The draw passes supported by this material. virtual DrawPass GetDrawModes() const { return DrawPass::None; diff --git a/Source/Engine/Graphics/Mesh.cs b/Source/Engine/Graphics/Mesh.cs index f639bff8f..22579eb07 100644 --- a/Source/Engine/Graphics/Mesh.cs +++ b/Source/Engine/Graphics/Mesh.cs @@ -435,7 +435,7 @@ namespace FlaxEngine /// Downloads the third vertex buffer that contains mesh vertices data. To download data from GPU set to true and call this method from the thread other than main thread (see ). /// /// - /// If mesh has no vertex colors (stored in vertex buffer 2) the the returned value is null. + /// If mesh has no vertex colors (stored in vertex buffer 2) the returned value is null. /// /// If set to true the data will be downloaded from the GPU, otherwise it can be loaded from the drive (source asset file) or from memory (if cached). Downloading mesh from GPU requires this call to be made from the other thread than main thread. Virtual assets are always downloaded from GPU memory due to lack of dedicated storage container for the asset data. /// The gathered data or null if mesh has no vertex colors. diff --git a/Source/Engine/Graphics/Models/ModelData.Tool.cpp b/Source/Engine/Graphics/Models/ModelData.Tool.cpp index ee1b219dd..ee0fcb348 100644 --- a/Source/Engine/Graphics/Models/ModelData.Tool.cpp +++ b/Source/Engine/Graphics/Models/ModelData.Tool.cpp @@ -791,7 +791,7 @@ void MeshData::ImproveCacheLocality() Allocator::Free(piCandidates); const auto endTime = Platform::GetTimeSeconds(); - LOG(Info, "Cache relevant optimzie for {0} vertices and {1} indices. Average output ACMR is {2}. Time: {3}s", vertexCount, indexCount, (float)iCacheMisses / indexCount / 3, Utilities::RoundTo2DecimalPlaces(endTime - startTime)); + LOG(Info, "Cache relevant optimize for {0} vertices and {1} indices. Average output ACMR is {2}. Time: {3}s", vertexCount, indexCount, (float)iCacheMisses / indexCount / 3, Utilities::RoundTo2DecimalPlaces(endTime - startTime)); } float MeshData::CalculateTrianglesArea() const diff --git a/Source/Engine/Graphics/Models/ModelData.h b/Source/Engine/Graphics/Models/ModelData.h index 1e4b59d0a..a3bb47fcc 100644 --- a/Source/Engine/Graphics/Models/ModelData.h +++ b/Source/Engine/Graphics/Models/ModelData.h @@ -5,7 +5,7 @@ #include "Engine/Core/Common.h" #include "Engine/Core/Math/BoundingSphere.h" #include "Engine/Core/Math/BoundingBox.h" -#include "Engine/Core/Math/VectorInt.h" +#include "Engine/Core/Math/Int4.h" #include "Engine/Serialization/Stream.h" #include "Engine/Graphics/Enums.h" #include "Types.h" diff --git a/Source/Engine/Graphics/Models/Types.h b/Source/Engine/Graphics/Models/Types.h index 248988243..9a95b8815 100644 --- a/Source/Engine/Graphics/Models/Types.h +++ b/Source/Engine/Graphics/Models/Types.h @@ -9,7 +9,7 @@ #include "Engine/Core/Math/Vector4.h" #include "Engine/Core/Math/Color.h" #include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/VectorInt.h" +#include "Engine/Core/Math/Int4.h" class Model; class SkinnedModel; diff --git a/Source/Engine/Graphics/PostProcessSettings.h b/Source/Engine/Graphics/PostProcessSettings.h index 4279cfc9b..400deb3c1 100644 --- a/Source/Engine/Graphics/PostProcessSettings.h +++ b/Source/Engine/Graphics/PostProcessSettings.h @@ -387,7 +387,7 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(ToneMappingSettings); float WhiteTemperature = 6500.0f; /// - /// Adjusts the white balance temperature tint for the scene by adjusting the cyan and magenta color ranges. Ideally, this setting should be used once you've adjusted the white balance temporature to get accurate colors. Under some light temperatures, the colors may appear to be more yellow or blue. This can be used to balance the resulting color to look more natural. The default value is `0`. + /// Adjusts the white balance temperature tint for the scene by adjusting the cyan and magenta color ranges. Ideally, this setting should be used once you've adjusted the white balance temperature to get accurate colors. Under some light temperatures, the colors may appear to be more yellow or blue. This can be used to balance the resulting color to look more natural. The default value is `0`. /// API_FIELD(Attributes="DefaultValue(0.0f), Limit(-1, 1, 0.001f), EditorOrder(1), PostProcessSetting((int)ToneMappingSettingsOverride.WhiteTint)") float WhiteTint = 0.0f; diff --git a/Source/Engine/Graphics/RenderTargetPool.cpp b/Source/Engine/Graphics/RenderTargetPool.cpp index 109ff8de9..a9db0283d 100644 --- a/Source/Engine/Graphics/RenderTargetPool.cpp +++ b/Source/Engine/Graphics/RenderTargetPool.cpp @@ -108,5 +108,5 @@ void RenderTargetPool::Release(GPUTexture* rt) } } - LOG(Error, "Trying to release temporary render target which has not been registred in service!"); + LOG(Error, "Trying to release temporary render target which has not been registered in service!"); } diff --git a/Source/Engine/Graphics/Shaders/GPUShader.h b/Source/Engine/Graphics/Shaders/GPUShader.h index 79b165396..76c8df546 100644 --- a/Source/Engine/Graphics/Shaders/GPUShader.h +++ b/Source/Engine/Graphics/Shaders/GPUShader.h @@ -97,7 +97,7 @@ public: /// /// Gets the vertex shader. /// - /// Thr shader program name. + /// The shader program name. /// The shader permutation index. /// The shader object. API_FUNCTION() FORCE_INLINE GPUShaderProgramVS* GetVS(const StringAnsiView& name, int32 permutationIndex = 0) const @@ -108,7 +108,7 @@ public: /// /// Gets the hull shader. /// - /// Thr shader program name. + /// The shader program name. /// The shader permutation index. /// The shader object. API_FUNCTION() FORCE_INLINE GPUShaderProgramHS* GetHS(const StringAnsiView& name, int32 permutationIndex = 0) const @@ -119,7 +119,7 @@ public: /// /// Gets domain shader. /// - /// Thr shader program name. + /// The shader program name. /// The shader permutation index. /// The shader object. API_FUNCTION() FORCE_INLINE GPUShaderProgramDS* GetDS(const StringAnsiView& name, int32 permutationIndex = 0) const @@ -130,7 +130,7 @@ public: /// /// Gets the geometry shader. /// - /// Thr shader program name. + /// The shader program name. /// The shader permutation index. /// The shader object. API_FUNCTION() FORCE_INLINE GPUShaderProgramGS* GetGS(const StringAnsiView& name, int32 permutationIndex = 0) const @@ -141,7 +141,7 @@ public: /// /// Gets the pixel shader. /// - /// Thr shader program name. + /// The shader program name. /// The shader permutation index. /// The shader object. API_FUNCTION() FORCE_INLINE GPUShaderProgramPS* GetPS(const StringAnsiView& name, int32 permutationIndex = 0) const @@ -152,7 +152,7 @@ public: /// /// Gets the compute shader. /// - /// Thr shader program name. + /// The shader program name. /// The shader permutation index. /// The shader object. API_FUNCTION() FORCE_INLINE GPUShaderProgramCS* GetCS(const StringAnsiView& name, int32 permutationIndex = 0) const @@ -176,7 +176,7 @@ public: /// /// Determines whether the specified shader program is in the shader. /// - /// Thr shader program name. + /// The shader program name. /// The shader permutation index. /// true if the shader is valid; otherwise, false. FORCE_INLINE bool HasShader(const StringAnsiView& name, int32 permutationIndex = 0) const diff --git a/Source/Engine/Graphics/Textures/GPUTexture.h b/Source/Engine/Graphics/Textures/GPUTexture.h index d0ae27e7f..8b5385f9e 100644 --- a/Source/Engine/Graphics/Textures/GPUTexture.h +++ b/Source/Engine/Graphics/Textures/GPUTexture.h @@ -483,7 +483,7 @@ public: /// /// Creates new staging readback texture with the same dimensions and properties as a source texture (but without a data transferred; warning: caller must delete object). /// - /// Thr staging readback texture. + /// The staging readback texture. GPUTexture* ToStagingReadback() const; /// diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUTimerQueryDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUTimerQueryDX11.cpp index 63cd9bcb4..5df4a45a5 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUTimerQueryDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUTimerQueryDX11.cpp @@ -118,7 +118,7 @@ float GPUTimerQueryDX11::GetResult() if (!SingleShotLog) { SingleShotLog = true; - LOG(Warning, "Unrealiable GPU timer query detected."); + LOG(Warning, "Unreliable GPU timer query detected."); } #endif } diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp index ce36a7347..4d1bd3e17 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp @@ -216,7 +216,7 @@ uint64 GPUContextDX12::Execute(bool waitForCompletion) ASSERT(_currentAllocator != nullptr); auto queue = _device->GetCommandQueue(); - // Flush reaming and buffered commands + // Flush remaining and buffered commands FlushState(); _currentState = nullptr; diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp index 317a6e9aa..944833ca3 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp @@ -391,7 +391,7 @@ bool GPUDeviceDX12::Init() { // Descriptor tables D3D12_DESCRIPTOR_RANGE r[2]; - // TODO: separate ranges for pixel/vertex visiblity and one shared for all? + // TODO: separate ranges for pixel/vertex visibility and one shared for all? { D3D12_DESCRIPTOR_RANGE& range = r[0]; range.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; diff --git a/Source/Engine/GraphicsDevice/DirectX/IncludeDirectXHeaders.h b/Source/Engine/GraphicsDevice/DirectX/IncludeDirectXHeaders.h index 8351deb71..ea621c22a 100644 --- a/Source/Engine/GraphicsDevice/DirectX/IncludeDirectXHeaders.h +++ b/Source/Engine/GraphicsDevice/DirectX/IncludeDirectXHeaders.h @@ -8,7 +8,7 @@ #include "Engine/Platform/Win32/IncludeWindowsHeaders.h" #include "Engine/Platform/Windows/ComPtr.h" -// Helper define to dispose the COM object with reaming references counter checking +// Helper define to dispose the COM object with remaining references counter checking #define DX_SAFE_RELEASE_CHECK(x, refs) if(x) { auto res = (x)->Release(); (x) = nullptr; CHECK(res == refs); } #endif diff --git a/Source/Engine/GraphicsDevice/Vulkan/CmdBufferVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/CmdBufferVulkan.cpp index c327fd32a..f9a39574c 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/CmdBufferVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/CmdBufferVulkan.cpp @@ -44,7 +44,7 @@ void CmdBufferVulkan::End() ASSERT(IsOutsideRenderPass()); #if GPU_ALLOW_PROFILE_EVENTS - // End reaming events + // End remaining events while (_eventsBegin--) vkCmdEndDebugUtilsLabelEXT(GetHandle()); #endif diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp index ea8fa6502..e8f770831 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp @@ -1155,7 +1155,7 @@ void GPUContextVulkan::FlushState() void GPUContextVulkan::Flush() { - // Flush reaming and buffered commands + // Flush remaining and buffered commands FlushState(); _currentState = nullptr; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index 85fc3dcd0..5457872d5 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -1363,23 +1363,7 @@ PixelFormat GPUDeviceVulkan::GetClosestSupportedPixelFormat(PixelFormat format, if (flags & GPUTextureFlags::UnorderedAccess) wantedFeatureFlags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; - // Check actual device for format support - const auto isSupported = [&](VkFormat vkFormat) - { - VkFormatProperties props; - vkGetPhysicalDeviceFormatProperties(Adapter->Gpu, vkFormat, &props); - const VkFormatFeatureFlags featureFlags = optimalTiling ? props.optimalTilingFeatures : props.linearTilingFeatures; - if ((featureFlags & wantedFeatureFlags) != wantedFeatureFlags) - return false; - - //VkImageFormatProperties imageProps; - //vkGetPhysicalDeviceImageFormatProperties(Adapter->Gpu, vkFormat, , &imageProps); - - return true; - }; - - VkFormat vkFormat = RenderToolsVulkan::ToVulkanFormat(format); - if (!isSupported(vkFormat)) + if (!IsVkFormatSupported(RenderToolsVulkan::ToVulkanFormat(format), wantedFeatureFlags, optimalTiling)) { // Special case for depth-stencil formats if (flags & GPUTextureFlags::DepthStencil) @@ -1389,7 +1373,7 @@ PixelFormat GPUDeviceVulkan::GetClosestSupportedPixelFormat(PixelFormat format, // Spec guarantees at least one depth-only, and one depth-stencil format to be supported if (hasStencil) { - if (isSupported(VK_FORMAT_D32_SFLOAT_S8_UINT)) + if (IsVkFormatSupported(VK_FORMAT_D32_SFLOAT_S8_UINT, wantedFeatureFlags, optimalTiling)) format = PixelFormat::D32_Float; else format = PixelFormat::D24_UNorm_S8_UInt; @@ -1493,6 +1477,20 @@ bool GPUDeviceVulkan::SaveValidationCache() #endif +bool GPUDeviceVulkan::IsVkFormatSupported(VkFormat vkFormat, VkFormatFeatureFlags wantedFeatureFlags, bool optimalTiling) const +{ + VkFormatProperties props; + vkGetPhysicalDeviceFormatProperties(Adapter->Gpu, vkFormat, &props); + const VkFormatFeatureFlags featureFlags = optimalTiling ? props.optimalTilingFeatures : props.linearTilingFeatures; + if ((featureFlags & wantedFeatureFlags) != wantedFeatureFlags) + return false; + + //VkImageFormatProperties imageProps; + //vkGetPhysicalDeviceImageFormatProperties(Adapter->Gpu, vkFormat, , &imageProps); + + return true; +} + GPUContext* GPUDeviceVulkan::GetMainContext() { return reinterpret_cast(MainContext); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h index 9bab15dda..ba972932b 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h @@ -720,6 +720,10 @@ public: #endif +private: + + bool IsVkFormatSupported(VkFormat vkFormat, VkFormatFeatureFlags wantedFeatureFlags, bool optimalTiling) const; + public: // [GPUDevice] diff --git a/Source/Engine/GraphicsDevice/Vulkan/RenderToolsVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/RenderToolsVulkan.h index b18ae9c1b..cf9b7e9cf 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/RenderToolsVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/RenderToolsVulkan.h @@ -232,10 +232,10 @@ public: } /// - /// Converts Flax comparision function to the Vulkan comparision operation. + /// Converts Flax comparison function to the Vulkan comparison operation. /// - /// The Flax comparision function. - /// The Vulkan comparision operation. + /// The Flax comparison function. + /// The Vulkan comparison operation. static FORCE_INLINE VkCompareOp ToVulkanCompareOp(const ComparisonFunc value) { return ComparisonFuncToVkCompareOp[(int32)value]; diff --git a/Source/Engine/Input/Enums.h b/Source/Engine/Input/Enums.h index 764a17922..e397dd3c2 100644 --- a/Source/Engine/Input/Enums.h +++ b/Source/Engine/Input/Enums.h @@ -8,7 +8,7 @@ #define MAX_GAMEPADS 8 /// -/// Hardware mouse cursor behaviour. +/// Hardware mouse cursor behavior. /// API_ENUM() enum class CursorLockMode { diff --git a/Source/Engine/Input/Mouse.h b/Source/Engine/Input/Mouse.h index 15fa17e6d..94875ea3a 100644 --- a/Source/Engine/Input/Mouse.h +++ b/Source/Engine/Input/Mouse.h @@ -124,7 +124,7 @@ public: virtual void SetMousePosition(const Vector2& newPosition) = 0; /// - /// Called when mouse cursor gets moved by the application. Invalidates the previous cached mouse position to prevent mouse jitter when locking the cursor programatically. + /// Called when mouse cursor gets moved by the application. Invalidates the previous cached mouse position to prevent mouse jitter when locking the cursor programmatically. /// /// The new mouse position. void OnMouseMoved(const Vector2& newPosition) diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index cf3e71f13..3d6450716 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -146,8 +146,32 @@ void AnimatedModel::GetNodeTransformation(const StringView& nodeName, Matrix& no GetNodeTransformation(SkinnedModel ? SkinnedModel->FindNode(nodeName) : -1, nodeTransformation, worldSpace); } +#define CHECK_ANIM_GRAPH_PARAM_ACCESS() \ + if (!AnimationGraph) \ + { \ + LOG(Warning, "Missing animation graph for animated model '{0}'", ToString()); \ + return; \ + } \ + if (AnimationGraph->WaitForLoaded()) \ + { \ + LOG(Warning, "Failed to load animation graph for animated model '{0}'", ToString()); \ + return; \ + } +#define CHECK_ANIM_GRAPH_PARAM_ACCESS_RESULT(result) \ + if (!AnimationGraph) \ + { \ + LOG(Warning, "Missing animation graph for animated model '{0}'", ToString()); \ + return result; \ + } \ + if (AnimationGraph->WaitForLoaded()) \ + { \ + LOG(Warning, "Failed to load animation graph for animated model '{0}'", ToString()); \ + return result; \ + } + AnimGraphParameter* AnimatedModel::GetParameter(const StringView& name) { + CHECK_ANIM_GRAPH_PARAM_ACCESS_RESULT(nullptr); for (auto& param : GraphInstance.Parameters) { if (param.Name == name) @@ -159,6 +183,7 @@ AnimGraphParameter* AnimatedModel::GetParameter(const StringView& name) Variant AnimatedModel::GetParameterValue(const StringView& name) { + CHECK_ANIM_GRAPH_PARAM_ACCESS_RESULT(Variant::Null); for (auto& param : GraphInstance.Parameters) { if (param.Name == name) @@ -170,6 +195,7 @@ Variant AnimatedModel::GetParameterValue(const StringView& name) void AnimatedModel::SetParameterValue(const StringView& name, const Variant& value) { + CHECK_ANIM_GRAPH_PARAM_ACCESS(); for (auto& param : GraphInstance.Parameters) { if (param.Name == name) @@ -183,6 +209,7 @@ void AnimatedModel::SetParameterValue(const StringView& name, const Variant& val Variant AnimatedModel::GetParameterValue(const Guid& id) { + CHECK_ANIM_GRAPH_PARAM_ACCESS_RESULT(Variant::Null); for (auto& param : GraphInstance.Parameters) { if (param.Identifier == id) @@ -194,6 +221,7 @@ Variant AnimatedModel::GetParameterValue(const Guid& id) void AnimatedModel::SetParameterValue(const Guid& id, const Variant& value) { + CHECK_ANIM_GRAPH_PARAM_ACCESS(); for (auto& param : GraphInstance.Parameters) { if (param.Identifier == id) diff --git a/Source/Engine/Level/Actors/StaticModel.cpp b/Source/Engine/Level/Actors/StaticModel.cpp index cba13a601..a884c9707 100644 --- a/Source/Engine/Level/Actors/StaticModel.cpp +++ b/Source/Engine/Level/Actors/StaticModel.cpp @@ -98,7 +98,7 @@ void StaticModel::SetVertexColor(int32 lodIndex, int32 meshIndex, int32 vertexIn { if (!Model || Model->WaitForLoaded()) { - LOG(Warning, "Cannot set vertex color if model is missing or faied to load."); + LOG(Warning, "Cannot set vertex color if model is missing or failed to load."); return; } diff --git a/Source/Engine/Level/Level.cpp b/Source/Engine/Level/Level.cpp index 7d257e104..53e400009 100644 --- a/Source/Engine/Level/Level.cpp +++ b/Source/Engine/Level/Level.cpp @@ -993,7 +993,7 @@ bool Level::loadScene(rapidjson_flax::Value& data, int32 engineBuild, bool autoI } // Synchronize prefab instances (prefab may have new objects added or some removed so deserialized instances need to synchronize with it) - // TODO: resave and force sync scenes durign game cooking so this step could be skipped in game + // TODO: resave and force sync scenes during game cooking so this step could be skipped in game Scripting::ObjectsLookupIdMapping.Set(&modifier.Value->IdsMapping); SceneObjectsFactory::SynchronizePrefabInstances(*sceneObjects.Value, actorToRemovedObjectsData, modifier.Value); Scripting::ObjectsLookupIdMapping.Set(nullptr); @@ -1005,7 +1005,7 @@ bool Level::loadScene(rapidjson_flax::Value& data, int32 engineBuild, bool autoI if (obj && obj->GetParent() == nullptr) { sceneObjects->At(i) = nullptr; - LOG(Warning, "Scene object {0} {1} has missing parent objct after scene load. Removing it.", obj->GetID(), obj->ToString()); + LOG(Warning, "Scene object {0} {1} has missing parent object after scene load. Removing it.", obj->GetID(), obj->ToString()); obj->DeleteObject(); } } diff --git a/Source/Engine/Level/Prefabs/Prefab.Apply.cpp b/Source/Engine/Level/Prefabs/Prefab.Apply.cpp index 84bd17962..4305046e0 100644 --- a/Source/Engine/Level/Prefabs/Prefab.Apply.cpp +++ b/Source/Engine/Level/Prefabs/Prefab.Apply.cpp @@ -509,7 +509,7 @@ bool FindCyclicReferences(Actor* actor, const Guid& prefabRootId) bool Prefab::ApplyAll(Actor* targetActor) { - // TODO: use more cached dictionaries and other collections containers to prevent memory allocations during apply (optimize fo apply 10 times per second the same prefab on many changes in editor) + // TODO: use more cached dictionaries and other collections containers to prevent memory allocations during apply (optimize for apply 10 times per second the same prefab on many changes in editor) PROFILE_CPU(); const auto startTime = DateTime::NowUTC(); diff --git a/Source/Engine/Navigation/NavMeshBuilder.cpp b/Source/Engine/Navigation/NavMeshBuilder.cpp index 3026af66a..fc0e9d51c 100644 --- a/Source/Engine/Navigation/NavMeshBuilder.cpp +++ b/Source/Engine/Navigation/NavMeshBuilder.cpp @@ -9,8 +9,9 @@ #include "NavLink.h" #include "NavModifierVolume.h" #include "NavMeshRuntime.h" +#include "Engine/Core/Log.h" #include "Engine/Core/Math/BoundingBox.h" -#include "Engine/Core/Math/VectorInt.h" +#include "Engine/Core/Math/Int3.h" #include "Engine/Physics/Colliders/BoxCollider.h" #include "Engine/Physics/Colliders/SphereCollider.h" #include "Engine/Physics/Colliders/CapsuleCollider.h" @@ -22,7 +23,6 @@ #include "Engine/Level/Scene/Scene.h" #include "Engine/Level/Level.h" #include "Engine/Level/SceneQuery.h" -#include "Engine/Core/Log.h" #include #include #include diff --git a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h index a93c50ec2..42aca7dbb 100644 --- a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h +++ b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h @@ -100,7 +100,7 @@ public: public: /// - /// Determinates whenever this emitter uses lights rendering. + /// Determines whenever this emitter uses lights rendering. /// /// True if emitter uses lights rendering, otherwise false. FORCE_INLINE bool UsesLightRendering() const diff --git a/Source/Engine/Particles/Graph/ParticleEmitterGraph.h b/Source/Engine/Particles/Graph/ParticleEmitterGraph.h index 0f92d5f22..76af84011 100644 --- a/Source/Engine/Particles/Graph/ParticleEmitterGraph.h +++ b/Source/Engine/Particles/Graph/ParticleEmitterGraph.h @@ -103,7 +103,7 @@ protected: public: /// - /// The Particle Emitter Graph data version number. Used to sync the Particle Emitter Graph data with the instances state. Handles graph reloads to enure data is valid. + /// The Particle Emitter Graph data version number. Used to sync the Particle Emitter Graph data with the instances state. Handles graph reloads to ensure data is valid. /// uint32 Version = 0; diff --git a/Source/Engine/Particles/ParticleManager.cpp b/Source/Engine/Particles/ParticleManager.cpp index 0e5640545..40cebd892 100644 --- a/Source/Engine/Particles/ParticleManager.cpp +++ b/Source/Engine/Particles/ParticleManager.cpp @@ -1172,7 +1172,7 @@ void ParticleManagerService::Update() // Update bounds after first system update updateBounds = true; } - // TODO: if using fixed timestep quantize the dt and accumulate reaming part for the next update? + // TODO: if using fixed timestep quantize the dt and accumulate remaining part for the next update? if (dt <= 1.0f / 240.0f) continue; dt *= effect->SimulationSpeed; diff --git a/Source/Engine/Particles/ParticlesSimulation.cpp b/Source/Engine/Particles/ParticlesSimulation.cpp index bbba833ff..0b6e3691d 100644 --- a/Source/Engine/Particles/ParticlesSimulation.cpp +++ b/Source/Engine/Particles/ParticlesSimulation.cpp @@ -115,7 +115,7 @@ int32 ParticleSystemInstance::GetParticlesCount() const const auto desc = GPUBufferDescription::Buffer(Emitters.Count() * sizeof(uint32), GPUBufferFlags::None, PixelFormat::Unknown, nullptr, sizeof(uint32), GPUResourceUsage::StagingReadback); if (GPUParticlesCountReadback->Init(desc)) { - LOG(Error, "Failed to create GPU particles coun readback buffer."); + LOG(Error, "Failed to create GPU particles count readback buffer."); } } diff --git a/Source/Engine/Physics/Colliders/Collider.h b/Source/Engine/Physics/Colliders/Collider.h index 8c6eeb59a..c836a7886 100644 --- a/Source/Engine/Physics/Colliders/Collider.h +++ b/Source/Engine/Physics/Colliders/Collider.h @@ -175,7 +175,7 @@ public: } /// - /// Attaches collider to the the specified rigid body. + /// Attaches collider to the specified rigid body. /// /// The rigid body. void Attach(RigidBody* rigidBody); diff --git a/Source/Engine/Physics/CollisionCooking.cpp b/Source/Engine/Physics/CollisionCooking.cpp index ea0f2f442..070f49936 100644 --- a/Source/Engine/Physics/CollisionCooking.cpp +++ b/Source/Engine/Physics/CollisionCooking.cpp @@ -13,7 +13,7 @@ #define ENSURE_CAN_COOK \ if (Physics::GetCooking() == nullptr) \ { \ - LOG(Warning, "Physics collisions cooking is disabled at runtime. Enable Physics Settigns option SupportCookingAtRuntime to use terrain generation at runtime."); \ + LOG(Warning, "Physics collisions cooking is disabled at runtime. Enable Physics Settings option SupportCookingAtRuntime to use terrain generation at runtime."); \ return true; \ } diff --git a/Source/Engine/Platform/Base/PlatformBase.cpp b/Source/Engine/Platform/Base/PlatformBase.cpp index 2a117dc34..7401dc3bf 100644 --- a/Source/Engine/Platform/Base/PlatformBase.cpp +++ b/Source/Engine/Platform/Base/PlatformBase.cpp @@ -19,6 +19,7 @@ #include "Engine/Engine/CommandLine.h" #include "Engine/Engine/Engine.h" #include "Engine/Utilities/StringConverter.h" +#include "Engine/Platform/BatteryInfo.h" #include // Check types sizes @@ -381,6 +382,11 @@ void PlatformBase::SetHighDpiAwarenessEnabled(bool enable) { } +BatteryInfo PlatformBase::GetBatteryInfo() +{ + return BatteryInfo(); +} + int32 PlatformBase::GetDpi() { return 96; diff --git a/Source/Engine/Platform/Base/PlatformBase.h b/Source/Engine/Platform/Base/PlatformBase.h index f7162b587..d2d34c88f 100644 --- a/Source/Engine/Platform/Base/PlatformBase.h +++ b/Source/Engine/Platform/Base/PlatformBase.h @@ -11,6 +11,7 @@ struct CPUInfo; struct MemoryStats; struct ProcessMemoryStats; struct CreateWindowSettings; +struct BatteryInfo; // ReSharper disable CppFunctionIsNotImplemented @@ -548,6 +549,11 @@ public: /// static void SetHighDpiAwarenessEnabled(bool enable); + /// + /// Gets the battery information. + /// + API_PROPERTY() static BatteryInfo GetBatteryInfo(); + /// /// Gets the screen DPI setting. /// diff --git a/Source/Engine/Platform/Base/WindowsManager.cpp b/Source/Engine/Platform/Base/WindowsManager.cpp index b49cbd058..75082c4f9 100644 --- a/Source/Engine/Platform/Base/WindowsManager.cpp +++ b/Source/Engine/Platform/Base/WindowsManager.cpp @@ -77,7 +77,7 @@ void WindowsManagerService::Update() void WindowsManagerService::Dispose() { - // Close reaming windows + // Close remaining windows WindowsManager::WindowsLocker.Lock(); auto windows = WindowsManager::Windows; for (auto& win : windows) diff --git a/Source/Engine/Platform/BatteryInfo.h b/Source/Engine/Platform/BatteryInfo.h new file mode 100644 index 000000000..2ed6b5cac --- /dev/null +++ b/Source/Engine/Platform/BatteryInfo.h @@ -0,0 +1,49 @@ +// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. + +#pragma once + +#include "Engine/Core/Types/BaseTypes.h" + +/// +/// Contains information about power supply (battery). +/// +API_STRUCT() struct BatteryInfo +{ +DECLARE_SCRIPTING_TYPE_MINIMAL(BatteryInfo); + + /// + /// Power supply status. + /// + API_ENUM() enum class States + { + /// + /// Unknown status. + /// + Unknown, + + /// + /// Power supply is connected and battery is charging. + /// + BatteryCharging, + + /// + /// Device is running on a battery. + /// + BatteryDischarging, + + /// + /// Device is connected to the stable power supply (AC). + /// + Connected, + }; + + /// + /// Power supply state. + /// + API_FIELD() BatteryInfo::States State = BatteryInfo::States::Unknown; + + /// + /// Battery percentage left (normalized to 0-1 range). + /// + API_FIELD() float BatteryLifePercent = 1.0f; +}; diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.cpp b/Source/Engine/Platform/Linux/LinuxPlatform.cpp index f070c05f1..a68e40f72 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.cpp +++ b/Source/Engine/Platform/Linux/LinuxPlatform.cpp @@ -346,7 +346,7 @@ static int X11_MessageBoxCreateWindow(MessageBoxData* data) { windowdata = data->Parent; windowdataWin = (X11::Window)windowdata->GetNativePtr(); - // TODO: place popup on the the screen that parent window is + // TODO: place popup on the screen that parent window is data->screen = X11_DefaultScreen(display); } else diff --git a/Source/Engine/Platform/Linux/LinuxWindow.cpp b/Source/Engine/Platform/Linux/LinuxWindow.cpp index 0ed5341ec..768df66bd 100644 --- a/Source/Engine/Platform/Linux/LinuxWindow.cpp +++ b/Source/Engine/Platform/Linux/LinuxWindow.cpp @@ -10,7 +10,7 @@ #include "Engine/Core/Log.h" #include "Engine/Core/Math/Math.h" #include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/VectorInt.h" +#include "Engine/Core/Math/Int2.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Utilities/StringConverter.h" diff --git a/Source/Engine/Platform/Win32/Win32Platform.cpp b/Source/Engine/Platform/Win32/Win32Platform.cpp index fc815b6ba..129ff4249 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.cpp +++ b/Source/Engine/Platform/Win32/Win32Platform.cpp @@ -5,6 +5,7 @@ #include "Engine/Platform/Platform.h" #include "Engine/Platform/MemoryStats.h" #include "Engine/Platform/CPUInfo.h" +#include "Engine/Platform/BatteryInfo.h" #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Types/String.h" #include "Engine/Core/Math/Math.h" @@ -15,6 +16,7 @@ #include #include #include +#include #pragma comment(lib, "Iphlpapi.lib") namespace @@ -308,6 +310,21 @@ bool Win32Platform::Is64BitPlatform() #endif } +BatteryInfo Win32Platform::GetBatteryInfo() +{ + BatteryInfo info; + SYSTEM_POWER_STATUS status; + GetSystemPowerStatus(&status); + info.BatteryLifePercent = (float)status.BatteryLifePercent / 255.0f; + if (status.BatteryFlag & 8) + info.State = BatteryInfo::States::BatteryCharging; + else if (status.BatteryFlag & 1 || status.BatteryFlag & 2 || status.BatteryFlag & 4) + info.State = BatteryInfo::States::BatteryDischarging; + else if (status.ACLineStatus == 1 || status.BatteryFlag & 128) + info.State = BatteryInfo::States::Connected; + return info; +} + CPUInfo Win32Platform::GetCPUInfo() { return CpuInfo; diff --git a/Source/Engine/Platform/Win32/Win32Platform.h b/Source/Engine/Platform/Win32/Win32Platform.h index 52ddeb25b..b6a4cdd62 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.h +++ b/Source/Engine/Platform/Win32/Win32Platform.h @@ -43,6 +43,7 @@ public: _aligned_free(ptr); } static bool Is64BitPlatform(); + static BatteryInfo GetBatteryInfo(); static CPUInfo GetCPUInfo(); static int32 GetCacheLineSize(); static MemoryStats GetMemoryStats(); diff --git a/Source/Engine/Platform/Windows/WindowsFileSystem.cpp b/Source/Engine/Platform/Windows/WindowsFileSystem.cpp index 0c0d9788c..7c6b04fef 100644 --- a/Source/Engine/Platform/Windows/WindowsFileSystem.cpp +++ b/Source/Engine/Platform/Windows/WindowsFileSystem.cpp @@ -231,7 +231,9 @@ bool WindowsFileSystem::ShowOpenFileDialog(Window* parentWindow, const StringVie while (*ptr) { filenames.Add(directory / ptr); - ptr += (lstrlenW(ptr) + 1); + ptr += lstrlenW(ptr); + if (multiSelect) + ptr++; } result = false; @@ -276,7 +278,9 @@ bool WindowsFileSystem::ShowSaveFileDialog(Window* parentWindow, const StringVie while (*ptr) { filenames.Add(directory / ptr); - ptr += (lstrlenW(ptr) + 1); + ptr += lstrlenW(ptr); + if (multiSelect) + ptr++; } result = false; diff --git a/Source/Engine/Render2D/Font.cpp b/Source/Engine/Render2D/Font.cpp index c9dd7b55c..209989d4f 100644 --- a/Source/Engine/Render2D/Font.cpp +++ b/Source/Engine/Render2D/Font.cpp @@ -33,7 +33,7 @@ Font::~Font() void Font::GetCharacter(Char c, FontCharacterEntry& result) { - // Try get character or cache it if cannot find + // Try to get the character or cache it if cannot be found if (!_characters.TryGet(c, result)) { // This thread race condition may happen in editor but in game we usually do all stuff with fonts on main thread (chars caching) diff --git a/Source/Engine/Render2D/FontAsset.cpp b/Source/Engine/Render2D/FontAsset.cpp index cf2571e4a..8b14b1cfc 100644 --- a/Source/Engine/Render2D/FontAsset.cpp +++ b/Source/Engine/Render2D/FontAsset.cpp @@ -55,7 +55,7 @@ void FontAsset::unload(bool isReloading) // Ensure to cleanup child font objects if (_fonts.HasItems()) { - LOG(Warning, "Font asset {0} is unloading but has {1} reaming font objects created", ToString(), _fonts.Count()); + LOG(Warning, "Font asset {0} is unloading but has {1} remaining font objects created", ToString(), _fonts.Count()); for (auto font : _fonts) { font->_asset = nullptr; diff --git a/Source/Engine/Render2D/FontManager.cpp b/Source/Engine/Render2D/FontManager.cpp index f05cd7280..ec7a61257 100644 --- a/Source/Engine/Render2D/FontManager.cpp +++ b/Source/Engine/Render2D/FontManager.cpp @@ -214,7 +214,7 @@ bool FontManager::AddNewEntry(Font* font, Char c, FontCharacterEntry& entry) return false; } - // Copy glyph data after rasterize (row by row) + // Copy glyph data after rasterization (row by row) for (int32 row = 0; row < glyphHeight; row++) { Platform::MemoryCopy(&GlyphImageData[row * glyphWidth], &bitmap->buffer[row * bitmap->pitch], glyphWidth); diff --git a/Source/Engine/Renderer/AmbientOcclusionPass.h b/Source/Engine/Renderer/AmbientOcclusionPass.h index 81d64a0e4..bfaf4bc19 100644 --- a/Source/Engine/Renderer/AmbientOcclusionPass.h +++ b/Source/Engine/Renderer/AmbientOcclusionPass.h @@ -60,7 +60,7 @@ private: float ShadowMultiplier; // [0.0, 5.0] Effect strength linear multiplier float ShadowPower; // [0.5, 5.0] Effect strength pow modifier float HorizonAngleThreshold; // [0.0, 0.2] Limits self-shadowing (makes the sampling area less of a hemisphere, more of a spherical cone, to avoid self-shadowing and various artifacts due to low tessellation and depth buffer imprecision, etc.) - float FadeOutFrom; // [0.0, ~ ] Distance to start start fading out the effect. + float FadeOutFrom; // [0.0, ~ ] Distance to start fading out the effect. float FadeOutTo; // [0.0, ~ ] Distance at which the effect is faded out. int QualityLevel; // [ 0, ] Effect quality; 0 - low, 1 - medium, 2 - high, 3 - very high; each quality level is roughly 2x more costly than the previous, except the q3 which is variable but, in general, above q2. int BlurPassCount; // [ 0, 6] Number of edge-sensitive smart blur passes to apply. Quality 0 is an exception with only one 'dumb' blur pass used. diff --git a/Source/Engine/Renderer/EyeAdaptationPass.cpp b/Source/Engine/Renderer/EyeAdaptationPass.cpp index 754c1489f..a85e0a72b 100644 --- a/Source/Engine/Renderer/EyeAdaptationPass.cpp +++ b/Source/Engine/Renderer/EyeAdaptationPass.cpp @@ -2,6 +2,7 @@ #include "EyeAdaptationPass.h" #include "RenderList.h" +#include "Engine/Core/Math/Int2.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Content.h" #include "Engine/Graphics/PostProcessBase.h" diff --git a/Source/Engine/Renderer/MotionBlurPass.cpp b/Source/Engine/Renderer/MotionBlurPass.cpp index f25d14c51..46b2ccd8f 100644 --- a/Source/Engine/Renderer/MotionBlurPass.cpp +++ b/Source/Engine/Renderer/MotionBlurPass.cpp @@ -57,11 +57,11 @@ bool MotionBlurPass::Init() // Prepare formats for the buffers auto format = MOTION_VECTORS_PIXEL_FORMAT; - if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(format).Support, (FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))) + if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(format).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) { - if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R32G32_Float).Support, (FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))) + if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R32G32_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) format = PixelFormat::R32G32_Float; - else if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R16G16B16A16_Float).Support, (FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))) + else if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R16G16B16A16_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) format = PixelFormat::R16G16B16A16_Float; else format = PixelFormat::R32G32B32A32_Float; @@ -285,7 +285,7 @@ void MotionBlurPass::Render(RenderContext& renderContext, GPUTexture*& input, GP PROFILE_GPU_CPU("Motion Blur"); // Setup shader inputs - const int32 maxBlurSize = (int32)((float)motionVectorsHeight * 0.05f); + const int32 maxBlurSize = Math::Max((int32)((float)motionVectorsHeight * 0.05f), 1); const int32 tileSize = Math::AlignUp(maxBlurSize, 8); const float timeScale = renderContext.Task->View.IsOfflinePass ? 1.0f : 1.0f / Time::Draw.UnscaledDeltaTime.GetTotalSeconds() / 60.0f; // 60fps as a reference Data data; diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index 5ec9d6446..11812a45c 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -6,6 +6,7 @@ #include "Engine/Graphics/Graphics.h" #include "Engine/Graphics/RenderBuffers.h" #include "Engine/Content/Content.h" +#include "Engine/Graphics/PixelFormatExtensions.h" #if USE_EDITOR #include "Engine/Renderer/Lightmaps.h" #endif @@ -77,6 +78,19 @@ bool ShadowsPass::Init() _shader.Get()->OnReloading.Bind(this); #endif + // If GPU doesn't support linear sampling for the shadow map then fallback to the single sample on lowest quality + const auto formatTexture = PixelFormatExtensions::FindShaderResourceFormat(SHADOW_MAPS_FORMAT, false); + const auto formatFeaturesDepth = GPUDevice::Instance->GetFormatFeatures(SHADOW_MAPS_FORMAT); + const auto formatFeaturesTexture = GPUDevice::Instance->GetFormatFeatures(formatTexture); + _supportsShadows = FORMAT_FEATURES_ARE_SUPPORTED(formatFeaturesDepth.Support, FormatSupport::DepthStencil | FormatSupport::Texture2D) + && FORMAT_FEATURES_ARE_SUPPORTED(formatFeaturesTexture.Support, FormatSupport::ShaderSample | FormatSupport::ShaderSampleComparison); + if (!_supportsShadows) + { + LOG(Warning, "GPU doesn't support shadows rendering"); + LOG(Warning, "Format: {0} features support: {1}", (int32)SHADOW_MAPS_FORMAT, (uint32)formatFeaturesDepth.Support); + LOG(Warning, "Format: {0} features support: {1}", (int32)formatTexture, (uint32)formatFeaturesTexture.Support); + } + return false; } @@ -130,24 +144,27 @@ void ShadowsPass::updateShadowMapSize() // Select new size _currentShadowMapsQuality = Graphics::ShadowMapsQuality; - switch (_currentShadowMapsQuality) + if (_supportsShadows) { - case Quality::Ultra: - newSizeCSM = 2048; - newSizeCube = 1024; - break; - case Quality::High: - newSizeCSM = 1024; - newSizeCube = 1024; - break; - case Quality::Medium: - newSizeCSM = 1024; - newSizeCube = 512; - break; - case Quality::Low: - newSizeCSM = 512; - newSizeCube = 256; - break; + switch (_currentShadowMapsQuality) + { + case Quality::Ultra: + newSizeCSM = 2048; + newSizeCube = 1024; + break; + case Quality::High: + newSizeCSM = 1024; + newSizeCube = 1024; + break; + case Quality::Medium: + newSizeCSM = 1024; + newSizeCube = 512; + break; + case Quality::Low: + newSizeCSM = 512; + newSizeCube = 256; + break; + } } // Check if size will change @@ -194,7 +211,7 @@ bool ShadowsPass::CanRenderShadow(RenderContext& renderContext, const RendererPo const float fadeDistance = Math::Max(light.ShadowsFadeDistance, 0.1f); const float fade = 1 - Math::Saturate((dstLightToView - light.Radius - light.ShadowsDistance + fadeDistance) / fadeDistance); - return fade > ZeroTolerance; + return fade > ZeroTolerance && _supportsShadows; } bool ShadowsPass::CanRenderShadow(RenderContext& renderContext, const RendererSpotLightData& light) @@ -206,12 +223,12 @@ bool ShadowsPass::CanRenderShadow(RenderContext& renderContext, const RendererSp const float fadeDistance = Math::Max(light.ShadowsFadeDistance, 0.1f); const float fade = 1 - Math::Saturate((dstLightToView - light.Radius - light.ShadowsDistance + fadeDistance) / fadeDistance); - return fade > ZeroTolerance; + return fade > ZeroTolerance && _supportsShadows; } bool ShadowsPass::CanRenderShadow(RenderContext& renderContext, const RendererDirectionalLightData& light) { - return true; + return _supportsShadows; } void ShadowsPass::Prepare(RenderContext& renderContext, GPUContext* context) diff --git a/Source/Engine/Renderer/ShadowsPass.h b/Source/Engine/Renderer/ShadowsPass.h index 8deef8258..3d3190670 100644 --- a/Source/Engine/Renderer/ShadowsPass.h +++ b/Source/Engine/Renderer/ShadowsPass.h @@ -25,6 +25,7 @@ private: GPUPipelineStatePermutationsPs(Quality::MAX) * 2 * 2> _psShadowDir; GPUPipelineStatePermutationsPs(Quality::MAX) * 2> _psShadowPoint; GPUPipelineStatePermutationsPs(Quality::MAX) * 2> _psShadowSpot; + bool _supportsShadows; // Shadow maps stuff int32 _shadowMapsSizeCSM; diff --git a/Source/Engine/Scripting/Attributes/Editor/EditorOrderAttribute.cs b/Source/Engine/Scripting/Attributes/Editor/EditorOrderAttribute.cs index 506666def..5b783b514 100644 --- a/Source/Engine/Scripting/Attributes/Editor/EditorOrderAttribute.cs +++ b/Source/Engine/Scripting/Attributes/Editor/EditorOrderAttribute.cs @@ -27,7 +27,7 @@ namespace FlaxEngine /// /// Current order is resolved runtime, and can change if custom editor class has changed. /// - /// The order order. + /// The order. public EditorOrderAttribute(int order) { Order = order; diff --git a/Source/Engine/Scripting/Attributes/SerializeAttribute.cs b/Source/Engine/Scripting/Attributes/SerializeAttribute.cs index 3cda97473..d120756ea 100644 --- a/Source/Engine/Scripting/Attributes/SerializeAttribute.cs +++ b/Source/Engine/Scripting/Attributes/SerializeAttribute.cs @@ -5,7 +5,7 @@ using System; namespace FlaxEngine { /// - /// Indicates that a field or a property of a serializable class should be be serialized. This class cannot be inherited. + /// Indicates that a field or a property of a serializable class should be serialized. This class cannot be inherited. /// [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] public sealed class SerializeAttribute : Attribute diff --git a/Source/Engine/Scripting/ManagedCLR/MAssembly.Mono.cpp b/Source/Engine/Scripting/ManagedCLR/MAssembly.Mono.cpp index 6c8e8f562..e40014e53 100644 --- a/Source/Engine/Scripting/ManagedCLR/MAssembly.Mono.cpp +++ b/Source/Engine/Scripting/ManagedCLR/MAssembly.Mono.cpp @@ -302,7 +302,7 @@ bool MAssembly::LoadWithImage(const String& assemblyPath) const auto assembly = mono_assembly_load_from_full(assemblyImage, name.Substring(0, name.Length() - 3).Get(), &status, false); if (status != MONO_IMAGE_OK || assembly == nullptr) { - // Close image if error occured + // Close image if error occurred mono_image_close(assemblyImage); Log::CLRInnerException(TEXT("Mono assembly image is corrupted at ") + assemblyPath); diff --git a/Source/Engine/Scripting/ManagedCLR/MAssembly.h b/Source/Engine/Scripting/ManagedCLR/MAssembly.h index ff8d5e8db..17cb8b624 100644 --- a/Source/Engine/Scripting/ManagedCLR/MAssembly.h +++ b/Source/Engine/Scripting/ManagedCLR/MAssembly.h @@ -234,7 +234,7 @@ public: #endif /// - /// Gets the classes lookup cache. Performs ful initialization if not cached. The result cache contains all classes from the assembly. + /// Gets the classes lookup cache. Performs full initialization if not cached. The result cache contains all classes from the assembly. /// /// The cache. const ClassesDictionary& GetClasses() const; diff --git a/Source/Engine/Scripting/ManagedCLR/MClass.h b/Source/Engine/Scripting/ManagedCLR/MClass.h index bfa813fb4..a8d083d7b 100644 --- a/Source/Engine/Scripting/ManagedCLR/MClass.h +++ b/Source/Engine/Scripting/ManagedCLR/MClass.h @@ -193,7 +193,7 @@ public: /// /// Returns an object referencing a method with the specified name and number of parameters. /// - /// If the the type contains more than one method of the given name and parameters count the returned value can be non-deterministic (one of the matching methods). + /// If the type contains more than one method of the given name and parameters count the returned value can be non-deterministic (one of the matching methods). /// The method name. /// The method parameters count. /// The method or null if failed to get it. diff --git a/Source/Engine/Scripting/ScriptingType.h b/Source/Engine/Scripting/ScriptingType.h index bdf5b3d5f..b27d92f2f 100644 --- a/Source/Engine/Scripting/ScriptingType.h +++ b/Source/Engine/Scripting/ScriptingType.h @@ -206,7 +206,7 @@ struct FLAXENGINE_API ScriptingType SetupScriptObjectVTableHandler SetupScriptObjectVTable; /// - /// The default instance of the scripting type. Used by serialization system for comparision to save only modified properties of the object. + /// The default instance of the scripting type. Used by serialization system for comparison to save only modified properties of the object. /// mutable ScriptingObject* DefaultInstance; } Script; @@ -282,7 +282,7 @@ struct FLAXENGINE_API ScriptingType } /// - /// Gets the default instance of the scripting type. Used by serialization system for comparision to save only modified properties of the object. + /// Gets the default instance of the scripting type. Used by serialization system for comparison to save only modified properties of the object. /// ScriptingObject* GetDefaultInstance() const; diff --git a/Source/Engine/Serialization/JsonWriter.cpp b/Source/Engine/Serialization/JsonWriter.cpp index d3f04a684..de90b49b4 100644 --- a/Source/Engine/Serialization/JsonWriter.cpp +++ b/Source/Engine/Serialization/JsonWriter.cpp @@ -195,7 +195,7 @@ void JsonWriter::SceneObject(::SceneObject* obj) auto prefab = Content::Load(obj->GetPrefabID()); if (prefab) { - // Request the prefab to be deserialized to the default instance (used for comparision to generate a diff) + // Request the prefab to be deserialized to the default instance (used for comparison to generate a diff) prefab->GetDefaultInstance(); // Get prefab object instance from the prefab diff --git a/Source/Engine/Serialization/Stream.cpp b/Source/Engine/Serialization/Stream.cpp index e10ae9fd6..2d3ef8b30 100644 --- a/Source/Engine/Serialization/Stream.cpp +++ b/Source/Engine/Serialization/Stream.cpp @@ -4,8 +4,9 @@ #include "WriteStream.h" #include "Engine/Core/Types/CommonValue.h" #include "Engine/Core/Types/Variant.h" -#include "Engine/Content/Asset.h" #include "Engine/Core/Collections/Dictionary.h" +#include "Engine/Content/Asset.h" +#include "Engine/Debug/DebugLog.h" #include "Engine/Scripting/ScriptingObject.h" #include "Engine/Scripting/ScriptingObjectReference.h" @@ -330,8 +331,19 @@ void ReadStream::ReadVariant(Variant* data) { int32 length; ReadInt32(&length); - ASSERT(data->AsBlob.Length == length); - ReadBytes(data->AsBlob.Data, length); + if (data->AsBlob.Length == length) + { + ReadBytes(data->AsBlob.Data, length); + } + else + { + LOG(Error, "Invalid Variant {2} data length {0}. Expected {1} bytes from stream.", data->AsBlob.Length, length, data->Type.ToString()); + + // Skip those bytes + void* ptr = Allocator::Allocate(length); + ReadBytes(ptr, length); + Allocator::Free(ptr); + } break; } case VariantType::Blob: diff --git a/Source/Engine/Serialization/Stream.h b/Source/Engine/Serialization/Stream.h index de7911fb4..d988a24df 100644 --- a/Source/Engine/Serialization/Stream.h +++ b/Source/Engine/Serialization/Stream.h @@ -37,9 +37,9 @@ public: public: /// - /// Returns true if error occured during reading/writing to the stream + /// Returns true if error occurred during reading/writing to the stream /// - /// True if error occured during reading/writing to the stream + /// True if error occurred during reading/writing to the stream virtual bool HasError() const { return _hasError; diff --git a/Source/Engine/Streaming/StreamingManager.cpp b/Source/Engine/Streaming/StreamingManager.cpp index d82a3b5ab..3b557e85f 100644 --- a/Source/Engine/Streaming/StreamingManager.cpp +++ b/Source/Engine/Streaming/StreamingManager.cpp @@ -92,7 +92,7 @@ void UpdateResource(StreamableResource* resource, DateTime now) } } - // Calculate residency level to stream in (resources may want to incease/decrease it's quality in steps rather than at once) + // Calculate residency level to stream in (resources may want to increase/decrease it's quality in steps rather than at once) int32 requestedResidency = handler->CalculateRequestedResidency(resource, targetResidency); // Create streaming task (resource type specific) diff --git a/Source/Engine/Terrain/Terrain.cpp b/Source/Engine/Terrain/Terrain.cpp index 9dabe1af0..aec2f7ffd 100644 --- a/Source/Engine/Terrain/Terrain.cpp +++ b/Source/Engine/Terrain/Terrain.cpp @@ -489,7 +489,7 @@ void Terrain::RemovePatch(const Int2& patchCoord) const auto patch = GetPatch(patchCoord); if (patch == nullptr) { - LOG(Warning, "Cannot remvoe patch at {0}x{1}. It does not exist.", patchCoord.X, patchCoord.Y); + LOG(Warning, "Cannot remove patch at {0}x{1}. It does not exist.", patchCoord.X, patchCoord.Y); return; } diff --git a/Source/Engine/Terrain/TerrainPatch.cpp b/Source/Engine/Terrain/TerrainPatch.cpp index d0050d455..791e93c7f 100644 --- a/Source/Engine/Terrain/TerrainPatch.cpp +++ b/Source/Engine/Terrain/TerrainPatch.cpp @@ -5,7 +5,6 @@ #include "Engine/Serialization/Serialization.h" #include "Engine/Graphics/RenderView.h" #include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/VectorInt.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Physics/Utilities.h" #include "Engine/Physics/Physics.h" diff --git a/Source/Engine/Terrain/TerrainPatch.h b/Source/Engine/Terrain/TerrainPatch.h index fcd97f4ec..b09848d61 100644 --- a/Source/Engine/Terrain/TerrainPatch.h +++ b/Source/Engine/Terrain/TerrainPatch.h @@ -5,7 +5,7 @@ #include "Terrain.h" #include "TerrainChunk.h" #include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/VectorInt.h" +#include "Engine/Core/Math/Int2.h" #include "Engine/Physics/Types.h" #include "Engine/Level/Scene/Lightmap.h" #include "Engine/Content/Assets/RawDataAsset.h" diff --git a/Source/Engine/Threading/ConcurrentBuffer.h b/Source/Engine/Threading/ConcurrentBuffer.h index 99159e206..99ebe5e86 100644 --- a/Source/Engine/Threading/ConcurrentBuffer.h +++ b/Source/Engine/Threading/ConcurrentBuffer.h @@ -382,7 +382,7 @@ public: /// Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection. /// /// The item. - /// The zero-based index of the first occurrence of itm within the entire collection, if found; otherwise, INVALID_INDEX. + /// The zero-based index of the first occurrence of item within the entire collection, if found; otherwise, INVALID_INDEX. int32 IndexOf(const T& item) const { for (int32 i = 0; i < _count; i++) diff --git a/Source/Engine/Threading/IRunnable.h b/Source/Engine/Threading/IRunnable.h index 7dc42f73a..83a2af305 100644 --- a/Source/Engine/Threading/IRunnable.h +++ b/Source/Engine/Threading/IRunnable.h @@ -41,7 +41,7 @@ public: } // Called when thread ends work (via Kill or normally) - // @param wasKilled True if thead has been killed + // @param wasKilled True if thread has been killed virtual void AfterWork(bool wasKilled) { } diff --git a/Source/Engine/Threading/ThreadPool.cpp b/Source/Engine/Threading/ThreadPool.cpp index 56d6f6289..ffd80d655 100644 --- a/Source/Engine/Threading/ThreadPool.cpp +++ b/Source/Engine/Threading/ThreadPool.cpp @@ -52,7 +52,7 @@ bool ThreadPoolService::Init() // Create tread auto runnable = New(true); runnable->OnWork.Bind(ThreadPool::ThreadProc); - auto thread = Thread::Create(runnable, String::Format(TEXT("Therad Pool {0}"), i)); + auto thread = Thread::Create(runnable, String::Format(TEXT("Thread Pool {0}"), i)); if (thread == nullptr) { LOG(Error, "Failed to spawn {0} thread in the Thread Pool", i + 1); diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp index c7f940574..41679a6a3 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp @@ -64,7 +64,7 @@ void MaterialLayer::Prepare() Guid MaterialLayer::GetMappedParamId(const Guid& id) { - // TODO: test ParamIdsMappings using Dictionary. will performance change? mamybe we don't wont to allocate too much memory + // TODO: test ParamIdsMappings using Dictionary. will performance change? maybe we don't wont to allocate too much memory for (int32 i = 0; i < ParamIdsMappings.Count(); i++) { diff --git a/Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp b/Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp index fef8d7f3c..50914ea2e 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp @@ -355,7 +355,7 @@ bool ProcessMesh(AssimpImporterData& data, const aiMesh* aMesh, MeshData& mesh, mesh.BlendIndices.SetAll(Int4::Zero); mesh.BlendWeights.SetAll(Vector4::Zero); - // Build skinning clusters and fill controls points data stutcture + // Build skinning clusters and fill controls points data structure for (unsigned boneId = 0; boneId < aMesh->mNumBones; boneId++) { const auto aBone = aMesh->mBones[boneId]; diff --git a/Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp b/Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp index 4c2876125..757dfa6ea 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp @@ -744,7 +744,7 @@ bool ProcessMesh(OpenFbxImporterData& data, const ofbx::Mesh* aMesh, MeshData& m auto length = delta.Length(); if (length > ZeroTolerance) delta /= length;*/ - auto delta = Vector3::Zero; // TODO: blend shape normals deltas fix when importing from ofbx + auto delta = Vector3::Zero; // TODO: blend shape normals deltas fix when importing from fbx blendShapeData.Vertices[i].NormalDelta = delta; } } diff --git a/Source/Engine/Tools/ModelTool/ModelTool.cpp b/Source/Engine/Tools/ModelTool/ModelTool.cpp index 3d6c74482..35cb3860b 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.cpp @@ -1131,7 +1131,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options opt dstLod.Meshes.RemoveAt(i--); } - LOG(Info, "Generated LOD{0}: triangles: {1} ({2}% of base LOD), verteces: {3} ({4}% of base LOD)", + LOG(Info, "Generated LOD{0}: triangles: {1} ({2}% of base LOD), verticies: {3} ({4}% of base LOD)", lodIndex, lodTriangleCount, (int32)(lodTriangleCount * 100 / baseLodTriangleCount), lodVertexCount, (int32)(lodVertexCount * 100 / baseLodVertexCount)); diff --git a/Source/Engine/Tools/TextureTool/TextureTool.cpp b/Source/Engine/Tools/TextureTool/TextureTool.cpp index a8af48764..67e4d7679 100644 --- a/Source/Engine/Tools/TextureTool/TextureTool.cpp +++ b/Source/Engine/Tools/TextureTool/TextureTool.cpp @@ -7,7 +7,7 @@ #include "Engine/Core/Types/DateTime.h" #include "Engine/Core/Math/Packed.h" #include "Engine/Core/Math/Color32.h" -#include "Engine/Core/Math/VectorInt.h" +#include "Engine/Core/Math/Int2.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Serialization/JsonWriter.h" #include "Engine/Serialization/JsonTools.h" @@ -316,7 +316,7 @@ bool TextureTool::Convert(TextureData& dst, const TextureData& src, const PixelF } if (src.Format == dstFormat) { - LOG(Warning, "Soure data and destination format are the same. Cannot perform conversion."); + LOG(Warning, "Source data and destination format are the same. Cannot perform conversion."); return true; } if (src.Depth != 1) @@ -343,7 +343,7 @@ bool TextureTool::Resize(TextureData& dst, const TextureData& src, int32 dstWidt } if (src.Width == dstWidth && src.Height == dstHeight) { - LOG(Warning, "Soure data and destination dimensions are the same. Cannot perform resizing."); + LOG(Warning, "Source data and destination dimensions are the same. Cannot perform resizing."); return true; } if (src.Depth != 1) @@ -489,11 +489,11 @@ TextureTool::PixelFormatSampler PixelFormatSamplers[] = sizeof(Half), [](const void* ptr) { - return Color(ConvertHalfToFloat(*(Half*)ptr), 0, 0, 1); + return Color(Float16Compressor::Decompress(*(Half*)ptr), 0, 0, 1); }, [](const void* ptr, const Color& color) { - *(Half*)ptr = ConvertFloatToHalf(color.R); + *(Half*)ptr = Float16Compressor::Compress(color.R); }, }, { diff --git a/Source/Engine/UI/GUI/Common/Dropdown.cs b/Source/Engine/UI/GUI/Common/Dropdown.cs index e78300e1a..917e51f6e 100644 --- a/Source/Engine/UI/GUI/Common/Dropdown.cs +++ b/Source/Engine/UI/GUI/Common/Dropdown.cs @@ -26,7 +26,7 @@ namespace FlaxEngine.GUI public Action ItemClicked; /// - /// Occurs when popup losts focus. + /// Occurs when popup lost focus. /// public Action LostFocus; diff --git a/Source/Engine/UI/GUI/ContainerControl.cs b/Source/Engine/UI/GUI/ContainerControl.cs index 44f8c782a..fb11f2eff 100644 --- a/Source/Engine/UI/GUI/ContainerControl.cs +++ b/Source/Engine/UI/GUI/ContainerControl.cs @@ -469,7 +469,7 @@ namespace FlaxEngine.GUI } /// - /// Checks if given point in thi container control space intersects with the child control content. + /// Checks if given point in this container control space intersects with the child control content. /// Also calculates result location in child control space which can be used to feed control with event at that point. /// /// The child control to check. @@ -636,7 +636,7 @@ namespace FlaxEngine.GUI } /// - /// Draws the children. Can be overriden to provide some customizations. Draw is performed with applied clipping mask for the client area. + /// Draws the children. Can be overridden to provide some customizations. Draw is performed with applied clipping mask for the client area. /// protected virtual void DrawChildren() { diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs index 74041610c..1c4eda965 100644 --- a/Source/Engine/UI/GUI/Control.cs +++ b/Source/Engine/UI/GUI/Control.cs @@ -1211,7 +1211,7 @@ namespace FlaxEngine.GUI } /// - /// Action fred when parent control gets changed. + /// Action fired when parent control gets changed. /// protected virtual void OnParentChangedInternal() { @@ -1252,9 +1252,9 @@ namespace FlaxEngine.GUI } /// - /// Helper utility function to sets the update callback to the root. Does nothing if value has not been modified. Handles if control ahs no root or parent. + /// Helper utility function to sets the update callback to the root. Does nothing if value has not been modified. Handles if control has no root or parent. /// - /// The cached update callback delegate (field in teh custom control implementation). + /// The cached update callback delegate (field in the custom control implementation). /// The value to assign. protected void SetUpdate(ref UpdateDelegate onUpdate, UpdateDelegate value) { @@ -1268,7 +1268,7 @@ namespace FlaxEngine.GUI } /// - /// Action fred when parent control gets resized (also when control gets non-null parent). + /// Action fired when parent control gets resized (also when control gets non-null parent). /// public virtual void OnParentResized() { diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index 733e0b3a1..04160db25 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -12,12 +12,12 @@ namespace FlaxEngine.GUI /// /// The splitter size (in pixels). /// - public const int SpliterSize = 4; + public const int SplitterSize = 4; /// /// The splitter half size (in pixels). /// - private const int SpliterSizeHalf = SpliterSize / 2; + private const int SplitterSizeHalf = SplitterSize / 2; private Orientation _orientation; private float _splitterValue; @@ -105,12 +105,12 @@ namespace FlaxEngine.GUI if (_orientation == Orientation.Horizontal) { var split = Mathf.RoundToInt(_splitterValue * Width); - _splitterRect = new Rectangle(Mathf.Clamp(split - SpliterSizeHalf, 0.0f, Width), 0, SpliterSize, Height); + _splitterRect = new Rectangle(Mathf.Clamp(split - SplitterSizeHalf, 0.0f, Width), 0, SplitterSize, Height); } else { var split = Mathf.RoundToInt(_splitterValue * Height); - _splitterRect = new Rectangle(0, Mathf.Clamp(split - SpliterSizeHalf, 0.0f, Height), Width, SpliterSize); + _splitterRect = new Rectangle(0, Mathf.Clamp(split - SplitterSizeHalf, 0.0f, Height), Width, SplitterSize); } } @@ -226,14 +226,14 @@ namespace FlaxEngine.GUI if (_orientation == Orientation.Horizontal) { var split = Mathf.RoundToInt(_splitterValue * Width); - Panel1.Bounds = new Rectangle(0, 0, split - SpliterSizeHalf, Height); - Panel2.Bounds = new Rectangle(split + SpliterSizeHalf, 0, Width - split - SpliterSizeHalf, Height); + Panel1.Bounds = new Rectangle(0, 0, split - SplitterSizeHalf, Height); + Panel2.Bounds = new Rectangle(split + SplitterSizeHalf, 0, Width - split - SplitterSizeHalf, Height); } else { var split = Mathf.RoundToInt(_splitterValue * Height); - Panel1.Bounds = new Rectangle(0, 0, Width, split - SpliterSizeHalf); - Panel2.Bounds = new Rectangle(0, split + SpliterSizeHalf, Width, Height - split - SpliterSizeHalf); + Panel1.Bounds = new Rectangle(0, 0, Width, split - SplitterSizeHalf); + Panel2.Bounds = new Rectangle(0, split + SplitterSizeHalf, Width, Height - split - SplitterSizeHalf); } } } diff --git a/Source/Engine/UI/GUI/Panels/UniformGridPanel.cs b/Source/Engine/UI/GUI/Panels/UniformGridPanel.cs index 089907901..62c6a9744 100644 --- a/Source/Engine/UI/GUI/Panels/UniformGridPanel.cs +++ b/Source/Engine/UI/GUI/Panels/UniformGridPanel.cs @@ -14,7 +14,7 @@ namespace FlaxEngine.GUI /// /// Gets or sets the padding given to each slot. /// - [EditorOrder(0), Tooltip("The padding margin appied to each item slot.")] + [EditorOrder(0), Tooltip("The padding margin applied to each item slot.")] public Margin SlotPadding { get => _slotPadding; diff --git a/Source/Engine/UI/GUI/WindowRootControl.cs b/Source/Engine/UI/GUI/WindowRootControl.cs index 03a994aa6..02c996b68 100644 --- a/Source/Engine/UI/GUI/WindowRootControl.cs +++ b/Source/Engine/UI/GUI/WindowRootControl.cs @@ -151,7 +151,7 @@ namespace FlaxEngine.GUI } /// - public override Vector2 TrackingMouseOffset => _window.TrackingMouseOffset; + public override Vector2 TrackingMouseOffset => _window.TrackingMouseOffset / _window._dpiScale; /// public override WindowRootControl RootWindow => this; @@ -262,14 +262,14 @@ namespace FlaxEngine.GUI return false; // Change focused control - Control prevous = _focusedControl; + Control previous = _focusedControl; _focusedControl = c; // Fire events - if (prevous != null) + if (previous != null) { - prevous.OnLostFocus(); - Assert.IsFalse(prevous.IsFocused); + previous.OnLostFocus(); + Assert.IsFalse(previous.IsFocused); } if (_focusedControl != null) { diff --git a/Source/Engine/UI/UICanvas.cs b/Source/Engine/UI/UICanvas.cs index 9ccbef214..e0b6425de 100644 --- a/Source/Engine/UI/UICanvas.cs +++ b/Source/Engine/UI/UICanvas.cs @@ -186,14 +186,14 @@ namespace FlaxEngine public CanvasRootControl GUI => _guiRoot; /// - /// Delegate schema for the callback used to perform custom canvas intersection test. Can be used to implement a canvas tha has a holes or non-rectangular shape. + /// Delegate schema for the callback used to perform custom canvas intersection test. Can be used to implement a canvas that has a holes or non-rectangular shape. /// /// The location of the point to test in coordinates of the canvas root control (see ). /// True if canvas was hit, otherwise false. public delegate bool TestCanvasIntersectionDelegate(ref Vector2 location); /// - /// The callback used to perform custom canvas intersection test. Can be used to implement a canvas tha has a holes or non-rectangular shape. + /// The callback used to perform custom canvas intersection test. Can be used to implement a canvas that has a holes or non-rectangular shape. /// [HideInEditor] public TestCanvasIntersectionDelegate TestCanvasIntersection; @@ -228,7 +228,10 @@ namespace FlaxEngine } } - private UICanvas() + /// + /// Initializes a new instance of the class. + /// + public UICanvas() { _guiRoot = new CanvasRootControl(this); _guiRoot.IsLayoutLocked = false; diff --git a/Source/Engine/Utilities/RectPack.h b/Source/Engine/Utilities/RectPack.h index f020b0481..a8ffb0b7e 100644 --- a/Source/Engine/Utilities/RectPack.h +++ b/Source/Engine/Utilities/RectPack.h @@ -25,7 +25,7 @@ struct RectPack SizeType Width; SizeType Height; - // The reaming space amount inside this slot (updated on every insertion, initial it equal to width*height). + // The remaining space amount inside this slot (updated on every insertion, initial it equal to width*height). SizeType SpaceLeft; // True, if slot has been allocated, otherwise it's free. diff --git a/Source/Engine/Utilities/StateMachine.h b/Source/Engine/Utilities/StateMachine.h index 292a67978..38e69a06b 100644 --- a/Source/Engine/Utilities/StateMachine.h +++ b/Source/Engine/Utilities/StateMachine.h @@ -50,7 +50,7 @@ public: /// /// Checks if can exit from that state /// - /// Next state to ener after exit from the current state + /// Next state to enter after exit from the current state /// True if can exit from that state, otherwise false virtual bool CanExit(State* nextState) const { diff --git a/Source/Engine/Visject/ShaderGraph.cpp b/Source/Engine/Visject/ShaderGraph.cpp index 61c609307..7b3c51f3e 100644 --- a/Source/Engine/Visject/ShaderGraph.cpp +++ b/Source/Engine/Visject/ShaderGraph.cpp @@ -380,6 +380,15 @@ void ShaderGenerator::ProcessGroupMath(Box* box, Node* node, Value& value) Value v2 = tryGetValue(node->GetBox(1), Value::Zero); value = writeFunction2(node, v1, v2, TEXT("atan2")); break; + } + // Near Equal + case 42: + { + Value v1 = tryGetValue(node->GetBox(0), Value::Zero); + Value v2 = tryGetValue(node->GetBox(1), Value::Zero).Cast(v1.Type); + Value epsilon = tryGetValue(node->GetBox(2), 2, Value::Zero); + value = writeLocal(ValueType::Bool, String::Format(TEXT("distance({0},{1}) < {2}"), v1.Value, v2.Value, epsilon.Value), node); + break; } // Degrees case 43: @@ -911,7 +920,7 @@ void ShaderGenerator::ProcessGroupComparisons(Box* box, Node* node, Value& value const Value condition = tryGetValue(node->GetBox(0), Value::False).AsBool(); const Value onTrue = tryGetValue(node->GetBox(2), 1, Value::Zero); const Value onFalse = tryGetValue(node->GetBox(1), 0, Value::Zero).Cast(onTrue.Type); - value = writeLocal(onTrue.Type, String::Format(TEXT("({0}) ? ({1}) : ({2})"), condition.Value, onTrue.Value, onFalse.Value), node); + value = writeLocal(onTrue.Type, String::Format(TEXT("{0} ? {1} : {2}"), condition.Value, onTrue.Value, onFalse.Value), node); break; } } diff --git a/Source/Shaders/BakeLightmap.shader b/Source/Shaders/BakeLightmap.shader index 4f206469e..14f99b4f4 100644 --- a/Source/Shaders/BakeLightmap.shader +++ b/Source/Shaders/BakeLightmap.shader @@ -328,7 +328,7 @@ void CS_BlurEmpty(uint3 GroupID : SV_GroupID, uint3 GroupThreadID : SV_GroupThre const int2 location = int2(GroupID.x, GroupID.y); const uint texelAdress = (location.y * AtlasSize + location.x) * NUM_SH_TARGETS; - // TODO: use more therads to sample lightmap and final therad make it blur + // TODO: use more threads to sample lightmap and final therad make it blur // Simple box filter (using only valid samples) const int blurRadius = 2; diff --git a/Source/Shaders/BitonicSort.shader b/Source/Shaders/BitonicSort.shader index b75f553b1..8a53802d0 100644 --- a/Source/Shaders/BitonicSort.shader +++ b/Source/Shaders/BitonicSort.shader @@ -32,7 +32,7 @@ uint InsertOneBit(uint value, uint oneBitMask) // Determines if two sort keys should be swapped in the list. KeySign is // either 1 or -1. Multiplication with the KeySign will either invert the sign -// (effectively a negation) or leave the value alone. When the the KeySign is +// (effectively a negation) or leave the value alone. When the KeySign is // 1, we are sorting descending, so when A < B, they should swap. For an // ascending sort, -A < -B should swap. bool ShouldSwap(Item a, Item b) diff --git a/Source/Tools/Flax.Build/Build/Plugins/VisualScriptingPlugin.cs b/Source/Tools/Flax.Build/Build/Plugins/VisualScriptingPlugin.cs index 612b6a582..b2656ce0d 100644 --- a/Source/Tools/Flax.Build/Build/Plugins/VisualScriptingPlugin.cs +++ b/Source/Tools/Flax.Build/Build/Plugins/VisualScriptingPlugin.cs @@ -22,7 +22,7 @@ namespace Flax.Build.Plugins private void OnGenerateCppScriptWrapperFunction(Builder.BuildData buildData, ClassInfo classInfo, FunctionInfo functionInfo, int scriptVTableSize, int scriptVTableIndex, StringBuilder contents) { - // Generate C++ wrapper function to invoke Visual Script instead of overriden native function (with support for base method callback) + // Generate C++ wrapper function to invoke Visual Script instead of overridden native function (with support for base method callback) BindingsGenerator.CppIncludeFiles.Add("Engine/Content/Assets/VisualScript.h"); diff --git a/Source/Tools/Flax.Build/Build/Target.cs b/Source/Tools/Flax.Build/Build/Target.cs index b7a6b2fbe..ebf1d36c9 100644 --- a/Source/Tools/Flax.Build/Build/Target.cs +++ b/Source/Tools/Flax.Build/Build/Target.cs @@ -225,7 +225,7 @@ namespace Flax.Build } /// - /// Setups the target building environment (native C++). Allows to modify compiler and linker options. Options applied here are used by all modules included into this target (can be overriden per module). + /// Setups the target building environment (native C++). Allows to modify compiler and linker options. Options applied here are used by all modules included into this target (can be overridden per module). /// /// The build options. public virtual void SetupTargetEnvironment(BuildOptions options) diff --git a/Source/Tools/Flax.Stats/CodeFrameNode.cs b/Source/Tools/Flax.Stats/CodeFrameNode.cs index 25d326ff4..e42bdcfef 100644 --- a/Source/Tools/Flax.Stats/CodeFrameNode.cs +++ b/Source/Tools/Flax.Stats/CodeFrameNode.cs @@ -75,14 +75,14 @@ namespace Flax.Stats /// /// Gets total amount of memory used by that node and all child nodes /// - public long TotaSizeOnDisk + public long TotalSizeOnDisk { get { long result = SizeOnDisk; for (int i = 0; i < Children.Length; i++) { - result += Children[i].TotaSizeOnDisk; + result += Children[i].TotalSizeOnDisk; } return result; } @@ -153,15 +153,15 @@ namespace Flax.Stats /// /// Gets total amount of lines of code per language /// - /// Language + /// Language /// Result amount of lines - public long GetTotalLinesOfCode(Languages languge) + public long GetTotalLinesOfCode(Languages language) { long result = 0; - result += LinesOfCode[(int)languge]; + result += LinesOfCode[(int)language]; for (int i = 0; i < Children.Length; i++) { - result += Children[i].GetTotalLinesOfCode(languge); + result += Children[i].GetTotalLinesOfCode(language); } return result; } @@ -270,9 +270,9 @@ namespace Flax.Stats public void CleanupDirectories() { - var chld = Children.ToList(); - chld.RemoveAll(e => ignoredFolders.Contains(e.ShortName.ToLower())); - Children = chld.ToArray(); + var child = Children.ToList(); + child.RemoveAll(e => ignoredFolders.Contains(e.ShortName.ToLower())); + Children = child.ToArray(); foreach (var a in Children) { diff --git a/Source/Tools/Flax.Stats/Tools.cs b/Source/Tools/Flax.Stats/Tools.cs index d947ae758..1e3ba1f74 100644 --- a/Source/Tools/Flax.Stats/Tools.cs +++ b/Source/Tools/Flax.Stats/Tools.cs @@ -103,7 +103,7 @@ namespace Flax.Stats } /// - /// Write string in UTF-8 encoding to the stream and ofset data + /// Write string in UTF-8 encoding to the stream and offset data /// /// File stream /// Data to write @@ -292,7 +292,7 @@ namespace Flax.Stats } /// - /// Write arry of Guids to the stream + /// Write array of Guids to the stream /// /// File stream /// Value to write