Additional OrientedBoundingBox functionality #12178
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added a few functions to the
OrientedBoundingBox
class:fromMinMax
computes an OBB from given min/max pointstransform
transforms an OBB with a matrixintersect
tests for intersection between two OBBsThe first ones are rather simple "convenience" functions. I used these functions, for example, in #12112 , but there, only 'drafted' them, still outside of the
OrientedBoundingBox
class.The
intersect
function is a bit more involved. It implements the "Separating Axis Theorem", as described in https://gamma.cs.unc.edu/users/gottschalk/main.pdf . Strangely, this function already did exist, back when there was still a class calledObjectOrientedBoundingBox
. This class was deprecated in #2782 and eventually removed, without a replacement for theintersect
function. So I'm not even 100% sure whether it should be added again 😬Issue number and link
No specific issue, but ...
Testing plan
In addition to the Specs/UnitTests, the following is a sandcastle that can be used for testing the
intersect
function this when running this branch on localhost:http://localhost:8080/Apps/Sandcastle/#c=3Vhtb9s2EP4rhL9ExlzZWpqt0FxvdZJlBtq4SJMtMgwUlETbQijJkKjEbpH/viMpipL8kqSxjWFFapA88l6eO94d5cVRytB9QB5Igt6jiDygU5IGWWj+LdaMccMT89M4YjiISDJutND3cYTQlMYusdEE05S0xtFj87dxNI4mWeSxII6QlxDMyOckCAMW3BMjdt0W8mIaJ0153hOipyQOCUuWVeH9eDHMGAV5FzndEGcQCoMoCLPQLu8+xQmDEY6OjTeW2Wkh/dts5cfwYtsxsV/9yDPCHqVlGPuEfsIsCRagaH5ezt+akyQOr2KGudnXCY5SKoaGlAx2mzNMJx8WJG3pJY9ED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eLdGYWuZUezOKYu5rnCj70sBKjMKWHnlPBhfzmAjqaR7xk3+ME6b3hL0WU/EGinWkZLca494OUdNSo1WWa+amuA0GUWuiTRHE0Brcqia6nOVupoI1W6YjvZ2U7ezFw6bzvZ2U4elXqtSrsHsJVrgd5QVABdDoQfik8C+pquuTJmkft4I94RTw5L16qYEpPGU4iMgdqHxg3ouINmLmRTh5yQMJbdvb51hVl6qYiG1edv0bKrPjRAv1c+L5hX52eo+sXB7H+8OdcIbmvfVzR7oTXWqjXWFms4rq2qrhdX5+eXL1PUeqailSQmReDa02bbg6xTvN/qOQAyxtBNSXKPXcjypRwwbohLC5nDTDM39ZLAJYZMAetyyRN8nB3xGe2Aj0wZu2Lk7IrRLkyTCWtXjJxdMdpo2jhSRQUm9W88ImgbrUY3ZUtKejzm/wjCeZwwlCXUMM02I+EcHtUkbbuZd0eY6aXis0q3rY50/eAeBf77NV+tkUdxmgJlklH6BWJr3Oh127C/cozGmGfW4T1JKF7yLTOr91EumqbZbcN09VRRdoXWXcZx6cmk12Vu7C976nXeZUlPv/O7zO+Ja9dtw6i6rmcwD6J5Bh3Ack5AWsK7bjAoDCKYQQvGx3gBY/ElAGYpI3M+hSHAjd+4UPRhLrpvO3/Ly178RvjDRkdCwlFuwXq5jCwYZw7HYXayhXmFTcU2mCRPgOEcHAxnn2A4rwJjdHAwRvsEY/TDYMgsflA01Bem/cChytJr8HAOj4ezVzyc1+ExOjweo73i8eP3RbYGu8Lj3dNoSIH7QkN1Oq9Bwzk0Gs5e0XBeh8bo0GiM9orG824KDIt2DMZ5n6Yaun8B
It uses one fixed bounding box, and allows editing the size, position, and orientation of the other one, showing the other one in red when they intersect (and printing infos to the console)
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change