Refactor engine to support double-precision vectors
This commit is contained in:
@@ -108,8 +108,8 @@ namespace FlaxEditor.Tools.Terrain.Brushes
|
||||
float falloff = halfSize * Falloff;
|
||||
float radius = halfSize - falloff;
|
||||
material.SetParameterValue("Color", color);
|
||||
material.SetParameterValue("BrushData0", new Vector4(position, radius));
|
||||
material.SetParameterValue("BrushData1", new Vector4(falloff, (float)FalloffType, 0, 0));
|
||||
material.SetParameterValue("BrushData0", new Float4(position, radius));
|
||||
material.SetParameterValue("BrushData1", new Float4(falloff, (float)FalloffType, 0, 0));
|
||||
}
|
||||
return material;
|
||||
}
|
||||
@@ -118,16 +118,17 @@ namespace FlaxEditor.Tools.Terrain.Brushes
|
||||
public override float Sample(ref Vector3 brushPosition, ref Vector3 samplePosition)
|
||||
{
|
||||
Vector3.DistanceXZ(ref brushPosition, ref samplePosition, out var distanceXZ);
|
||||
float distance = (float)distanceXZ;
|
||||
float halfSize = Size * 0.5f;
|
||||
float falloff = halfSize * Falloff;
|
||||
float radius = halfSize - falloff;
|
||||
|
||||
switch (FalloffType)
|
||||
{
|
||||
case FalloffTypes.Smooth: return CalculateFalloff_Smooth(distanceXZ, radius, falloff);
|
||||
case FalloffTypes.Linear: return CalculateFalloff_Linear(distanceXZ, radius, falloff);
|
||||
case FalloffTypes.Spherical: return CalculateFalloff_Spherical(distanceXZ, radius, falloff);
|
||||
case FalloffTypes.Tip: return CalculateFalloff_Tip(distanceXZ, radius, falloff);
|
||||
case FalloffTypes.Smooth: return CalculateFalloff_Smooth(distance, radius, falloff);
|
||||
case FalloffTypes.Linear: return CalculateFalloff_Linear(distance, radius, falloff);
|
||||
case FalloffTypes.Spherical: return CalculateFalloff_Spherical(distance, radius, falloff);
|
||||
case FalloffTypes.Tip: return CalculateFalloff_Tip(distance, radius, falloff);
|
||||
default: throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
UseScroll = true,
|
||||
Offsets = Margin.Zero,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
TabsSize = new Vector2(50, 32),
|
||||
TabsSize = new Float2(50, 32),
|
||||
Parent = this
|
||||
};
|
||||
|
||||
|
||||
@@ -61,14 +61,14 @@ namespace FlaxEditor.Tools.Terrain
|
||||
[EditorOrder(330), EditorDisplay("Import Data"), DefaultValue(null), Tooltip("Custom terrain splat map used as a source of the terrain layers weights. Each channel from RGBA is used as an independent layer weight for terrain layers compositing.")]
|
||||
public Texture Splatmap2;
|
||||
|
||||
[EditorOrder(400), EditorDisplay("Transform", "Position"), DefaultValue(typeof(Vector3), "0,0,0"), Tooltip("Position of the terrain (importer offset it on the Y axis.)")]
|
||||
public Vector3 Position = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
[EditorOrder(400), EditorDisplay("Transform", "Position"), DefaultValue(typeof(Double3), "0,0,0"), Tooltip("Position of the terrain (importer offset it on the Y axis.)")]
|
||||
public Double3 Position = new Double3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
[EditorOrder(410), EditorDisplay("Transform", "Rotation"), DefaultValue(typeof(Quaternion), "0,0,0,1"), Tooltip("Orientation of the terrain")]
|
||||
public Quaternion Orientation = Quaternion.Identity;
|
||||
|
||||
[EditorOrder(420), EditorDisplay("Transform", "Scale"), DefaultValue(typeof(Vector3), "1,1,1"), Limit(float.MinValue, float.MaxValue, 0.01f), Tooltip("Scale of the terrain")]
|
||||
public Vector3 Scale = Vector3.One;
|
||||
[EditorOrder(420), EditorDisplay("Transform", "Scale"), DefaultValue(typeof(Float3), "1,1,1"), Limit(float.MinValue, float.MaxValue, 0.01f), Tooltip("Scale of the terrain")]
|
||||
public Float3 Scale = Float3.One;
|
||||
}
|
||||
|
||||
private readonly Options _options = new Options();
|
||||
@@ -134,7 +134,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
settingsEditor.Panel.Parent = this;
|
||||
_editor = settingsEditor;
|
||||
|
||||
_dialogSize = new Vector2(TotalWidth, settingsEditor.Panel.Bottom);
|
||||
_dialogSize = new Float2(TotalWidth, settingsEditor.Panel.Bottom);
|
||||
|
||||
settingsEditor.Select(_options);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace FlaxEditor.Tools.Terrain
|
||||
// Chunk Properties
|
||||
_chunkProperties = new Panel(ScrollBars.None)
|
||||
{
|
||||
Location = new Vector2(_selectionInfoLabel.X, _selectionInfoLabel.Bottom + 4),
|
||||
Location = new Float2(_selectionInfoLabel.X, _selectionInfoLabel.Bottom + 4),
|
||||
Parent = panel,
|
||||
};
|
||||
var chunkOverrideMaterialLabel = new Label(0, 0, 90, 64)
|
||||
@@ -95,13 +95,13 @@ namespace FlaxEditor.Tools.Terrain
|
||||
Text = "Override Material",
|
||||
Parent = _chunkProperties,
|
||||
};
|
||||
_chunkOverrideMaterial = new AssetPicker(new ScriptType(typeof(MaterialBase)), new Vector2(chunkOverrideMaterialLabel.Right + 4, 0))
|
||||
_chunkOverrideMaterial = new AssetPicker(new ScriptType(typeof(MaterialBase)), new Float2(chunkOverrideMaterialLabel.Right + 4, 0))
|
||||
{
|
||||
Width = 300.0f,
|
||||
Parent = _chunkProperties,
|
||||
};
|
||||
_chunkOverrideMaterial.SelectedItemChanged += OnSelectedChunkOverrideMaterialChanged;
|
||||
_chunkProperties.Size = new Vector2(_chunkOverrideMaterial.Right + 4, _chunkOverrideMaterial.Bottom + 4);
|
||||
_chunkProperties.Size = new Float2(_chunkOverrideMaterial.Right + 4, _chunkOverrideMaterial.Bottom + 4);
|
||||
|
||||
// Delete patch
|
||||
_deletePatchButton = new Button(_selectionInfoLabel.X, _selectionInfoLabel.Bottom + 4)
|
||||
|
||||
@@ -104,8 +104,8 @@ namespace FlaxEditor.Tools.Terrain.Paint
|
||||
var brushBoundsPatchLocalMax = (brushBoundsLocal.Maximum - patchPositionLocal) * unitsPerVertexInv;
|
||||
|
||||
// Calculate patch heightmap area to modify by brush
|
||||
var brushPatchMin = new Int2(Mathf.FloorToInt(brushBoundsPatchLocalMin.X), Mathf.FloorToInt(brushBoundsPatchLocalMin.Z));
|
||||
var brushPatchMax = new Int2(Mathf.CeilToInt(brushBoundsPatchLocalMax.X), Mathf.FloorToInt(brushBoundsPatchLocalMax.Z));
|
||||
var brushPatchMin = new Int2((int)Math.Floor(brushBoundsPatchLocalMin.X), (int)Math.Floor(brushBoundsPatchLocalMin.Z));
|
||||
var brushPatchMax = new Int2((int)Math.Ceiling(brushBoundsPatchLocalMax.X), (int)Math.Ceiling(brushBoundsPatchLocalMax.Z));
|
||||
var modifiedOffset = brushPatchMin;
|
||||
var modifiedSize = brushPatchMax - brushPatchMin;
|
||||
|
||||
|
||||
@@ -102,8 +102,8 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
var brushBoundsPatchLocalMax = (brushBoundsLocal.Maximum - patchPositionLocal) * unitsPerVertexInv;
|
||||
|
||||
// Calculate patch heightmap area to modify by brush
|
||||
var brushPatchMin = new Int2(Mathf.FloorToInt(brushBoundsPatchLocalMin.X), Mathf.FloorToInt(brushBoundsPatchLocalMin.Z));
|
||||
var brushPatchMax = new Int2(Mathf.CeilToInt(brushBoundsPatchLocalMax.X), Mathf.FloorToInt(brushBoundsPatchLocalMax.Z));
|
||||
var brushPatchMin = new Int2((int)Math.Floor(brushBoundsPatchLocalMin.X), (int)Math.Floor(brushBoundsPatchLocalMin.Z));
|
||||
var brushPatchMax = new Int2((int)Math.Ceiling(brushBoundsPatchLocalMax.X), (int)Math.Ceiling(brushBoundsPatchLocalMax.Z));
|
||||
var modifiedOffset = brushPatchMin;
|
||||
var modifiedSize = brushPatchMax - brushPatchMin;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "TerrainTools.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Cache.h"
|
||||
#include "Engine/Core/Math/Int2.h"
|
||||
#include "Engine/Core/Math/Color32.h"
|
||||
#include "Engine/Core/Collections/CollectionPoolCache.h"
|
||||
#include "Engine/Terrain/TerrainPatch.h"
|
||||
|
||||
Reference in New Issue
Block a user