Debug draw capsule now works with different orientations

This commit is contained in:
Kah Wei 2023-01-08 01:43:40 +08:00
parent 5c5ff38b49
commit f44e7b7a1c
1 changed files with 5 additions and 5 deletions

View File

@ -362,12 +362,12 @@ namespace SHADE
void SHDebugDrawSystem::drawWireCapsule(LinesBatch& lineBatch, MeshBatch& meshBatch, const SHVec3& position, const SHQuaternion& rotation, float height, float radius, const SHColour& color)
{
// Get local axis vectors
const SHVec3 LOCAL_UP = SHVec3::Up;
const SHVec3 LOCAL_RIGHT = SHVec3::Right;
const SHVec3 LOCAL_FORWARD = SHVec3::Forward;
const SHVec3 LOCAL_UP = SHVec3::Rotate(SHVec3::Up, rotation);
const SHVec3 LOCAL_RIGHT = SHVec3::Rotate(SHVec3::Right, rotation);
const SHVec3 LOCAL_FORWARD = SHVec3::Rotate(SHVec3::Forward, rotation);
// Rotate the circle
SHQuaternion circleOrientation = SHQuaternion::FromEuler(SHVec3(SHMath::DegreesToRadians(90.0), 0.0f, 0.0f));
SHQuaternion circleOrientation = SHQuaternion::FromEuler(SHVec3(SHMath::DegreesToRadians(90.0), 0.0f, 0.0f)) * rotation;
// Compute top and bottom of the cylinder
const SHVec3 HALF_UP = LOCAL_UP * (height * 0.5f - radius);
@ -396,7 +396,7 @@ namespace SHADE
const SHMatrix BOT_CAP_MAT = SHMatrix::Transform
(
BOT_POS,
rotation * SHQuaternion::FromEuler(SHVec3(SHMath::DegreesToRadians(180.0), 0.0f, 0.0f)),
SHQuaternion::FromEuler(SHVec3(SHMath::DegreesToRadians(180.0), 0.0f, 0.0f)) * rotation,
RADIUS_SCALE
);
drawMesh