Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
poi-vrc committed Jan 25, 2024
1 parent f5083f1 commit e460b75
Show file tree
Hide file tree
Showing 45 changed files with 586 additions and 106 deletions.
2 changes: 0 additions & 2 deletions Editor/Animations/AnimationStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ namespace Chocopoi.DressingFramework.Animations
/// Animation store
///
/// Warning: This API is subject to change.
/// Since MA have not exposed the AnimationDatabase and NDMF does not have the standard, if the same project contains MA and DK is using NDMF runtime,
/// this context feature is not available as no animators will be cloned to prevent unexpected behaviour.
/// </summary>
public class AnimationStore : ContextFeature
{
Expand Down
3 changes: 0 additions & 3 deletions Editor/Animations/PathRemapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ namespace Chocopoi.DressingFramework.Animations
/// Path remapper
///
/// Warning: This API is subject to change.
/// Since MA have not exposed the PathMappings API, if the same project contains MA and NDMF,
/// this will only provide a way to detect GameObject relocations but does not remap existing
/// animations to prevent unexpected behaviour.
/// </summary>
public class PathRemapper : ContextFeature
{
Expand Down
11 changes: 11 additions & 0 deletions Editor/Animations/VRChat/VRCAnimUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#if DK_VRCSDK3A
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
using VRC.SDK3.Avatars.Components;

namespace Chocopoi.DressingFramework.Animations.VRChat
Expand Down Expand Up @@ -69,6 +70,16 @@ public static AnimatorController GetDefaultLayerAnimator(VRCAvatarDescriptor.Ani
}
return controller;
}

public static bool IsProxyAnimation(Motion m)
{
if (m == null)
{
return false;
}
var animPath = AssetDatabase.GetAssetPath(m);
return animPath != null && animPath != "" && animPath.Contains("/Animation/ProxyAnim/proxy");
}
}
}
#endif
1 change: 0 additions & 1 deletion Editor/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using System;
using System.Collections.Generic;
using Chocopoi.DressingFramework.Animations;
using Chocopoi.DressingFramework.Detail.DK.Logging;
using Chocopoi.DressingFramework.Dynamics;
using Chocopoi.DressingFramework.Logging;
using UnityEngine;
Expand Down
8 changes: 4 additions & 4 deletions Editor/Detail/DK/DKMenuStore.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2023 chocopoi
*
* This file is part of DressingTools.
* This file is part of DressingFramework.
*
* DressingTools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* DressingFramework is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* DressingTools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* DressingFramework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License along with DressingFramework. If not, see <https://www.gnu.org/licenses/>.
*/

using Chocopoi.DressingFramework.Menu;
Expand Down
8 changes: 4 additions & 4 deletions Editor/Detail/DK/Logging/ReportWindow.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2023 chocopoi
*
* This file is part of DressingTools.
* This file is part of DressingFramework.
*
* DressingTools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* DressingFramework is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* DressingTools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* DressingFramework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License along with DressingFramework. If not, see <https://www.gnu.org/licenses/>.
*/

using System;
Expand Down
1 change: 0 additions & 1 deletion Editor/Detail/DK/Passes/VRChat/CloneVRCAnimLayersPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/

#if DK_VRCSDK3A
using System.IO;
using Chocopoi.DressingFramework.Animations.VRChat;
using Chocopoi.DressingFramework.Extensibility.Sequencing;
using Chocopoi.DressingFramework.Localization;
Expand Down
83 changes: 83 additions & 0 deletions Editor/Detail/DK/Passes/VRChat/ScanVRCAnimationsPass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2024 chocopoi
*
* This file is part of DressingFramework.
*
* DressingFramework is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* DressingFramework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DressingFramework. If not, see <https://www.gnu.org/licenses/>.
*/

#if DK_VRCSDK3A
using System.Collections.Generic;
using Chocopoi.DressingFramework.Animations;
using Chocopoi.DressingFramework.Animations.VRChat;
using Chocopoi.DressingFramework.Extensibility.Sequencing;
using UnityEditor.Animations;
using UnityEngine;
using VRC.SDK3.Avatars.Components;

namespace Chocopoi.DressingFramework.Detail.DK.Passes.VRChat
{
internal class ScanVRCAnimationsPass : BuildPass
{
public override BuildConstraint Constraint =>
InvokeAtStage(BuildStage.Preparation)
.AfterPass(typeof(CloneVRCAnimLayersPass))
.Build();

private void ScanAnimLayers(Context ctx, VRCAvatarDescriptor.CustomAnimLayer[] animLayers)
{
var store = ctx.Feature<AnimationStore>();

foreach (var animLayer in animLayers)
{
if (animLayer.isDefault || animLayer.animatorController == null || !(animLayer.animatorController is AnimatorController))
{
continue;
}

var controller = (AnimatorController)animLayer.animatorController;
var visitedMotions = new HashSet<Motion>();

foreach (var layer in controller.layers)
{
var stack = new Stack<AnimatorStateMachine>();
stack.Push(layer.stateMachine);

while (stack.Count > 0)
{
var stateMachine = stack.Pop();

foreach (var state in stateMachine.states)
{
store.RegisterMotion(state.state.motion, (AnimationClip clip) => state.state.motion = clip, (Motion m) => !VRCAnimUtils.IsProxyAnimation(m), visitedMotions);
}

foreach (var childStateMachine in stateMachine.stateMachines)
{
stack.Push(childStateMachine.stateMachine);
}
}
}
}
}

public override bool Invoke(Context ctx)
{
if (!ctx.AvatarGameObject.TryGetComponent<VRCAvatarDescriptor>(out var avatarDesc))
{
// not a VRC avatar
return true;
}

ScanAnimLayers(ctx, avatarDesc.baseAnimationLayers);
ScanAnimLayers(ctx, avatarDesc.specialAnimationLayers);

return true;
}
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Editor/Detail/DressingFrameworkPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private void RegisterInternalPasses()
#if DK_VRCSDK3A
RegisterBuildPass(new DK.Passes.VRChat.CloneVRCAnimLayersPass());
RegisterBuildPass(new DK.Passes.VRChat.CloneVRCExMenuAndParamsPass());
RegisterBuildPass(new DK.Passes.VRChat.ScanVRCAnimationsPass());
RegisterBuildPass(new DK.Passes.VRChat.ApplyVRCExParamsPass());
#endif
}
Expand Down
1 change: 0 additions & 1 deletion Editor/Dynamics/DynamicsStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

using System.Collections.Generic;
using Chocopoi.DressingFramework.Dynamics.Proxy;
using UnityEngine;

namespace Chocopoi.DressingFramework.Dynamics
{
Expand Down
2 changes: 1 addition & 1 deletion Editor/Extensibility/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Chocopoi.DressingFramework.Extensibility
internal class PluginManager
{
private static HashSet<Type> s_pluginTypesCache;
private Dictionary<string, Plugin> _plugins;
private readonly Dictionary<string, Plugin> _plugins;

public PluginManager()
{
Expand Down
28 changes: 14 additions & 14 deletions Editor/Extensibility/Sequencing/BuildConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public BuildConstraintBuilder(BuildStage stage)
/// <param name="type">Hook type</param>
/// <param name="optional">Optional dependency. If not optional, the dependency solving will fail if the dependency does not exist.</param>
/// <returns>This builder</returns>
public BuildConstraintBuilder BeforeHook(Type type, bool optional = false)
public BuildConstraintBuilder BeforePass(Type type, bool optional = false)
{
InnerBefore(type.FullName, optional);
return this;
Expand All @@ -119,7 +119,7 @@ public BuildConstraintBuilder BeforeHook(Type type, bool optional = false)
/// <param name="identifier">Hook identifier</param>
/// <param name="optional">Optional dependency. If not optional, the dependency solving will fail if the dependency does not exist.</param>
/// <returns>This builder</returns>
public BuildConstraintBuilder BeforeHook(string identifier, bool optional = false)
public BuildConstraintBuilder BeforePass(string identifier, bool optional = false)
{
InnerBefore(identifier, optional);
return this;
Expand All @@ -131,7 +131,7 @@ public BuildConstraintBuilder BeforeHook(string identifier, bool optional = fals
/// <param name="type">Hook type</param>
/// <param name="optional">Optional dependency. If not optional, the dependency solving will fail if the dependency does not exist</param>
/// <returns>This builder</returns>
public BuildConstraintBuilder AfterHook(Type type, bool optional = false)
public BuildConstraintBuilder AfterPass(Type type, bool optional = false)
{
InnerAfter(type.FullName, optional);
return this;
Expand All @@ -143,7 +143,7 @@ public BuildConstraintBuilder AfterHook(Type type, bool optional = false)
/// <param name="identifier">Hook identifier</param>
/// <param name="optional">Optional dependency. If not optional, the dependency solving will fail if the dependency does not exist</param>
/// <returns>This builder</returns>
public BuildConstraintBuilder AfterHook(string identifier, bool optional = false)
public BuildConstraintBuilder AfterPass(string identifier, bool optional = false)
{
InnerAfter(identifier, optional);
return this;
Expand All @@ -155,9 +155,9 @@ public BuildConstraintBuilder AfterHook(string identifier, bool optional = false
/// <param name="type">Hook type</param>
/// <param name="optional">Optional dependency. If not optional, the dependency solving will fail if the dependency does not exist.</param>
/// <returns>This builder</returns>
public BuildConstraintBuilder BeforeRuntimeHook(Type type, bool optional = false)
public BuildConstraintBuilder BeforeRuntimePass(Type type, bool optional = false)
{
InnerBeforeRuntimeHook(type.FullName, optional);
InnerBeforeRuntimePass(type.FullName, optional);
return this;
}

Expand All @@ -167,9 +167,9 @@ public BuildConstraintBuilder BeforeRuntimeHook(Type type, bool optional = false
/// <param name="identifier">Hook identifier</param>
/// <param name="optional">Optional dependency. If not optional, the dependency solving will fail if the dependency does not exist.</param>
/// <returns>This builder</returns>
public BuildConstraintBuilder BeforeRuntimeHook(string identifier, bool optional = false)
public BuildConstraintBuilder BeforeRuntimePass(string identifier, bool optional = false)
{
InnerBeforeRuntimeHook(identifier, optional);
InnerBeforeRuntimePass(identifier, optional);
return this;
}

Expand All @@ -179,9 +179,9 @@ public BuildConstraintBuilder BeforeRuntimeHook(string identifier, bool optional
/// <param name="type">Hook type</param>
/// <param name="optional">Optional dependency. If not optional, the dependency solving will fail if the dependency does not exist</param>
/// <returns>This builder</returns>
public BuildConstraintBuilder AfterRuntimeHook(Type type, bool optional = false)
public BuildConstraintBuilder AfterRuntimePass(Type type, bool optional = false)
{
InnerAfterRuntimeHook(type.FullName, optional);
InnerAfterRuntimePass(type.FullName, optional);
return this;
}

Expand All @@ -191,13 +191,13 @@ public BuildConstraintBuilder AfterRuntimeHook(Type type, bool optional = false)
/// <param name="identifier">Hook identifier</param>
/// <param name="optional">Optional dependency. If not optional, the dependency solving will fail if the dependency does not exist</param>
/// <returns>This builder</returns>
public BuildConstraintBuilder AfterRuntimeHook(string identifier, bool optional = false)
public BuildConstraintBuilder AfterRuntimePass(string identifier, bool optional = false)
{
InnerAfterRuntimeHook(identifier, optional);
InnerAfterRuntimePass(identifier, optional);
return this;
}

protected BuildConstraintBuilder InnerBeforeRuntimeHook(string identifier, bool optional = false)
protected BuildConstraintBuilder InnerBeforeRuntimePass(string identifier, bool optional = false)
{
beforeRuntimeHooks.Add(new Dependency<string>()
{
Expand All @@ -207,7 +207,7 @@ protected BuildConstraintBuilder InnerBeforeRuntimeHook(string identifier, bool
return this;
}

protected BuildConstraintBuilder InnerAfterRuntimeHook(string identifier, bool optional = false)
protected BuildConstraintBuilder InnerAfterRuntimePass(string identifier, bool optional = false)
{
afterRuntimeHooks.Add(new Dependency<string>()
{
Expand Down
4 changes: 0 additions & 4 deletions Editor/Menu/MenuGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
* You should have received a copy of the GNU General Public License along with DressingFramework. If not, see <https://www.gnu.org/licenses/>.
*/

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Chocopoi.DressingFramework.Menu
{
Expand All @@ -36,11 +34,9 @@ public MenuGroup()
public void Add(MenuItem menuItem) => Items.Add(menuItem);
public void Clear() => Items.Clear();
public int Count() => Items.Count;
public MenuItem Get(int index) => Items[index];
public IEnumerator<MenuItem> GetEnumerator() => Items.GetEnumerator();
public void Insert(int index, MenuItem menuItem) => Items.Insert(index, menuItem);
public void Remove(int index) => Items.RemoveAt(index);
public void Set(int index, MenuItem menuItem) => Items[index] = menuItem;
IEnumerator IEnumerable.GetEnumerator() => Items.GetEnumerator();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@
*/

#if DK_VRCSDK3A

using UnityEngine;
using VRC.SDK3.Avatars.ScriptableObjects;

namespace Chocopoi.DressingFramework.Menu.VRChat
{
public class VRCMenuBuilder : MenuRepositoryBuilder
public static class VRCMenuBuilderExtensions
{
public VRCMenuBuilder(VRCExpressionsMenu vrcMenu, Context ctx = null) : base(new VRCMenuWrapper(vrcMenu, ctx))
{
}

public MenuRepositoryBuilder AddSubMenu(string name, VRCExpressionsMenu vrcMenu, Texture2D icon = null)
public static MenuRepositoryBuilder AddSubMenu(this MenuRepositoryBuilder builder, string name, VRCExpressionsMenu vrcMenu, Texture2D icon = null)
{
// TODO: parameter on open
return AddMenuItem(new VRCMenuItem()
return builder.AddMenuItem(new VRCMenuItem()
{
name = name,
icon = icon,
Expand All @@ -35,11 +30,6 @@ public MenuRepositoryBuilder AddSubMenu(string name, VRCExpressionsMenu vrcMenu,
vrcSubMenu = vrcMenu
});
}

public VRCExpressionsMenu GetContainingVRCExpressionsMenu()
{
return ((VRCMenuWrapper)GetContainingMenuRepository()).GetContainingMenu();
}
}
}
#endif
File renamed without changes.
4 changes: 2 additions & 2 deletions Editor/Menu/VRChat/VRCMenuWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class VRCMenuWrapper : IMenuRepository
{
public MenuItem this[int index] { get => VRCMenuUtils.ControlToMenuItem(_vrcMenu.controls[index]); set => _vrcMenu.controls[index] = VRCMenuUtils.MenuItemToControl(value, _ctx); }

private VRCExpressionsMenu _vrcMenu;
private Context _ctx;
private readonly VRCExpressionsMenu _vrcMenu;
private readonly Context _ctx;

public VRCMenuWrapper(VRCExpressionsMenu vrcMenu, Context ctx = null)
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using UnityEditor.Animations;
using UnityEngine;

namespace Chocopoi.DressingFramework.Tests.Details.DK.Animations
namespace Chocopoi.DressingFramework.Tests.Animations
{
public class AnimationStoreTest : EditorTestBase
{
Expand Down
Loading

0 comments on commit e460b75

Please sign in to comment.