< 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
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 113
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_HasParent()100%11100%
get_HasLeftChild()100%11100%
get_HasRightChild()100%11100%
get_HasChildren()100%22100%
get_Default()100%11100%
Reset()100%11100%

File(s)

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

#LineLine coverage
 1//=======================================================================
 2// SwiftBVHNode.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024–present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8namespace SwiftCollections.Query;
 9
 10/// <summary>
 11/// Represents a node in a Bounding Volume Hierarchy (BVH).
 12/// Stores spatial data and maintains hierarchical relationships.
 13/// </summary>
 14public struct SwiftBVHNode<TKey, TVolume>
 15    where TVolume : struct, IBoundVolume<TVolume>
 16{
 17    /// <summary>
 18    /// Gets or sets the value stored in the node.
 19    /// </summary>
 20    public TKey Value { get; set; }
 21
 22    /// <summary>
 23    /// Gets or sets the bounding volume of the node.
 24    /// </summary>
 25    public TVolume Bounds { get; set; }
 26
 27    /// <summary>
 28    /// Gets or sets the index of the parent node.
 29    /// </summary>
 30    public int ParentIndex { get; set; }
 31
 32    /// <summary>
 33    /// Determines if the node has a parent.
 34    /// </summary>
 335    public readonly bool HasParent => ParentIndex != -1;
 36
 37    /// <summary>
 38    /// Gets or sets the index value associated with this instance.
 39    /// </summary>
 40    public int MyIndex { get; set; }
 41
 42    /// <summary>
 43    /// Gets or sets the index of the left child node.
 44    /// </summary>
 45    public int LeftChildIndex { get; set; }
 46
 47    /// <summary>
 48    /// Determines if the node has a left child.
 49    /// </summary>
 1052250    public readonly bool HasLeftChild => LeftChildIndex != -1;
 51
 52    /// <summary>
 53    /// Gets or sets the index of the right child node.
 54    /// </summary>
 55    public int RightChildIndex { get; set; }
 56
 57    /// <summary>
 58    /// Determines if the node has a right child.
 59    /// </summary>
 1052160    public readonly bool HasRightChild => RightChildIndex != -1;
 61
 62    /// <summary>
 63    /// Determines if the node has any children.
 64    /// </summary>
 365    public readonly bool HasChildren => HasLeftChild || HasRightChild;
 66
 67    /// <summary>
 68    /// Gets or sets a value indicating whether this node is a leaf node.
 69    /// </summary>
 70    public bool IsLeaf { get; set; }
 71
 72    /// <summary>
 73    /// Tracks the number of nodes in the subtree rooted at this node.
 74    /// </summary>
 75    public int SubtreeSize { get; set; }
 76
 77    /// <summary>
 78    /// Determines whether or not this node has been allocated from the pool or is a pooled instance
 79    /// </summary>
 80    public bool IsAllocated { get; set; }
 81
 82    /// <summary>
 83    /// Provides a custom default instance of <see cref="SwiftBVHNode{TKey, TVolume}"/>.
 84    /// </summary>
 585    public static SwiftBVHNode<TKey, TVolume> Default => new()
 586    {
 587        Value = default!,
 588        Bounds = default,
 589        ParentIndex = -1,
 590        LeftChildIndex = -1,
 591        RightChildIndex = -1,
 592        SubtreeSize = 0,
 593        IsLeaf = false,
 594        IsAllocated = false
 595    };
 96
 97    /// <summary>
 98    /// Resets the node to its default state.
 99    /// Clears all references and metadata.
 100    /// </summary>
 101    public void Reset()
 102    {
 61996103        Value = default!;
 61996104        Bounds = default;
 61996105        IsLeaf = false;
 61996106        ParentIndex = -1;
 61996107        MyIndex = -1;
 61996108        LeftChildIndex = -1;
 61996109        RightChildIndex = -1;
 61996110        SubtreeSize = 0;
 61996111        IsAllocated = false;
 61996112    }
 113}