diff --git a/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs b/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs index 86ee3dc17..158ccc370 100644 --- a/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs +++ b/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. +using FlaxEditor.GUI.ContextMenu; using FlaxEngine; using FlaxEditor.GUI.Input; using Object = FlaxEngine.Object; @@ -12,8 +13,9 @@ namespace FlaxEditor.Viewport.Previews /// public class AnimatedModelPreview : AssetPreview { + private ContextMenuButton _showBoundsButton; private AnimatedModel _previewModel; - private bool _showNodes; + private bool _showNodes, _showBounds; /// /// Gets or sets the skinned model asset to preview. @@ -44,10 +46,23 @@ namespace FlaxEditor.Viewport.Previews { _showNodes = value; if (value) - { ShowDebugDraw = true; - ShowEditorPrimitives = true; - } + } + } + + /// + /// Gets or sets a value indicating whether show animated model bounding box debug view. + /// + public bool ShowBounds + { + get => _showBounds; + set + { + _showBounds = value; + if (value) + ShowDebugDraw = true; + if (_showBoundsButton != null) + _showBoundsButton.Checked = value; } } @@ -84,6 +99,9 @@ namespace FlaxEditor.Viewport.Previews if (useWidgets) { + // Show Bounds + _showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds); + // Preview LOD { var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD"); @@ -160,6 +178,12 @@ namespace FlaxEditor.Viewport.Previews } } } + + // Draw bounds + if (_showBounds) + { + DebugDraw.DrawWireBox(_previewModel.Box, Color.Violet.RGBMultiplied(0.8f), 0, false); + } } /// diff --git a/Source/Editor/Viewport/Previews/AssetPreview.cs b/Source/Editor/Viewport/Previews/AssetPreview.cs index f6126480c..150990447 100644 --- a/Source/Editor/Viewport/Previews/AssetPreview.cs +++ b/Source/Editor/Viewport/Previews/AssetPreview.cs @@ -85,6 +85,11 @@ namespace FlaxEditor.Viewport.Previews view.Flags |= ViewFlags.DebugDraw; Task.View = view; } + if (value) + { + // Need to show editor primitives to show debug shapes + ShowEditorPrimitives = true; + } } } diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index a62aad592..df1650eac 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -617,7 +617,7 @@ void AnimatedModel::DrawGeneric(RenderContext& renderContext) void AnimatedModel::OnDebugDrawSelected() { - DEBUG_DRAW_WIRE_BOX(_box, Color::Violet * 0.8f, 0, true); + DEBUG_DRAW_WIRE_BOX(_box, Color::Violet.RGBMultiplied(0.8f), 0, true); // Base ModelInstanceActor::OnDebugDrawSelected();