< Summary

Class:DCL.Rendereable
Assembly:MeshesInfo
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/MeshesInfo/Rendereable.cs
Covered lines:15
Uncovered lines:9
Coverable lines:24
Total lines:67
Line coverage:62.5% (15 of 24)
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/WorldRuntime/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 long ownerId;
 19        public GameObject container;
 70420        public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>();
 70421        public HashSet<Mesh> meshes = new HashSet<Mesh>();
 70422        public HashSet<Renderer> renderers = new HashSet<Renderer>();
 70423        public HashSet<Material> materials = new HashSet<Material>();
 70424        public HashSet<Texture> textures = new HashSet<Texture>();
 70425        public HashSet<AnimationClip> animationClips = new HashSet<AnimationClip>();
 26        public int totalTriangleCount = 0;
 27        public long animationClipSize = 0;
 28        public long meshDataSize = 0;
 29
 30        public bool Equals(Rendereable other)
 31        {
 032            return container == other.container;
 33        }
 34
 35        public object Clone()
 36        {
 037            var result = (Rendereable) this.MemberwiseClone();
 038            result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount);
 039            result.renderers = new HashSet<Renderer>(renderers);
 040            result.materials = new HashSet<Material>(materials);
 041            result.textures = new HashSet<Texture>(textures);
 042            result.meshes = new HashSet<Mesh>(meshes);
 043            return result;
 44        }
 45
 46        public static Rendereable CreateFromGameObject(GameObject go)
 47        {
 3948            Rendereable rendereable = new Rendereable();
 3949            rendereable.container = go;
 3950            rendereable.renderers = MeshesInfoUtils.ExtractUniqueRenderers(go);
 3951            rendereable.materials = MeshesInfoUtils.ExtractUniqueMaterials(rendereable.renderers);
 3952            rendereable.textures = MeshesInfoUtils.ExtractUniqueTextures(rendereable.materials);
 3953            rendereable.meshes = MeshesInfoUtils.ExtractUniqueMeshes(rendereable.renderers);
 3954            rendereable.meshToTriangleCount = MeshesInfoUtils.ExtractMeshToTriangleMap(rendereable.meshes.ToList());
 3955            rendereable.totalTriangleCount =
 56                MeshesInfoUtils.ComputeTotalTriangles(rendereable.renderers, rendereable.meshToTriangleCount);
 57
 3958            return rendereable;
 59        }
 60
 61        public override string ToString()
 62        {
 063            return
 64                $"Rendereable - owner: {ownerId} ... textures: {textures.Count} ... triangles: {totalTriangleCount} ... 
 65        }
 66    }
 67}