Refactored Model to make faces first class objects for use in AABBTree, renamed BoundingBox.intersect to intersect?

This commit is contained in:
2019-02-25 17:59:09 -06:00
parent 0d7210b3f7
commit 8ccd1506f3
7 changed files with 60 additions and 32 deletions

View File

@@ -26,13 +26,6 @@ class IMICFPS
return temp
end
# 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
@@ -42,6 +35,13 @@ class IMICFPS
return temp
end
# 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
# does this bounding box envelop other bounding box? (inclusive of border)
def contains?(other)
other.min.x >= min.x && other.min.y >= min.y && other.min.z >= min.z &&