38 #ifndef FCL_CONSERVATIVE_ADVANCEMENT_INL_H
39 #define FCL_CONSERVATIVE_ADVANCEMENT_INL_H
83 using S =
typename BV::S;
91 if(
collide(&o1, tf1, &o2, tf2, request, result))
115 distanceRecurse<S>(&node, 0, 0,
nullptr);
149 template<
typename BV,
typename ConservativeAdvancementOrientedNode>
158 using S =
typename BV::S;
166 if(
collide(&o1, tf1, &o2, tf2, request, result))
173 ConservativeAdvancementOrientedNode node;
177 node.motion1 = motion1;
178 node.motion2 = motion2;
183 node.motion2->getCurrentTransform(tf2);
187 node.R = tf.linear();
188 node.T = tf.translation();
195 if(node.delta_t <= node.t_err)
201 node.toc += node.delta_t;
208 node.motion1->integrate(node.toc);
209 node.motion2->integrate(node.toc);
221 template<
typename Shape1,
typename Shape2,
typename NarrowPhaseSolver>
226 const NarrowPhaseSolver* solver,
229 typename Shape1::S& toc)
231 using S =
typename Shape1::S;
239 if(
collide(&o1, tf1, &o2, tf2, request, result))
290 template<
typename BV,
typename Shape,
typename NarrowPhaseSolver>
295 const NarrowPhaseSolver* nsolver,
300 using S =
typename BV::S;
307 if(
collide(&o1, tf1, &o2, tf2, request, result))
323 initialize(node, *o1_tmp, tf1, o2, tf2, nsolver);
328 distanceRecurse<S>(&node, 0, 0,
nullptr);
360 template<
typename BV,
typename Shape,
typename NarrowPhaseSolver,
typename ConservativeAdvancementOrientedNode>
365 const NarrowPhaseSolver* nsolver,
370 using S =
typename BV::S;
377 if(
collide(&o1, tf1, &o2, tf2, request, result))
383 ConservativeAdvancementOrientedNode node;
387 node.motion1 = motion1;
388 node.motion2 = motion2;
393 node.motion2->getCurrentTransform(tf2);
403 if(node.delta_t <= node.t_err)
408 node.toc += node.delta_t;
415 node.motion1->integrate(node.toc);
416 node.motion2->integrate(node.toc);
428 template<
typename Shape,
typename NarrowPhaseSolver>
433 const NarrowPhaseSolver* nsolver,
436 typename Shape::S& toc)
438 using S =
typename Shape::S;
440 return detail::conservativeAdvancementMeshShapeOriented<RSS<S>, Shape, NarrowPhaseSolver,
MeshShapeConservativeAdvancementTraversalNodeRSS<Shape, NarrowPhaseSolver> >(o1, motion1, o2, motion2, nsolver, request, result, toc);
443 template<
typename Shape,
typename NarrowPhaseSolver>
448 const NarrowPhaseSolver* nsolver,
451 typename Shape::S& toc)
453 using S =
typename Shape::S;
455 return detail::conservativeAdvancementMeshShapeOriented<OBBRSS<S>, Shape, NarrowPhaseSolver,
MeshShapeConservativeAdvancementTraversalNodeOBBRSS<Shape, NarrowPhaseSolver> >(o1, motion1, o2, motion2, nsolver, request, result, toc);
458 template<
typename Shape,
typename BV,
typename NarrowPhaseSolver>
463 const NarrowPhaseSolver* nsolver,
468 using S =
typename BV::S;
475 if(
collide(&o1, tf1, &o2, tf2, request, result))
491 initialize(node, o1, tf1, *o2_tmp, tf2, nsolver);
528 template<
typename Shape,
typename BV,
typename NarrowPhaseSolver,
typename ConservativeAdvancementOrientedNode>
533 const NarrowPhaseSolver* nsolver,
538 using S =
typename BV::S;
544 if(
collide(&o1, tf1, &o2, tf2, request, result))
550 ConservativeAdvancementOrientedNode node;
554 node.motion1 = motion1;
555 node.motion2 = motion2;
560 node.motion2->getCurrentTransform(tf2);
570 if(node.delta_t <= node.t_err)
575 node.toc += node.delta_t;
582 node.motion1->integrate(node.toc);
583 node.motion2->integrate(node.toc);
596 template <
typename S,
typename Shape,
typename NarrowPhaseSolver>
604 const NarrowPhaseSolver* nsolver,
609 return detail::conservativeAdvancementShapeMeshOriented<Shape, RSS<S>, NarrowPhaseSolver,
ShapeMeshConservativeAdvancementTraversalNodeRSS<Shape, NarrowPhaseSolver> >(o1, motion1, o2, motion2, nsolver, request, result, toc);
617 const NarrowPhaseSolver* nsolver,
622 return detail::conservativeAdvancementShapeMeshOriented<Shape, OBBRSS<S>, NarrowPhaseSolver,
ShapeMeshConservativeAdvancementTraversalNodeOBBRSS<Shape, NarrowPhaseSolver> >(o1, motion1, o2, motion2, nsolver, request, result, toc);
626 template<
typename Shape,
typename NarrowPhaseSolver>
631 const NarrowPhaseSolver* nsolver,
634 typename Shape::S& toc)
637 typename Shape::S, Shape, NarrowPhaseSolver>::run(
638 o1, motion1, o2, motion2, nsolver, request, result, toc);
641 template<
typename Shape,
typename NarrowPhaseSolver>
646 const NarrowPhaseSolver* nsolver,
649 typename Shape::S& toc)
652 typename Shape::S, Shape, NarrowPhaseSolver>::run(
653 o1, motion1, o2, motion2, nsolver, request, result, toc);
657 template <
typename S,
typename NarrowPhaseSolver>
665 const NarrowPhaseSolver* ,
675 template <
typename S,
typename NarrowPhaseSolver>
683 const NarrowPhaseSolver* ,
692 template<
typename BV,
typename NarrowPhaseSolver>
698 using S =
typename BV::S;
714 template<
typename Shape1,
typename Shape2,
typename NarrowPhaseSolver>
719 using S =
typename Shape1::S;
721 const Shape1*
obj1 =
static_cast<const Shape1*
>(o1);
722 const Shape2*
obj2 =
static_cast<const Shape2*
>(o2);
735 template<
typename Shape,
typename BV,
typename NarrowPhaseSolver>
740 using S =
typename BV::S;
742 const Shape*
obj1 =
static_cast<const Shape*
>(o1);
749 bool is_collide = conservativeAdvancement<Shape, BV, NarrowPhaseSolver>(*
obj1, motion1, *
obj2, motion2, nsolver, c_request, c_result, toc);
757 template<
typename BV,
typename Shape,
typename NarrowPhaseSolver>
762 using S =
typename BV::S;
765 const Shape*
obj2 =
static_cast<const Shape*
>(o2);
771 bool is_collide = conservativeAdvancement<BV, Shape, NarrowPhaseSolver>(*
obj1, motion1, *
obj2, motion2, nsolver, c_request, c_result, toc);
779 template<
typename NarrowPhaseSolver>
782 using S =
typename NarrowPhaseSolver::S;
787 conservative_advancement_matrix[i][j] =
nullptr;
791 conservative_advancement_matrix[
GEOM_BOX][
GEOM_BOX] = &ShapeConservativeAdvancement<Box<S>,
Box<S>, NarrowPhaseSolver>;
794 conservative_advancement_matrix[
GEOM_BOX][
GEOM_CONE] = &ShapeConservativeAdvancement<Box<S>,
Cone<S>, NarrowPhaseSolver>;
800 conservative_advancement_matrix[
GEOM_SPHERE][
GEOM_BOX] = &ShapeConservativeAdvancement<Sphere<S>,
Box<S>, NarrowPhaseSolver>;
809 conservative_advancement_matrix[
GEOM_CAPSULE][
GEOM_BOX] = &ShapeConservativeAdvancement<Capsule<S>,
Box<S>, NarrowPhaseSolver>;
818 conservative_advancement_matrix[
GEOM_CONE][
GEOM_BOX] = &ShapeConservativeAdvancement<Cone<S>,
Box<S>, NarrowPhaseSolver>;
821 conservative_advancement_matrix[
GEOM_CONE][
GEOM_CONE] = &ShapeConservativeAdvancement<Cone<S>,
Cone<S>, NarrowPhaseSolver>;
836 conservative_advancement_matrix[
GEOM_CONVEX][
GEOM_BOX] = &ShapeConservativeAdvancement<Convex<S>,
Box<S>, NarrowPhaseSolver>;
845 conservative_advancement_matrix[
GEOM_PLANE][
GEOM_BOX] = &ShapeConservativeAdvancement<Plane<S>,
Box<S>, NarrowPhaseSolver>;
863 conservative_advancement_matrix[
BV_AABB][
GEOM_BOX] = &BVHShapeConservativeAdvancement<AABB<S>,
Box<S>, NarrowPhaseSolver>;
866 conservative_advancement_matrix[
BV_AABB][
GEOM_CONE] = &BVHShapeConservativeAdvancement<AABB<S>,
Cone<S>, NarrowPhaseSolver>;
869 conservative_advancement_matrix[
BV_AABB][
GEOM_PLANE] = &BVHShapeConservativeAdvancement<AABB<S>,
Plane<S>, NarrowPhaseSolver>;
872 conservative_advancement_matrix[
BV_OBB][
GEOM_BOX] = &BVHShapeConservativeAdvancement<OBB<S>,
Box<S>, NarrowPhaseSolver>;
873 conservative_advancement_matrix[
BV_OBB][
GEOM_SPHERE] = &BVHShapeConservativeAdvancement<OBB<S>,
Sphere<S>, NarrowPhaseSolver>;
875 conservative_advancement_matrix[
BV_OBB][
GEOM_CONE] = &BVHShapeConservativeAdvancement<OBB<S>,
Cone<S>, NarrowPhaseSolver>;
877 conservative_advancement_matrix[
BV_OBB][
GEOM_CONVEX] = &BVHShapeConservativeAdvancement<OBB<S>,
Convex<S>, NarrowPhaseSolver>;
878 conservative_advancement_matrix[
BV_OBB][
GEOM_PLANE] = &BVHShapeConservativeAdvancement<OBB<S>,
Plane<S>, NarrowPhaseSolver>;
881 conservative_advancement_matrix[
BV_OBBRSS][
GEOM_BOX] = &BVHShapeConservativeAdvancement<OBBRSS<S>,
Box<S>, NarrowPhaseSolver>;
884 conservative_advancement_matrix[
BV_OBBRSS][
GEOM_CONE] = &BVHShapeConservativeAdvancement<OBBRSS<S>,
Cone<S>, NarrowPhaseSolver>;
890 conservative_advancement_matrix[
BV_RSS][
GEOM_BOX] = &BVHShapeConservativeAdvancement<RSS<S>,
Box<S>, NarrowPhaseSolver>;
891 conservative_advancement_matrix[
BV_RSS][
GEOM_SPHERE] = &BVHShapeConservativeAdvancement<RSS<S>,
Sphere<S>, NarrowPhaseSolver>;
893 conservative_advancement_matrix[
BV_RSS][
GEOM_CONE] = &BVHShapeConservativeAdvancement<RSS<S>,
Cone<S>, NarrowPhaseSolver>;
895 conservative_advancement_matrix[
BV_RSS][
GEOM_CONVEX] = &BVHShapeConservativeAdvancement<RSS<S>,
Convex<S>, NarrowPhaseSolver>;
896 conservative_advancement_matrix[
BV_RSS][
GEOM_PLANE] = &BVHShapeConservativeAdvancement<RSS<S>,
Plane<S>, NarrowPhaseSolver>;
899 conservative_advancement_matrix[
BV_KDOP16][
GEOM_BOX] = &BVHShapeConservativeAdvancement<KDOP<S, 16>,
Box<S>, NarrowPhaseSolver>;
902 conservative_advancement_matrix[
BV_KDOP16][
GEOM_CONE] = &BVHShapeConservativeAdvancement<KDOP<S, 16>,
Cone<S>, NarrowPhaseSolver>;
905 conservative_advancement_matrix[
BV_KDOP16][
GEOM_PLANE] = &BVHShapeConservativeAdvancement<KDOP<S, 16>,
Plane<S>, NarrowPhaseSolver>;
908 conservative_advancement_matrix[
BV_KDOP18][
GEOM_BOX] = &BVHShapeConservativeAdvancement<KDOP<S, 18>,
Box<S>, NarrowPhaseSolver>;
911 conservative_advancement_matrix[
BV_KDOP18][
GEOM_CONE] = &BVHShapeConservativeAdvancement<KDOP<S, 18>,
Cone<S>, NarrowPhaseSolver>;
914 conservative_advancement_matrix[
BV_KDOP18][
GEOM_PLANE] = &BVHShapeConservativeAdvancement<KDOP<S, 18>,
Plane<S>, NarrowPhaseSolver>;
917 conservative_advancement_matrix[
BV_KDOP24][
GEOM_BOX] = &BVHShapeConservativeAdvancement<KDOP<S, 24>,
Box<S>, NarrowPhaseSolver>;
920 conservative_advancement_matrix[
BV_KDOP24][
GEOM_CONE] = &BVHShapeConservativeAdvancement<KDOP<S, 24>,
Cone<S>, NarrowPhaseSolver>;
923 conservative_advancement_matrix[
BV_KDOP24][
GEOM_PLANE] = &BVHShapeConservativeAdvancement<KDOP<S, 24>,
Plane<S>, NarrowPhaseSolver>;
926 conservative_advancement_matrix[
BV_kIOS][
GEOM_BOX] = &BVHShapeConservativeAdvancement<kIOS<S>,
Box<S>, NarrowPhaseSolver>;
929 conservative_advancement_matrix[
BV_kIOS][
GEOM_CONE] = &BVHShapeConservativeAdvancement<kIOS<S>,
Cone<S>, NarrowPhaseSolver>;
932 conservative_advancement_matrix[
BV_kIOS][
GEOM_PLANE] = &BVHShapeConservativeAdvancement<kIOS<S>,
Plane<S>, NarrowPhaseSolver>;
936 conservative_advancement_matrix[
GEOM_BOX][
BV_AABB] = &ShapeBVHConservativeAdvancement<Box<S>,
AABB<S>, NarrowPhaseSolver>;
937 conservative_advancement_matrix[
GEOM_SPHERE][
BV_AABB] = &ShapeBVHConservativeAdvancement<Sphere<S>,
AABB<S>, NarrowPhaseSolver>;
938 conservative_advancement_matrix[
GEOM_CAPSULE][
BV_AABB] = &ShapeBVHConservativeAdvancement<Capsule<S>,
AABB<S>, NarrowPhaseSolver>;
939 conservative_advancement_matrix[
GEOM_CONE][
BV_AABB] = &ShapeBVHConservativeAdvancement<Cone<S>,
AABB<S>, NarrowPhaseSolver>;
940 conservative_advancement_matrix[
GEOM_CYLINDER][
BV_AABB] = &ShapeBVHConservativeAdvancement<Cylinder<S>,
AABB<S>, NarrowPhaseSolver>;
941 conservative_advancement_matrix[
GEOM_CONVEX][
BV_AABB] = &ShapeBVHConservativeAdvancement<Convex<S>,
AABB<S>, NarrowPhaseSolver>;
942 conservative_advancement_matrix[
GEOM_PLANE][
BV_AABB] = &ShapeBVHConservativeAdvancement<Plane<S>,
AABB<S>, NarrowPhaseSolver>;
945 conservative_advancement_matrix[
GEOM_BOX][
BV_OBB] = &ShapeBVHConservativeAdvancement<Box<S>,
OBB<S>, NarrowPhaseSolver>;
946 conservative_advancement_matrix[
GEOM_SPHERE][
BV_OBB] = &ShapeBVHConservativeAdvancement<Sphere<S>,
OBB<S>, NarrowPhaseSolver>;
947 conservative_advancement_matrix[
GEOM_CAPSULE][
BV_OBB] = &ShapeBVHConservativeAdvancement<Capsule<S>,
OBB<S>, NarrowPhaseSolver>;
948 conservative_advancement_matrix[
GEOM_CONE][
BV_OBB] = &ShapeBVHConservativeAdvancement<Cone<S>,
OBB<S>, NarrowPhaseSolver>;
949 conservative_advancement_matrix[
GEOM_CYLINDER][
BV_OBB] = &ShapeBVHConservativeAdvancement<Cylinder<S>,
OBB<S>, NarrowPhaseSolver>;
950 conservative_advancement_matrix[
GEOM_CONVEX][
BV_OBB] = &ShapeBVHConservativeAdvancement<Convex<S>,
OBB<S>, NarrowPhaseSolver>;
951 conservative_advancement_matrix[
GEOM_PLANE][
BV_OBB] = &ShapeBVHConservativeAdvancement<Plane<S>,
OBB<S>, NarrowPhaseSolver>;
952 conservative_advancement_matrix[
GEOM_HALFSPACE][
BV_OBB] = &ShapeBVHConservativeAdvancement<Halfspace<S>,
OBB<S>, NarrowPhaseSolver>;
954 conservative_advancement_matrix[
GEOM_BOX][
BV_RSS] = &ShapeBVHConservativeAdvancement<Box<S>,
RSS<S>, NarrowPhaseSolver>;
955 conservative_advancement_matrix[
GEOM_SPHERE][
BV_RSS] = &ShapeBVHConservativeAdvancement<Sphere<S>,
RSS<S>, NarrowPhaseSolver>;
956 conservative_advancement_matrix[
GEOM_CAPSULE][
BV_RSS] = &ShapeBVHConservativeAdvancement<Capsule<S>,
RSS<S>, NarrowPhaseSolver>;
957 conservative_advancement_matrix[
GEOM_CONE][
BV_RSS] = &ShapeBVHConservativeAdvancement<Cone<S>,
RSS<S>, NarrowPhaseSolver>;
958 conservative_advancement_matrix[
GEOM_CYLINDER][
BV_RSS] = &ShapeBVHConservativeAdvancement<Cylinder<S>,
RSS<S>, NarrowPhaseSolver>;
959 conservative_advancement_matrix[
GEOM_CONVEX][
BV_RSS] = &ShapeBVHConservativeAdvancement<Convex<S>,
RSS<S>, NarrowPhaseSolver>;
960 conservative_advancement_matrix[
GEOM_PLANE][
BV_RSS] = &ShapeBVHConservativeAdvancement<Plane<S>,
RSS<S>, NarrowPhaseSolver>;
961 conservative_advancement_matrix[
GEOM_HALFSPACE][
BV_RSS] = &ShapeBVHConservativeAdvancement<Halfspace<S>,
RSS<S>, NarrowPhaseSolver>;
963 conservative_advancement_matrix[
GEOM_BOX][
BV_OBBRSS] = &ShapeBVHConservativeAdvancement<Box<S>,
OBBRSS<S>, NarrowPhaseSolver>;
999 conservative_advancement_matrix[
GEOM_BOX][
BV_kIOS] = &ShapeBVHConservativeAdvancement<Box<S>,
kIOS<S>, NarrowPhaseSolver>;
1000 conservative_advancement_matrix[
GEOM_SPHERE][
BV_kIOS] = &ShapeBVHConservativeAdvancement<Sphere<S>,
kIOS<S>, NarrowPhaseSolver>;
1001 conservative_advancement_matrix[
GEOM_CAPSULE][
BV_kIOS] = &ShapeBVHConservativeAdvancement<Capsule<S>,
kIOS<S>, NarrowPhaseSolver>;
1002 conservative_advancement_matrix[
GEOM_CONE][
BV_kIOS] = &ShapeBVHConservativeAdvancement<Cone<S>,
kIOS<S>, NarrowPhaseSolver>;
1003 conservative_advancement_matrix[
GEOM_CYLINDER][
BV_kIOS] = &ShapeBVHConservativeAdvancement<Cylinder<S>,
kIOS<S>, NarrowPhaseSolver>;
1004 conservative_advancement_matrix[
GEOM_CONVEX][
BV_kIOS] = &ShapeBVHConservativeAdvancement<Convex<S>,
kIOS<S>, NarrowPhaseSolver>;
1005 conservative_advancement_matrix[
GEOM_PLANE][
BV_kIOS] = &ShapeBVHConservativeAdvancement<Plane<S>,
kIOS<S>, NarrowPhaseSolver>;
1008 conservative_advancement_matrix[
BV_AABB][
BV_AABB] = &BVHConservativeAdvancement<AABB<S>, NarrowPhaseSolver>;
1009 conservative_advancement_matrix[
BV_OBB][
BV_OBB] = &BVHConservativeAdvancement<OBB<S>, NarrowPhaseSolver>;
1010 conservative_advancement_matrix[
BV_RSS][
BV_RSS] = &BVHConservativeAdvancement<RSS<S>, NarrowPhaseSolver>;
1011 conservative_advancement_matrix[
BV_OBBRSS][
BV_OBBRSS] = &BVHConservativeAdvancement<OBBRSS<S>, NarrowPhaseSolver>;
1012 conservative_advancement_matrix[
BV_KDOP16][
BV_KDOP16] = &BVHConservativeAdvancement<KDOP<S, 16>, NarrowPhaseSolver>;
1013 conservative_advancement_matrix[
BV_KDOP18][
BV_KDOP18] = &BVHConservativeAdvancement<KDOP<S, 18>, NarrowPhaseSolver>;
1014 conservative_advancement_matrix[
BV_KDOP24][
BV_KDOP24] = &BVHConservativeAdvancement<KDOP<S, 24>, NarrowPhaseSolver>;
1015 conservative_advancement_matrix[
BV_kIOS][
BV_kIOS] = &BVHConservativeAdvancement<kIOS<S>, NarrowPhaseSolver>;