I am currently trying to line trace from the top-back-right corner of a cube regardless of it’s rotation, but am having a bit of trouble. Here is my trace code:
This works fine when the cube’s rotation is a divisor of 90, but is off when the rotation is a divisor of 90 + 45. Here is a screenshot of what I want:
That is the result when the cube is at 0/90/180/270 degrees rotation. Here is the result when it is at 45/135/215/315 degrees of rotation:
As you can see, the trace is clearly off, but I have no clue why. I am rotating the box extent vector, so in my mind it should be working. Can anyone give me some pointers?
I originally didn’t have any better understanding from seeing the bounds, but then I decided to add a constant rotation to my mesh to see the line trace pattern, and I now do understand what is happening.
It turns out that the box extent was in world space. Thanks DevilsD, and in case it helps you, here is what I figured out to get the box extent relative to the object, which is what I am now using and works:
I was attempting to do the same but I was using the bounds of a volume, so to fix my problem i just used the actual volume box extent vector instead of its bounds.