Skip to content

Commit

Permalink
max
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Oct 7, 2024
1 parent 27fc432 commit d688a15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
22 changes: 2 additions & 20 deletions Assets/VRM/Runtime/LookAt/CurveMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public class CurveMapper : IEquatable<CurveMapper>
[Range(0, 90.0f)]
public float CurveYRangeDegree;

// zero 除算などを回避する閾値
public const float MIMIMUM_INPUT_MAX_VALUE = 1e-5f;

public CurveMapper(float xRange, float yRange)
{
CurveXRangeDegree = xRange;
Expand Down Expand Up @@ -64,23 +61,8 @@ IEnumerable<Keyframe> ToKeys(float[] values)

public float Map(float src)
{
if (CurveXRangeDegree < MIMIMUM_INPUT_MAX_VALUE)
{
// https://github.com/vrm-c/UniVRM/issues/2452
return src <= 0 ? 0 : CurveYRangeDegree;
}
else
{
if (src < 0)
{
src = 0;
}
else if (src > CurveXRangeDegree)
{
src = CurveXRangeDegree;
}
return Curve.Evaluate(src / CurveXRangeDegree) * CurveYRangeDegree;
}
// https://github.com/vrm-c/UniVRM/issues/2452
return Curve.Evaluate(Mathf.Clamp(src, 0, 1) / MathF.Max(CurveXRangeDegree, 0.001f)) * CurveYRangeDegree;
}

public bool Equals(CurveMapper other)
Expand Down
22 changes: 2 additions & 20 deletions Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public class CurveMapper
[Range(0, 90.0f)]
public float CurveYRangeDegree;

// zero 除算などを回避する閾値
public const float MIMIMUM_INPUT_MAX_VALUE = 1e-5f;

public CurveMapper(float xRange, float yRange)
{
CurveXRangeDegree = xRange;
Expand All @@ -32,23 +29,8 @@ public void OnValidate()

public float Map(float src)
{
if (CurveXRangeDegree < MIMIMUM_INPUT_MAX_VALUE)
{
// https://github.com/vrm-c/UniVRM/issues/2452
return src <= 0 ? 0 : CurveXRangeDegree;
}
else
{
if (src < 0)
{
src = 0;
}
else if (src > CurveXRangeDegree)
{
src = CurveXRangeDegree;
}
return src / CurveXRangeDegree * CurveYRangeDegree;
}
// https://github.com/vrm-c/UniVRM/issues/2452
return Mathf.Clamp(src, 0, CurveXRangeDegree) / Mathf.Max(0.001f, CurveXRangeDegree) * CurveYRangeDegree;
}
}
}

0 comments on commit d688a15

Please sign in to comment.