< Summary

Class:DCL.Models.MeshesInfoUtils
Assembly:MeshesInfo
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Scene/MeshesInfo/MeshesInfoUtils.cs
Covered lines:10
Uncovered lines:0
Coverable lines:10
Total lines:43
Line coverage:100% (10 of 10)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BuildMergedBounds(...)0%440100%
GetSafeBounds(...)0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Scene/MeshesInfo/MeshesInfoUtils.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL.Models
 4{
 5    public static class MeshesInfoUtils
 6    {
 7        public static Bounds BuildMergedBounds(Renderer[] renderers)
 8        {
 3249            Bounds bounds = new Bounds();
 10
 165611            for (int i = 0; i < renderers.Length; i++)
 12            {
 50413                if (renderers[i] == null)
 14                    continue;
 15
 50416                if (i == 0)
 32417                    bounds = renderers[i].GetSafeBounds();
 18                else
 18019                    bounds.Encapsulate(renderers[i].GetSafeBounds());
 20            }
 21
 32422            return bounds;
 23        }
 24
 25        /// <summary>
 26        /// This get the renderer bounds with a check to ensure the renderer is at a safe position.
 27        /// If the renderer is too far away from 0,0,0, wasm target ensures a crash.
 28        /// </summary>
 29        /// <param name="renderer"></param>
 30        /// <returns>The bounds value if the value is correct, or a mocked bounds object with clamped values if its too 
 31        public static Bounds GetSafeBounds( this Renderer renderer )
 32        {
 33            // World extents are of 4800 world mts, so this limit far exceeds the world size.
 34            const float POSITION_OVERFLOW_LIMIT = 10000;
 35            const float POSITION_OVERFLOW_LIMIT_SQR = POSITION_OVERFLOW_LIMIT * POSITION_OVERFLOW_LIMIT;
 36
 400837            if ( renderer.transform.position.sqrMagnitude > POSITION_OVERFLOW_LIMIT_SQR )
 1338                return new Bounds( Vector3.one * POSITION_OVERFLOW_LIMIT, Vector3.one * 0.1f );
 39
 399540            return renderer.bounds;
 41        }
 42    }
 43}