< Summary

Class:DCL.Asset_GLTFast_Instance
Assembly:AssetPromiseKeeper
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/GLTFast/Asset_GLTFast_Instance.cs
Covered lines:0
Uncovered lines:32
Coverable lines:32
Total lines:95
Line coverage:0% (0 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Asset_GLTFast_Instance()0%2100%
ExtractRenderers()0%2100%
Cleanup()0%2100%
Hide()0%2100%
Show(...)0%6200%
ToRendereable()0%72800%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/GLTFast/Asset_GLTFast_Instance.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using DCL.Configuration;
 4using UnityEditor;
 5using UnityEngine;
 6using Object = UnityEngine.Object;
 7
 8namespace DCL
 9{
 10    public class Asset_GLTFast_Instance : Asset_WithPoolableContainer
 11    {
 12        internal AssetPromise_GLTFast_Loader ownerPromise;
 013        public sealed override GameObject container { get; set; }
 14
 015        public Asset_GLTFast_Instance()
 16        {
 017            container = new GameObject("GLTFast Container")
 18            {
 19                transform = { position = EnvironmentSettings.MORDOR }
 20            };
 021        }
 22
 023        public Renderer[] ExtractRenderers() => container.GetComponentsInChildren<Renderer>();
 24
 25        public override void Cleanup()
 26        {
 027            AssetPromiseKeeper_GLTFast.i.Forget(ownerPromise);
 028            Object.Destroy(container);
 029        }
 30
 31        public void Hide()
 32        {
 033            container.SetActive(false);
 034            container.transform.parent = null;
 035            container.transform.position = EnvironmentSettings.MORDOR;
 036        }
 37
 38        public void Show(Action success)
 39        {
 040            container.SetActive(true);
 041            success?.Invoke();
 042        }
 43
 44        public Rendereable ToRendereable()
 45        {
 046            Renderer[] renderers = container.gameObject.GetComponentsInChildren<Renderer>();
 047            HashSet<Mesh> meshes = new HashSet<Mesh>();
 048            HashSet<Material> materials = new HashSet<Material>();
 049            HashSet<Texture> textures = new HashSet<Texture>();
 50
 051            foreach (Renderer renderer in renderers)
 52            {
 53                switch (renderer)
 54                {
 55                    case SkinnedMeshRenderer skinnedMeshRenderer:
 056                        meshes.Add(skinnedMeshRenderer.sharedMesh);
 057                        break;
 58                    case MeshRenderer:
 059                        meshes.Add(renderer.GetComponent<MeshFilter>().sharedMesh);
 60                        break;
 61                }
 62
 063                foreach (Material material in renderer.sharedMaterials) { materials.Add(material); }
 64            }
 65
 066            for (int i = 0; i < ownerPromise.asset.GltfImport.TextureCount; i++)
 067                textures.Add(ownerPromise.asset.GltfImport.GetTexture(i));
 68
 069            HashSet<AnimationClip> animations = new HashSet<AnimationClip>();
 70
 071            var animationClips = ownerPromise.asset.GltfImport.GetAnimationClips();
 72
 073            if (animationClips != null)
 074                foreach (AnimationClip clip in animationClips)
 075                    animations.Add(clip);
 76
 077            return new Rendereable
 78            {
 79                container = container,
 80                meshes = meshes,
 81                renderers = new HashSet<Renderer>(renderers),
 82                materials = materials,
 83                textures = textures,
 84                meshToTriangleCount = new Dictionary<Mesh, int>(),
 85                animationClips = animations,
 86
 87                // TODO: Fill me!
 88                totalTriangleCount = 0,
 89                animationClipSize = 0,
 90                meshDataSize = 0,
 91                isGLTFast = true
 92            };
 93        }
 94    }
 95}