< 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:18
Uncovered lines:5
Coverable lines:23
Total lines:65
Line coverage:78.2% (18 of 23)
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%129066.67%

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;
 12314            public float width = 1f; // Plane
 12315            public float height = 1f; // Plane
 16
 4917            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 18        }
 19
 10820        public PlaneShape() { model = new Model(); }
 21
 022        public override int GetClassId() { return (int) CLASS_ID.PLANE_SHAPE; }
 23
 24        public override Mesh GenerateGeometry()
 25        {
 3626            var model = (Model) this.model;
 27
 3628            Mesh mesh = PrimitiveMeshBuilder.BuildPlane(1f);
 3629            if (model.uvs != null && model.uvs.Length > 0)
 30            {
 331                mesh.uv = Utils.FloatArrayToV2List(model.uvs);
 32            }
 33
 3634            return mesh;
 35        }
 36
 37        protected override bool ShouldGenerateNewMesh(BaseShape.Model previousModel)
 38        {
 4939            if (currentMesh == null)
 3840                return true;
 41
 1142            PlaneShape.Model newPlaneModel = (PlaneShape.Model) this.model;
 1143            PlaneShape.Model oldPlaneModel = (PlaneShape.Model) previousModel;
 44
 1145            if (newPlaneModel.uvs != null && oldPlaneModel.uvs != null)
 46            {
 1147                if (newPlaneModel.uvs.Length != oldPlaneModel.uvs.Length)
 248                    return true;
 49
 1850                for (int i = 0; i < newPlaneModel.uvs.Length; i++)
 51                {
 052                    if (newPlaneModel.uvs[i] != oldPlaneModel.uvs[i])
 053                        return true;
 54                }
 55            }
 56            else
 57            {
 058                if (newPlaneModel.uvs != oldPlaneModel.uvs)
 059                    return true;
 60            }
 61
 962            return newPlaneModel.width != oldPlaneModel.width || newPlaneModel.height != oldPlaneModel.height;
 63        }
 64    }
 65}