Can now update AABBTree however something weird is happening where the tree grows for the same numbeer of objects...

This commit is contained in:
2019-02-25 09:35:01 -06:00
parent 5cf07ca620
commit d5a5ced955
9 changed files with 140 additions and 33 deletions

View File

@@ -26,13 +26,14 @@ class IMICFPS
return temp
end
# returns boolean
# returns whether both bounding boxes intersect
def intersect(other)
(@min.x <= other.max.x && @max.x >= other.min.x) &&
(@min.y <= other.max.y && @max.y >= other.min.y) &&
(@min.z <= other.max.z && @max.z >= other.min.z)
end
# returns the difference between both bounding boxes
def difference(other)
temp = BoundingBox.new
temp.min = @min - other.min
@@ -41,6 +42,13 @@ class IMICFPS
return temp
end
# returns whether the vector is inside of the bounding box
def contains(vector)
vector.x.between?(@min.x, @max.x) &&
vector.y.between?(@min.y, @max.y) &&
vector.z.between?(@min.z, @max.z)
end
def volume
width * height * depth
end
@@ -82,5 +90,25 @@ class IMICFPS
return temp
end
def +(other)
box = BoundingBox.new
box.min = self.min + other.min
box.min = self.max + other.max
return box
end
def -(other)
box = BoundingBox.new
box.min = self.min - other.min
box.min = self.max - other.max
return box
end
def sum
@min.sum + @max.sum
end
end
end