From d688a1568e13ebb923b2005599983d899f9da7b2 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 7 Oct 2024 15:31:14 +0900 Subject: [PATCH] max --- Assets/VRM/Runtime/LookAt/CurveMapper.cs | 22 ++----------------- .../Runtime/Components/LookAt/CurveMapper.cs | 22 ++----------------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/Assets/VRM/Runtime/LookAt/CurveMapper.cs b/Assets/VRM/Runtime/LookAt/CurveMapper.cs index 49a38b30b..6f9b0490c 100644 --- a/Assets/VRM/Runtime/LookAt/CurveMapper.cs +++ b/Assets/VRM/Runtime/LookAt/CurveMapper.cs @@ -17,9 +17,6 @@ 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; @@ -64,23 +61,8 @@ namespace VRM 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) diff --git a/Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs b/Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs index 7c884f50c..8beaf22c6 100644 --- a/Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs +++ b/Assets/VRM10/Runtime/Components/LookAt/CurveMapper.cs @@ -13,9 +13,6 @@ 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; @@ -32,23 +29,8 @@ namespace UniVRM10 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; } } } \ No newline at end of file