Format code #1292
This commit is contained in:
@@ -22,8 +22,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private struct UndoData
|
private struct UndoData
|
||||||
{
|
{
|
||||||
public Spline spline;
|
public Spline Spline;
|
||||||
public BezierCurve<Transform>.Keyframe[] beforeKeyframes;
|
public BezierCurve<Transform>.Keyframe[] BeforeKeyframes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -82,16 +82,24 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentIn(Spline spline, int index) { }
|
public override void OnMoveTangentIn(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentOut(Spline spline, int index) { }
|
public override void OnMoveTangentOut(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectKeyframe(Spline spline, int index) { }
|
public override void OnSelectKeyframe(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectTangent(Spline spline, int index) { }
|
public override void OnSelectTangent(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -109,16 +117,24 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentIn(Spline spline, int index) { }
|
public override void OnMoveTangentIn(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentOut(Spline spline, int index) { }
|
public override void OnMoveTangentOut(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectKeyframe(Spline spline, int index) { }
|
public override void OnSelectKeyframe(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectTangent(Spline spline, int index) { }
|
public override void OnSelectTangent(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -139,7 +155,9 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectTangent(Spline selectedSpline, int index) { }
|
public override void OnSelectTangent(Spline selectedSpline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentIn(Spline spline, int index)
|
public override void OnMoveTangentIn(Spline spline, int index)
|
||||||
@@ -170,8 +188,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
// inverse of reference tangent
|
// inverse of reference tangent
|
||||||
otherTangent.Translation = -referenceTangent.Translation.Normalized * otherTangent.Translation.Length;
|
otherTangent.Translation = -referenceTangent.Translation.Normalized * otherTangent.Translation.Length;
|
||||||
|
|
||||||
if (alignWithIn) keyframe.TangentOut = otherTangent;
|
if (alignWithIn)
|
||||||
if (!alignWithIn) keyframe.TangentIn = otherTangent;
|
keyframe.TangentOut = otherTangent;
|
||||||
|
if (!alignWithIn)
|
||||||
|
keyframe.TangentIn = otherTangent;
|
||||||
|
|
||||||
spline.SetSplineKeyframe(index, keyframe);
|
spline.SetSplineKeyframe(index, keyframe);
|
||||||
}
|
}
|
||||||
@@ -191,16 +211,24 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentIn(Spline spline, int index) { }
|
public override void OnMoveTangentIn(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentOut(Spline spline, int index) { }
|
public override void OnMoveTangentOut(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectKeyframe(Spline spline, int index) { }
|
public override void OnSelectKeyframe(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectTangent(Spline spline, int index) { }
|
public override void OnSelectTangent(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -217,16 +245,24 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentIn(Spline spline, int index) { }
|
public override void OnMoveTangentIn(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnMoveTangentOut(Spline spline, int index) { }
|
public override void OnMoveTangentOut(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectKeyframe(Spline spline, int index) { }
|
public override void OnSelectKeyframe(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void OnSelectTangent(Spline spline, int index) { }
|
public override void OnSelectTangent(Spline spline, int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Color HighlightedColor = FlaxEngine.GUI.Style.Current.BackgroundSelected;
|
private readonly Color HighlightedColor = FlaxEngine.GUI.Style.Current.BackgroundSelected;
|
||||||
@@ -327,7 +363,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
_setLinearAllTangentsButton.Button.Clicked += EndEditSpline;
|
_setLinearAllTangentsButton.Button.Clicked += EndEditSpline;
|
||||||
_setSmoothAllTangentsButton.Button.Clicked += EndEditSpline;
|
_setSmoothAllTangentsButton.Button.Clicked += EndEditSpline;
|
||||||
|
|
||||||
if (_selectedSpline) _selectedSpline.SplineUpdated += OnSplineEdited;
|
if (_selectedSpline)
|
||||||
|
_selectedSpline.SplineUpdated += OnSplineEdited;
|
||||||
|
|
||||||
SetSelectedTangentTypeAsCurrent();
|
SetSelectedTangentTypeAsCurrent();
|
||||||
SetEditButtonsColor();
|
SetEditButtonsColor();
|
||||||
@@ -338,7 +375,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override void Deinitialize()
|
protected override void Deinitialize()
|
||||||
{
|
{
|
||||||
if (_selectedSpline) _selectedSpline.SplineUpdated -= OnSplineEdited;
|
if (_selectedSpline)
|
||||||
|
_selectedSpline.SplineUpdated -= OnSplineEdited;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSplineEdited()
|
private void OnSplineEdited()
|
||||||
@@ -376,27 +414,37 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
_lastTanOutPos = currentTangentOutPosition;
|
_lastTanOutPos = currentTangentOutPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_tanInChanged) _currentTangentMode.OnMoveTangentIn(_selectedSpline, index);
|
if (_tanInChanged)
|
||||||
if (_tanOutChanged) _currentTangentMode.OnMoveTangentOut(_selectedSpline, index);
|
_currentTangentMode.OnMoveTangentIn(_selectedSpline, index);
|
||||||
|
if (_tanOutChanged)
|
||||||
|
_currentTangentMode.OnMoveTangentOut(_selectedSpline, index);
|
||||||
|
|
||||||
currentTangentInPosition = _selectedSpline.GetSplineLocalTangent(index, true).Translation;
|
currentTangentInPosition = _selectedSpline.GetSplineLocalTangent(index, true).Translation;
|
||||||
currentTangentOutPosition = _selectedSpline.GetSplineLocalTangent(index, false).Translation;
|
currentTangentOutPosition = _selectedSpline.GetSplineLocalTangent(index, false).Translation;
|
||||||
|
|
||||||
// update last tangents position after changes
|
// update last tangents position after changes
|
||||||
if (_selectedSpline) _lastTanInPos = currentTangentInPosition;
|
if (_selectedSpline)
|
||||||
if (_selectedSpline) _lastTanOutPos = currentTangentOutPosition;
|
_lastTanInPos = currentTangentInPosition;
|
||||||
|
if (_selectedSpline)
|
||||||
|
_lastTanOutPos = currentTangentOutPosition;
|
||||||
_tanInChanged = false;
|
_tanInChanged = false;
|
||||||
_tanOutChanged = false;
|
_tanOutChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetSelectedTangentTypeAsCurrent()
|
private void SetSelectedTangentTypeAsCurrent()
|
||||||
{
|
{
|
||||||
if (_lastPointSelected == null || _selectedPoint == null) return;
|
if (_lastPointSelected == null || _selectedPoint == null)
|
||||||
if (IsLinearTangentMode(_selectedSpline, _lastPointSelected.Index)) SetModeLinear();
|
return;
|
||||||
else if (IsAlignedTangentMode(_selectedSpline, _lastPointSelected.Index)) SetModeAligned();
|
if (IsLinearTangentMode(_selectedSpline, _lastPointSelected.Index))
|
||||||
else if (IsSmoothInTangentMode(_selectedSpline, _lastPointSelected.Index)) SetModeSmoothIn();
|
SetModeLinear();
|
||||||
else if (IsSmoothOutTangentMode(_selectedSpline, _lastPointSelected.Index)) SetModeSmoothOut();
|
else if (IsAlignedTangentMode(_selectedSpline, _lastPointSelected.Index))
|
||||||
else if (IsFreeTangentMode(_selectedSpline, _lastPointSelected.Index)) SetModeFree();
|
SetModeAligned();
|
||||||
|
else if (IsSmoothInTangentMode(_selectedSpline, _lastPointSelected.Index))
|
||||||
|
SetModeSmoothIn();
|
||||||
|
else if (IsSmoothOutTangentMode(_selectedSpline, _lastPointSelected.Index))
|
||||||
|
SetModeSmoothOut();
|
||||||
|
else if (IsFreeTangentMode(_selectedSpline, _lastPointSelected.Index))
|
||||||
|
SetModeFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetEditButtonsColor()
|
private void SetEditButtonsColor()
|
||||||
@@ -442,13 +490,15 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
|
|
||||||
private bool CanSetTangentSmoothIn()
|
private bool CanSetTangentSmoothIn()
|
||||||
{
|
{
|
||||||
if (!CanEditTangent()) return false;
|
if (!CanEditTangent())
|
||||||
|
return false;
|
||||||
return _lastPointSelected.Index != 0;
|
return _lastPointSelected.Index != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanSetTangentSmoothOut()
|
private bool CanSetTangentSmoothOut()
|
||||||
{
|
{
|
||||||
if (!CanEditTangent()) return false;
|
if (!CanEditTangent())
|
||||||
|
return false;
|
||||||
return _lastPointSelected.Index < _selectedSpline.SplinePointsCount - 1;
|
return _lastPointSelected.Index < _selectedSpline.SplinePointsCount - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,14 +514,16 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
|
|
||||||
private void SetModeLinear()
|
private void SetModeLinear()
|
||||||
{
|
{
|
||||||
if (_currentTangentMode is LinearTangentMode) return;
|
if (_currentTangentMode is LinearTangentMode)
|
||||||
|
return;
|
||||||
_currentTangentMode = new LinearTangentMode();
|
_currentTangentMode = new LinearTangentMode();
|
||||||
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetModeFree()
|
private void SetModeFree()
|
||||||
{
|
{
|
||||||
if (_currentTangentMode is FreeTangentMode) return;
|
if (_currentTangentMode is FreeTangentMode)
|
||||||
|
return;
|
||||||
_currentTangentMode = new FreeTangentMode();
|
_currentTangentMode = new FreeTangentMode();
|
||||||
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
||||||
SetEditButtonsColor();
|
SetEditButtonsColor();
|
||||||
@@ -479,21 +531,24 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
|
|
||||||
private void SetModeAligned()
|
private void SetModeAligned()
|
||||||
{
|
{
|
||||||
if (_currentTangentMode is AlignedTangentMode) return;
|
if (_currentTangentMode is AlignedTangentMode)
|
||||||
|
return;
|
||||||
_currentTangentMode = new AlignedTangentMode();
|
_currentTangentMode = new AlignedTangentMode();
|
||||||
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetModeSmoothIn()
|
private void SetModeSmoothIn()
|
||||||
{
|
{
|
||||||
if (_currentTangentMode is SmoothInTangentMode) return;
|
if (_currentTangentMode is SmoothInTangentMode)
|
||||||
|
return;
|
||||||
_currentTangentMode = new SmoothInTangentMode();
|
_currentTangentMode = new SmoothInTangentMode();
|
||||||
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetModeSmoothOut()
|
private void SetModeSmoothOut()
|
||||||
{
|
{
|
||||||
if (_currentTangentMode is SmoothOutTangentMode) return;
|
if (_currentTangentMode is SmoothOutTangentMode)
|
||||||
|
return;
|
||||||
_currentTangentMode = new SmoothOutTangentMode();
|
_currentTangentMode = new SmoothOutTangentMode();
|
||||||
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
_currentTangentMode.OnSetMode(_selectedSpline, _lastPointSelected.Index);
|
||||||
}
|
}
|
||||||
@@ -505,7 +560,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
{
|
{
|
||||||
var currentSelected = Editor.Instance.SceneEditing.Selection[0];
|
var currentSelected = Editor.Instance.SceneEditing.Selection[0];
|
||||||
|
|
||||||
if (currentSelected == _selectedPoint) return;
|
if (currentSelected == _selectedPoint)
|
||||||
|
return;
|
||||||
if (currentSelected is SplineNode.SplinePointNode)
|
if (currentSelected is SplineNode.SplinePointNode)
|
||||||
{
|
{
|
||||||
_selectedPoint = currentSelected as SplineNode.SplinePointNode;
|
_selectedPoint = currentSelected as SplineNode.SplinePointNode;
|
||||||
@@ -546,8 +602,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSelected == _selectedTangentIn) return;
|
if (currentSelected == _selectedTangentIn)
|
||||||
if (currentSelected == _selectedTangentOut) return;
|
return;
|
||||||
|
if (currentSelected == _selectedTangentOut)
|
||||||
|
return;
|
||||||
|
|
||||||
var index = _lastPointSelected.Index;
|
var index = _lastPointSelected.Index;
|
||||||
|
|
||||||
@@ -556,7 +614,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
_selectedTangentIn = currentSelected as SplineNode.SplinePointTangentNode;
|
_selectedTangentIn = currentSelected as SplineNode.SplinePointTangentNode;
|
||||||
_selectedTangentOut = null;
|
_selectedTangentOut = null;
|
||||||
_currentTangentMode.OnSelectTangent(_selectedSpline, index);
|
_currentTangentMode.OnSelectTangent(_selectedSpline, index);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,9 +645,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
{
|
{
|
||||||
if (Values[i] is Spline spline)
|
if (Values[i] is Spline spline)
|
||||||
{
|
{
|
||||||
splines.Add(new UndoData {
|
splines.Add(new UndoData
|
||||||
spline = spline,
|
{
|
||||||
beforeKeyframes = spline.SplineKeyframes.Clone() as BezierCurve<Transform>.Keyframe[]
|
Spline = spline,
|
||||||
|
BeforeKeyframes = spline.SplineKeyframes.Clone() as BezierCurve<Transform>.Keyframe[]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -609,9 +668,9 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
for (int i = 0; i < selectedSplinesUndoData.Length; i++)
|
for (int i = 0; i < selectedSplinesUndoData.Length; i++)
|
||||||
{
|
{
|
||||||
var splineUndoData = selectedSplinesUndoData[i];
|
var splineUndoData = selectedSplinesUndoData[i];
|
||||||
Presenter.Undo.AddAction(new EditSplineAction(_selectedSpline, splineUndoData.beforeKeyframes));
|
Presenter.Undo.AddAction(new EditSplineAction(_selectedSpline, splineUndoData.BeforeKeyframes));
|
||||||
SplineNode.OnSplineEdited(splineUndoData.spline);
|
SplineNode.OnSplineEdited(splineUndoData.Spline);
|
||||||
Editor.Instance.Scene.MarkSceneEdited(splineUndoData.spline.Scene);
|
Editor.Instance.Scene.MarkSceneEdited(splineUndoData.Spline.Scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,7 +688,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
|
|
||||||
private static bool IsFreeTangentMode(Spline spline, int index)
|
private static bool IsFreeTangentMode(Spline spline, int index)
|
||||||
{
|
{
|
||||||
if (IsLinearTangentMode(spline, index) ||
|
if (IsLinearTangentMode(spline, index) ||
|
||||||
IsAlignedTangentMode(spline, index) ||
|
IsAlignedTangentMode(spline, index) ||
|
||||||
IsSmoothInTangentMode(spline, index) ||
|
IsSmoothInTangentMode(spline, index) ||
|
||||||
IsSmoothOutTangentMode(spline, index))
|
IsSmoothOutTangentMode(spline, index))
|
||||||
@@ -748,8 +807,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
var smoothRange = SplineNode.NodeSizeByDistance(spline.GetSplinePoint(index), 10f);
|
var smoothRange = SplineNode.NodeSizeByDistance(spline.GetSplinePoint(index), 10f);
|
||||||
|
|
||||||
// force smooth it's linear point
|
// force smooth it's linear point
|
||||||
if (tangentInSize == 0f) tangentInSize = smoothRange;
|
if (tangentInSize == 0f)
|
||||||
if (tangentOutSize == 0f) tangentOutSize = smoothRange;
|
tangentInSize = smoothRange;
|
||||||
|
if (tangentOutSize == 0f)
|
||||||
|
tangentOutSize = smoothRange;
|
||||||
|
|
||||||
// try get next / last keyframe
|
// try get next / last keyframe
|
||||||
var nextKeyframe = !isLastKeyframe ? spline.GetSplineKeyframe(index + 1) : keyframe;
|
var nextKeyframe = !isLastKeyframe ? spline.GetSplineKeyframe(index + 1) : keyframe;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ using FlaxEditor.Modules;
|
|||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEngine.Json;
|
using FlaxEngine.Json;
|
||||||
using Object = FlaxEngine.Object;
|
using Object = FlaxEngine.Object;
|
||||||
using FlaxEditor.Viewport.Cameras;
|
|
||||||
|
|
||||||
namespace FlaxEditor.SceneGraph.Actors
|
namespace FlaxEditor.SceneGraph.Actors
|
||||||
{
|
{
|
||||||
@@ -22,7 +21,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
|||||||
[HideInEditor]
|
[HideInEditor]
|
||||||
public sealed class SplineNode : ActorNode
|
public sealed class SplineNode : ActorNode
|
||||||
{
|
{
|
||||||
public sealed class SplinePointNode : ActorChildNode<SplineNode>
|
internal sealed class SplinePointNode : ActorChildNode<SplineNode>
|
||||||
{
|
{
|
||||||
public unsafe SplinePointNode(SplineNode node, Guid id, int index)
|
public unsafe SplinePointNode(SplineNode node, Guid id, int index)
|
||||||
: base(node, id, index)
|
: base(node, id, index)
|
||||||
@@ -224,7 +223,7 @@ namespace FlaxEditor.SceneGraph.Actors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class SplinePointTangentNode : ActorChildNode
|
internal sealed class SplinePointTangentNode : ActorChildNode
|
||||||
{
|
{
|
||||||
private SplineNode _node;
|
private SplineNode _node;
|
||||||
private int _index;
|
private int _index;
|
||||||
@@ -415,36 +414,6 @@ namespace FlaxEditor.SceneGraph.Actors
|
|||||||
return distance * nodeSize;
|
return distance * nodeSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDebugDraw(ViewportDebugDrawData data)
|
|
||||||
{
|
|
||||||
DrawSpline((Spline)Actor, Color.White, Actor.Transform, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawSpline(Spline spline, Color color, Transform transform, bool depthTest)
|
|
||||||
{
|
|
||||||
var count = spline.SplineKeyframes.Length;
|
|
||||||
if (count == 0)
|
|
||||||
return;
|
|
||||||
var keyframes = spline.SplineKeyframes;
|
|
||||||
var pointIndex = 0;
|
|
||||||
var prev = spline.GetSplineKeyframe(0);
|
|
||||||
var prevPos = transform.LocalToWorld(prev.Value.Translation);
|
|
||||||
var pointSize = NodeSizeByDistance(spline.GetSplinePoint(0), PointNodeSize);
|
|
||||||
DebugDraw.DrawWireSphere(new BoundingSphere(prevPos, pointSize), color, 0.0f, depthTest);
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var next = keyframes[pointIndex];
|
|
||||||
var nextPos = transform.LocalToWorld(next.Value.Translation);
|
|
||||||
var d = (next.Time - prev.Time) / 3.0f;
|
|
||||||
pointSize = NodeSizeByDistance(spline.GetSplinePoint(i), PointNodeSize);
|
|
||||||
DebugDraw.DrawWireSphere(new BoundingSphere(nextPos, pointSize), color, 0.0f, depthTest);
|
|
||||||
DebugDraw.DrawBezier(prevPos, prevPos + prev.TangentOut.Translation * d, nextPos + next.TangentIn.Translation * d, nextPos, color, 0.0f, depthTest);
|
|
||||||
prev = next;
|
|
||||||
prevPos = nextPos;
|
|
||||||
pointIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal)
|
public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -484,8 +484,7 @@ namespace
|
|||||||
|
|
||||||
void Spline::OnDebugDraw()
|
void Spline::OnDebugDraw()
|
||||||
{
|
{
|
||||||
const Color color = GetSplineColor();
|
DrawSpline(this, GetSplineColor().AlphaMultiplied(0.7f), _transform, true);
|
||||||
DrawSpline(this, color.AlphaMultiplied(0.7f), _transform, true);
|
|
||||||
|
|
||||||
// Base
|
// Base
|
||||||
Actor::OnDebugDraw();
|
Actor::OnDebugDraw();
|
||||||
@@ -493,8 +492,7 @@ void Spline::OnDebugDraw()
|
|||||||
|
|
||||||
void Spline::OnDebugDrawSelected()
|
void Spline::OnDebugDrawSelected()
|
||||||
{
|
{
|
||||||
const Color color = GetSplineColor();
|
DrawSpline(this, Color::White, _transform, false);
|
||||||
DrawSpline(this, color.AlphaMultiplied(0.3f), _transform, false);
|
|
||||||
|
|
||||||
// Base
|
// Base
|
||||||
Actor::OnDebugDrawSelected();
|
Actor::OnDebugDrawSelected();
|
||||||
|
|||||||
@@ -354,6 +354,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
|
// Spline color getter for debug drawing, can be overriden by custom spline types.
|
||||||
virtual Color GetSplineColor()
|
virtual Color GetSplineColor()
|
||||||
{
|
{
|
||||||
return Color::White;
|
return Color::White;
|
||||||
|
|||||||
Reference in New Issue
Block a user