I am implementing my own Raycasting library to find out how it works. As a starting point, I have a box that rotates and, using rays, detects various obstacles that it encounters in its path. It is worth mentioning: it works for me using the AABB line intersection method. The following figure shows how this works:
Crossing a line with AABB
My problem arises when I turn one of the walls above and try to use the same method to check for ray collisions:
Rotated Object Collision
I was looking for a possible solution to fix this using various algorithms such as the Separation Axis Theorem and Cohen-Sutherland, but I could not find anything like the intersection of AABB, but using OBB. Any ideas on how to get around the problem in the second picture, where does it collide with the boundaries of the object when it is rotated? I use Unity and C #.
source
share