< Summary

Class:DCL.Controllers.SceneBoundsFeedbackStyle_Simple
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneBoundariesController/SceneBoundsFeedbackStyle_Simple.cs
Covered lines:17
Uncovered lines:5
Coverable lines:22
Total lines:58
Line coverage:77.2% (17 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SceneBoundsFeedbackStyle_Simple()0%110100%
ApplyFeedback(...)0%16160100%
CleanFeedback()0%2.152066.67%
GetOriginalMaterials(...)0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneBoundariesController/SceneBoundsFeedbackStyle_Simple.cs

#LineLine coverage
 1using DCL.Models;
 2using UnityEngine;
 3using System.Collections.Generic;
 4
 5namespace DCL.Controllers
 6{
 7    public class SceneBoundsFeedbackStyle_Simple : ISceneBoundsFeedbackStyle
 8    {
 6339        private readonly List<Renderer> disabledRenderers = new List<Renderer>();
 10
 11        public void ApplyFeedback(MeshesInfo meshesInfo, bool isInsideBoundaries)
 12        {
 9413            if (meshesInfo?.renderers == null || meshesInfo.renderers.Length == 0)
 2814                return;
 15
 6616            if (meshesInfo?.currentShape != null && !meshesInfo.currentShape.IsVisible())
 117                return;
 18
 29619            for (int i = 0; i < meshesInfo.renderers.Length; i++)
 20            {
 8321                if (meshesInfo.renderers[i] == null)
 22                    continue;
 23
 8324                if (isInsideBoundaries == meshesInfo.renderers[i].enabled)
 25                    continue;
 26
 6227                meshesInfo.renderers[i].enabled = isInsideBoundaries;
 28
 6229                if (isInsideBoundaries && disabledRenderers.Contains(meshesInfo.renderers[i]))
 1330                    disabledRenderers.Remove( meshesInfo.renderers[i]);
 4931                else if (!isInsideBoundaries && !disabledRenderers.Contains(meshesInfo.renderers[i]))
 4932                    disabledRenderers.Add( meshesInfo.renderers[i]);
 33            }
 6534        }
 35
 36        public void CleanFeedback()
 37        {
 5638            foreach (var renderer in disabledRenderers)
 39            {
 040                renderer.enabled = true;
 41            }
 42
 2843            disabledRenderers.Clear();
 2844        }
 45
 46        public List<Material> GetOriginalMaterials(MeshesInfo meshesInfo)
 47        {
 048            List<Material> result = new List<Material>();
 49
 050            for (int i = 0; i < meshesInfo.renderers.Length; i++)
 51            {
 052                result.AddRange(meshesInfo.renderers[i].sharedMaterials);
 53            }
 54
 055            return result;
 56        }
 57    }
 58}