fix: multiple animation generation bugs in shape changer (#867)

This commit is contained in:
bd_ 2024-06-03 13:28:14 +09:00 committed by GitHub
parent 66f3e7075c
commit 14897926bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -303,13 +303,13 @@ namespace nadena.dev.modular_avatar.core.editor
}, },
new ChildMotion() new ChildMotion()
{ {
motion = delTree, motion = AnimResult(info.ShapeKey, 100),
timeScale = 1, timeScale = 1,
threshold = 0.6f threshold = 0.6f
}, },
new ChildMotion() new ChildMotion()
{ {
motion = delTree, motion = AnimResult(info.ShapeKey, 100),
timeScale = 1, timeScale = 1,
threshold = 1 threshold = 1
}, },
@ -366,6 +366,8 @@ namespace nadena.dev.modular_avatar.core.editor
childMotions.Add(initMotion); childMotions.Add(initMotion);
paramNames.Add(MergeBlendTreePass.ALWAYS_ONE); paramNames.Add(MergeBlendTreePass.ALWAYS_ONE);
initialValues[MergeBlendTreePass.ALWAYS_ONE] = 1; initialValues[MergeBlendTreePass.ALWAYS_ONE] = 1;
initialValues[setParam] = 0;
initialValues[delParam] = 0;
foreach (var group in groups) foreach (var group in groups)
{ {
@ -455,18 +457,15 @@ namespace nadena.dev.modular_avatar.core.editor
var paramList = animController.parameters.ToList(); var paramList = animController.parameters.ToList();
var paramSet = paramList.Select(p => p.name).ToHashSet(); var paramSet = paramList.Select(p => p.name).ToHashSet();
foreach (var paramName in FindParams(bt)) foreach (var paramName in initialValues.Keys.Except(paramSet))
{ {
if (!paramSet.Contains(paramName)) paramList.Add(new AnimatorControllerParameter()
{ {
paramList.Add(new AnimatorControllerParameter() name = paramName,
{ type = AnimatorControllerParameterType.Float,
name = paramName, defaultFloat = initialValues[paramName], // TODO
type = AnimatorControllerParameterType.Float, });
defaultFloat = 0, // TODO paramSet.Add(paramName);
});
paramSet.Add(paramName);
}
} }
animController.parameters = paramList.ToArray(); animController.parameters = paramList.ToArray();
@ -558,7 +557,11 @@ namespace nadena.dev.modular_avatar.core.editor
shapeKeys[key] = info; shapeKeys[key] = info;
// Add initial state // Add initial state
info.setObjects.Add(new ActionGroupKey(asc, key, null, shape)); var agk = new ActionGroupKey(asc, key, null, shape);
agk.IsDelete = false;
agk.InitiallyActive = true;
agk.Value = renderer.GetBlendShapeWeight(shapeId);
info.setObjects.Add(agk);
} }
var action = new ActionGroupKey(asc, key, changer.gameObject, shape); var action = new ActionGroupKey(asc, key, changer.gameObject, shape);