< Summary

Class:DCL.Components.SphereShape
Assembly:MainScripts
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        {
 1913            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 14        }
 15
 3316        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        {
 925            if (mesh == null)
 26            {
 827                mesh = PrimitiveMeshBuilder.BuildSphere(1f);
 28            }
 29
 930            meshUses++;
 31
 932            return mesh;
 33        }
 34
 35        protected override void DestroyGeometry()
 36        {
 937            meshUses--;
 938            if (meshUses == 0)
 39            {
 940                GameObject.Destroy(mesh);
 41            }
 942        }
 43
 1944        protected override bool ShouldGenerateNewMesh(BaseShape.Model newModel) { return currentMesh == null; }
 45    }
 46}