Module: AABBNodeDebugHelpers

Included in:
AABBNode
Defined in:
lib/gamebox/core/aabb_helpers.rb

Instance Method Summary collapse

Instance Method Details

#contains_children?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
# File 'lib/gamebox/core/aabb_helpers.rb', line 25

def contains_children?
  if leaf?
    true
  else
    @bb.contain?(a.bb) &&
      @bb.contain?(b.bb) &&
      @a.contains_children? &&
      @b.contains_children?
  end
end

#each_leaf(&blk) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/gamebox/core/aabb_helpers.rb', line 44

def each_leaf(&blk)
  if leaf?
    blk.call self
  else leaf?
    @a.each_leaf &blk
    @b.each_leaf &blk
  end
end

#each_node(&blk) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/gamebox/core/aabb_helpers.rb', line 36

def each_node(&blk)
  blk.call self
  unless leaf?
    @a.each_node &blk
    @b.each_node &blk
  end
end

#rootObject



53
54
55
56
57
58
59
# File 'lib/gamebox/core/aabb_helpers.rb', line 53

def root
  node = self
  while node.parent
    node = node.parent
  end
  node
end