Ran rubocop -a

This commit is contained in:
2020-12-14 16:04:31 -06:00
parent 2447dde1af
commit 26dd688124
59 changed files with 770 additions and 741 deletions

View File

@@ -23,7 +23,7 @@ module CyberarmEngine
def ==(other)
@min == other.min &&
@max == other.max
@max == other.max
end
# returns a new bounding box that includes both bounding boxes
@@ -37,7 +37,7 @@ module CyberarmEngine
temp.max.y = [@max.y, other.max.y].max
temp.max.z = [@max.z, other.max.z].max
return temp
temp
end
# returns the difference between both bounding boxes
@@ -46,7 +46,7 @@ module CyberarmEngine
temp.min = @min - other.min
temp.max = @max - other.max
return temp
temp
end
# returns whether bounding box intersects other
@@ -55,8 +55,8 @@ module CyberarmEngine
other.intersect?(self)
elsif other.is_a?(BoundingBox)
(@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)
(@min.y <= other.max.y && @max.y >= other.min.y) &&
(@min.z <= other.max.z && @max.z >= other.min.z)
else
raise "Unknown collider: #{other.class}"
end
@@ -65,20 +65,20 @@ module CyberarmEngine
# 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 &&
other.max.x <= max.x && other.max.y <= max.y && other.max.z <= max.z
other.max.x <= max.x && other.max.y <= max.y && other.max.z <= max.z
end
# returns whether the 3D vector is inside of the bounding box
def inside?(vector)
(vector.x.between?(@min.x, @max.x) || vector.x.between?(@max.x, @min.x)) &&
(vector.y.between?(@min.y, @max.y) || vector.y.between?(@max.y, @min.y)) &&
(vector.z.between?(@min.z, @max.z) || vector.z.between?(@max.z, @min.z))
(vector.y.between?(@min.y, @max.y) || vector.y.between?(@max.y, @min.y)) &&
(vector.z.between?(@min.z, @max.z) || vector.z.between?(@max.z, @min.z))
end
# returns whether the 2D vector is inside of the bounding box
def point?(vector)
(vector.x.between?(@min.x, @max.x) || vector.x.between?(@max.x, @min.x)) &&
(vector.y.between?(@min.y, @max.y) || vector.y.between?(@max.y, @min.y))
(vector.y.between?(@min.y, @max.y) || vector.y.between?(@max.y, @min.y))
end
def volume
@@ -107,7 +107,7 @@ module CyberarmEngine
temp.max.y = @max.y.to_f * entity.scale.y
temp.max.z = @max.z.to_f * entity.scale.z
return temp
temp
end
def normalize_with_offset(entity)
@@ -120,23 +120,23 @@ module CyberarmEngine
temp.max.y = @max.y.to_f * entity.scale.y + entity.position.y
temp.max.z = @max.z.to_f * entity.scale.z + entity.position.z
return temp
temp
end
def +(other)
box = BoundingBox.new
box.min = self.min + other.min
box.min = self.max + other.max
box.min = min + other.min
box.min = max + other.max
return box
box
end
def -(other)
box = BoundingBox.new
box.min = self.min - other.min
box.min = self.max - other.max
box.min = min - other.min
box.min = max - other.max
return box
box
end
def sum
@@ -147,4 +147,4 @@ module CyberarmEngine
BoundingBox.new(@min.x, @min.y, @min.z, @max.x, @max.y, @max.z)
end
end
end
end