mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 16:12:35 +00:00
Can now update AABBTree however something weird is happening where the tree grows for the same numbeer of objects...
This commit is contained in:
@@ -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
|
||||
@@ -76,6 +76,10 @@ class IMICFPS
|
||||
self / Vector.new(mag, mag, mag)
|
||||
end
|
||||
|
||||
def sum
|
||||
@x + @y + @z + @weight
|
||||
end
|
||||
|
||||
def to_a
|
||||
[@x, @y, @z, @weight]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user