< Summary

Class:DCL.Components.PlaneShape
Assembly:DCL.Components.ParametrizedShape
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/ParametrizedShapes/PlaneShape.cs
Covered lines:19
Uncovered lines:5
Coverable lines:24
Total lines:65
Line coverage:79.1% (19 of 24)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Model()0%110100%
GetDataFromJSON(...)0%110100%
PlaneShape()0%110100%
GetClassId()0%2100%
GenerateGeometry()0%330100%
ShouldGenerateNewMesh(...)0%11.479068.75%

File(s)

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

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Helpers;
 3using DCL.Models;
 4using UnityEngine;
 5
 6namespace DCL.Components
 7{
 8    public class PlaneShape : ParametrizedShape<PlaneShape.Model>
 9    {
 10        [System.Serializable]
 11        new public class Model : BaseShape.Model
 12        {
 13            public float[] uvs;
 11714            public float width = 1f; // Plane
 11715            public float height = 1f; // Plane
 16
 4517            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 18        }
 19
 10520        public PlaneShape() { model = new Model(); }
 21
 022        public override int GetClassId() { return (int) CLASS_ID.PLANE_SHAPE; }
 23
 24        public override Mesh GenerateGeometry()
 25        {
 3526            var model = (Model) this.model;
 27
 3528            Mesh mesh = PrimitiveMeshBuilder.BuildPlane(1f);
 3529            if (model.uvs != null && model.uvs.Length > 0)
 30            {
 331                mesh.uv = Utils.FloatArrayToV2List(model.uvs);
 32            }
 33
 3534            return mesh;
 35        }
 36
 37        protected override bool ShouldGenerateNewMesh(BaseShape.Model previousModel)
 38        {
 4539            if (currentMesh == null)
 3740                return true;
 41
 842            PlaneShape.Model newPlaneModel = (PlaneShape.Model) this.model;
 843            PlaneShape.Model oldPlaneModel = (PlaneShape.Model) previousModel;
 44
 845            if (newPlaneModel.uvs != null && oldPlaneModel.uvs != null)
 46            {
 847                if (newPlaneModel.uvs.Length != oldPlaneModel.uvs.Length)
 248                    return true;
 49
 1250                for (int i = 0; i < newPlaneModel.uvs.Length; i++)
 51                {
 052                    if (newPlaneModel.uvs[i] != oldPlaneModel.uvs[i])
 053                        return true;
 54                }
 655            }
 56            else
 57            {
 058                if (newPlaneModel.uvs != oldPlaneModel.uvs)
 059                    return true;
 60            }
 61
 662            return newPlaneModel.width != oldPlaneModel.width || newPlaneModel.height != oldPlaneModel.height;
 63        }
 64    }
 65}