diff --git a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs index 526c91d20..00322fc81 100644 --- a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs +++ b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs @@ -55,11 +55,11 @@ namespace FlaxEditor.CustomEditors.Editors private void OnSetupContextMenu(PropertyNameLabel label, ContextMenu menu, CustomEditor linkedEditor) { menu.ItemsContainer.RemoveChildren(); - + menu.AddButton("Copy", linkedEditor.Copy); var paste = menu.AddButton("Paste", linkedEditor.Paste); paste.Enabled = linkedEditor.CanPaste; - + menu.AddSeparator(); var moveUpButton = menu.AddButton("Move up", OnMoveUpClicked); moveUpButton.Enabled = Index > 0; @@ -118,7 +118,7 @@ namespace FlaxEditor.CustomEditors.Editors Editor = editor; Index = index; Offsets = new Margin(7, 7, 0, 0); - + MouseButtonRightClicked += OnMouseButtonRightClicked; if (_canReorder) { @@ -173,6 +173,7 @@ namespace FlaxEditor.CustomEditors.Editors /// Determines if value of collection can be null. /// protected bool NotNullItems; + private IntValueBox _sizeBox; private Color _background; private int _elementsCount; diff --git a/Source/Editor/Tools/Terrain/Sculpt/Mode.cs b/Source/Editor/Tools/Terrain/Sculpt/Mode.cs index a92b899e1..cce2f982f 100644 --- a/Source/Editor/Tools/Terrain/Sculpt/Mode.cs +++ b/Source/Editor/Tools/Terrain/Sculpt/Mode.cs @@ -53,11 +53,11 @@ namespace FlaxEditor.Tools.Terrain.Sculpt /// /// Gets all patches that will be affected by the brush /// - /// - /// - /// - /// - public unsafe virtual List GetAffectedPatches(Brush brush, ref Options options, SculptTerrainGizmoMode gizmo, FlaxEngine.Terrain terrain) + /// The brush. + /// The options. + /// The gizmo. + /// The terrain. + public virtual unsafe List GetAffectedPatches(Brush brush, ref Options options, SculptTerrainGizmoMode gizmo, FlaxEngine.Terrain terrain) { List affectedPatches = new(); @@ -155,7 +155,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt /// The options. /// The gizmo. /// The terrain. - public unsafe void Apply(Brush brush, ref Options options, SculptTerrainGizmoMode gizmo, FlaxEngine.Terrain terrain) + public void Apply(Brush brush, ref Options options, SculptTerrainGizmoMode gizmo, FlaxEngine.Terrain terrain) { var affectedPatches = GetAffectedPatches(brush, ref options, gizmo, terrain); @@ -176,7 +176,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt /// /// /// - public unsafe virtual void ApplyBrush(SculptTerrainGizmoMode gizmo, List affectedPatches) + public virtual void ApplyBrush(SculptTerrainGizmoMode gizmo, List affectedPatches) { for (int i = 0; i < affectedPatches.Count; i++) { diff --git a/Source/Editor/Tools/Terrain/Sculpt/SmoothMode.cs b/Source/Editor/Tools/Terrain/Sculpt/SmoothMode.cs index 49ccfe0de..387bb555e 100644 --- a/Source/Editor/Tools/Terrain/Sculpt/SmoothMode.cs +++ b/Source/Editor/Tools/Terrain/Sculpt/SmoothMode.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using FlaxEngine; -using FlaxEditor.Tools.Terrain.Brushes; using System; namespace FlaxEditor.Tools.Terrain.Sculpt @@ -29,15 +28,9 @@ namespace FlaxEditor.Tools.Terrain.Sculpt var heightmapSize = affectedPatches[0].HeightmapSize; var radius = Mathf.Max(Mathf.CeilToInt(FilterRadius * 0.01f * affectedPatches[0].Brush.Size), 2); - - ///// - /// Calculate bounding coordinates of the total affected area - /// - - + // Calculate bounding coordinates of the total affected area Int2 modifieedAreaMinCoord = Int2.Maximum; Int2 modifiedAreaMaxCoord = Int2.Minimum; - for (int i = 0; i < affectedPatches.Count; i++) { var patch = affectedPatches[i]; @@ -46,27 +39,14 @@ namespace FlaxEditor.Tools.Terrain.Sculpt var br = tl + patch.ModifiedSize; if (tl.X <= modifieedAreaMinCoord.X && tl.Y <= modifieedAreaMinCoord.Y) - { modifieedAreaMinCoord = tl; - } - if (br.X >= modifiedAreaMaxCoord.X && br.Y >= modifiedAreaMaxCoord.Y) - { modifiedAreaMaxCoord = br; - } } - - var totalModifiedSize = modifiedAreaMaxCoord - modifieedAreaMinCoord; - - ///// - /// Build map of heights in affected area - /// - - + // Build map of heights in affected area var modifiedHeights = new float[totalModifiedSize.X * totalModifiedSize.Y]; - for (int i = 0; i < affectedPatches.Count; i++) { var patch = affectedPatches[i]; @@ -75,32 +55,26 @@ namespace FlaxEditor.Tools.Terrain.Sculpt { for (int x = 0; x < patch.ModifiedSize.X; x++) { - // read height from current patch + // Read height from current patch var localCoordX = (x + patch.ModifiedOffset.X); var localCoordY = (z + patch.ModifiedOffset.Y); var coordHeight = patch.SourceHeightMap[(localCoordY * heightmapSize) + localCoordX]; - // calculate the absolute coordinate of the terrain point + // Calculate the absolute coordinate of the terrain point var absoluteCurrentPointCoord = patch.PatchCoord * (heightmapSize - 1) + patch.ModifiedOffset + new Int2(x, z); var currentPointCoordRelativeToModifiedArea = absoluteCurrentPointCoord - modifieedAreaMinCoord; - // store height + // Store height var index = (currentPointCoordRelativeToModifiedArea.Y * totalModifiedSize.X) + currentPointCoordRelativeToModifiedArea.X; modifiedHeights[index] = coordHeight; } } } - - ///// - /// Iterate through modified points and smooth now that we have height information for all necessary points - /// - - + // Iterate through modified points and smooth now that we have height information for all necessary points for (int i = 0; i < affectedPatches.Count; i++) { var patch = affectedPatches[i]; - var brushPosition = patch.Gizmo.CursorPosition; var strength = Mathf.Saturate(patch.Strength); @@ -108,16 +82,16 @@ namespace FlaxEditor.Tools.Terrain.Sculpt { for (int x = 0; x < patch.ModifiedSize.X; x++) { - // read height from current patch + // Read height from current patch var localCoordX = (x + patch.ModifiedOffset.X); var localCoordY = (z + patch.ModifiedOffset.Y); var coordHeight = patch.SourceHeightMap[(localCoordY * heightmapSize) + localCoordX]; - // calculate the absolute coordinate of the terrain point + // Calculate the absolute coordinate of the terrain point var absoluteCurrentPointCoord = patch.PatchCoord * (heightmapSize - 1) + patch.ModifiedOffset + new Int2(x, z); var currentPointCoordRelativeToModifiedArea = absoluteCurrentPointCoord - modifieedAreaMinCoord; - // calculate brush influence at the current position + // Calculate brush influence at the current position var samplePositionLocal = patch.PatchPositionLocal + new Vector3(localCoordX * FlaxEngine.Terrain.UnitsPerVertex, coordHeight, localCoordY * FlaxEngine.Terrain.UnitsPerVertex); Vector3.Transform(ref samplePositionLocal, ref patch.TerrainWorld, out Vector3 samplePositionWorld); var paintAmount = patch.Brush.Sample(ref brushPosition, ref samplePositionWorld) * strength; @@ -149,7 +123,6 @@ namespace FlaxEditor.Tools.Terrain.Sculpt { var coordIndex = (dz * totalModifiedSize.X) + dx; var height = modifiedHeights[coordIndex]; - smoothValue += height; smoothValueSamples++; }