fix CurveMapper. zero inputMaxValue

This commit is contained in:
ousttrue 2024-10-07 14:49:36 +09:00
parent 521cfa0901
commit 9ffebd5b87
2 changed files with 20 additions and 0 deletions

View File

@ -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;

View File

@ -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;