Exemplo n.º 1
0
    public IEnumerator CurvesAreOptimizedCorrectly()
    {
        var curvesSource = Resources.Load <AnimationCurveContainer>("CurveOptimizedCorrectlySource");
        //NOTE(Brian): We are going to output the optimization result in this SO, so it can be debugged more easily
        var curvesResult = Resources.Load <AnimationCurveContainer>("CurveOptimizedCorrectlyResult");

        curvesResult.curves = new AnimationCurve[curvesSource.curves.Length];

        for (int i = 0; i < curvesSource.curves.Length; i++)
        {
            var curve = curvesSource.curves[i];

            List <Keyframe> keys = new List <Keyframe>();

            for (int i1 = 0; i1 < curve.length; i1++)
            {
                keys.Add(curve[i1]);
            }

            var result        = GLTFSceneImporter.OptimizeKeyFrames(keys.ToArray());
            var modifiedCurve = new AnimationCurve(result);

            curvesResult.curves[i] = modifiedCurve;

            for (float time = 0; time < 1.0f; time += 0.032f)
            {
                var v1 = curve.Evaluate(time);
                var v2 = modifiedCurve.Evaluate(time);

                UnityEngine.Assertions.Assert.AreApproximatelyEqual(v1, v2, 0.01f);
            }
        }

        yield break;
    }