Gravity constant moved into constants.rb, camera can now report what it is looking at, entity has knowledge of camera now, AABB tree search can now use either BoundingBox or Ray colliders

This commit is contained in:
2019-08-13 09:47:23 -05:00
parent 771b6a4247
commit 016e8109de
9 changed files with 57 additions and 33 deletions

View File

@@ -55,13 +55,13 @@ class IMICFPS
end
end
def search_subtree(bounding_box, items = [])
if @bounding_box.intersect?(bounding_box)
def search_subtree(collider, items = [])
if @bounding_box.intersect?(collider)
if leaf?
items << self
else
@a.search_subtree(bounding_box, items)
@b.search_subtree(bounding_box, items)
@a.search_subtree(collider, items)
@b.search_subtree(collider, items)
end
end

View File

@@ -35,11 +35,11 @@ class IMICFPS
insert_leaf(leaf)
end
# Returns a list of all collided objects inside Bounding Box
def search(bounding_box, return_nodes = false)
# Returns a list of all objects that collided with collider
def search(collider, return_nodes = false)
items = []
if @root
items = @root.search_subtree(bounding_box)
items = @root.search_subtree(collider)
items.map! {|e| e.object} unless return_nodes
end