< 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:71
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;
 68320        public Dictionary<Mesh, int> meshToTriangleCount = new ();
 68321        public HashSet<Mesh> meshes = new ();
 68322        public HashSet<Renderer> renderers = new ();
 68323        public HashSet<Material> materials = new ();
 68324        public HashSet<Texture> textures = new ();
 68325        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        public bool Equals(Rendereable other)
 35        {
 036            return container == other.container;
 37        }
 38
 39        public object Clone()
 40        {
 041            var result = (Rendereable) this.MemberwiseClone();
 042            result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount);
 043            result.renderers = new HashSet<Renderer>(renderers);
 044            result.materials = new HashSet<Material>(materials);
 045            result.textures = new HashSet<Texture>(textures);
 046            result.meshes = new HashSet<Mesh>(meshes);
 047            return result;
 48        }
 49
 50        public static Rendereable CreateFromGameObject(GameObject go)
 51        {
 3952            Rendereable rendereable = new Rendereable();
 3953            rendereable.container = go;
 3954            rendereable.renderers = MeshesInfoUtils.ExtractUniqueRenderers(go);
 3955            rendereable.materials = MeshesInfoUtils.ExtractUniqueMaterials(rendereable.renderers);
 3956            rendereable.textures = MeshesInfoUtils.ExtractUniqueTextures(rendereable.materials);
 3957            rendereable.meshes = MeshesInfoUtils.ExtractUniqueMeshes(rendereable.renderers);
 3958            rendereable.meshToTriangleCount = MeshesInfoUtils.ExtractMeshToTriangleMap(rendereable.meshes.ToList());
 3959            rendereable.totalTriangleCount =
 60                MeshesInfoUtils.ComputeTotalTriangles(rendereable.renderers, rendereable.meshToTriangleCount);
 61
 3962            return rendereable;
 63        }
 64
 65        public override string ToString()
 66        {
 067            return
 68                $"Rendereable - owner: {ownerId} ... textures: {textures.Count} ... triangles: {totalTriangleCount} ... 
 69        }
 70    }
 71}