mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-24 13:29:01 +08:00
parent
fd3de6e680
commit
ec2bc9f109
@ -236,8 +236,10 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool? ProbeWriteDefaults(AnimatorController controller)
|
internal static bool? ProbeWriteDefaults(AnimatorController controller)
|
||||||
{
|
{
|
||||||
|
if (controller == null) return null;
|
||||||
|
|
||||||
bool hasWDOn = false;
|
bool hasWDOn = false;
|
||||||
bool hasWDOff = false;
|
bool hasWDOff = false;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
private HashSet<string> activeProps = new();
|
private HashSet<string> activeProps = new();
|
||||||
|
|
||||||
private AnimationClip _initialStateClip;
|
private AnimationClip _initialStateClip;
|
||||||
|
private bool _writeDefaults;
|
||||||
|
|
||||||
public ReactiveObjectPass(ndmf.BuildContext context)
|
public ReactiveObjectPass(ndmf.BuildContext context)
|
||||||
{
|
{
|
||||||
@ -33,6 +34,10 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
|
|
||||||
internal void Execute()
|
internal void Execute()
|
||||||
{
|
{
|
||||||
|
// Having a WD OFF layer after WD ON layers can break WD. We match the behavior of the existing states,
|
||||||
|
// and if mixed, use WD ON to maximize compatibility.
|
||||||
|
_writeDefaults = MergeAnimatorProcessor.ProbeWriteDefaults(FindFxController().animatorController as AnimatorController) ?? true;
|
||||||
|
|
||||||
var analysis = new ReactiveObjectAnalyzer(context).Analyze(context.AvatarRootObject);
|
var analysis = new ReactiveObjectAnalyzer(context).Analyze(context.AvatarRootObject);
|
||||||
|
|
||||||
var shapes = analysis.Shapes;
|
var shapes = analysis.Shapes;
|
||||||
@ -277,7 +282,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
var initial = new AnimationClip();
|
var initial = new AnimationClip();
|
||||||
var initialState = new AnimatorState();
|
var initialState = new AnimatorState();
|
||||||
initialState.motion = initial;
|
initialState.motion = initial;
|
||||||
initialState.writeDefaultValues = false;
|
initialState.writeDefaultValues = _writeDefaults;
|
||||||
initialState.name = "<default>";
|
initialState.name = "<default>";
|
||||||
asm.defaultState = initialState;
|
asm.defaultState = initialState;
|
||||||
|
|
||||||
@ -349,7 +354,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
state.name = group.ControllingConditions[0].DebugName.Replace(".", "_");
|
state.name = group.ControllingConditions[0].DebugName.Replace(".", "_");
|
||||||
|
|
||||||
state.motion = clip;
|
state.motion = clip;
|
||||||
state.writeDefaultValues = false;
|
state.writeDefaultValues = _writeDefaults;
|
||||||
states.Add(new ChildAnimatorState
|
states.Add(new ChildAnimatorState
|
||||||
{
|
{
|
||||||
position = new Vector3(x, y),
|
position = new Vector3(x, y),
|
||||||
@ -525,8 +530,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
|
|
||||||
private void ApplyController(AnimatorStateMachine asm, string layerName)
|
private void ApplyController(AnimatorStateMachine asm, string layerName)
|
||||||
{
|
{
|
||||||
var fx = context.AvatarDescriptor.baseAnimationLayers
|
var fx = FindFxController();
|
||||||
.FirstOrDefault(l => l.type == VRCAvatarDescriptor.AnimLayerType.FX);
|
|
||||||
if (fx.animatorController == null)
|
if (fx.animatorController == null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("No FX layer found");
|
throw new InvalidOperationException("No FX layer found");
|
||||||
@ -567,5 +572,13 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
}
|
}
|
||||||
).ToArray();
|
).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private VRCAvatarDescriptor.CustomAnimLayer FindFxController()
|
||||||
|
{
|
||||||
|
var fx = context.AvatarDescriptor.baseAnimationLayers
|
||||||
|
.FirstOrDefault(l => l.type == VRCAvatarDescriptor.AnimLayerType.FX);
|
||||||
|
|
||||||
|
return fx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user