< 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:96
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-2024 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 
 26        ///     managed.
 27        /// </summary>
 28        /// <example>
 29        ///     By checking the <see cref="DebugDrawBuffer.Finalized" /> property we can skip over the expensive buildin
 30        ///     <code>
 31        ///         DebugDrawBuffer buffer = DebugDraw.GetUnmanagedBuffer(gameObjet.GetInstanceID());
 32        ///         if (!buffer.Finalized)
 33        ///         {
 34        ///             /// Draw lots of stuff ...
 35        ///             buffer.DrawWireCube(Color.white, worldPosition, size);
 36        ///         }
 37        ///         buffer.Execute();
 38        ///     </code>
 39        /// </example>
 40        /// <param name="key">
 41        ///     A value based key used to reference a <see cref="DebugDrawBuffer" /> in a
 42        ///     <see cref="IntKeyDictionary{TValue}" />.
 43        /// </param>
 44        /// <param name="initialColorCount">Initial number of internal materials to allocate (x2).</param>
 45        /// <param name="verticesPerMesh">The number of vertices to split batched meshes on.</param>
 46        /// <returns>
 47        ///     A newly created <see cref="DebugDrawBuffer" /> if the provided key is not found, or the previously
 48        ///     created <see cref="DebugDrawBuffer" /> identified by the <paramref name="key" />.
 49        /// </returns>
 50        public static DebugDrawBuffer GetUnmanagedBuffer(int key, int initialColorCount = 5,
 51            int verticesPerMesh = DebugDrawBuffer.DefaultMaximumVerticesPerMesh)
 552        {
 553            if (s_UnmanagedBuffers.ContainsKey(key))
 154            {
 155                return s_UnmanagedBuffers[key];
 56            }
 57
 458            DebugDrawBuffer newBuffer = new DebugDrawBuffer(key, initialColorCount, verticesPerMesh);
 459            s_UnmanagedBuffers.AddWithExpandCheck(key, newBuffer);
 460            return newBuffer;
 561        }
 62
 63        /// <summary>
 64        ///     Returns if the provided key has an unmanaged <see cref="DebugDrawBuffer" /> referenced.
 65        /// </summary>
 66        /// <param name="key">
 67        ///     The key used to reference the <see cref="DebugDrawBuffer" />.
 68        /// </param>
 69        /// <returns>true/false if the key has a <see cref="DebugDrawBuffer" /> associated with it.</returns>
 70        public static bool HasUnmanagedBuffer(int key)
 271        {
 272            return s_UnmanagedBuffers.ContainsKey(key);
 273        }
 74
 75        /// <summary>
 76        ///     Dereference the indicated unmanaged <see cref="DebugDrawBuffer" /> from the provider.
 77        /// </summary>
 78        /// <param name="key">
 79        ///     The key used to reference the <see cref="DebugDrawBuffer" />.
 80        /// </param>
 81        public static void RemoveUnmanagedBuffer(int key)
 482        {
 483            s_UnmanagedBuffers.TryRemove(key);
 484        }
 85
 86        // public static void Render()
 87        // {
 88        //     int currentIndex = 0;
 89        //     while (s_ManagedBuffers.MoveNext(ref currentIndex))
 90        //     {
 91        //         DebugDrawBuffer buffer = s_ManagedBuffers.Entries[currentIndex - 1].Value;
 92        //         buffer.Execute();
 93        //     }
 94        // }
 95    }
 96}

Coverage by test methods





Methods/Properties

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