diff --git a/src/collision/ContactManifold.cpp b/src/collision/ContactManifold.cpp index 846a418a..803a9e82 100644 --- a/src/collision/ContactManifold.cpp +++ b/src/collision/ContactManifold.cpp @@ -65,9 +65,6 @@ ContactManifold::~ContactManifold() { ContactPoint* nextContactPoint = contactPoint->getNext(); - // TODO : Delete this - bool test = mMemoryAllocator.isReleaseNeeded(); - // Delete the contact point contactPoint->~ContactPoint(); mMemoryAllocator.release(contactPoint, sizeof(ContactPoint)); diff --git a/src/collision/MiddlePhaseTriangleCallback.cpp b/src/collision/MiddlePhaseTriangleCallback.cpp index a1a183ac..de6c22ea 100644 --- a/src/collision/MiddlePhaseTriangleCallback.cpp +++ b/src/collision/MiddlePhaseTriangleCallback.cpp @@ -34,10 +34,9 @@ void MiddlePhaseTriangleCallback::testTriangle(uint meshSubPart, uint triangleIn // Create a triangle collision shape (the allocated memory for the TriangleShape will be released in the // destructor of the corresponding NarrowPhaseInfo. - decimal margin = mConcaveShape->getTriangleMargin(); TriangleShape* triangleShape = new (mAllocator.allocate(sizeof(TriangleShape))) TriangleShape(trianglePoints[0], trianglePoints[1], trianglePoints[2], - verticesNormals, meshSubPart, triangleIndex, margin); + verticesNormals, meshSubPart, triangleIndex); // Create a narrow phase info for the narrow-phase collision detection NarrowPhaseInfo* firstNarrowPhaseInfo = narrowPhaseInfoList; diff --git a/src/collision/shapes/BoxShape.cpp b/src/collision/shapes/BoxShape.cpp index 54666136..01c4d965 100644 --- a/src/collision/shapes/BoxShape.cpp +++ b/src/collision/shapes/BoxShape.cpp @@ -37,11 +37,11 @@ using namespace reactphysics3d; * @param extent The vector with the three extents of the box (in meters) * @param margin The collision margin (in meters) around the collision shape */ -BoxShape::BoxShape(const Vector3& extent, decimal margin) - : ConvexPolyhedronShape(CollisionShapeName::BOX, margin), mExtent(extent - Vector3(margin, margin, margin)) { - assert(extent.x > decimal(0.0) && extent.x > margin); - assert(extent.y > decimal(0.0) && extent.y > margin); - assert(extent.z > decimal(0.0) && extent.z > margin); +BoxShape::BoxShape(const Vector3& extent) + : ConvexPolyhedronShape(CollisionShapeName::BOX), mExtent(extent) { + assert(extent.x > decimal(0.0)); + assert(extent.y > decimal(0.0)); + assert(extent.z > decimal(0.0)); // Vertices mHalfEdgeStructure.addVertex(0); diff --git a/src/collision/shapes/BoxShape.h b/src/collision/shapes/BoxShape.h index d64222ff..56c14797 100644 --- a/src/collision/shapes/BoxShape.h +++ b/src/collision/shapes/BoxShape.h @@ -81,7 +81,7 @@ class BoxShape : public ConvexPolyhedronShape { // -------------------- Methods -------------------- // /// Constructor - BoxShape(const Vector3& extent, decimal margin = OBJECT_MARGIN); + BoxShape(const Vector3& extent); /// Destructor virtual ~BoxShape() override = default; diff --git a/src/collision/shapes/ConcaveMeshShape.cpp b/src/collision/shapes/ConcaveMeshShape.cpp index 0a9e1fd6..84e95e2c 100644 --- a/src/collision/shapes/ConcaveMeshShape.cpp +++ b/src/collision/shapes/ConcaveMeshShape.cpp @@ -59,7 +59,6 @@ void ConcaveMeshShape::initBVHTree() { // Create the AABB for the triangle AABB aabb = AABB::createAABBForTriangle(trianglePoints); - aabb.inflate(mTriangleMargin, mTriangleMargin, mTriangleMargin); // Add the AABB with the index of the triangle into the dynamic AABB tree mDynamicAABBTree.addObject(aabb, subPart, triangleIndex); @@ -152,9 +151,8 @@ void ConcaveMeshRaycastCallback::raycastTriangles() { Vector3 verticesNormals[3]; mConcaveMeshShape.getTriangleVerticesNormals(data[0], data[1], verticesNormals); // Create a triangle collision shape - decimal margin = mConcaveMeshShape.getTriangleMargin(); TriangleShape triangleShape(trianglePoints[0], trianglePoints[1], trianglePoints[2], - verticesNormals, data[0], data[1], margin); + verticesNormals, data[0], data[1]); triangleShape.setRaycastTestType(mConcaveMeshShape.getRaycastTestType()); // Ray casting test against the collision shape diff --git a/src/collision/shapes/ConcaveShape.cpp b/src/collision/shapes/ConcaveShape.cpp index e8c032d2..cac82e45 100644 --- a/src/collision/shapes/ConcaveShape.cpp +++ b/src/collision/shapes/ConcaveShape.cpp @@ -32,6 +32,6 @@ using namespace reactphysics3d; // Constructor ConcaveShape::ConcaveShape(CollisionShapeName name) - : CollisionShape(name, CollisionShapeType::CONCAVE_SHAPE), mTriangleMargin(0), mRaycastTestType(TriangleRaycastSide::FRONT) { + : CollisionShape(name, CollisionShapeType::CONCAVE_SHAPE), mRaycastTestType(TriangleRaycastSide::FRONT) { } diff --git a/src/collision/shapes/ConcaveShape.h b/src/collision/shapes/ConcaveShape.h index 34e347e0..abc3759b 100644 --- a/src/collision/shapes/ConcaveShape.h +++ b/src/collision/shapes/ConcaveShape.h @@ -63,9 +63,6 @@ class ConcaveShape : public CollisionShape { // -------------------- Attributes -------------------- // - // Margin use for collision detection for each triangle - decimal mTriangleMargin; - /// Raycast test type for the triangle (front, back, front-back) TriangleRaycastSide mRaycastTestType; @@ -90,9 +87,6 @@ class ConcaveShape : public CollisionShape { /// Deleted assignment operator ConcaveShape& operator=(const ConcaveShape& shape) = delete; - /// Return the triangle margin - decimal getTriangleMargin() const; - /// Return the raycast test type (front, back, front-back) TriangleRaycastSide getRaycastTestType() const; @@ -109,11 +103,6 @@ class ConcaveShape : public CollisionShape { virtual void testAllTriangles(TriangleCallback& callback, const AABB& localAABB) const=0; }; -// Return the triangle margin -inline decimal ConcaveShape::getTriangleMargin() const { - return mTriangleMargin; -} - // Return true if the collision shape is convex, false if it is concave inline bool ConcaveShape::isConvex() const { return false; diff --git a/src/collision/shapes/ConvexMeshShape.cpp b/src/collision/shapes/ConvexMeshShape.cpp index 995ef9bb..f6011375 100644 --- a/src/collision/shapes/ConvexMeshShape.cpp +++ b/src/collision/shapes/ConvexMeshShape.cpp @@ -41,8 +41,8 @@ using namespace reactphysics3d; * @param stride Stride between the beginning of two elements in the vertices array * @param margin Collision margin (in meters) around the collision shape */ -ConvexMeshShape::ConvexMeshShape(PolyhedronMesh* polyhedronMesh, decimal margin) - : ConvexPolyhedronShape(CollisionShapeName::CONVEX_MESH, margin), mPolyhedronMesh(polyhedronMesh), mMinBounds(0, 0, 0), mMaxBounds(0, 0, 0) { +ConvexMeshShape::ConvexMeshShape(PolyhedronMesh* polyhedronMesh) + : ConvexPolyhedronShape(CollisionShapeName::CONVEX_MESH), mPolyhedronMesh(polyhedronMesh), mMinBounds(0, 0, 0), mMaxBounds(0, 0, 0) { // Recalculate the bounds of the mesh recalculateBounds(); diff --git a/src/collision/shapes/ConvexMeshShape.h b/src/collision/shapes/ConvexMeshShape.h index b42c02e2..4ceabe11 100644 --- a/src/collision/shapes/ConvexMeshShape.h +++ b/src/collision/shapes/ConvexMeshShape.h @@ -99,9 +99,7 @@ class ConvexMeshShape : public ConvexPolyhedronShape { // -------------------- Methods -------------------- // /// Constructor - // TODO : Do we really need to use the margin anymore ? Maybe for raycasting ? If not, remove all the - // comments documentation about margin - ConvexMeshShape(PolyhedronMesh* polyhedronMesh, decimal margin = OBJECT_MARGIN); + ConvexMeshShape(PolyhedronMesh* polyhedronMesh); /// Destructor virtual ~ConvexMeshShape() override = default; diff --git a/src/collision/shapes/ConvexPolyhedronShape.cpp b/src/collision/shapes/ConvexPolyhedronShape.cpp index 0db54a85..ab93584d 100644 --- a/src/collision/shapes/ConvexPolyhedronShape.cpp +++ b/src/collision/shapes/ConvexPolyhedronShape.cpp @@ -31,7 +31,7 @@ using namespace reactphysics3d; // Constructor -ConvexPolyhedronShape::ConvexPolyhedronShape(CollisionShapeName name, decimal margin) - : ConvexShape(name, CollisionShapeType::CONVEX_POLYHEDRON, margin) { +ConvexPolyhedronShape::ConvexPolyhedronShape(CollisionShapeName name) + : ConvexShape(name, CollisionShapeType::CONVEX_POLYHEDRON) { } diff --git a/src/collision/shapes/ConvexPolyhedronShape.h b/src/collision/shapes/ConvexPolyhedronShape.h index fe1f07a9..96707d69 100644 --- a/src/collision/shapes/ConvexPolyhedronShape.h +++ b/src/collision/shapes/ConvexPolyhedronShape.h @@ -47,7 +47,7 @@ class ConvexPolyhedronShape : public ConvexShape { // -------------------- Methods -------------------- // /// Constructor - ConvexPolyhedronShape(CollisionShapeName name, decimal margin); + ConvexPolyhedronShape(CollisionShapeName name); /// Destructor virtual ~ConvexPolyhedronShape() override = default; diff --git a/src/collision/shapes/ConvexShape.h b/src/collision/shapes/ConvexShape.h index 9a2b7e00..04f8aad6 100644 --- a/src/collision/shapes/ConvexShape.h +++ b/src/collision/shapes/ConvexShape.h @@ -59,7 +59,7 @@ class ConvexShape : public CollisionShape { // -------------------- Methods -------------------- // /// Constructor - ConvexShape(CollisionShapeName name, CollisionShapeType type, decimal margin); + ConvexShape(CollisionShapeName name, CollisionShapeType type, decimal margin = decimal(0.0)); /// Destructor virtual ~ConvexShape() override = default; diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index b13cf69b..2afba401 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -260,9 +260,8 @@ void TriangleOverlapCallback::testTriangle(uint meshSubPart, uint triangleIndex, const Vector3* verticesNormals) { // Create a triangle collision shape - decimal margin = mHeightFieldShape.getTriangleMargin(); TriangleShape triangleShape(trianglePoints[0], trianglePoints[1], trianglePoints[2], - verticesNormals, meshSubPart, triangleIndex, margin); + verticesNormals, meshSubPart, triangleIndex); triangleShape.setRaycastTestType(mHeightFieldShape.getRaycastTestType()); // Ray casting test against the collision shape diff --git a/src/collision/shapes/TriangleShape.cpp b/src/collision/shapes/TriangleShape.cpp index c72dd133..48baa225 100644 --- a/src/collision/shapes/TriangleShape.cpp +++ b/src/collision/shapes/TriangleShape.cpp @@ -44,8 +44,8 @@ using namespace reactphysics3d; * @param margin The collision margin (in meters) around the collision shape */ TriangleShape::TriangleShape(const Vector3& point1, const Vector3& point2, const Vector3& point3, - const Vector3* verticesNormals, uint meshSubPart, uint triangleIndex, decimal margin) - : ConvexPolyhedronShape(CollisionShapeName::TRIANGLE, margin), mMeshSubPart(meshSubPart), mTriangleIndex(triangleIndex) { + const Vector3* verticesNormals, uint meshSubPart, uint triangleIndex) + : ConvexPolyhedronShape(CollisionShapeName::TRIANGLE), mMeshSubPart(meshSubPart), mTriangleIndex(triangleIndex) { mPoints[0] = point1; mPoints[1] = point2; diff --git a/src/collision/shapes/TriangleShape.h b/src/collision/shapes/TriangleShape.h index 19cedfef..c31a594c 100644 --- a/src/collision/shapes/TriangleShape.h +++ b/src/collision/shapes/TriangleShape.h @@ -108,7 +108,7 @@ class TriangleShape : public ConvexPolyhedronShape { /// Constructor TriangleShape(const Vector3& point1, const Vector3& point2, const Vector3& point3, - const Vector3* verticesNormals, uint meshSubPart, uint triangleIndex, decimal margin = OBJECT_MARGIN); + const Vector3* verticesNormals, uint meshSubPart, uint triangleIndex); /// Destructor virtual ~TriangleShape() override = default; diff --git a/src/configuration.h b/src/configuration.h index 04cb0956..b2c53021 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -100,9 +100,6 @@ constexpr decimal DEFAULT_ROLLING_RESISTANCE = decimal(0.0); /// True if the spleeping technique is enabled constexpr bool SPLEEPING_ENABLED = true; -/// Object margin for collision detection in meters (for the GJK-EPA Algorithm) -constexpr decimal OBJECT_MARGIN = decimal(0.04); - /// Distance threshold for two contact points for a valid persistent contact (in meters) constexpr decimal PERSISTENT_CONTACT_DIST_THRESHOLD = decimal(0.03); diff --git a/test/tests/collision/TestPointInside.h b/test/tests/collision/TestPointInside.h index abb54791..608b439b 100644 --- a/test/tests/collision/TestPointInside.h +++ b/test/tests/collision/TestPointInside.h @@ -115,7 +115,7 @@ class TestPointInside : public Test { mLocalShapeToWorld = mBodyTransform * mShapeTransform; // Create collision shapes - mBoxShape = new BoxShape(Vector3(2, 3, 4), 0); + mBoxShape = new BoxShape(Vector3(2, 3, 4)); mBoxProxyShape = mBoxBody->addCollisionShape(mBoxShape, mShapeTransform); mSphereShape = new SphereShape(3); diff --git a/test/tests/collision/TestRaycast.h b/test/tests/collision/TestRaycast.h index 93860a1c..81013570 100644 --- a/test/tests/collision/TestRaycast.h +++ b/test/tests/collision/TestRaycast.h @@ -192,7 +192,7 @@ class TestRaycast : public Test { mLocalShapeToWorld = mBodyTransform * mShapeTransform; // Create collision shapes - mBoxShape = new BoxShape(Vector3(2, 3, 4), 0); + mBoxShape = new BoxShape(Vector3(2, 3, 4)); mBoxProxyShape = mBoxBody->addCollisionShape(mBoxShape, mShapeTransform); mSphereShape = new SphereShape(3);