Implemented a first class BoundingBox, refactored to use bounding box.

This commit is contained in:
2019-02-23 18:28:47 -06:00
parent 7aa99a70a7
commit fc72f2bdc8
6 changed files with 132 additions and 65 deletions

View File

@@ -9,6 +9,11 @@ class IMICFPS
@aabb_tree.add(entity.normalized_bounding_box, entity)
end
def update
lazy_check_collisions
@aabb_tree.update
end
def remove(entity)
@aabb_tree.remove(entity)
end
@@ -19,8 +24,10 @@ class IMICFPS
@game_state.entities.each do |other|
next if entity == other
next if entity.is_a?(Terrain) || other.is_a?(Terrain)
next unless entity.collidable?
next unless other.collidable?
if entity.intersect(other)
if entity.normalized_bounding_box.intersect(other.normalized_bounding_box)
entity.debug_color = Color.new(1.0,0.0,0.0)
other.debug_color = Color.new(1.0,0.0,0.0)
@@ -33,10 +40,5 @@ class IMICFPS
end
end
end
def update
lazy_check_collisions
# @aabb_tree.rebuild
end
end
end