Is OrientedBoundingBox as smallest as possible at creation?

Hi!



I have read the source code of OrientedBoundingBox and I'm a bit disappointed, it seems to work like BoundingBox at its creation, its volume is not as smallest as possible, it computes the smallest axis-aligned bounding box and after that, it updates the corner depending on the orientation. The problem is the result is far from satisfying if your bounded object is not axis-aligned at the beginning. Am I wrong? Have I misread anything? Is there a workaround?



In my case, I want to use OrientedBoundingBox for my portals, maybe I can get the really smallest oriented bounding box by using the normal of the triangles and then update the axis by using it.

Hi!



As my portals are flat, I suggest the following steps to solve my problem in my particular case:

  • get the normal of a triangle composing the portal
  • get 2 vertices of this triangle
  • compute a vector with these vertices
  • use the cross product to compute a third vector
  • normalize the 3 vectors
  • make a matrix with them
  • use the invert of this matrix as a rotation matrix on the portal
  • compute the oriented bounding box
  • use the matrix as a rotation matrix on the portal
  • update the oriented bounding box



    Is it a good way to compute the smallest oriented bounding box for a flat object?