diff --git a/sources/reactphysics3d/collision/CollisionDetection.cpp b/sources/reactphysics3d/collision/CollisionDetection.cpp index 13b29104..1ca1d194 100644 --- a/sources/reactphysics3d/collision/CollisionDetection.cpp +++ b/sources/reactphysics3d/collision/CollisionDetection.cpp @@ -25,9 +25,11 @@ #include "../body/OBB.h" #include "../body/RigidBody.h" #include +#include // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; +using namespace std; // Constructor CollisionDetection::CollisionDetection(PhysicsWorld* world) { @@ -243,4 +245,4 @@ void CollisionDetection::computeContact(const ContactInfo* const contactInfo) { world->addConstraint(new Contact(obb1->getBodyPointer(), obb2->getBodyPointer(), normal, penetrationDepth, clippedFace.at(i))); } } -} +} \ No newline at end of file diff --git a/sources/reactphysics3d/collision/CollisionDetection.h b/sources/reactphysics3d/collision/CollisionDetection.h index 832296a9..64e4e904 100644 --- a/sources/reactphysics3d/collision/CollisionDetection.h +++ b/sources/reactphysics3d/collision/CollisionDetection.h @@ -51,6 +51,7 @@ class CollisionDetection { void computeNarrowPhase(); // Compute the narrow-phase collision detection void computeAllContacts(); // Compute all the contacts from the collision info list void computeContact(const ContactInfo* const contactInfo); // Compute a contact (and add it to the physics world) for two colliding bodies + void computeContact2(const ContactInfo* const contactInfo); // Compute a contact (and add it to the physics world) for two colliding bodies public : CollisionDetection(PhysicsWorld* physicsWorld); // Constructor diff --git a/sources/reactphysics3d/collision/ContactInfo.h b/sources/reactphysics3d/collision/ContactInfo.h index a795526d..74975116 100644 --- a/sources/reactphysics3d/collision/ContactInfo.h +++ b/sources/reactphysics3d/collision/ContactInfo.h @@ -42,8 +42,8 @@ struct ContactInfo { const OBB* const obb2; // Body pointer of the second bounding volume const Vector3D normal; // Normal vector the the collision contact const double penetrationDepth; // Penetration depth of the contact - - ContactInfo(const OBB* const obb1, const OBB* const obb2, const Vector3D& normal, double penetrationDepth); // Constructor + + ContactInfo(const OBB* const obb1, const OBB* const obb2, const Vector3D& normal, double penetrationDepth); // Constructor }; } // End of the ReactPhysics3D namespace diff --git a/sources/reactphysics3d/collision/SATAlgorithm.cpp b/sources/reactphysics3d/collision/SATAlgorithm.cpp index 8d1afbfe..f8cf972d 100644 --- a/sources/reactphysics3d/collision/SATAlgorithm.cpp +++ b/sources/reactphysics3d/collision/SATAlgorithm.cpp @@ -27,6 +27,7 @@ #include #include + // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; @@ -95,7 +96,7 @@ bool SATAlgorithm::computeCollisionTest(const OBB* const obb1, const OBB* const double absC[3][3]; // absC[i][j] = abs(DotProduct(obb1.Ai, obb2.Bj)) double udc1[3]; // DotProduct(obb1.Ai, obb2.center - obb1.center) double udc2[3]; // DotProduct(obb2.Ai, obb2.center - obb1.center) - + Vector3D boxDistance = obb2->getCenter() - obb1->getCenter(); // Vector between the centers of the OBBs // Axis A0 @@ -170,7 +171,6 @@ bool SATAlgorithm::computeCollisionTest(const OBB* const obb1, const OBB* const } else if (penetrationDepth < minPenetrationDepth) { // Interval 1 and 2 overlap with a smaller penetration depth on this axis minPenetrationDepth = penetrationDepth; // Update the minimum penetration depth - normal = computeContactNormal(obb1->getAxis(2), boxDistance); // Compute the contact normal with the correct sign } // Axis B0 diff --git a/sources/reactphysics3d/constraint/Contact.h b/sources/reactphysics3d/constraint/Contact.h index 9cf238db..8a0ddfb1 100644 --- a/sources/reactphysics3d/constraint/Contact.h +++ b/sources/reactphysics3d/constraint/Contact.h @@ -30,7 +30,7 @@ namespace reactphysics3d { // Constants const double FRICTION_COEFFICIENT = 0.1; // Friction coefficient -const double PENETRATION_FACTOR = 0.6; // Penetration factor (between 0 and 1) which specify the importance of the +const double PENETRATION_FACTOR = 1.0; // Penetration factor (between 0 and 1) which specify the importance of the // penetration depth in order to calculate the correct impulse for the contact /* -------------------------------------------------------------------