Rectangle intersection API?
-
Is there any API to get if 2 rectangles (vectors as x, y, w, h) intersect? My own function is called so many times during an update(), that it currently hurt performance.
-
@Nisse5 The 2D rectangle intersection shouldn't make a huge difference since the algo is quite simple. Do you have one of these?
- Some magic around centers (minimizes ifs - might speed things up, but never tried it)
- Classic-one having 4 ifs and 3 ors
-
@mixaal Yes, I do. My conclusion is that it's not the algorithm that causing the delays, it's the constant repetition of interpreted code. Running the function about 1000 times cause 4-5 milliseconds per frame update (time that I would like to use elsewhere, to keep my update cycle to always be below 16 ms). I can gain about 1 ms performance by putting the code directly in the loop (and not use a function call).
I'd expect an API doing the same thing to have insignificant impact on performance.
-
absolutely true here on many counts. the iteration is costly, the calculations are not.
we are already looking at ways to improve this!