< 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:13
Uncovered lines:0
Coverable lines:13
Total lines:44
Line coverage:100% (13 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BakedCombineInstances()0%110100%
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    {
 1910        private List<Mesh> bakedMeshes = new List<Mesh>();
 11
 12        public void Dispose()
 13        {
 21814            foreach ( var mesh in bakedMeshes )
 15            {
 9016                Object.Destroy(mesh);
 17            }
 1918        }
 19
 20        public void Bake(List<CombineInstance> combineInstances, List<SkinnedMeshRenderer> renderers)
 21        {
 1922            int combineInstancesCount = combineInstances.Count;
 23
 21824            for ( int i = 0; i < combineInstancesCount; i++)
 25            {
 9026                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.
 9034                renderers[i].BakeMesh(mesh, true);
 35
 9036                var combinedInstance = combineInstances[i];
 9037                combinedInstance.mesh = mesh;
 9038                bakedMeshes.Add(mesh);
 39
 9040                combineInstances[i] = combinedInstance;
 41            }
 1942        }
 43    }
 44}