diff --git a/Assets/VRM/Runtime/LookAt/CurveMapper.cs b/Assets/VRM/Runtime/LookAt/CurveMapper.cs index b5d0a8f3f..d64586a49 100644 --- a/Assets/VRM/Runtime/LookAt/CurveMapper.cs +++ b/Assets/VRM/Runtime/LookAt/CurveMapper.cs @@ -17,6 +17,9 @@ namespace VRM [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; @@ -61,6 +64,13 @@ namespace VRM public float Map(float src) { + if (CurveXRangeDegree < MIMIMUM_INPUT_MAX_VALUE) + { + // https://github.com/vrm-c/UniVRM/issues/2452 + return 0; + // or CurveYRangeDegree ? + } + if (src < 0) { src = 0; diff --git a/Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs b/Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs index 55dcba9ff..f451c291e 100644 --- a/Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs +++ b/Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs @@ -17,6 +17,9 @@ namespace UniVRM10 [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; @@ -33,6 +36,13 @@ namespace UniVRM10 public float Map(float src) { + if (CurveXRangeDegree < MIMIMUM_INPUT_MAX_VALUE) + { + // https://github.com/vrm-c/UniVRM/issues/2452 + return 0; + // or CurveYRangeDegree ? + } + if (src < 0) { src = 0;