Reputation: 23
I am struggling to understand/implement James Arvo's algorithm to transform an AABB, nicely given in this answer. Given that we are modifying the AABB with the translation and rotation of our object, how is this supposed to work over each frame? In the algorithm, we initially set the new AABB to be a zero volume box at our position. However, when modifying this based on the old AABB and our objects transformation, aren't we double dipping the translation of our object?
If we assume no rotation or scaling, our matrix just becomes the identity matrix, which should hopefully make my point (or misunderstanding) clear:
new_min = new_max = position
// no need to iterate through matrix, since off diagonals are now 0, and on diagonals are 1
for i<3
a = old_min[i] // <- this is just previous frame's position AABB
b = old_max[i]
new_min += min(a,b)
new_max += max(a,b)
But our old_min and max contain the previous frame's position information, and we are then adding to our current frame's position. When I tried to implement this, this is exactly what I found, with my AABB's racing off to infinity.
What am I misunderstanding?
Upvotes: 0
Views: 304
Reputation: 23
Answering for posterity, or for those who are too dense like me.
Simply calculate the changed AABB per frame, using the original, at creation, AABB. That's it.
Upvotes: 0