Why doesn't AABB's intersection() method take position, scale and rotation into account?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By okapii

The AABB’s intersection()-method obviously doesn’t take the object’s position, rotation and scale into account.
The position can be accounted for by adjusting the AABB’s position property according to the mesh-instance’s origin-position. But I am stumped as to how to address the fact that the AABB does not reflect rotation and scale. I assumed that the bounding box would span around the rotated object correctly but this does not happen. No matter how one rotates or scales the object, the AABB will always reflect the unrotated and unscaled version of the object. There surely has to be a solution for this as the AABBs would be fairly useless otherwise?

:bust_in_silhouette: Reply From: Zylann

Perhaps you should use get_transformed_aabb()? https://docs.godotengine.org/en/stable/classes/class_visualinstance.html#class-visualinstance-method-get-transformed-aabb

Thanks, that was the solution!

okapii | 2020-09-16 10:47