< Summary

Class:DCL.Rendereable
Assembly:MeshesInfo
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Scene/MeshesInfo/Rendereable.cs
Covered lines:14
Uncovered lines:9
Coverable lines:23
Total lines:62
Line coverage:60.8% (14 of 23)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Rendereable()0%110100%
Equals(...)0%2100%
Clone()0%2100%
CreateFromGameObject(...)0%110100%
ToString()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Scene/MeshesInfo/Rendereable.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using DCL.Models;
 5using UnityEngine;
 6
 7namespace DCL
 8{
 9    /// <summary>
 10    /// The Rendereable object represents any loaded object that should be visible in the world.
 11    ///
 12    /// With this in place, the SceneBoundsChecker, CullingController and SceneMetricsCounter
 13    /// implementations can  be changed to be reactive, and lots of FindObjects and GetComponentsInChildren
 14    /// calls can be saved.
 15    /// </summary>
 16    public class Rendereable : ICloneable
 17    {
 18        public string ownerId;
 19        public GameObject container;
 60620        public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>();
 60621        public HashSet<Mesh> meshes = new HashSet<Mesh>();
 60622        public HashSet<Renderer> renderers = new HashSet<Renderer>();
 60623        public HashSet<Material> materials = new HashSet<Material>();
 60624        public HashSet<Texture> textures = new HashSet<Texture>();
 25        public int totalTriangleCount = 0;
 26
 27        public bool Equals(Rendereable other)
 28        {
 029            return container == other.container;
 30        }
 31
 32        public object Clone()
 33        {
 034            var result = (Rendereable)this.MemberwiseClone();
 035            result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount);
 036            result.renderers = new HashSet<Renderer>(renderers);
 037            result.materials = new HashSet<Material>(materials);
 038            result.textures = new HashSet<Texture>(textures);
 039            result.meshes = new HashSet<Mesh>(meshes);
 040            return result;
 41        }
 42
 43        public static Rendereable CreateFromGameObject(GameObject go)
 44        {
 1945            Rendereable rendereable = new Rendereable();
 1946            rendereable.container = go;
 1947            rendereable.renderers = MeshesInfoUtils.ExtractUniqueRenderers(go);
 1948            rendereable.materials = MeshesInfoUtils.ExtractUniqueMaterials(rendereable.renderers);
 1949            rendereable.textures = MeshesInfoUtils.ExtractUniqueTextures(rendereable.materials);
 1950            rendereable.meshes = MeshesInfoUtils.ExtractUniqueMeshes(rendereable.renderers);
 1951            rendereable.meshToTriangleCount = MeshesInfoUtils.ExtractMeshToTriangleMap(rendereable.meshes.ToList());
 1952            rendereable.totalTriangleCount = MeshesInfoUtils.ComputeTotalTriangles(rendereable.renderers, rendereable.me
 53
 1954            return rendereable;
 55        }
 56
 57        public override string ToString()
 58        {
 059            return $"Rendereable - owner: {ownerId} ... textures: {textures.Count} ... triangles: {totalTriangleCount} .
 60        }
 61    }
 62}