Codestyle fixes
This commit is contained in:
@@ -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.
|
||||
/// </summary>
|
||||
protected bool NotNullItems;
|
||||
|
||||
private IntValueBox _sizeBox;
|
||||
private Color _background;
|
||||
private int _elementsCount;
|
||||
|
||||
@@ -53,11 +53,11 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
/// <summary>
|
||||
/// Gets all patches that will be affected by the brush
|
||||
/// </summary>
|
||||
/// <param name="brush"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="gizmo"></param>
|
||||
/// <param name="terrain"></param>
|
||||
public unsafe virtual List<ApplyParams> GetAffectedPatches(Brush brush, ref Options options, SculptTerrainGizmoMode gizmo, FlaxEngine.Terrain terrain)
|
||||
/// <param name="brush">The brush.</param>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <param name="gizmo">The gizmo.</param>
|
||||
/// <param name="terrain">The terrain.</param>
|
||||
public virtual unsafe List<ApplyParams> GetAffectedPatches(Brush brush, ref Options options, SculptTerrainGizmoMode gizmo, FlaxEngine.Terrain terrain)
|
||||
{
|
||||
List<ApplyParams> affectedPatches = new();
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
/// <param name="options">The options.</param>
|
||||
/// <param name="gizmo">The gizmo.</param>
|
||||
/// <param name="terrain">The terrain.</param>
|
||||
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
|
||||
/// </summary>
|
||||
/// <param name="gizmo"></param>
|
||||
/// <param name="affectedPatches"></param>
|
||||
public unsafe virtual void ApplyBrush(SculptTerrainGizmoMode gizmo, List<ApplyParams> affectedPatches)
|
||||
public virtual void ApplyBrush(SculptTerrainGizmoMode gizmo, List<ApplyParams> affectedPatches)
|
||||
{
|
||||
for (int i = 0; i < affectedPatches.Count; i++)
|
||||
{
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user