< Summary

Class:DCL.Skybox.TransitioningValues
Assembly:ProceduralSkybox
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/Functionality/TransitioningValues.cs
Covered lines:0
Uncovered lines:45
Coverable lines:45
Total lines:120
Line coverage:0% (0 of 45)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetTransitionValue(...)0%56700%
GetTransitionValue(...)0%56700%
GetTransitionValue(...)0%56700%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/Functionality/TransitioningValues.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5namespace DCL.Skybox
 6{
 7    public static class TransitioningValues
 8    {
 9        public static float GetTransitionValue(List<TransitioningFloat> list, float percentage, float defaultVal = 0)
 10        {
 011            if (list == null || list.Count < 1)
 12            {
 013                return defaultVal;
 14            }
 15
 016            if (list.Count == 1)
 17            {
 018                return list[0].value;
 19            }
 20
 021            TransitioningFloat min = list[0], max = list[0];
 22
 23
 024            for (int i = 0; i < list.Count; i++)
 25            {
 026                if (percentage <= list[i].percentage)
 27                {
 028                    max = list[i];
 29
 030                    if ((i - 1) > 0)
 31                    {
 032                        min = list[i - 1];
 33                    }
 34
 035                    break;
 36                }
 37            }
 38
 039            float t = Mathf.InverseLerp(min.percentage, max.percentage, percentage);
 040            return Mathf.Lerp(min.value, max.value, t);
 41        }
 42
 43        public static Vector2 GetTransitionValue(List<TransitioningVector2> list, float percentage, Vector2 defaultVal =
 44        {
 045            Vector2 offset = defaultVal;
 46
 047            if (list == null || list.Count == 0)
 48            {
 049                return offset;
 50            }
 51
 052            if (list.Count == 1)
 53            {
 054                offset = list[0].value;
 055                return offset;
 56            }
 57
 58
 059            TransitioningVector2 min = list[0], max = list[0];
 60
 061            for (int i = 0; i < list.Count; i++)
 62            {
 063                if (percentage <= list[i].percentage)
 64                {
 065                    max = list[i];
 66
 067                    if ((i - 1) > 0)
 68                    {
 069                        min = list[i - 1];
 70                    }
 71
 072                    break;
 73                }
 74            }
 075            float t = Mathf.InverseLerp(min.percentage, max.percentage, percentage);
 076            offset = Vector2.Lerp(min.value, max.value, t);
 77
 078            return offset;
 79        }
 80
 81        public static Vector3 GetTransitionValue(List<TransitioningVector3> list, float percentage)
 82        {
 083            Vector3 offset = new Vector3(0, 0, 0);
 84
 085            if (list == null || list.Count == 0)
 86            {
 087                return offset;
 88            }
 89
 090            if (list.Count == 1)
 91            {
 092                offset = list[0].value;
 093                return offset;
 94            }
 95
 96
 097            TransitioningVector3 min = list[0], max = list[0];
 98
 099            for (int i = 0; i < list.Count; i++)
 100            {
 0101                if (percentage <= list[i].percentage)
 102                {
 0103                    max = list[i];
 104
 0105                    if ((i - 1) > 0)
 106                    {
 0107                        min = list[i - 1];
 108                    }
 109
 0110                    break;
 111                }
 112            }
 113
 0114            float t = Mathf.InverseLerp(min.percentage, max.percentage, percentage);
 0115            offset = Vector3.Lerp(min.value, max.value, t);
 116
 0117            return offset;
 118        }
 119    }
 120}