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

Method ComputeHeight

CollisionB2DynamicTree.go:653–664  ·  view source on GitHub ↗

Compute the height of a sub-tree.

(nodeId int)

Source from the content-addressed store, hash-verified

651
652// Compute the height of a sub-tree.
653func (tree B2DynamicTree) ComputeHeight(nodeId int) int {
654 B2Assert(0 <= nodeId && nodeId < tree.M_nodeCapacity)
655 node := &tree.M_nodes[nodeId]
656
657 if node.IsLeaf() {
658 return 0
659 }
660
661 height1 := tree.ComputeHeight(node.Child1)
662 height2 := tree.ComputeHeight(node.Child2)
663 return 1 + MaxInt(height1, height2)
664}
665
666func (tree B2DynamicTree) ComputeTotalHeight() int {
667 return tree.ComputeHeight(tree.M_root)

Callers 1

ComputeTotalHeightMethod · 0.95

Calls 3

B2AssertFunction · 0.85
MaxIntFunction · 0.85
IsLeafMethod · 0.80

Tested by

no test coverage detected