mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 21:22:33 +00:00
BoundingBox#intersect? now supports Ray
This commit is contained in:
@@ -49,11 +49,17 @@ module CyberarmEngine
|
|||||||
return temp
|
return temp
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns whether both bounding boxes intersect
|
# returns whether bounding box intersects other
|
||||||
def intersect?(other)
|
def intersect?(other)
|
||||||
(@min.x <= other.max.x && @max.x >= other.min.x) &&
|
if other.is_a?(Ray)
|
||||||
(@min.y <= other.max.y && @max.y >= other.min.y) &&
|
other.intersect?(self)
|
||||||
(@min.z <= other.max.z && @max.z >= other.min.z)
|
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)
|
||||||
|
else
|
||||||
|
raise "Unknown collider: #{other.class}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# does this bounding box envelop other bounding box? (inclusive of border)
|
# does this bounding box envelop other bounding box? (inclusive of border)
|
||||||
|
|||||||
Reference in New Issue
Block a user