Skip to content

Commit

Permalink
B2DynamicTree Validate
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-r committed Feb 9, 2020
1 parent 806cbf3 commit add4467
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CollisionB2DynamicTree.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,20 @@ func (tree B2DynamicTree) ValidateMetrics(index int) {
}

func (tree B2DynamicTree) Validate() {
tree.ValidateStructure(tree.M_root)
tree.ValidateMetrics(tree.M_root)

freeCount := 0
freeIndex := tree.M_freeList
for freeIndex != B2_nullNode {
B2Assert(0 <= freeIndex && freeIndex < tree.M_nodeCapacity)
freeIndex = tree.M_nodes[freeIndex].Next
freeCount++
}

B2Assert(tree.GetHeight() == tree.ComputeTotalHeight())

B2Assert(tree.M_nodeCount+freeCount == tree.M_nodeCapacity)
}

func (tree B2DynamicTree) GetMaxBalance() int {
Expand Down

0 comments on commit add4467

Please sign in to comment.