Skip to content

Commit

Permalink
export with bone normalize cause, drop look at curve params
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed May 19, 2021
1 parent 3f7fa08 commit b8223a2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Assets/VRM/Runtime/LookAt/CurveMapper.cs
Expand Up @@ -7,7 +7,7 @@
namespace VRM
{
[Serializable]
public class CurveMapper
public class CurveMapper : IEquatable<CurveMapper>
{
public AnimationCurve Curve = AnimationCurve.Linear(0, 0, 1.0f, 1.0f);

Expand Down Expand Up @@ -37,6 +37,12 @@ public void OnValidate()
}
}

public void Assign(CurveMapper mapper)
{
CurveXRangeDegree = mapper.CurveXRangeDegree;
CurveYRangeDegree = mapper.CurveYRangeDegree;
}

public void Apply(glTF_VRM_DegreeMap degreeMap)
{
CurveXRangeDegree = degreeMap.xRange;
Expand Down Expand Up @@ -71,5 +77,21 @@ public float Map(float src)
}
return Curve.Evaluate(src / CurveXRangeDegree) * CurveYRangeDegree;
}

public bool Equals(CurveMapper other)
{
if (CurveXRangeDegree != other.CurveXRangeDegree) return false;
if (CurveYRangeDegree != other.CurveYRangeDegree) return false;
return true;
}

public override bool Equals(object obj)
{
if (obj is CurveMapper mapper)
{
return Equals(mapper);
}
return base.Equals(obj);
}
}
}
7 changes: 7 additions & 0 deletions Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs
Expand Up @@ -228,6 +228,10 @@ public static GameObject Execute(GameObject go, bool forceTPose)
if (src != null)
{
var dst = root.AddComponent<VRMLookAtBoneApplyer>();
dst.HorizontalInner.Assign(src.HorizontalInner);
dst.HorizontalOuter.Assign(src.HorizontalOuter);
dst.VerticalUp.Assign(src.VerticalUp);
dst.VerticalDown.Assign(src.VerticalDown);
}
}
{
Expand All @@ -236,6 +240,9 @@ public static GameObject Execute(GameObject go, bool forceTPose)
if (src != null)
{
var dst = root.AddComponent<VRMLookAtBlendShapeApplyer>();
dst.Horizontal.Assign(src.Horizontal);
dst.VerticalUp.Assign(src.VerticalUp);
dst.VerticalDown.Assign(src.VerticalDown);
}
}

Expand Down

0 comments on commit b8223a2

Please sign in to comment.