< 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:10
Uncovered lines:2
Coverable lines:12
Total lines:46
Line coverage:83.3% (10 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%2.062075%
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            {
 127                mesh = PrimitiveMeshBuilder.BuildSphere(1f);
 28            }
 29
 930            meshUses++;
 31
 932            return mesh;
 33        }
 34
 35        protected override void DestroyGeometry()
 36        {
 437            meshUses--;
 438            if (meshUses == 0)
 39            {
 040                GameObject.Destroy(mesh);
 41            }
 442        }
 43
 1944        protected override bool ShouldGenerateNewMesh(BaseShape.Model newModel) { return currentMesh == null; }
 45    }
 46}