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

Function GetWireBox

Source/Engine/Physics/Colliders/BoxCollider.cpp:89–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87namespace
88{
89 OrientedBoundingBox GetWireBox(const Vector3& min, const Vector3& max, const float margin)
90 {
91 OrientedBoundingBox box;
92 const Vector3 vec = max - min;
93 const Vector3 dir = Float3::Normalize(vec);
94 Quaternion orientation;
95 if (Vector3::Dot(dir, Float3::Up) >= 0.999f)
96 Quaternion::RotationAxis(Float3::Left, PI_HALF, orientation);
97 else
98 Quaternion::LookRotation(dir, Float3::Cross(Float3::Cross(dir, Float3::Up), dir), orientation);
99 const Vector3 up = orientation * Vector3::Up;
100 Matrix world;
101 Matrix::CreateWorld(min + vec * 0.5f, dir, up, world);
102 world.Decompose(box.Transformation);
103 Matrix invWorld;
104 Matrix::Invert(world, invWorld);
105 Vector3 vecLocal;
106 Vector3::TransformNormal(vec * 0.5f, invWorld, vecLocal);
107 box.Extents.X = margin;
108 box.Extents.Y = margin;
109 box.Extents.Z = vecLocal.Z;
110 return box;
111 }
112}
113
114void BoxCollider::OnDebugDrawSelf()

Callers 1

OnDebugDrawSelfMethod · 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