< Summary

Class:DCL.Components.PlaneShape
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/ParametrizedShapes/PlaneShape.cs
Covered lines:18
Uncovered lines:6
Coverable lines:24
Total lines:65
Line coverage:75% (18 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%13.279062.5%

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;
 6114            public float width = 1f; // Plane
 6115            public float height = 1f; // Plane
 16
 2517            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 18        }
 19
 5120        public PlaneShape() { model = new Model(); }
 21
 022        public override int GetClassId() { return (int) CLASS_ID.PLANE_SHAPE; }
 23
 24        public override Mesh GenerateGeometry()
 25        {
 1526            var model = (Model) this.model;
 27
 1528            Mesh mesh = PrimitiveMeshBuilder.BuildPlane(1f);
 1529            if (model.uvs != null && model.uvs.Length > 0)
 30            {
 131                mesh.uv = Utils.FloatArrayToV2List(model.uvs);
 32            }
 33
 1534            return mesh;
 35        }
 36
 37        protected override bool ShouldGenerateNewMesh(BaseShape.Model previousModel)
 38        {
 2539            if (currentMesh == null)
 1940                return true;
 41
 642            PlaneShape.Model newPlaneModel = (PlaneShape.Model) this.model;
 643            PlaneShape.Model oldPlaneModel = (PlaneShape.Model) previousModel;
 44
 645            if (newPlaneModel.uvs != null && oldPlaneModel.uvs != null)
 46            {
 647                if (newPlaneModel.uvs.Length != oldPlaneModel.uvs.Length)
 048                    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}