Refactored GameObject to Entity, replaced @x,@y,@z with @position, added @velocity vector to Entity, bricked Player terrain interaction while authoring Axis Aligned Bounding Box Tree for CollisionManager to handle all collision interaction. Added PhysicsManager stub.

This commit is contained in:
2019-02-20 10:49:56 -06:00
parent df05ec5150
commit 7b903fbdb9
27 changed files with 288 additions and 385 deletions

49
lib/trees/aabb_tree.rb Normal file
View File

@@ -0,0 +1,49 @@
class IMICFPS
class AABBTree
def initialize
@objects = {}
@root = nil
end
def add(bounding_box, object)
raise "BoundingBox can't be nil!" unless bounding_box
raise "Object can't be nil!" unless object
if @root
@root.insert_subtree(bounding_box, object)
else
@root = AABBNode.new(parent: nil, object: object, bounding_box: BoundingBox.new(0,0,0, 0,0,0))
end
end
def update(object)
end
# Returns a list of all collided objects inside Bounding Box
def search(bounding_box)
items = []
@root.search_subtree(bounding_box)
end
def remove(object)
end
class AABBNode
def initialize(parent:, object:, bounding_box:)
@parent = parent
@object = object
@bounding_box = bounding_box
end
def insert_subtree(bounding_box, object)
p "#{bounding_box} -> #{object.class}"
end
def remove_subtree(node)
end
def search_subtree(bounding_box)
end
end
end
end