< Summary

Class:DCL.BakedCombineInstances
Assembly:AvatarMeshCombiner
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarMeshCombiner/BakedCombineInstances.cs
Covered lines:12
Uncovered lines:1
Coverable lines:13
Total lines:44
Line coverage:92.3% (12 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BakedCombineInstances()0%2100%
Dispose()0%220100%
Bake(...)0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/AvatarMeshCombiner/BakedCombineInstances.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using Object = UnityEngine.Object;
 5
 6namespace DCL
 7{
 8    public class BakedCombineInstances : IDisposable
 9    {
 010        private List<Mesh> bakedMeshes = new List<Mesh>();
 11
 12        public void Dispose()
 13        {
 18014            foreach ( var mesh in bakedMeshes )
 15            {
 7416                Object.Destroy(mesh);
 17            }
 1618        }
 19
 20        public void Bake(List<CombineInstance> combineInstances, List<SkinnedMeshRenderer> renderers)
 21        {
 1622            int combineInstancesCount = combineInstances.Count;
 23
 18024            for ( int i = 0; i < combineInstancesCount; i++)
 25            {
 7426                Mesh mesh = new Mesh();
 27
 28                // Important note: It seems that mesh normals are scaled by the matrix when using BakeMesh.
 29                //                 This is wrong and and shouldn't happen, so we have to arrange them manually.
 30                //
 31                //                 We DON'T do this yet because the meshes can be read-only, so the original
 32                //                 normals can't be extracted. For normals, visual artifacts are minor because
 33                //                 toon shader doesn't use any kind of normal mapping.
 7434                renderers[i].BakeMesh(mesh, true);
 35
 7436                var combinedInstance = combineInstances[i];
 7437                combinedInstance.mesh = mesh;
 7438                bakedMeshes.Add(mesh);
 39
 7440                combineInstances[i] = combinedInstance;
 41            }
 1642        }
 43    }
 44}