41 #include <../src/collision_node.h>
45 #include <../src/traits_traversal.h>
49 #ifdef COAL_HAS_OCTOMAP
51 template <
typename TypeA,
typename TypeB>
52 std::size_t OctreeCollide(
const CollisionGeometry* o1,
const Transform3s&
tf1,
53 const CollisionGeometry* o2,
const Transform3s&
tf2,
54 const GJKSolver* nsolver,
55 const CollisionRequest& request,
56 CollisionResult& result) {
57 if (request.isSatisfied(result))
return result.numContacts();
59 if (request.security_margin < 0)
61 std::invalid_argument);
63 typename TraversalTraitsCollision<TypeA, TypeB>::CollisionTraversal_t node(
65 const TypeA* obj1 =
dynamic_cast<const TypeA*
>(o1);
66 const TypeB* obj2 =
dynamic_cast<const TypeB*
>(o2);
67 OcTreeSolver otsolver(nsolver);
70 collide(&node, request, result);
72 return result.numContacts();
78 template <
typename T_BVH,
typename T_SH>
80 enum {
Options = RelativeTransformationIsIdentity };
82 #define BVH_SHAPE_DEFAULT_TO_ORIENTED(bv) \
83 template <typename T_SH> \
84 struct bvh_shape_traits<bv, T_SH> { \
85 enum { Options = 0 }; \
91 #undef BVH_SHAPE_DEFAULT_TO_ORIENTED
98 template <
typename T_BVH,
typename T_SH,
109 std::invalid_argument);
111 if (_Options & RelativeTransformationIsIdentity)
112 return aligned(o1,
tf1, o2,
tf2, nsolver, request, result);
114 return oriented(o1,
tf1, o2,
tf2, nsolver, request, result);
124 MeshShapeCollisionTraversalNode<T_BVH, T_SH, RelativeTransformationIsIdentity>
129 const T_SH* obj2 =
static_cast<const T_SH*
>(o2);
131 initialize(node, *obj1_tmp, tf1_tmp, *obj2,
tf2, nsolver, result);
145 MeshShapeCollisionTraversalNode<T_BVH, T_SH, 0> node(request);
147 const T_SH* obj2 =
static_cast<const T_SH*
>(o2);
161 template <
typename BV,
typename Shape>
173 const HF& height_field =
static_cast<const HF&
>(*o1);
174 const Shape& shape =
static_cast<const Shape&
>(*o2);
176 HeightFieldShapeCollisionTraversalNode<BV, Shape, 0> node(request);
185 template <
typename OrientedMeshCollisionTraversalNode,
typename T_BVH>
194 OrientedMeshCollisionTraversalNode node(request);
199 collide(&node, request, result);
206 template <
typename T_BVH>
220 MeshCollisionTraversalNode<T_BVH> node(request);
228 initialize(node, *obj1_tmp, tf1_tmp, *obj2_tmp, tf2_tmp, result);
242 return details::orientedMeshCollide<MeshCollisionTraversalNodeOBB, OBB>(
243 o1,
tf1, o2,
tf2, request, result);
253 return details::orientedMeshCollide<MeshCollisionTraversalNodeOBBRSS, OBBRSS>(
254 o1,
tf1, o2,
tf2, request, result);
264 return details::orientedMeshCollide<MeshCollisionTraversalNodekIOS, kIOS>(
265 o1,
tf1, o2,
tf2, request, result);
268 template <
typename T_BVH>
274 return BVHCollide<T_BVH>(o1,
tf1, o2,
tf2, request, result);
290 &ShapeShapeCollide<Box, Halfspace>;
292 &ShapeShapeCollide<Box, Ellipsoid>;
294 &ShapeShapeCollide<Box, TriangleP>;
298 &ShapeShapeCollide<Sphere, Sphere>;
300 &ShapeShapeCollide<Sphere, Capsule>;
303 &ShapeShapeCollide<Sphere, Cylinder>;
305 &ShapeShapeCollide<Sphere, ConvexBase>;
308 &ShapeShapeCollide<Sphere, Halfspace>;
310 &ShapeShapeCollide<Sphere, Ellipsoid>;
312 &ShapeShapeCollide<Sphere, TriangleP>;
315 &ShapeShapeCollide<Ellipsoid, Box>;
317 &ShapeShapeCollide<Ellipsoid, Sphere>;
319 &ShapeShapeCollide<Ellipsoid, Capsule>;
321 &ShapeShapeCollide<Ellipsoid, Cone>;
323 &ShapeShapeCollide<Ellipsoid, Cylinder>;
325 &ShapeShapeCollide<Ellipsoid, ConvexBase>;
327 &ShapeShapeCollide<Ellipsoid, Plane>;
329 &ShapeShapeCollide<Ellipsoid, Halfspace>;
331 &ShapeShapeCollide<Ellipsoid, Ellipsoid>;
333 &ShapeShapeCollide<Ellipsoid, TriangleP>;
337 &ShapeShapeCollide<Capsule, Sphere>;
339 &ShapeShapeCollide<Capsule, Capsule>;
342 &ShapeShapeCollide<Capsule, Cylinder>;
344 &ShapeShapeCollide<Capsule, ConvexBase>;
346 &ShapeShapeCollide<Capsule, Plane>;
348 &ShapeShapeCollide<Capsule, Halfspace>;
350 &ShapeShapeCollide<Capsule, Ellipsoid>;
352 &ShapeShapeCollide<Capsule, TriangleP>;
359 &ShapeShapeCollide<Cone, Cylinder>;
361 &ShapeShapeCollide<Cone, ConvexBase>;
364 &ShapeShapeCollide<Cone, Halfspace>;
366 &ShapeShapeCollide<Cone, Ellipsoid>;
368 &ShapeShapeCollide<Cone, TriangleP>;
372 &ShapeShapeCollide<Cylinder, Sphere>;
374 &ShapeShapeCollide<Cylinder, Capsule>;
376 &ShapeShapeCollide<Cylinder, Cone>;
378 &ShapeShapeCollide<Cylinder, Cylinder>;
380 &ShapeShapeCollide<Cylinder, ConvexBase>;
382 &ShapeShapeCollide<Cylinder, Plane>;
384 &ShapeShapeCollide<Cylinder, Halfspace>;
386 &ShapeShapeCollide<Cylinder, Ellipsoid>;
388 &ShapeShapeCollide<Cylinder, TriangleP>;
392 &ShapeShapeCollide<ConvexBase, Sphere>;
394 &ShapeShapeCollide<ConvexBase, Capsule>;
396 &ShapeShapeCollide<ConvexBase, Cone>;
398 &ShapeShapeCollide<ConvexBase, Cylinder>;
400 &ShapeShapeCollide<ConvexBase, ConvexBase>;
402 &ShapeShapeCollide<ConvexBase, Plane>;
404 &ShapeShapeCollide<ConvexBase, Halfspace>;
406 &ShapeShapeCollide<ConvexBase, Ellipsoid>;
408 &ShapeShapeCollide<ConvexBase, TriangleP>;
413 &ShapeShapeCollide<Plane, Capsule>;
416 &ShapeShapeCollide<Plane, Cylinder>;
418 &ShapeShapeCollide<Plane, ConvexBase>;
421 &ShapeShapeCollide<Plane, Halfspace>;
423 &ShapeShapeCollide<Plane, Ellipsoid>;
425 &ShapeShapeCollide<Plane, TriangleP>;
428 &ShapeShapeCollide<Halfspace, Box>;
430 &ShapeShapeCollide<Halfspace, Sphere>;
432 &ShapeShapeCollide<Halfspace, Capsule>;
434 &ShapeShapeCollide<Halfspace, Cone>;
436 &ShapeShapeCollide<Halfspace, Cylinder>;
438 &ShapeShapeCollide<Halfspace, ConvexBase>;
440 &ShapeShapeCollide<Halfspace, Plane>;
442 &ShapeShapeCollide<Halfspace, Halfspace>;
444 &ShapeShapeCollide<Halfspace, Ellipsoid>;
446 &ShapeShapeCollide<Halfspace, TriangleP>;
449 &ShapeShapeCollide<TriangleP, Box>;
451 &ShapeShapeCollide<TriangleP, Sphere>;
453 &ShapeShapeCollide<TriangleP, Capsule>;
455 &ShapeShapeCollide<TriangleP, Cone>;
457 &ShapeShapeCollide<TriangleP, Cylinder>;
459 &ShapeShapeCollide<TriangleP, ConvexBase>;
461 &ShapeShapeCollide<TriangleP, Plane>;
463 &ShapeShapeCollide<TriangleP, Halfspace>;
465 &ShapeShapeCollide<TriangleP, Ellipsoid>;
467 &ShapeShapeCollide<TriangleP, TriangleP>;
658 #ifdef COAL_HAS_OCTOMAP
664 &OctreeCollide<OcTree, Cylinder>;
666 &OctreeCollide<OcTree, ConvexBase>;
669 &OctreeCollide<OcTree, Halfspace>;
671 &OctreeCollide<OcTree, Ellipsoid>;
678 &OctreeCollide<Cylinder, OcTree>;
680 &OctreeCollide<ConvexBase, OcTree>;
683 &OctreeCollide<Halfspace, OcTree>;
688 &OctreeCollide<OcTree, BVHModel<AABB> >;
690 &OctreeCollide<OcTree, BVHModel<OBB> >;
692 &OctreeCollide<OcTree, BVHModel<RSS> >;
694 &OctreeCollide<OcTree, BVHModel<OBBRSS> >;
696 &OctreeCollide<OcTree, BVHModel<kIOS> >;
698 &OctreeCollide<OcTree, BVHModel<KDOP<16> > >;
700 &OctreeCollide<OcTree, BVHModel<KDOP<18> > >;
702 &OctreeCollide<OcTree, BVHModel<KDOP<24> > >;
704 &OctreeCollide<OcTree, HeightField<AABB> >;
706 &OctreeCollide<OcTree, HeightField<OBBRSS> >;
709 &OctreeCollide<BVHModel<AABB>,
OcTree>;
713 &OctreeCollide<BVHModel<OBBRSS>,
OcTree>;
715 &OctreeCollide<BVHModel<kIOS>,
OcTree>;
717 &OctreeCollide<BVHModel<KDOP<16> >,
OcTree>;
719 &OctreeCollide<BVHModel<KDOP<18> >,
OcTree>;
721 &OctreeCollide<BVHModel<KDOP<24> >,
OcTree>;
723 &OctreeCollide<HeightField<AABB>,
OcTree>;
725 &OctreeCollide<HeightField<OBBRSS>,
OcTree>;