From 8bab9c13483210a865bd96bbdf30b1e2db05f4c2 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Sun, 3 Sep 2017 18:05:23 +0200 Subject: [PATCH] Remove unused cachedCollisionData parameter --- src/collision/narrowphase/GJK/GJKAlgorithm.cpp | 17 +++++------------ src/collision/narrowphase/SAT/SATAlgorithm.cpp | 6 +++--- src/collision/shapes/BoxShape.h | 6 ++---- src/collision/shapes/CapsuleShape.h | 6 ++---- src/collision/shapes/ConvexMeshShape.cpp | 5 +---- src/collision/shapes/ConvexMeshShape.h | 3 +-- src/collision/shapes/ConvexShape.cpp | 5 ++--- src/collision/shapes/ConvexShape.h | 8 ++------ src/collision/shapes/SphereShape.h | 6 ++---- src/collision/shapes/TriangleShape.h | 5 ++--- 10 files changed, 22 insertions(+), 45 deletions(-) diff --git a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp index 609c415a..9bc1d00d 100644 --- a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp +++ b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp @@ -66,9 +66,6 @@ GJKAlgorithm::GJKResult GJKAlgorithm::testCollision(NarrowPhaseInfo* narrowPhase const ConvexShape* shape1 = static_cast(narrowPhaseInfo->collisionShape1); const ConvexShape* shape2 = static_cast(narrowPhaseInfo->collisionShape2); - void** shape1CachedCollisionData = narrowPhaseInfo->cachedCollisionData1; - void** shape2CachedCollisionData = narrowPhaseInfo->cachedCollisionData2; - bool isPolytopeShape = shape1->isPolyhedron() && shape2->isPolyhedron(); // Get the local-space to world-space transforms @@ -109,8 +106,8 @@ GJKAlgorithm::GJKResult GJKAlgorithm::testCollision(NarrowPhaseInfo* narrowPhase do { // Compute the support points for original objects (without margins) A and B - suppA = shape1->getLocalSupportPointWithoutMargin(-v, shape1CachedCollisionData); - suppB = body2Tobody1 * shape2->getLocalSupportPointWithoutMargin(rotateToBody2 * v, shape2CachedCollisionData); + suppA = shape1->getLocalSupportPointWithoutMargin(-v); + suppB = body2Tobody1 * shape2->getLocalSupportPointWithoutMargin(rotateToBody2 * v); // Compute the support point for the Minkowski difference A-B w = suppA - suppB; @@ -237,8 +234,6 @@ bool GJKAlgorithm::testPointInside(const Vector3& localPoint, ProxyShape* proxyS const ConvexShape* shape = static_cast(proxyShape->getCollisionShape()); - void** shapeCachedCollisionData = proxyShape->getCachedCollisionData(); - // Support point of object B (object B is a single point) const Vector3 suppB(localPoint); @@ -254,7 +249,7 @@ bool GJKAlgorithm::testPointInside(const Vector3& localPoint, ProxyShape* proxyS do { // Compute the support points for original objects (without margins) A and B - suppA = shape->getLocalSupportPointWithoutMargin(-v, shapeCachedCollisionData); + suppA = shape->getLocalSupportPointWithoutMargin(-v); // Compute the support point for the Minkowski difference A-B w = suppA - suppB; @@ -300,8 +295,6 @@ bool GJKAlgorithm::raycast(const Ray& ray, ProxyShape* proxyShape, RaycastInfo& const ConvexShape* shape = static_cast(proxyShape->getCollisionShape()); - void** shapeCachedCollisionData = proxyShape->getCachedCollisionData(); - Vector3 suppA; // Current lower bound point on the ray (starting at ray's origin) Vector3 suppB; // Support point on the collision shape const decimal machineEpsilonSquare = MACHINE_EPSILON * MACHINE_EPSILON; @@ -321,7 +314,7 @@ bool GJKAlgorithm::raycast(const Ray& ray, ProxyShape* proxyShape, RaycastInfo& Vector3 n(decimal(0.0), decimal(0.0), decimal(0.0)); decimal lambda = decimal(0.0); suppA = ray.point1; // Current lower bound point on the ray (starting at ray's origin) - suppB = shape->getLocalSupportPointWithoutMargin(rayDirection, shapeCachedCollisionData); + suppB = shape->getLocalSupportPointWithoutMargin(rayDirection); Vector3 v = suppA - suppB; decimal vDotW, vDotR; decimal distSquare = v.lengthSquare(); @@ -331,7 +324,7 @@ bool GJKAlgorithm::raycast(const Ray& ray, ProxyShape* proxyShape, RaycastInfo& while (distSquare > epsilon && nbIterations < MAX_ITERATIONS_GJK_RAYCAST) { // Compute the support points - suppB = shape->getLocalSupportPointWithoutMargin(v, shapeCachedCollisionData); + suppB = shape->getLocalSupportPointWithoutMargin(v); w = suppA - suppB; vDotW = v.dot(w); diff --git a/src/collision/narrowphase/SAT/SATAlgorithm.cpp b/src/collision/narrowphase/SAT/SATAlgorithm.cpp index 87be645b..d1062704 100644 --- a/src/collision/narrowphase/SAT/SATAlgorithm.cpp +++ b/src/collision/narrowphase/SAT/SATAlgorithm.cpp @@ -314,7 +314,7 @@ decimal SATAlgorithm::computeEdgeVsCapsuleInnerSegmentPenetrationDepth(const Con outAxis.normalize(); // Compute the penetration depth - const Vector3 capsuleSupportPoint = capsule->getLocalSupportPointWithMargin(-outAxis, nullptr); + const Vector3 capsuleSupportPoint = capsule->getLocalSupportPointWithMargin(-outAxis); const Vector3 capsuleSupportPointToEdgePoint = pointOnPolyhedronEdge - capsuleSupportPoint; penetrationDepth = capsuleSupportPointToEdgePoint.dot(outAxis); } @@ -335,7 +335,7 @@ decimal SATAlgorithm::computePolyhedronFaceVsCapsulePenetrationDepth(uint polyhe // Compute the penetration depth (using the capsule support in the direction opposite to the face normal) outFaceNormalCapsuleSpace = polyhedronToCapsuleTransform.getOrientation() * faceNormal; - const Vector3 capsuleSupportPoint = capsule->getLocalSupportPointWithMargin(-outFaceNormalCapsuleSpace, nullptr); + const Vector3 capsuleSupportPoint = capsule->getLocalSupportPointWithMargin(-outFaceNormalCapsuleSpace); const Vector3 pointOnPolyhedronFace = polyhedronToCapsuleTransform * polyhedron->getVertexPosition(face.faceVertices[0]); const Vector3 capsuleSupportPointToFacePoint = pointOnPolyhedronFace - capsuleSupportPoint; const decimal penetrationDepth = capsuleSupportPointToFacePoint.dot(outFaceNormalCapsuleSpace); @@ -932,7 +932,7 @@ decimal SATAlgorithm::testSingleFaceDirectionPolyhedronVsPolyhedron(const Convex const Vector3 faceNormalPolyhedron2Space = polyhedron1ToPolyhedron2.getOrientation() * faceNormal; // Get the support point of polyhedron 2 in the inverse direction of face normal - const Vector3 supportPoint = polyhedron2->getLocalSupportPointWithoutMargin(-faceNormalPolyhedron2Space, nullptr); + const Vector3 supportPoint = polyhedron2->getLocalSupportPointWithoutMargin(-faceNormalPolyhedron2Space); // Compute the penetration depth const Vector3 faceVertex = polyhedron1ToPolyhedron2 * polyhedron1->getVertexPosition(face.faceVertices[0]); diff --git a/src/collision/shapes/BoxShape.h b/src/collision/shapes/BoxShape.h index 5a07b0cb..d64222ff 100644 --- a/src/collision/shapes/BoxShape.h +++ b/src/collision/shapes/BoxShape.h @@ -65,8 +65,7 @@ class BoxShape : public ConvexPolyhedronShape { // -------------------- Methods -------------------- // /// Return a local support point in a given direction without the object margin - virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const override; + virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction) const override; /// Return true if a point is inside the collision shape virtual bool testPointInside(const Vector3& localPoint, ProxyShape* proxyShape) const override; @@ -170,8 +169,7 @@ inline size_t BoxShape::getSizeInBytes() const { } // Return a local support point in a given direction without the objec margin -inline Vector3 BoxShape::getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const { +inline Vector3 BoxShape::getLocalSupportPointWithoutMargin(const Vector3& direction) const { return Vector3(direction.x < 0.0 ? -mExtent.x : mExtent.x, direction.y < 0.0 ? -mExtent.y : mExtent.y, diff --git a/src/collision/shapes/CapsuleShape.h b/src/collision/shapes/CapsuleShape.h index 9c0a4545..8aebff58 100644 --- a/src/collision/shapes/CapsuleShape.h +++ b/src/collision/shapes/CapsuleShape.h @@ -56,8 +56,7 @@ class CapsuleShape : public ConvexShape { // -------------------- Methods -------------------- // /// Return a local support point in a given direction without the object margin - virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const override; + virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction) const override; /// Return true if a point is inside the collision shape virtual bool testPointInside(const Vector3& localPoint, ProxyShape* proxyShape) const override; @@ -169,8 +168,7 @@ inline bool CapsuleShape::isPolyhedron() const { /// Therefore, in this method, we compute the support points of both top and bottom spheres of /// the capsule and return the point with the maximum dot product with the direction vector. Note /// that the object margin is implicitly the radius and height of the capsule. -inline Vector3 CapsuleShape::getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const { +inline Vector3 CapsuleShape::getLocalSupportPointWithoutMargin(const Vector3& direction) const { // Support point top sphere decimal dotProductTop = mHalfHeight * direction.y; diff --git a/src/collision/shapes/ConvexMeshShape.cpp b/src/collision/shapes/ConvexMeshShape.cpp index c8f03fa3..995ef9bb 100644 --- a/src/collision/shapes/ConvexMeshShape.cpp +++ b/src/collision/shapes/ConvexMeshShape.cpp @@ -56,10 +56,7 @@ ConvexMeshShape::ConvexMeshShape(PolyhedronMesh* polyhedronMesh, decimal margin) /// it as a start in a hill-climbing (local search) process to find the new support vertex which /// will be in most of the cases very close to the previous one. Using hill-climbing, this method /// runs in almost constant time. -Vector3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const { - - // TODO : Do we still need to have cachedCollisionData or we can remove it from everywhere ? +Vector3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const Vector3& direction) const { double maxDotProduct = DECIMAL_SMALLEST; uint indexMaxDotProduct = 0; diff --git a/src/collision/shapes/ConvexMeshShape.h b/src/collision/shapes/ConvexMeshShape.h index dd2b7021..b42c02e2 100644 --- a/src/collision/shapes/ConvexMeshShape.h +++ b/src/collision/shapes/ConvexMeshShape.h @@ -83,8 +83,7 @@ class ConvexMeshShape : public ConvexPolyhedronShape { virtual void setLocalScaling(const Vector3& scaling) override; /// Return a local support point in a given direction without the object margin. - virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const override; + virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction) const override; /// Return true if a point is inside the collision shape virtual bool testPointInside(const Vector3& localPoint, ProxyShape* proxyShape) const override; diff --git a/src/collision/shapes/ConvexShape.cpp b/src/collision/shapes/ConvexShape.cpp index 649e50f5..90c5356f 100644 --- a/src/collision/shapes/ConvexShape.cpp +++ b/src/collision/shapes/ConvexShape.cpp @@ -37,11 +37,10 @@ ConvexShape::ConvexShape(CollisionShapeName name, CollisionShapeType type, decim } // Return a local support point in a given direction with the object margin -Vector3 ConvexShape::getLocalSupportPointWithMargin(const Vector3& direction, - void** cachedCollisionData) const { +Vector3 ConvexShape::getLocalSupportPointWithMargin(const Vector3& direction) const { // Get the support point without margin - Vector3 supportPoint = getLocalSupportPointWithoutMargin(direction, cachedCollisionData); + Vector3 supportPoint = getLocalSupportPointWithoutMargin(direction); if (mMargin != decimal(0.0)) { diff --git a/src/collision/shapes/ConvexShape.h b/src/collision/shapes/ConvexShape.h index 4bf4b718..9a2b7e00 100644 --- a/src/collision/shapes/ConvexShape.h +++ b/src/collision/shapes/ConvexShape.h @@ -49,14 +49,10 @@ class ConvexShape : public CollisionShape { // -------------------- Methods -------------------- // // Return a local support point in a given direction with the object margin - // TODO : Try to remove cachedCollisionData parameter - Vector3 getLocalSupportPointWithMargin(const Vector3& direction, - void** cachedCollisionData) const; + Vector3 getLocalSupportPointWithMargin(const Vector3& direction) const; /// Return a local support point in a given direction without the object margin - // TODO : Try to remove cachedCollisionData parameter - virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const=0; + virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction) const=0; public : diff --git a/src/collision/shapes/SphereShape.h b/src/collision/shapes/SphereShape.h index fe55a7a8..70f651de 100644 --- a/src/collision/shapes/SphereShape.h +++ b/src/collision/shapes/SphereShape.h @@ -49,8 +49,7 @@ class SphereShape : public ConvexShape { // -------------------- Methods -------------------- // /// Return a local support point in a given direction without the object margin - virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const override; + virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction) const override; /// Return true if a point is inside the collision shape virtual bool testPointInside(const Vector3& localPoint, ProxyShape* proxyShape) const override; @@ -123,8 +122,7 @@ inline size_t SphereShape::getSizeInBytes() const { } // Return a local support point in a given direction without the object margin -inline Vector3 SphereShape::getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const { +inline Vector3 SphereShape::getLocalSupportPointWithoutMargin(const Vector3& direction) const { // Return the center of the sphere (the radius is taken into account in the object margin) return Vector3(0.0, 0.0, 0.0); diff --git a/src/collision/shapes/TriangleShape.h b/src/collision/shapes/TriangleShape.h index 609d5892..19cedfef 100644 --- a/src/collision/shapes/TriangleShape.h +++ b/src/collision/shapes/TriangleShape.h @@ -81,8 +81,7 @@ class TriangleShape : public ConvexPolyhedronShape { // -------------------- Methods -------------------- // /// Return a local support point in a given direction without the object margin - virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction, - void** cachedCollisionData) const override; + virtual Vector3 getLocalSupportPointWithoutMargin(const Vector3& direction) const override; /// Get a smooth contact normal for collision for a triangle of the mesh Vector3 computeSmoothLocalContactNormalForTriangle(const Vector3& localContactPoint) const; @@ -190,7 +189,7 @@ inline size_t TriangleShape::getSizeInBytes() const { } // Return a local support point in a given direction without the object margin -inline Vector3 TriangleShape::getLocalSupportPointWithoutMargin(const Vector3& direction, void** cachedCollisionData) const { +inline Vector3 TriangleShape::getLocalSupportPointWithoutMargin(const Vector3& direction) const { Vector3 dotProducts(direction.dot(mPoints[0]), direction.dot(mPoints[1]), direction.dot(mPoints[2])); return mPoints[dotProducts.getMaxAxis()]; }