// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System.Collections.Generic; using UltimateXR.Extensions.System; using UnityEngine; namespace UltimateXR.Extensions.Unity.Render { /// /// extensions. /// public static class RendererExt { #region Public Methods /// /// Calculates the encapsulating a set of renderers. /// /// Renderers to compute the bounds for /// encapsulating all renderers public static Bounds CalculateBounds(this IEnumerable renderers) { renderers.ThrowIfNull(nameof(renderers)); Bounds bounds = default; bool isFirst = true; foreach (Renderer r in renderers) { Bounds b = r.bounds; if (isFirst) { bounds = r.bounds; isFirst = false; } else { bounds.Encapsulate(b); } } return bounds; } #endregion } }