Skip to content

Commit

Permalink
Clamp01
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Oct 7, 2024
1 parent d688a15 commit a17aa97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Assets/VRM/Runtime/LookAt/CurveMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ IEnumerable<Keyframe> ToKeys(float[] values)
public float Map(float src)
{
// https://github.com/vrm-c/UniVRM/issues/2452
return Curve.Evaluate(Mathf.Clamp(src, 0, 1) / MathF.Max(CurveXRangeDegree, 0.001f)) * CurveYRangeDegree;
var t = Mathf.Clamp01(Mathf.Clamp(src, 0, 1) / MathF.Max(CurveXRangeDegree, 0.001f));
return Curve.Evaluate(t) * CurveYRangeDegree;
}

public bool Equals(CurveMapper other)
Expand Down
3 changes: 2 additions & 1 deletion Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public void OnValidate()
public float Map(float src)
{
// https://github.com/vrm-c/UniVRM/issues/2452
return Mathf.Clamp(src, 0, CurveXRangeDegree) / Mathf.Max(0.001f, CurveXRangeDegree) * CurveYRangeDegree;
var t = Mathf.Clamp01(Mathf.Clamp(src, 0, CurveXRangeDegree) / Mathf.Max(0.001f, CurveXRangeDegree));
return t * CurveYRangeDegree;
}
}
}

0 comments on commit a17aa97

Please sign in to comment.