MCPcopy Create free account
hub / github.com/ByteArena/box2d / GetMaxBalance

Method GetMaxBalance

CollisionB2DynamicTree.go:739–756  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

737}
738
739func (tree B2DynamicTree) GetMaxBalance() int {
740 maxBalance := 0
741 for i := 0; i < tree.M_nodeCapacity; i++ {
742 node := &tree.M_nodes[i]
743 if node.Height <= 1 {
744 continue
745 }
746
747 B2Assert(node.IsLeaf() == false)
748
749 child1 := node.Child1
750 child2 := node.Child2
751 balance := AbsInt(tree.M_nodes[child2].Height - tree.M_nodes[child1].Height)
752 maxBalance = MaxInt(maxBalance, balance)
753 }
754
755 return maxBalance
756}
757
758func (tree *B2DynamicTree) RebuildBottomUp() {
759 //int* nodes = (int*)b2Alloc(m_nodeCount * sizeof(int));

Callers 1

GetTreeBalanceMethod · 0.80

Calls 4

B2AssertFunction · 0.85
AbsIntFunction · 0.85
MaxIntFunction · 0.85
IsLeafMethod · 0.80

Tested by

no test coverage detected