mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-02-07 06:12:47 +08:00
feat: control groups now use default-to-off, no override support for now
This commit is contained in:
parent
cae4622bfc
commit
93a0171940
@ -110,7 +110,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
AnimationClip clip = new AnimationClip();
|
AnimationClip clip = new AnimationClip();
|
||||||
foreach (var renderer in avatar.GetComponentsInChildren<SkinnedMeshRenderer>())
|
foreach (var renderer in avatar.GetComponentsInChildren<SkinnedMeshRenderer>())
|
||||||
{
|
{
|
||||||
if (!renderer.sharedMesh) continue;
|
if (!renderer.sharedMesh) continue;
|
||||||
int nShapes = renderer.sharedMesh.blendShapeCount;
|
int nShapes = renderer.sharedMesh.blendShapeCount;
|
||||||
for (int i = 0; i < nShapes; i++)
|
for (int i = 0; i < nShapes; i++)
|
||||||
{
|
{
|
||||||
@ -222,8 +222,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
expParams.parameters?.ToList() ?? new List<VRCExpressionParameters.Parameter>();
|
expParams.parameters?.ToList() ?? new List<VRCExpressionParameters.Parameter>();
|
||||||
List<BlendTree> blendTrees = new List<BlendTree>();
|
List<BlendTree> blendTrees = new List<BlendTree>();
|
||||||
|
|
||||||
Dictionary<ActionController, List<ModularAvatarMenuItem>> groupedItems =
|
Dictionary<Component, List<ModularAvatarMenuItem>> groupedItems =
|
||||||
new Dictionary<ActionController, List<ModularAvatarMenuItem>>();
|
new Dictionary<Component, List<ModularAvatarMenuItem>>();
|
||||||
|
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
@ -274,7 +274,21 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
group.Insert(0, null);
|
group.Insert(0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSaved = kvp.Key.isSavedProp, isSynced = kvp.Key.isSyncedProp;
|
bool isSaved, isSynced;
|
||||||
|
if (kvp.Key is ControlGroup cg_)
|
||||||
|
{
|
||||||
|
isSaved = cg_.isSaved;
|
||||||
|
isSynced = cg_.isSynced;
|
||||||
|
}
|
||||||
|
else if (kvp.Key is ModularAvatarMenuItem menuItem)
|
||||||
|
{
|
||||||
|
isSaved = menuItem.isSaved;
|
||||||
|
isSynced = menuItem.isSynced;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Unknown type " + kvp.Key.GetType());
|
||||||
|
}
|
||||||
|
|
||||||
expParameters.Add(new VRCExpressionParameters.Parameter()
|
expParameters.Add(new VRCExpressionParameters.Parameter()
|
||||||
{
|
{
|
||||||
@ -341,7 +355,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
|
|
||||||
void MergeCurves(
|
void MergeCurves(
|
||||||
IDictionary<MenuCurveBinding, (Component, AnimationCurve)> curves,
|
IDictionary<MenuCurveBinding, (Component, AnimationCurve)> curves,
|
||||||
ActionController controller,
|
Component controller,
|
||||||
Func<SwitchedMenuAction, IDictionary<MenuCurveBinding, AnimationCurve>> getCurves,
|
Func<SwitchedMenuAction, IDictionary<MenuCurveBinding, AnimationCurve>> getCurves,
|
||||||
bool ignoreDuplicates
|
bool ignoreDuplicates
|
||||||
)
|
)
|
||||||
@ -382,7 +396,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
private List<Motion> GenerateMotions(
|
private List<Motion> GenerateMotions(
|
||||||
List<ModularAvatarMenuItem> items,
|
List<ModularAvatarMenuItem> items,
|
||||||
Dictionary<MenuCurveBinding, Component> bindings,
|
Dictionary<MenuCurveBinding, Component> bindings,
|
||||||
ActionController controller
|
Component controller
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Dictionary<MenuCurveBinding, Component> newBindings = new Dictionary<MenuCurveBinding, Component>();
|
Dictionary<MenuCurveBinding, Component> newBindings = new Dictionary<MenuCurveBinding, Component>();
|
||||||
@ -397,7 +411,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
|
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
MergeCurves(inactiveCurves, item, a => a.GetInactiveCurves(false), true);
|
MergeCurves(inactiveCurves, item, a => a.GetInactiveCurves(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var inactiveMotion = CurvesToMotion(inactiveCurves);
|
var inactiveMotion = CurvesToMotion(inactiveCurves);
|
||||||
|
@ -39,7 +39,7 @@ namespace nadena.dev.modular_avatar.core
|
|||||||
).ToImmutableDictionary();
|
).ToImmutableDictionary();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableDictionary<MenuCurveBinding, AnimationCurve> GetInactiveCurves(bool isDefault)
|
public ImmutableDictionary<MenuCurveBinding, AnimationCurve> GetInactiveCurves()
|
||||||
{
|
{
|
||||||
var builder = ImmutableDictionary<MenuCurveBinding, AnimationCurve>.Empty.ToBuilder();
|
var builder = ImmutableDictionary<MenuCurveBinding, AnimationCurve>.Empty.ToBuilder();
|
||||||
|
|
||||||
@ -49,19 +49,9 @@ namespace nadena.dev.modular_avatar.core
|
|||||||
|
|
||||||
if (target == null) continue;
|
if (target == null) continue;
|
||||||
|
|
||||||
bool active;
|
|
||||||
if (isDefault)
|
|
||||||
{
|
|
||||||
active = !obj.Active; // inactive state is the opposite of the default state
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
active = target.activeSelf; // inactive state is the current state
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.Add(
|
builder.Add(
|
||||||
new MenuCurveBinding(target, typeof(GameObject), "m_IsActive"),
|
new MenuCurveBinding(target, typeof(GameObject), "m_IsActive"),
|
||||||
AnimationCurve.Constant(0, 1, active ? 1 : 0)
|
AnimationCurve.Constant(0, 1, 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,14 +3,11 @@
|
|||||||
namespace nadena.dev.modular_avatar.core
|
namespace nadena.dev.modular_avatar.core
|
||||||
{
|
{
|
||||||
[AddComponentMenu("Modular Avatar/MA Control Group")]
|
[AddComponentMenu("Modular Avatar/MA Control Group")]
|
||||||
public class ControlGroup : ActionController
|
public class ControlGroup : AvatarTagComponent
|
||||||
{
|
{
|
||||||
public bool isSynced = true;
|
public bool isSynced = true;
|
||||||
public bool isSaved = true;
|
public bool isSaved = true;
|
||||||
|
|
||||||
public ModularAvatarMenuItem defaultValue;
|
public ModularAvatarMenuItem defaultValue;
|
||||||
|
|
||||||
internal override bool isSyncedProp => isSynced;
|
|
||||||
internal override bool isSavedProp => isSaved;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,10 +24,11 @@ namespace nadena.dev.modular_avatar.core
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the curves applied when this action is inactive (and no other actions override).
|
/// Returns the curves applied when this action is inactive (and no other actions override).
|
||||||
|
/// In general, this should depend only on the path and state of the target objects, and not on the
|
||||||
|
/// configuration of the action itself (apart from target selection).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isDefault">True if this action is part of the default toggle option.</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
ImmutableDictionary<MenuCurveBinding, AnimationCurve> GetInactiveCurves(bool isDefault);
|
ImmutableDictionary<MenuCurveBinding, AnimationCurve> GetInactiveCurves();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TargetParameter
|
public enum TargetParameter
|
||||||
|
Loading…
Reference in New Issue
Block a user