Implemented a custom physics engine #316
|
@ -73,7 +73,15 @@ namespace SHADE
|
|||
continue;
|
||||
|
||||
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;
|
||||
|
|
|
@ -42,9 +42,15 @@ namespace SHADE
|
|||
/* Type Definitions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
struct ContactInfo
|
||||
{
|
||||
SHVec3 position;
|
||||
SHVec3 normal;
|
||||
};
|
||||
|
||||
using TriggerEvents = std::vector<SHTriggerEvent>;
|
||||
using CollisionEvents = std::vector<SHCollisionEvent>;
|
||||
using ContactPoints = std::vector<SHVec3>;
|
||||
using ContactPoints = std::vector<ContactInfo>;
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Constructors & Destructor */
|
||||
|
|
|
@ -79,8 +79,9 @@ namespace SHADE
|
|||
const auto& CONTACT_POINTS = physicsSystem->physicsWorld->GetContactPoints();
|
||||
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->DrawLine(contactPoint.position, contactPoint.position + contactPoint.normal * 0.3f, CONTACT_COLOUR, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
static const SHColour& DRAW_COLOUR = DEBUG_DRAW_COLOURS[SHUtilities::ConvertEnum(Colours::RAYCAST)];
|
||||
|
|
|
@ -141,7 +141,6 @@ namespace SHADE
|
|||
SHEventHandle onColliderDraw(SHEventPtr onColliderDrawEvent);
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue