| 87 | namespace |
| 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 | |
| 114 | void BoxCollider::OnDebugDrawSelf() |
no test coverage detected