< 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:13
Uncovered lines:8
Coverable lines:21
Total lines:66
Line coverage:61.9% (13 of 21)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:7
Method coverage:71.4% (5 of 7)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetDataFromJSON(...)0%110100%
GetDataFromPb(...)0%30500%
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.Helpers;
 2using DCL.Models;
 3using UnityEngine;
 4using Decentraland.Sdk.Ecs6;
 5
 6namespace DCL.Components
 7{
 8    public class SphereShape : ParametrizedShape<SphereShape.Model>
 9    {
 10        [System.Serializable]
 11        public new class Model : BaseShape.Model
 12        {
 13            public override BaseModel GetDataFromJSON(string json) =>
 2314                Utils.SafeFromJson<Model>(json);
 15
 16            public override BaseModel GetDataFromPb(ComponentBodyPayload pbModel)
 17            {
 018                if (pbModel.PayloadCase != ComponentBodyPayload.PayloadOneofCase.SphereShape)
 019                    return Utils.SafeUnimplemented<SphereShape, Model>(
 20                        expected: ComponentBodyPayload.PayloadOneofCase.SphereShape, actual: pbModel.PayloadCase);
 21
 022                var pb = new Model();
 023                if (pbModel.SphereShape.HasVisible) pb.visible = pbModel.SphereShape.Visible;
 024                if (pbModel.SphereShape.HasWithCollisions) pb.withCollisions = pbModel.SphereShape.WithCollisions;
 025                if (pbModel.SphereShape.HasIsPointerBlocker) pb.isPointerBlocker = pbModel.SphereShape.IsPointerBlocker;
 26
 027                return pb;
 28            }
 29        }
 30
 31        public static Mesh mesh;
 32        private static int meshUses;
 33
 1234        public SphereShape()
 35        {
 1236            model = new Model();
 1237        }
 38
 39        public override int GetClassId() =>
 040            (int) CLASS_ID.SPHERE_SHAPE;
 41
 42        public override Mesh GenerateGeometry()
 43        {
 1044            if (mesh == null)
 45            {
 946                mesh = PrimitiveMeshBuilder.BuildSphere(1f);
 47            }
 48
 1049            meshUses++;
 50
 1051            return mesh;
 52        }
 53
 54        protected override void DestroyGeometry()
 55        {
 1056            meshUses--;
 1057            if (meshUses == 0)
 58            {
 1059                GameObject.Destroy(mesh);
 60            }
 1061        }
 62
 63        protected override bool ShouldGenerateNewMesh(BaseShape.Model newModel) =>
 2364            currentMesh == null;
 65    }
 66}