Skip to main content
5 events
when toggle format what by license comment
Dec 8, 2011 at 14:43 comment added David Gouveia Glad I could help! I actually first found out about this on this book where they specifically warn you about this pitfall.
Dec 8, 2011 at 11:42 comment added Stephen Tierney Kind sir you are entirely correct! I have realised that my code only works for rotation by values divisible by 90 degrees (90, 180, 280, 360 etc). Thank you for alerting me to this.
Dec 8, 2011 at 6:09 comment added David Gouveia It's hard to explain without an actual picture of the problem but check this image. The blue square is your sprite, and the AABB you want to get is the black square outline. Now try to consider what would happen if you only used the top-left/bottom-right corners (pick any two diagonal corners on the blue square). If you try to draw an AABB between those two corners, you'll get a much smaller area that doesn't cover the entire sprite.
Dec 8, 2011 at 6:03 comment added David Gouveia I have not tried it, but it seems to me this won't work correctly unless a few other steps are taken. First, because the sprite's transformation matrix is usually going to be defined in object space, while its bounds will usually be in world space. And even if you took care to work in the same space, transforming only the top-left and bottom-right corners isn't enough to fit an AABB. This is actually a pretty common mistake. You need to transform all four corners and then find the absolute minimum and maximum values of x and y between all four of them for it to work.
Dec 8, 2011 at 1:08 history answered Stephen Tierney CC BY-SA 3.0