Add more utilities for using Matrix3x3

This commit is contained in:
Wojciech Figat
2022-04-04 17:09:47 +02:00
parent 52bb5803b3
commit 3ded5326a2
8 changed files with 95 additions and 72 deletions

View File

@@ -8,11 +8,18 @@
OrientedBoundingBox::OrientedBoundingBox(const BoundingBox& bb)
{
const Vector3 center = bb.Minimum + (bb.Maximum - bb.Minimum) / 2.0f;
const Vector3 center = bb.Minimum + (bb.Maximum - bb.Minimum) * 0.5f;
Extents = bb.Maximum - center;
Matrix::Translation(center, Transformation);
}
OrientedBoundingBox::OrientedBoundingBox(const Vector3& extents, const Matrix3x3& rotationScale, const Vector3& translation)
: Extents(extents)
, Transformation(rotationScale)
{
Transformation.SetTranslation(translation);
}
OrientedBoundingBox::OrientedBoundingBox(Vector3 points[], int32 pointCount)
{
ASSERT(points && pointCount > 0);
@@ -104,6 +111,12 @@ void OrientedBoundingBox::GetBoundingBox(BoundingBox& result) const
BoundingBox::FromPoints(corners, 8, result);
}
void OrientedBoundingBox::Transform(const Matrix& matrix)
{
const Matrix tmp = Transformation;
Matrix::Multiply(tmp, matrix, Transformation);
}
ContainmentType OrientedBoundingBox::Contains(const Vector3& point, float* distance) const
{
// Transform the point into the obb coordinates