Implemented a custom physics engine #316
|
@ -36,12 +36,6 @@ namespace SHADE
|
|||
friend class SHCollisionShapeLibrary;
|
||||
|
||||
public:
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Data Members */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
static constexpr float RADIUS = 0.1f;
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Constructors & Destructor */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace SHADE
|
|||
const SHConvexPolyhedronCollisionShape& CONVEX = dynamic_cast<const SHConvexPolyhedronCollisionShape&>(B);
|
||||
|
||||
const SHVec3 CENTER = SPHERE.GetCenter();
|
||||
const float TOTAL_RADIUS = SPHERE.GetWorldRadius() + SHConvexPolyhedronCollisionShape::RADIUS;
|
||||
const float RADIUS = SPHERE.GetWorldRadius();
|
||||
|
||||
// Find closest face of polygon to circle
|
||||
|
||||
|
@ -86,7 +86,7 @@ namespace SHADE
|
|||
// Early out:
|
||||
// If face is facing away from center, signed dist is negative.
|
||||
// Therefore signed distance is only positive when sphere is in front of the face.
|
||||
if (SIGNED_DIST > TOTAL_RADIUS)
|
||||
if (SIGNED_DIST > RADIUS)
|
||||
return false;
|
||||
|
||||
if (SIGNED_DIST > bestDistance)
|
||||
|
@ -97,7 +97,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
uint32_t numContacts = 0;
|
||||
const float PENETRATION = TOTAL_RADIUS - bestDistance;
|
||||
const float PENETRATION = RADIUS - bestDistance;
|
||||
|
||||
// Check if center is inside polyhedron (below the face)
|
||||
if (bestDistance < SHMath::EPSILON)
|
||||
|
@ -182,7 +182,7 @@ namespace SHADE
|
|||
manifold.normal = CP_TO_CENTER;
|
||||
|
||||
SHContact newContact;
|
||||
newContact.penetration = TOTAL_RADIUS - projection;
|
||||
newContact.penetration = RADIUS - projection;
|
||||
newContact.position = CP;
|
||||
newContact.featurePair.key = 0;
|
||||
|
||||
|
@ -196,7 +196,7 @@ namespace SHADE
|
|||
|
||||
// Check region C (closest point)
|
||||
{
|
||||
if (C_TO_CENTER.LengthSquared() < TOTAL_RADIUS * TOTAL_RADIUS)
|
||||
if (C_TO_CENTER.LengthSquared() < RADIUS * RADIUS)
|
||||
{
|
||||
manifold.normal = -SHVec3::Normalise(C_TO_CENTER);
|
||||
|
||||
|
@ -213,13 +213,13 @@ namespace SHADE
|
|||
}
|
||||
|
||||
// Region D
|
||||
if (PENETRATION <= TOTAL_RADIUS)
|
||||
if (PENETRATION <= RADIUS)
|
||||
{
|
||||
manifold.normal = -NORMAL;
|
||||
|
||||
SHContact newContact;
|
||||
newContact.penetration = PENETRATION;
|
||||
newContact.position = SPHERE.GetCenter() - NORMAL * TOTAL_RADIUS;
|
||||
newContact.position = SPHERE.GetCenter() - NORMAL * RADIUS;
|
||||
newContact.featurePair.key = 0;
|
||||
|
||||
manifold.contacts[numContacts++] = newContact;
|
||||
|
|
|
@ -108,7 +108,6 @@ namespace SHADE
|
|||
|
||||
|
||||
/*
|
||||
* TODO: A lot of this needs to be cleaned up.
|
||||
* Resolve Contacts
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue