< Summary

Class:DCL.Components.SphereShape
Assembly:DCL.Components.ParametrizedShape
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/ParametrizedShapes/SphereShape.cs
Covered lines:11
Uncovered lines:1
Coverable lines:12
Total lines:46
Line coverage:91.6% (11 of 12)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetDataFromJSON(...)0%110100%
SphereShape()0%110100%
GetClassId()0%2100%
GenerateGeometry()0%220100%
DestroyGeometry()0%220100%
ShouldGenerateNewMesh(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/ParametrizedShapes/SphereShape.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Helpers;
 3using DCL.Models;
 4using UnityEngine;
 5
 6namespace DCL.Components
 7{
 8    public class SphereShape : ParametrizedShape<SphereShape.Model>
 9    {
 10        [System.Serializable]
 11        new public class Model : BaseShape.Model
 12        {
 2313            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 14        }
 15
 3616        public SphereShape() { model = new Model(); }
 17
 018        public override int GetClassId() { return (int) CLASS_ID.SPHERE_SHAPE; }
 19
 20        public static Mesh mesh = null;
 21        private static int meshUses = 0;
 22
 23        public override Mesh GenerateGeometry()
 24        {
 1025            if (mesh == null)
 26            {
 927                mesh = PrimitiveMeshBuilder.BuildSphere(1f);
 28            }
 29
 1030            meshUses++;
 31
 1032            return mesh;
 33        }
 34
 35        protected override void DestroyGeometry()
 36        {
 1037            meshUses--;
 1038            if (meshUses == 0)
 39            {
 1040                GameObject.Destroy(mesh);
 41            }
 1042        }
 43
 2344        protected override bool ShouldGenerateNewMesh(BaseShape.Model newModel) { return currentMesh == null; }
 45    }
 46}