-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
586 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
2 changes: 1 addition & 1 deletion
2
Editor/Menu/MenuGroupBuilder.cs.meta → ...sses/VRChat/ScanVRCAnimationsPass.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.