Refactor OrientedBoundingBox to use Transform for transformation instead of Matrix (for large worlds)

This commit is contained in:
Wojtek Figat
2022-06-16 10:51:59 +02:00
parent 995e5bc6ff
commit 9ba117cde3
16 changed files with 168 additions and 780 deletions

View File

@@ -60,11 +60,13 @@ namespace
else
Quaternion::LookRotation(dir, Float3::Cross(Float3::Cross(dir, Float3::Up), dir), orientation);
const Vector3 up = orientation * Vector3::Up;
Matrix::CreateWorld(min + vec * 0.5f, dir, up, box.Transformation);
Matrix inv;
Matrix::Invert(box.Transformation, inv);
Matrix world;
Matrix::CreateWorld(min + vec * 0.5f, dir, up, world);
world.Decompose(box.Transformation);
Matrix invWorld;
Matrix::Invert(world, invWorld);
Vector3 vecLocal;
Vector3::TransformNormal(vec * 0.5f, inv, vecLocal);
Vector3::TransformNormal(vec * 0.5f, invWorld, vecLocal);
box.Extents.X = margin;
box.Extents.Y = margin;
box.Extents.Z = vecLocal.Z;