< Summary

Class:GDX.Experimental.DebugDraw
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Experimental/DebugDraw.cs
Covered lines:15
Uncovered lines:0
Coverable lines:15
Total lines:95
Line coverage:100% (15 of 15)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DebugDraw()0%110100%
GetUnmanagedBuffer(...)0%220100%
HasUnmanagedBuffer(...)0%110100%
RemoveUnmanagedBuffer(...)0%110100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Experimental/DebugDraw.cs

#LineLine coverage
 1// Copyright (c) 2020-2023 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using GDX.Collections.Generic;
 6
 7namespace GDX.Experimental
 8{
 9    /// <summary>
 10    ///     A debug draw system useful in both the editor and at runtime.
 11    /// </summary>
 12    public static class DebugDraw
 13    {
 14        // /// <summary>
 15        // ///     A dictionary of known <see cref="DebugDrawBuffer"/> and their ID which are automatically executed.
 16        // /// </summary>
 17        // static IntKeyDictionary<DebugDrawBuffer> s_ManagedBuffers = new IntKeyDictionary<DebugDrawBuffer>(10);
 18
 19        /// <summary>
 20        ///     A dictionary of known <see cref="DebugDrawBuffer"/> and their ID which are not automatically executed.
 21        /// </summary>
 122        static IntKeyDictionary<DebugDrawBuffer> s_UnmanagedBuffers = new IntKeyDictionary<DebugDrawBuffer>(10);
 23
 24        /// <summary>
 25        /// Get an instance of <see cref="DebugDrawBuffer"/> based on the provided <paramref name="key"/> that is not ma
 26        /// </summary>
 27        /// <example>
 28        ///     By checking the <see cref="DebugDrawBuffer.Finalized"/> property we can skip over the expensive building
 29        ///     <code>
 30        ///         DebugDrawBuffer buffer = DebugDraw.GetUnmanagedBuffer(gameObjet.GetInstanceID());
 31        ///         if (!buffer.Finalized)
 32        ///         {
 33        ///             /// Draw lots of stuff ...
 34        ///             buffer.DrawWireCube(Color.white, worldPosition, size);
 35        ///         }
 36        ///         buffer.Execute();
 37        ///     </code>
 38        /// </example>
 39        /// <param name="key">
 40        ///     A value based key used to reference a <see cref="DebugDrawBuffer"/> in a
 41        ///     <see cref="IntKeyDictionary{TValue}"/>.
 42        /// </param>
 43        /// <param name="initialColorCount">Initial number of internal materials to allocate (x2).</param>
 44        /// <param name="verticesPerMesh">The number of vertices to split batched meshes on.</param>
 45        /// <returns>
 46        ///     A newly created <see cref="DebugDrawBuffer"/> if the provided key is not found, or the previously
 47        ///     created <see cref="DebugDrawBuffer"/> identified by the <paramref name="key"/>.
 48        /// </returns>
 49        public static DebugDrawBuffer GetUnmanagedBuffer(int key, int initialColorCount = 5,
 50            int verticesPerMesh = DebugDrawBuffer.DefaultMaximumVerticesPerMesh)
 551        {
 552            if (s_UnmanagedBuffers.ContainsKey(key))
 153            {
 154                return s_UnmanagedBuffers[key];
 55            }
 56
 457            DebugDrawBuffer newBuffer = new DebugDrawBuffer(key, initialColorCount, verticesPerMesh);
 458            s_UnmanagedBuffers.AddWithExpandCheck(key, newBuffer);
 459            return newBuffer;
 560        }
 61
 62        /// <summary>
 63        ///     Returns if the provided key has an unmanaged <see cref="DebugDrawBuffer"/> referenced.
 64        /// </summary>
 65        /// <param name="key">
 66        ///     The key used to reference the <see cref="DebugDrawBuffer"/>.
 67        /// </param>
 68        /// <returns>true/false if the key has a <see cref="DebugDrawBuffer"/> associated with it.</returns>
 69        public static bool HasUnmanagedBuffer(int key)
 270        {
 271            return s_UnmanagedBuffers.ContainsKey(key);
 272        }
 73
 74        /// <summary>
 75        ///     Dereference the indicated unmanaged <see cref="DebugDrawBuffer"/> from the provider.
 76        /// </summary>
 77        /// <param name="key">
 78        ///     The key used to reference the <see cref="DebugDrawBuffer"/>.
 79        /// </param>
 80        public static void RemoveUnmanagedBuffer(int key)
 481        {
 482            s_UnmanagedBuffers.TryRemove(key);
 483        }
 84
 85        // public static void Render()
 86        // {
 87        //     int currentIndex = 0;
 88        //     while (s_ManagedBuffers.MoveNext(ref currentIndex))
 89        //     {
 90        //         DebugDrawBuffer buffer = s_ManagedBuffers.Entries[currentIndex - 1].Value;
 91        //         buffer.Execute();
 92        //     }
 93        // }
 94    }
 95}

Coverage by test methods





Methods/Properties

DebugDraw()
GetUnmanagedBuffer(System.Int32, System.Int32, System.Int32)
HasUnmanagedBuffer(System.Int32)
RemoveUnmanagedBuffer(System.Int32)