< 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:72
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;
 68220        public Dictionary<Mesh, int> meshToTriangleCount = new ();
 68221        public HashSet<Mesh> meshes = new ();
 68222        public HashSet<Renderer> renderers = new ();
 68223        public HashSet<Material> materials = new ();
 68224        public HashSet<Texture> textures = new ();
 68225        public HashSet<AnimationClip> animationClips = new ();
 26        public int totalTriangleCount = 0;
 27        public long animationClipSize = 0;
 28        public long meshDataSize = 0;
 29
 30        //Kinerius: since our old importer and the new one has a lot of architectural design differences, we have to kee
 31        // This can be safely removed once we get rid of the old importer
 32        public bool isGLTFast = false;
 33
 34
 35        public bool Equals(Rendereable other)
 36        {
 037            return container == other.container;
 38        }
 39
 40        public object Clone()
 41        {
 042            var result = (Rendereable)MemberwiseClone();
 043            result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount);
 044            result.renderers = new HashSet<Renderer>(renderers);
 045            result.materials = new HashSet<Material>(materials);
 046            result.textures = new HashSet<Texture>(textures);
 047            result.meshes = new HashSet<Mesh>(meshes);
 048            return result;
 49        }
 50
 51        public static Rendereable CreateFromGameObject(GameObject go)
 52        {
 3953            Rendereable rendereable = new Rendereable();
 3954            rendereable.container = go;
 3955            rendereable.renderers = MeshesInfoUtils.ExtractUniqueRenderers(go);
 3956            rendereable.materials = MeshesInfoUtils.ExtractUniqueMaterials(rendereable.renderers);
 3957            rendereable.textures = MeshesInfoUtils.ExtractUniqueTextures(rendereable.materials);
 3958            rendereable.meshes = MeshesInfoUtils.ExtractUniqueMeshes(rendereable.renderers);
 3959            rendereable.meshToTriangleCount = MeshesInfoUtils.ExtractMeshToTriangleMap(rendereable.meshes.ToList());
 3960            rendereable.totalTriangleCount =
 61                MeshesInfoUtils.ComputeTotalTriangles(rendereable.renderers, rendereable.meshToTriangleCount);
 62
 3963            return rendereable;
 64        }
 65
 66        public override string ToString()
 67        {
 068            return $"Rendereable - owner: {ownerId} ... textures: {textures.Count} ... triangles: {totalTriangleCount} "
 69                $"... materials: {materials.Count} ... meshes: {meshes.Count} ... renderers: {renderers.Count}";
 70        }
 71    }
 72}