Skip to content

Commit

Permalink
Add improved global animator masking support and some extra proxy ani…
Browse files Browse the repository at this point in the history
…mation conversion
  • Loading branch information
SaracenOne committed Aug 4, 2022
1 parent 09b3fea commit f5bd46c
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions Editor/VRC3CVR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public enum VRCBaseAnimatorID
// *first* layer.
AvatarMask gestureMask;

AvatarMask emptyMask;
AvatarMask fullMask;
AvatarMask musclesOnlyMask;

// Hands combined from both ChilloutVR animationClips
AnimationClip handCombinedFistAnimationClip;
AnimationClip handCombinedGunAnimationClip;
Expand Down Expand Up @@ -199,6 +203,11 @@ void Convert()
avatarMaskCombineCache = new Dictionary<(AvatarMask, AvatarMask), AvatarMask>();
gestureMask = null;

// Load hardcoded masks
emptyMask = (AvatarMask)AssetDatabase.LoadAssetAtPath("Assets/PeanutTools/vrc3cvr/Editor/vrc3cvrEmptyMask.mask", typeof(AvatarMask));
fullMask = (AvatarMask)AssetDatabase.LoadAssetAtPath("Assets/PeanutTools/vrc3cvr/Editor/vrc3cvrFullMask.mask", typeof(AvatarMask));
musclesOnlyMask = (AvatarMask)AssetDatabase.LoadAssetAtPath("Assets/PeanutTools/vrc3cvr/Editor/vrc3cvrMusclesOnly.mask", typeof(AvatarMask));

AssetDatabase.Refresh();

Directory.CreateDirectory(Application.dataPath + "/" + outputDirName);
Expand Down Expand Up @@ -761,6 +770,18 @@ Motion ReplaceProxyAnimationClip(Motion clip) {
} else {
return clip;
}
case "proxy_stand_still":
return (AnimationClip)AssetDatabase.LoadAssetAtPath("Assets/ABI.CCK/Animations/LocIdle.anim", typeof(AnimationClip));
case "proxy_idle":
return (AnimationClip)AssetDatabase.LoadAssetAtPath("Assets/ABI.CCK/Animations/LocIdle.anim", typeof(AnimationClip));
case "proxy_idle_2":
return (AnimationClip)AssetDatabase.LoadAssetAtPath("Assets/ABI.CCK/Animations/LocIdle.anim", typeof(AnimationClip));
case "proxy_idle_3":
return (AnimationClip)AssetDatabase.LoadAssetAtPath("Assets/ABI.CCK/Animations/LocIdle.anim", typeof(AnimationClip));
case "proxy_run_forward":
return (AnimationClip)AssetDatabase.LoadAssetAtPath("Assets/ABI.CCK/Animations/LocRunningForward.anim", typeof(AnimationClip));
case "proxy_run_backward":
return (AnimationClip)AssetDatabase.LoadAssetAtPath("Assets/ABI.CCK/Animations/LocRunningBackward.anim", typeof(AnimationClip));
default:
return clip;
}
Expand Down Expand Up @@ -1040,9 +1061,9 @@ AvatarMask GetAvatarMaskForLayerAndVRCAnimator(VRCBaseAnimatorID animatorID, int
switch(animatorID)
{
case VRCBaseAnimatorID.BASE:
return ReplaceVRCMask(originalMask);
return GetCombinedAvatarMask(ReplaceVRCMask(fullMask), ReplaceVRCMask(originalMask));
case VRCBaseAnimatorID.ADDITIVE:
return ReplaceVRCMask(originalMask);
return GetCombinedAvatarMask(ReplaceVRCMask(fullMask), ReplaceVRCMask(originalMask));
case VRCBaseAnimatorID.GESTURE:
if (layerID == 0) {
gestureMask = ReplaceVRCMask(originalMask);
Expand All @@ -1051,9 +1072,9 @@ AvatarMask GetAvatarMaskForLayerAndVRCAnimator(VRCBaseAnimatorID animatorID, int
return GetCombinedAvatarMask(ReplaceVRCMask(gestureMask), ReplaceVRCMask(originalMask));
}
case VRCBaseAnimatorID.ACTION:
return ReplaceVRCMask(originalMask);
return GetCombinedAvatarMask(ReplaceVRCMask(musclesOnlyMask), ReplaceVRCMask(originalMask));
case VRCBaseAnimatorID.FX:
return (AvatarMask)AssetDatabase.LoadAssetAtPath("Assets/PeanutTools/vrc3cvr/Editor/vrc3cvrEmptyMask.mask", typeof(AvatarMask));
return emptyMask;
default:
Debug.Log("Unknown VRC animator id");
return null;
Expand Down

0 comments on commit f5bd46c

Please sign in to comment.