37#ifndef COAL_INTERNAL_SHAPE_SHAPE_CONTACT_PATCH_FUNC_H 38#define COAL_INTERNAL_SHAPE_SHAPE_CONTACT_PATCH_FUNC_H 51template <
typename ShapeType1,
typename ShapeType2>
64 result.
check(request),
65 "The contact patch result and request are incompatible (issue of " 66 "contact patch size or maximum number of contact patches). Make sure " 67 "result is initialized with request.",
70 const ShapeType1& s1 =
static_cast<const ShapeType1&
>(*o1);
71 const ShapeType2& s2 =
static_cast<const ShapeType2&
>(*o2);
72 for (
size_t i = 0; i < collision_result.
numContacts(); ++i) {
79 csolver->
computePatch(s1, tf1, s2, tf2, contact, contact_patch);
89template <
bool InvertShapes,
typename OtherShapeType,
typename PlaneOrHalfspace>
92 const PlaneOrHalfspace& s2,
134#define PLANE_OR_HSPACE_AND_OTHER_SHAPE_CONTACT_PATCH(PlaneOrHspace) \ 135 template <typename OtherShapeType> \ 136 struct ComputeShapeShapeContactPatch<OtherShapeType, PlaneOrHspace> { \ 137 static void run(const CollisionGeometry* o1, const Transform3s& tf1, \ 138 const CollisionGeometry* o2, const Transform3s& tf2, \ 139 const CollisionResult& collision_result, \ 140 const ContactPatchSolver* csolver, \ 141 const ContactPatchRequest& request, \ 142 ContactPatchResult& result) { \ 143 if (!collision_result.isCollision()) { \ 147 result.check(request), \ 148 "The contact patch result and request are incompatible (issue of " \ 149 "contact patch size or maximum number of contact patches). Make " \ 151 "result is initialized with request.", \ 154 const OtherShapeType& s1 = static_cast<const OtherShapeType&>(*o1); \ 155 const PlaneOrHspace& s2 = static_cast<const PlaneOrHspace&>(*o2); \ 156 for (size_t i = 0; i < collision_result.numContacts(); ++i) { \ 157 if (i >= request.max_num_patch) { \ 160 csolver->setSupportGuess(collision_result.cached_support_func_guess); \ 161 const Contact& contact = collision_result.getContact(i); \ 162 ContactPatch& contact_patch = result.getUnusedContactPatch(); \ 163 computePatchPlaneOrHalfspace<false, OtherShapeType, PlaneOrHspace>( \ 164 s1, tf1, s2, tf2, csolver, contact, contact_patch); \ 169 template <typename OtherShapeType> \ 170 struct ComputeShapeShapeContactPatch<PlaneOrHspace, OtherShapeType> { \ 171 static void run(const CollisionGeometry* o1, const Transform3s& tf1, \ 172 const CollisionGeometry* o2, const Transform3s& tf2, \ 173 const CollisionResult& collision_result, \ 174 const ContactPatchSolver* csolver, \ 175 const ContactPatchRequest& request, \ 176 ContactPatchResult& result) { \ 177 if (!collision_result.isCollision()) { \ 181 result.check(request), \ 182 "The contact patch result and request are incompatible (issue of " \ 183 "contact patch size or maximum number of contact patches). Make " \ 185 "result is initialized with request.", \ 188 const PlaneOrHspace& s1 = static_cast<const PlaneOrHspace&>(*o1); \ 189 const OtherShapeType& s2 = static_cast<const OtherShapeType&>(*o2); \ 190 for (size_t i = 0; i < collision_result.numContacts(); ++i) { \ 191 if (i >= request.max_num_patch) { \ 194 csolver->setSupportGuess(collision_result.cached_support_func_guess); \ 195 const Contact& contact = collision_result.getContact(i); \ 196 ContactPatch& contact_patch = result.getUnusedContactPatch(); \ 197 computePatchPlaneOrHalfspace<true, OtherShapeType, PlaneOrHspace>( \ 198 s2, tf2, s1, tf1, csolver, contact, contact_patch); \ 206#define PLANE_HSPACE_CONTACT_PATCH(PlaneOrHspace1, PlaneOrHspace2) \ 208 struct ComputeShapeShapeContactPatch<PlaneOrHspace1, PlaneOrHspace2> { \ 209 static void run(const CollisionGeometry* o1, const Transform3s& tf1, \ 210 const CollisionGeometry* o2, const Transform3s& tf2, \ 211 const CollisionResult& collision_result, \ 212 const ContactPatchSolver* csolver, \ 213 const ContactPatchRequest& request, \ 214 ContactPatchResult& result) { \ 215 COAL_UNUSED_VARIABLE(o1); \ 216 COAL_UNUSED_VARIABLE(tf1); \ 217 COAL_UNUSED_VARIABLE(o2); \ 218 COAL_UNUSED_VARIABLE(tf2); \ 219 COAL_UNUSED_VARIABLE(csolver); \ 220 if (!collision_result.isCollision()) { \ 224 result.check(request), \ 225 "The contact patch result and request are incompatible (issue of " \ 226 "contact patch size or maximum number of contact patches). Make " \ 228 "result is initialized with request.", \ 231 for (size_t i = 0; i < collision_result.numContacts(); ++i) { \ 232 if (i >= request.max_num_patch) { \ 235 const Contact& contact = collision_result.getContact(i); \ 236 ContactPatch& contact_patch = result.getUnusedContactPatch(); \ 237 constructContactPatchFrameFromContact(contact, contact_patch); \ 238 contact_patch.addPoint(contact.pos); \ 248#undef PLANE_OR_HSPACE_AND_OTHER_SHAPE_CONTACT_PATCH 249#undef PLANE_HSPACE_CONTACT_PATCH 251template <
typename ShapeType1,
typename ShapeType2>
259 o1, tf1, o2, tf2, collision_result, csolver, request, result);
The geometry for the object for collision or distance computation.
Definition collision_object.h:94
Half Space: this is equivalent to the Plane in ODE. A Half space has a priviledged direction: the dir...
Definition geometric_shapes.h:892
Infinite plane. A plane can be viewed as two half spaces; it has no priviledged direction....
Definition geometric_shapes.h:983
#define COAL_ASSERT(check, message, exception)
Definition fwd.hh:82
#define COAL_UNUSED_VARIABLE(var)
Definition fwd.hh:56
SupportOptions
Options for the computation of support points. NoSweptSphere option is used when the support function...
Definition support_functions.h:58
void getShapeSupportSet(const TriangleP *triangle, SupportSet &support_set, int &, ShapeSupportData &, size_t num_sampled_supports=6, CoalScalar tol=1e-3)
Triangle support set function. Assumes the support set frame has already been computed.
Main namespace.
Definition broadphase_bruteforce.h:44
void computePatchPlaneOrHalfspace(const OtherShapeType &s1, const Transform3s &tf1, const PlaneOrHalfspace &s2, const Transform3s &tf2, const ContactPatchSolver *csolver, const Contact &contact, ContactPatch &contact_patch)
Computes the contact patch between a Plane/Halfspace and another shape.
Definition shape_shape_contact_patch_func.h:90
void ShapeShapeContactPatch(const CollisionGeometry *o1, const Transform3s &tf1, const CollisionGeometry *o2, const Transform3s &tf2, const CollisionResult &collision_result, const ContactPatchSolver *csolver, const ContactPatchRequest &request, ContactPatchResult &result)
Definition shape_shape_contact_patch_func.h:252
ContactPatch SupportSet
Structure used for internal computations. A support set and a contact patch can be represented by the...
Definition collision_data.h:721
void constructContactPatchFrameFromContact(const Contact &contact, ContactPatch &contact_patch)
Construct a frame from a Contact's position and normal. Because both Contact's position and normal ar...
Definition collision_data.h:704
collision result
Definition collision_data.h:390
size_t numContacts() const
number of contacts found
Definition collision_data.h:446
bool isCollision() const
return binary collision result
Definition collision_data.h:443
const Contact & getContact(size_t i) const
get the i-th contact calculated
Definition collision_data.h:449
support_func_guess_t cached_support_func_guess
stores the last support function vertex index, when relevant.
Definition collision_data.h:280
@ IsStrictlyConvex
Definition geometric_shapes_traits.h:50