mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
Can now update AABBTree however something weird is happening where the tree grows for the same numbeer of objects...
This commit is contained in:
26
lib/trees/aabb_tree_debug.rb
Normal file
26
lib/trees/aabb_tree_debug.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class IMICFPS
|
||||
# Gets included into AABBTree
|
||||
module AABBTreeDebug
|
||||
def inspect
|
||||
@branches, @leaves = 0, 0
|
||||
if @root
|
||||
node = @root
|
||||
|
||||
debug_search(node.a)
|
||||
debug_search(node.b)
|
||||
end
|
||||
|
||||
puts "<#{self.class}:#{self.object_id}> has #{@branches} branches and #{@leaves} leaves"
|
||||
end
|
||||
|
||||
def debug_search(node)
|
||||
if node.leaf?
|
||||
@leaves += 1
|
||||
else
|
||||
@branches += 1
|
||||
debug_search(node.a)
|
||||
debug_search(node.b)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user