mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-02-01 03:02:56 +08:00
chore: extract mapping constraint source to one method
This commit is contained in:
parent
27bb7b6312
commit
664a6c3081
@ -118,53 +118,27 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
for (int i = 0; i < nSources; i++)
|
||||
{
|
||||
var source = constraint.GetSource(i);
|
||||
if (source.sourceTransform == null) continue;
|
||||
if (!BoneRemappings.TryGetValue(source.sourceTransform, out var remap)) continue;
|
||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
||||
|
||||
if (retarget != null)
|
||||
{
|
||||
source.sourceTransform = retarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
source.sourceTransform = remap;
|
||||
}
|
||||
|
||||
source.sourceTransform = MapConstraintSource(source.sourceTransform);
|
||||
constraint.SetSource(i, source);
|
||||
}
|
||||
}
|
||||
|
||||
private void FixupAimConstraint(AimConstraint constraint)
|
||||
{
|
||||
if (constraint.worldUpObject == null) return;
|
||||
if (!BoneRemappings.TryGetValue(constraint.worldUpObject, out var remap)) return;
|
||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
||||
|
||||
if (retarget != null)
|
||||
{
|
||||
constraint.worldUpObject = retarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
constraint.worldUpObject = remap;
|
||||
}
|
||||
constraint.worldUpObject = MapConstraintSource(constraint.worldUpObject);
|
||||
}
|
||||
|
||||
private void FixupLookAtConstraint(LookAtConstraint constraint)
|
||||
{
|
||||
if (constraint.worldUpObject == null) return;
|
||||
if (!BoneRemappings.TryGetValue(constraint.worldUpObject, out var remap)) return;
|
||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
||||
constraint.worldUpObject = MapConstraintSource(constraint.worldUpObject);
|
||||
}
|
||||
|
||||
if (retarget != null)
|
||||
private Transform MapConstraintSource(Transform transform)
|
||||
{
|
||||
constraint.worldUpObject = retarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
constraint.worldUpObject = remap;
|
||||
}
|
||||
if (transform == null) return null;
|
||||
if (!BoneRemappings.TryGetValue(transform, out var remap)) return transform;
|
||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
||||
return retarget != null ? retarget : remap;
|
||||
}
|
||||
|
||||
private void UpdateBoneReferences(Component c, Retargetable retargetable = Retargetable.Disable)
|
||||
|
Loading…
Reference in New Issue
Block a user