MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetWriteBox

Function GetWriteBox

Source/Engine/Level/Actors/BoxVolume.cpp:48–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46namespace
47{
48 OrientedBoundingBox GetWriteBox(const Vector3& min, const Vector3& max, const float margin)
49 {
50 OrientedBoundingBox box;
51 const Vector3 vec = max - min;
52 const Vector3 dir = Vector3::Normalize(vec);
53 Quaternion orientation;
54 if (Vector3::Dot(dir, Vector3::Up) >= 0.999f)
55 Quaternion::RotationAxis(Vector3::Left, PI_HALF, orientation);
56 else
57 Quaternion::LookRotation(dir, Vector3::Cross(Vector3::Cross(dir, Vector3::Up), dir), orientation);
58 const Vector3 up = orientation * Vector3::Up;
59 Matrix world;
60 Matrix::CreateWorld(min + vec * 0.5f, dir, up, world);
61 world.Decompose(box.Transformation);
62 Matrix invWorld;
63 Matrix::Invert(world, invWorld);
64 Vector3 vecLocal;
65 Vector3::TransformNormal(vec * 0.5f, invWorld, vecLocal);
66 box.Extents.X = margin;
67 box.Extents.Y = margin;
68 box.Extents.Z = vecLocal.Z;
69 return box;
70 }
71}
72
73void BoxVolume::OnDebugDrawSelected()

Callers 2

OnDebugDrawSelectedMethod · 0.85
RayCastWireMethod · 0.85

Calls 6

DotFunction · 0.85
RotationAxisFunction · 0.85
LookRotationFunction · 0.85
NormalizeFunction · 0.50
InvertFunction · 0.50
DecomposeMethod · 0.45

Tested by

no test coverage detected