Contacts now draw normals

This commit is contained in:
Diren D Bharwani 2022-12-30 21:42:44 +08:00
parent 50e3ddf0dd
commit a36d03b03b
5 changed files with 18 additions and 9 deletions

View File

@ -73,7 +73,15 @@ namespace SHADE
continue; continue;
for (uint32_t i = 0; i < manifold.numContacts; ++i) for (uint32_t i = 0; i < manifold.numContacts; ++i)
contactPoints.emplace_back(manifold.contacts[i].position); {
const ContactInfo INFO
{
.position = manifold.contacts[i].position
, .normal = manifold.normal
};
contactPoints.emplace_back(INFO);
}
} }
return contactPoints; return contactPoints;

View File

@ -42,9 +42,15 @@ namespace SHADE
/* Type Definitions */ /* Type Definitions */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
struct ContactInfo
{
SHVec3 position;
SHVec3 normal;
};
using TriggerEvents = std::vector<SHTriggerEvent>; using TriggerEvents = std::vector<SHTriggerEvent>;
using CollisionEvents = std::vector<SHCollisionEvent>; using CollisionEvents = std::vector<SHCollisionEvent>;
using ContactPoints = std::vector<SHVec3>; using ContactPoints = std::vector<ContactInfo>;
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */ /* Constructors & Destructor */

View File

@ -79,8 +79,9 @@ namespace SHADE
const auto& CONTACT_POINTS = physicsSystem->physicsWorld->GetContactPoints(); const auto& CONTACT_POINTS = physicsSystem->physicsWorld->GetContactPoints();
for (auto& contactPoint : CONTACT_POINTS) for (auto& contactPoint : CONTACT_POINTS)
{ {
const SHMatrix TRS = SHMatrix::Transform(contactPoint, SHQuaternion::Identity, SHVec3{ 0.1f }); const SHMatrix TRS = SHMatrix::Transform(contactPoint.position, SHQuaternion::Identity, SHVec3{ 0.1f });
debugDrawSystem->DrawCube(TRS, CONTACT_COLOUR); debugDrawSystem->DrawCube(TRS, CONTACT_COLOUR);
debugDrawSystem->DrawLine(contactPoint.position, contactPoint.position + contactPoint.normal * 0.3f, CONTACT_COLOUR, true);
} }
} }

View File

@ -149,11 +149,6 @@ namespace SHADE
} }
} }
void SHPhysicsDebugDrawSystem::drawContact(SHDebugDrawSystem* debugDrawSystem, const DebugDrawInfo::Contact& contactInfo) noexcept
{
static const SHColour& DRAW_COLOUR = DEBUG_DRAW_COLOURS[SHUtilities::ConvertEnum(Colours::CONTACT)];
}
void SHPhysicsDebugDrawSystem::drawRaycast(SHDebugDrawSystem* debugDrawSystem, const DebugDrawInfo::Raycast& raycastInfo) noexcept void SHPhysicsDebugDrawSystem::drawRaycast(SHDebugDrawSystem* debugDrawSystem, const DebugDrawInfo::Raycast& raycastInfo) noexcept
{ {
static const SHColour& DRAW_COLOUR = DEBUG_DRAW_COLOURS[SHUtilities::ConvertEnum(Colours::RAYCAST)]; static const SHColour& DRAW_COLOUR = DEBUG_DRAW_COLOURS[SHUtilities::ConvertEnum(Colours::RAYCAST)];

View File

@ -141,7 +141,6 @@ namespace SHADE
SHEventHandle onColliderDraw(SHEventPtr onColliderDrawEvent); SHEventHandle onColliderDraw(SHEventPtr onColliderDrawEvent);
static void drawCollider (SHDebugDrawSystem* debugDrawSystem, const SHCollider& collider) noexcept; static void drawCollider (SHDebugDrawSystem* debugDrawSystem, const SHCollider& collider) noexcept;
static void drawContact (SHDebugDrawSystem* debugDrawSystem, const DebugDrawInfo::Contact& contactInfo) noexcept;
static void drawRaycast (SHDebugDrawSystem* debugDrawSystem, const DebugDrawInfo::Raycast& raycastInfo) noexcept; static void drawRaycast (SHDebugDrawSystem* debugDrawSystem, const DebugDrawInfo::Raycast& raycastInfo) noexcept;
}; };