37 #ifndef HPP_FCL_INTERNAL_SHAPE_SHAPE_FUNC_H 38 #define HPP_FCL_INTERNAL_SHAPE_SHAPE_FUNC_H 50 template <
typename T_SH1,
typename T_SH2>
52 const Transform3f&
tf1,
53 const CollisionGeometry* o2,
54 const Transform3f&
tf2,
55 const GJKSolver* nsolver,
56 const DistanceRequest& request,
57 DistanceResult& result);
59 template <
typename T_SH1,
typename T_SH2>
60 struct ShapeShapeCollider {
61 static std::size_t
run(
const CollisionGeometry* o1,
const Transform3f&
tf1,
62 const CollisionGeometry* o2,
const Transform3f&
tf2,
63 const GJKSolver* nsolver,
64 const CollisionRequest& request,
65 CollisionResult& result) {
66 if (request.isSatisfied(result))
return result.numContacts();
68 DistanceResult distanceResult;
69 DistanceRequest distanceRequest(request.enable_contact);
71 o1,
tf1, o2,
tf2, nsolver, distanceRequest, distanceResult);
73 size_t num_contacts = 0;
74 const Vec3f&
p1 = distanceResult.nearest_points[0];
75 const Vec3f& p2 = distanceResult.nearest_points[1];
76 FCL_REAL distToCollision = distance - request.security_margin;
80 if (distToCollision <= request.collision_distance_threshold &&
81 result.numContacts() < request.num_max_contacts) {
82 if (result.numContacts() < request.num_max_contacts) {
83 const Vec3f& p1 = distanceResult.nearest_points[0];
84 const Vec3f& p2 = distanceResult.nearest_points[1];
87 o1, o2, distanceResult.b1, distanceResult.b2, (p1 + p2) / 2,
88 (distance <= 0 ? distanceResult.normal : (p2 - p1).normalized()),
91 result.addContact(contact);
93 num_contacts = result.numContacts();
100 template <
typename ShapeType1,
typename ShapeType2>
101 std::size_t ShapeShapeCollide(
const CollisionGeometry* o1,
102 const Transform3f& tf1,
103 const CollisionGeometry* o2,
104 const Transform3f& tf2,
const GJKSolver* nsolver,
105 const CollisionRequest& request,
106 CollisionResult& result) {
108 o1, tf1, o2, tf2, nsolver, request, result);
111 #define SHAPE_SHAPE_DISTANCE_SPECIALIZATION(T1, T2) \ 113 HPP_FCL_DLLAPI FCL_REAL ShapeShapeDistance<T1, T2>( \ 114 const CollisionGeometry* o1, const Transform3f& tf1, \ 115 const CollisionGeometry* o2, const Transform3f& tf2, \ 116 const GJKSolver* nsolver, const DistanceRequest& request, \ 117 DistanceResult& result); \ 119 HPP_FCL_DLLAPI FCL_REAL ShapeShapeDistance<T2, T1>( \ 120 const CollisionGeometry* o1, const Transform3f& tf1, \ 121 const CollisionGeometry* o2, const Transform3f& tf2, \ 122 const GJKSolver* nsolver, const DistanceRequest& request, \ 123 DistanceResult& result) 125 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Box, Halfspace);
126 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Box, Plane);
127 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Box, Sphere);
128 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Capsule, Capsule);
129 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Capsule, Halfspace);
130 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Capsule, Plane);
131 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Cone, Halfspace);
132 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Cone, Plane);
133 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Cylinder, Halfspace);
134 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Cylinder, Plane);
135 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Sphere, Halfspace);
136 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Sphere, Plane);
137 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Sphere, Sphere);
138 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(Sphere, Cylinder);
140 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(ConvexBase, Halfspace);
141 SHAPE_SHAPE_DISTANCE_SPECIALIZATION(TriangleP, Halfspace);
143 #undef SHAPE_SHAPE_DISTANCE_SPECIALIZATION 145 #define SHAPE_SHAPE_COLLIDE_SPECIALIZATION(T1, T2) \ 147 struct ShapeShapeCollider<T1, T2> { \ 148 static HPP_FCL_DLLAPI std::size_t run(const CollisionGeometry* o1, \ 149 const Transform3f& tf1, \ 150 const CollisionGeometry* o2, \ 151 const Transform3f& tf2, \ 152 const GJKSolver* nsolver, \ 153 const CollisionRequest& request, \ 154 CollisionResult& result); \ 157 SHAPE_SHAPE_COLLIDE_SPECIALIZATION(Sphere, Sphere);
159 #undef SHAPE_SHAPE_COLLIDE_SPECIALIZATION
FCL_REAL ShapeShapeDistance(const CollisionGeometry *o1, const Transform3f &tf1, const CollisionGeometry *o2, const Transform3f &tf2, const GJKSolver *nsolver, const DistanceRequest &request, DistanceResult &result)
HPP_FCL_DLLAPI FCL_REAL distance(const Matrix3f &R0, const Vec3f &T0, const kIOS &b1, const kIOS &b2, Vec3f *P=NULL, Vec3f *Q=NULL)
Approximate distance between two kIOS bounding volumes.
void updateDistanceLowerBoundFromLeaf(const CollisionRequest &, CollisionResult &res, const FCL_REAL &distance, const Vec3f &p0, const Vec3f &p1)
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f