g3n / engine

Go 3D Game Engine (http://g3n.rocks)
https://discord.gg/NfaeVr8zDg
BSD 2-Clause "Simplified" License
2.79k stars 295 forks source link

Is bounding box for geometry type object oriented? #233

Closed NataliaDobosz closed 3 years ago

NataliaDobosz commented 3 years ago

Does BoundigBox() method for Geometry type calculates axis-aligned or object oriented bounding box?

danaugrs commented 3 years ago

Hi! Geometry's BoundingBox() computes the axis-aligned bounding box in the geometry's reference frame. If you transform the object that is using that geometry and you want to find the axis-aligned bounding box in the global reference frame you need to apply the world matrix. Here's an example of how we do this in the renderer:

https://github.com/g3n/engine/blob/6d0136f3444c35f7c4d4189575b815562c30b3ef/renderer/renderer.go#L236-L238