Add debug drawing selected skeleton node in Skinned Model window viewport
This commit is contained in:
@@ -128,6 +128,18 @@ namespace FlaxEditor.Viewport.Previews
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EditorPrimitives EditorPrimitives => _editorPrimitives;
|
public EditorPrimitives EditorPrimitives => _editorPrimitives;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom debug drawing event (via <see cref="FlaxEngine.DebugDraw"/>).
|
||||||
|
/// </summary>
|
||||||
|
public event CustomDebugDrawDelegate CustomDebugDraw;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Debug shapes drawing delegate.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">The GPU context.</param>
|
||||||
|
/// <param name="renderContext">The render context.</param>
|
||||||
|
public delegate void CustomDebugDrawDelegate(GPUContext context, ref RenderContext renderContext);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="AssetPreview"/> class.
|
/// Initializes a new instance of the <see cref="AssetPreview"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -249,6 +261,7 @@ namespace FlaxEditor.Viewport.Previews
|
|||||||
{
|
{
|
||||||
DebugDraw.SetContext(_debugDrawContext);
|
DebugDraw.SetContext(_debugDrawContext);
|
||||||
DebugDraw.UpdateContext(_debugDrawContext, 1.0f / Mathf.Max(Engine.FramesPerSecond, 1));
|
DebugDraw.UpdateContext(_debugDrawContext, 1.0f / Mathf.Max(Engine.FramesPerSecond, 1));
|
||||||
|
CustomDebugDraw?.Invoke(context, ref renderContext);
|
||||||
OnDebugDraw(context, ref renderContext);
|
OnDebugDraw(context, ref renderContext);
|
||||||
DebugDraw.Draw(ref renderContext, target.View(), targetDepth.View(), true);
|
DebugDraw.Draw(ref renderContext, target.View(), targetDepth.View(), true);
|
||||||
DebugDraw.SetContext(IntPtr.Zero);
|
DebugDraw.SetContext(IntPtr.Zero);
|
||||||
|
|||||||
@@ -278,6 +278,8 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
[CustomEditor(typeof(ProxyEditor))]
|
[CustomEditor(typeof(ProxyEditor))]
|
||||||
private sealed class SkeletonPropertiesProxy : PropertiesProxyBase
|
private sealed class SkeletonPropertiesProxy : PropertiesProxyBase
|
||||||
{
|
{
|
||||||
|
internal Tree NodesTree;
|
||||||
|
|
||||||
private class ProxyEditor : ProxyEditorBase
|
private class ProxyEditor : ProxyEditorBase
|
||||||
{
|
{
|
||||||
public override void Initialize(LayoutElementsContainer layout)
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
@@ -325,6 +327,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
node.TreeNode.ExpandAll(true);
|
node.TreeNode.ExpandAll(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
proxy.NodesTree = tree.TreeControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blend Shapes
|
// Blend Shapes
|
||||||
@@ -808,6 +811,21 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
{
|
{
|
||||||
Proxy = new SkeletonPropertiesProxy();
|
Proxy = new SkeletonPropertiesProxy();
|
||||||
Presenter.Select(Proxy);
|
Presenter.Select(Proxy);
|
||||||
|
window._preview.CustomDebugDraw += OnDebugDraw;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDebugDraw(GPUContext context, ref RenderContext renderContext)
|
||||||
|
{
|
||||||
|
var proxy = (SkeletonPropertiesProxy)Proxy;
|
||||||
|
if (proxy.NodesTree != null)
|
||||||
|
{
|
||||||
|
// Draw selected skeleton nodes
|
||||||
|
foreach (var node in proxy.NodesTree.Selection)
|
||||||
|
{
|
||||||
|
proxy.Window._preview.PreviewActor.GetNodeTransformation(node.Text, out var nodeTransformation, true);
|
||||||
|
DebugDraw.DrawWireSphere(new BoundingSphere(nodeTransformation.TranslationVector, 4.0f), Color.Red, 0.0f, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user