Add minor improvement to anim graph editing
This commit is contained in:
@@ -570,7 +570,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
var icon = Editor.Instance.Icons.VisjectBoxOpen32;
|
||||
var size = BlendPoint.DefaultSize * _debugScale;
|
||||
var debugPos = BlendSpacePosToBlendPointPos(_debugPos);
|
||||
var debugRect = new Rectangle(debugPos + new Float2(size * -0.5f) + size * 0.5f, new Float2(size));
|
||||
var debugRect = new Rectangle(debugPos + new Float2(size * -0.5f), new Float2(size));
|
||||
var outline = Color.Black; // Shadow
|
||||
Render2D.DrawSprite(icon, debugRect.MakeExpanded(2.0f), outline);
|
||||
Render2D.DrawSprite(icon, debugRect, style.ProgressNormal);
|
||||
|
||||
@@ -228,6 +228,13 @@ namespace FlaxEditor.Surface
|
||||
/// </summary>
|
||||
protected virtual void OnContextChanged()
|
||||
{
|
||||
// Cache viewport of the context (used to restore when leaving it)
|
||||
if (_context != null)
|
||||
{
|
||||
_context._cachedViewCenterPosition = ViewCenterPosition;
|
||||
_context._cachedViewScale = ViewScale;
|
||||
}
|
||||
|
||||
var context = ContextStack.Count > 0 ? ContextStack.Peek() : null;
|
||||
_context = context;
|
||||
if (ContextStack.Count == 0)
|
||||
@@ -249,6 +256,18 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
ContextChanged?.Invoke(_context);
|
||||
|
||||
// Restore viewport in the context
|
||||
if (_context?._cachedViewScale > 0.0f)
|
||||
{
|
||||
ViewScale = _context._cachedViewScale;
|
||||
ViewCenterPosition = _context._cachedViewCenterPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show whole surface on load
|
||||
ShowWholeGraph();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace FlaxEditor.Surface
|
||||
private bool _isModified;
|
||||
private VisjectSurface _surface;
|
||||
private SurfaceMeta _meta = new SurfaceMeta();
|
||||
internal Float2 _cachedViewCenterPosition;
|
||||
internal float _cachedViewScale = -1; // Negative scale to indicate missing data (will show whole surface on start)
|
||||
|
||||
/// <summary>
|
||||
/// The parent context. Defines the higher key surface graph context. May be null for the top-level context.
|
||||
|
||||
@@ -371,6 +371,9 @@ namespace FlaxEditor.Windows.Assets
|
||||
// Update navbar
|
||||
_surface.UpdateNavigationBar(_navigationBar, _toolstrip);
|
||||
|
||||
// Show whole model
|
||||
_preview.ResetCamera();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -437,6 +440,16 @@ namespace FlaxEditor.Windows.Assets
|
||||
_debugFlows.Clear();
|
||||
}
|
||||
|
||||
// Update preview values when debugging specific instance
|
||||
if (debugActor != null && debugActor != _preview.PreviewActor)
|
||||
{
|
||||
var parameters = debugActor.Parameters;
|
||||
foreach (var p in parameters)
|
||||
{
|
||||
_preview.PreviewActor.SetParameterValue(p.Identifier, p.Value);
|
||||
}
|
||||
}
|
||||
|
||||
_showNodesButton.Checked = _preview.ShowNodes;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
/// <param name="predicate">The prediction function. Should return true for the target element to find.</param>
|
||||
/// <returns>The first found item or default value if nothing found.</returns>
|
||||
template<typename T, typename AllocationType>
|
||||
static T First(const Array<T, AllocationType>& obj, const Function<bool(const T&)> predicate)
|
||||
static T First(const Array<T, AllocationType>& obj, const Function<bool(const T&)>& predicate)
|
||||
{
|
||||
for (int32 i = 0; i < obj.Count(); i++)
|
||||
{
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
/// <param name="predicate">The prediction function. Should return true for the target element to find.</param>
|
||||
/// <returns>The first found item or default value if nothing found.</returns>
|
||||
template<typename T, typename AllocationType>
|
||||
static T* First(const Array<T*, AllocationType>& obj, const Function<bool(const T*)> predicate)
|
||||
static T* First(const Array<T*, AllocationType>& obj, const Function<bool(const T*)>& predicate)
|
||||
{
|
||||
for (int32 i = 0; i < obj.Count(); i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user