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++)
|
for (int i = 0; i < nSources; i++)
|
||||||
{
|
{
|
||||||
var source = constraint.GetSource(i);
|
var source = constraint.GetSource(i);
|
||||||
if (source.sourceTransform == null) continue;
|
source.sourceTransform = MapConstraintSource(source.sourceTransform);
|
||||||
if (!BoneRemappings.TryGetValue(source.sourceTransform, out var remap)) continue;
|
|
||||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
|
||||||
|
|
||||||
if (retarget != null)
|
|
||||||
{
|
|
||||||
source.sourceTransform = retarget;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
source.sourceTransform = remap;
|
|
||||||
}
|
|
||||||
|
|
||||||
constraint.SetSource(i, source);
|
constraint.SetSource(i, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixupAimConstraint(AimConstraint constraint)
|
private void FixupAimConstraint(AimConstraint constraint)
|
||||||
{
|
{
|
||||||
if (constraint.worldUpObject == null) return;
|
constraint.worldUpObject = MapConstraintSource(constraint.worldUpObject);
|
||||||
if (!BoneRemappings.TryGetValue(constraint.worldUpObject, out var remap)) return;
|
|
||||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
|
||||||
|
|
||||||
if (retarget != null)
|
|
||||||
{
|
|
||||||
constraint.worldUpObject = retarget;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
constraint.worldUpObject = remap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixupLookAtConstraint(LookAtConstraint constraint)
|
private void FixupLookAtConstraint(LookAtConstraint constraint)
|
||||||
{
|
{
|
||||||
if (constraint.worldUpObject == null) return;
|
constraint.worldUpObject = MapConstraintSource(constraint.worldUpObject);
|
||||||
if (!BoneRemappings.TryGetValue(constraint.worldUpObject, out var remap)) return;
|
}
|
||||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
|
||||||
|
|
||||||
if (retarget != null)
|
private Transform MapConstraintSource(Transform transform)
|
||||||
{
|
{
|
||||||
constraint.worldUpObject = retarget;
|
if (transform == null) return null;
|
||||||
}
|
if (!BoneRemappings.TryGetValue(transform, out var remap)) return transform;
|
||||||
else
|
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
||||||
{
|
return retarget != null ? retarget : remap;
|
||||||
constraint.worldUpObject = remap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateBoneReferences(Component c, Retargetable retargetable = Retargetable.Disable)
|
private void UpdateBoneReferences(Component c, Retargetable retargetable = Retargetable.Disable)
|
||||||
|
Loading…
Reference in New Issue
Block a user