ManifoldBetweenTwoFaces.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Jolt/Physics/Collision/Shape/ConvexShape.h>
  6. #include <Jolt/Physics/Collision/ContactListener.h>
  7. JPH_NAMESPACE_BEGIN
  8. /// Remove contact points if there are > 4 (no more than 4 are needed for a stable solution)
  9. /// @param inPenetrationAxis is the world space penetration axis (must be normalized)
  10. /// @param ioContactPointsOn1 The contact points on shape 1 relative to inCenterOfMass
  11. /// @param ioContactPointsOn2 The contact points on shape 2 relative to inCenterOfMass
  12. /// On output ioContactPointsOn1/2 are reduced to 4 or less points
  13. #ifdef JPH_DEBUG_RENDERER
  14. /// @param inCenterOfMass Center of mass position of body 1
  15. #endif
  16. JPH_EXPORT void PruneContactPoints(Vec3Arg inPenetrationAxis, ContactPoints &ioContactPointsOn1, ContactPoints &ioContactPointsOn2
  17. #ifdef JPH_DEBUG_RENDERER
  18. , RVec3Arg inCenterOfMass
  19. #endif
  20. );
  21. /// Determine contact points between 2 faces of 2 shapes and return them in outContactPoints 1 & 2
  22. /// @param inContactPoint1 The contact point on shape 1 relative to inCenterOfMass
  23. /// @param inContactPoint2 The contact point on shape 2 relative to inCenterOfMass
  24. /// @param inPenetrationAxis The local space penetration axis in world space
  25. /// @param inMaxContactDistanceSq After face 2 is clipped against face 1, each remaining point on face 2 is tested against the plane of face 1. If the distance^2 on the positive side of the plane is larger than this distance, the point will be discarded as a contact point.
  26. /// @param inShape1Face The supporting faces on shape 1 relative to inCenterOfMass
  27. /// @param inShape2Face The supporting faces on shape 2 relative to inCenterOfMass
  28. /// @param outContactPoints1 Returns the contact points between the two shapes for shape 1 relative to inCenterOfMass (any existing points in the output array are left as is)
  29. /// @param outContactPoints2 Returns the contact points between the two shapes for shape 2 relative to inCenterOfMass (any existing points in the output array are left as is)
  30. #ifdef JPH_DEBUG_RENDERER
  31. /// @param inCenterOfMass Center of mass position of body 1
  32. #endif
  33. JPH_EXPORT void ManifoldBetweenTwoFaces(Vec3Arg inContactPoint1, Vec3Arg inContactPoint2, Vec3Arg inPenetrationAxis, float inMaxContactDistanceSq, const ConvexShape::SupportingFace &inShape1Face, const ConvexShape::SupportingFace &inShape2Face, ContactPoints &outContactPoints1, ContactPoints &outContactPoints2
  34. #ifdef JPH_DEBUG_RENDERER
  35. , RVec3Arg inCenterOfMass
  36. #endif
  37. );
  38. JPH_NAMESPACE_END