< Summary

Information
Class: SwiftCollections.Query.SwiftBVHNode<T1, T2>
Assembly: SwiftCollections
File(s): /home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Query/BoundingVolume/SwiftBVHNode.cs
Line coverage
94%
Covered lines: 32
Uncovered lines: 2
Coverable lines: 34
Total lines: 106
Line coverage: 94.1%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Value()100%11100%
get_Bounds()100%11100%
get_ParentIndex()100%11100%
get_HasParent()100%210%
get_MyIndex()100%11100%
get_LeftChildIndex()100%11100%
get_HasLeftChild()100%11100%
get_RightChildIndex()100%11100%
get_HasRightChild()100%11100%
get_HasChildren()0%620%
get_IsLeaf()100%11100%
get_SubtreeSize()100%11100%
get_IsAllocated()100%11100%
get_Default()100%11100%
Reset()100%11100%

File(s)

/home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Query/BoundingVolume/SwiftBVHNode.cs

#LineLine coverage
 1namespace SwiftCollections.Query;
 2
 3/// <summary>
 4/// Represents a node in a Bounding Volume Hierarchy (BVH).
 5/// Stores spatial data and maintains hierarchical relationships.
 6/// </summary>
 7public struct SwiftBVHNode<TKey, TVolume>
 8    where TVolume : struct, IBoundVolume<TVolume>
 9{
 10    /// <summary>
 11    /// Gets or sets the value stored in the node.
 12    /// </summary>
 11745113    public TKey Value { get; set; }
 14
 15    /// <summary>
 16    /// Gets or sets the bounding volume of the node.
 17    /// </summary>
 93124418    public TVolume Bounds { get; set; }
 19
 20    /// <summary>
 21    /// Gets or sets the index of the parent node.
 22    /// </summary>
 13451323    public int ParentIndex { get; set; }
 24
 25    /// <summary>
 26    /// Determines if the node has a parent.
 27    /// </summary>
 028    public readonly bool HasParent => ParentIndex != -1;
 29
 30    /// <summary>
 31    /// Gets or sets the index value associated with this instance.
 32    /// </summary>
 8841233    public int MyIndex { get; set; }
 34
 35    /// <summary>
 36    /// Gets or sets the index of the left child node.
 37    /// </summary>
 66356838    public int LeftChildIndex { get; set; }
 39
 40    /// <summary>
 41    /// Determines if the node has a left child.
 42    /// </summary>
 1051643    public readonly bool HasLeftChild => LeftChildIndex != -1;
 44
 45    /// <summary>
 46    /// Gets or sets the index of the right child node.
 47    /// </summary>
 65988048    public int RightChildIndex { get; set; }
 49
 50    /// <summary>
 51    /// Determines if the node has a right child.
 52    /// </summary>
 1051653    public readonly bool HasRightChild => RightChildIndex != -1;
 54
 55    /// <summary>
 56    /// Determines if the node has any children.
 57    /// </summary>
 058    public readonly bool HasChildren => HasLeftChild || HasRightChild;
 59
 60    /// <summary>
 61    /// Gets or sets a value indicating whether this node is a leaf node.
 62    /// </summary>
 28417363    public bool IsLeaf { get; set; }
 64
 65    /// <summary>
 66    /// Tracks the number of nodes in the subtree rooted at this node.
 67    /// </summary>
 80946368    public int SubtreeSize { get; set; }
 69
 70    /// <summary>
 71    /// Determines whether or not this node has been allocated from the pool or is a pooled instance
 72    /// </summary>
 109599173    public bool IsAllocated { get; set; }
 74
 75    /// <summary>
 76    /// Provides a custom default instance of <see cref="SwiftBVHNode{TKey, TVolume}"/>.
 77    /// </summary>
 478    public static SwiftBVHNode<TKey, TVolume> Default => new()
 479    {
 480        Value = default!,
 481        Bounds = default,
 482        ParentIndex = -1,
 483        LeftChildIndex = -1,
 484        RightChildIndex = -1,
 485        SubtreeSize = 0,
 486        IsLeaf = false,
 487        IsAllocated = false
 488    };
 89
 90    /// <summary>
 91    /// Resets the node to its default state.
 92    /// Clears all references and metadata.
 93    /// </summary>
 94    public void Reset()
 95    {
 6198296        Value = default!;
 6198297        Bounds = default;
 6198298        IsLeaf = false;
 6198299        ParentIndex = -1;
 61982100        MyIndex = -1;
 61982101        LeftChildIndex = -1;
 61982102        RightChildIndex = -1;
 61982103        SubtreeSize = 0;
 61982104        IsAllocated = false;
 61982105    }
 106}