38 #ifndef FCL_TRAVERSAL_MESHCOLLISIONTRAVERSALNODE_INL_H
39 #define FCL_TRAVERSAL_MESHCOLLISIONTRAVERSALNODE_INL_H
62 const Transform3<double>& tf1,
64 const Transform3<double>& tf2,
65 const CollisionRequest<double>& request,
66 CollisionResult<double>& result);
77 const Transform3<double>& tf1,
79 const Transform3<double>& tf2,
80 const CollisionRequest<double>& request,
81 CollisionResult<double>& result);
92 const Transform3<double>& tf1,
94 const Transform3<double>& tf2,
95 const CollisionRequest<double>& request,
96 CollisionResult<double>& result);
107 const Transform3<double>& tf1,
109 const Transform3<double>& tf2,
110 const CollisionRequest<double>& request,
111 CollisionResult<double>& result);
114 template <
typename BV>
120 tri_indices1 =
nullptr;
121 tri_indices2 =
nullptr;
125 template <
typename BV>
128 if(this->enable_statistics) this->num_leaf_tests++;
130 const BVNode<BV>& node1 = this->model1->getBV(b1);
131 const BVNode<BV>& node2 = this->model2->getBV(b2);
136 const Triangle& tri_id1 = tri_indices1[primitive_id1];
137 const Triangle& tri_id2 = tri_indices2[primitive_id2];
146 if(this->model1->isOccupied() && this->model2->isOccupied())
148 bool is_intersect =
false;
150 if(!this->request.enable_contact)
155 if(this->result->numContacts() < this->request.num_max_contacts)
156 this->result->addContact(
Contact<S>(this->model1, this->model2, primitive_id1, primitive_id2));
163 unsigned int n_contacts;
174 if(this->request.num_max_contacts < n_contacts + this->result->numContacts())
175 n_contacts = (this->request.num_max_contacts >= this->result->numContacts()) ? (this->request.num_max_contacts - this->result->numContacts()) : 0;
177 for(
unsigned int i = 0; i < n_contacts; ++i)
179 this->result->addContact(
Contact<S>(this->model1, this->model2, primitive_id1, primitive_id2, contacts[i], normal, penetration));
184 if(is_intersect && this->request.enable_cost)
188 this->result->addCostSource(
CostSource<S>(overlap_part, cost_density), this->request.num_max_cost_sources);
191 else if((!this->model1->isFree() && !this->model2->isFree()) && this->request.enable_cost)
197 this->result->addCostSource(
CostSource<S>(overlap_part, cost_density), this->request.num_max_cost_sources);
203 template <
typename BV>
206 return this->request.isSatisfied(*(this->result));
210 template <
typename BV>
222 using S =
typename BV::S;
228 if(!tf1.matrix().isIdentity())
230 std::vector<Vector3<S>> vertices_transformed1(model1.
num_vertices);
235 vertices_transformed1[i] = new_v;
245 if(!tf2.matrix().isIdentity())
247 std::vector<Vector3<S>> vertices_transformed2(model2.
num_vertices);
252 vertices_transformed2[i] = new_v;
282 template <
typename S>
291 template <
typename S>
294 if(this->enable_statistics) this->num_bv_tests++;
296 return !
overlap(R, T, this->model1->getBV(b1).bv, this->model2->getBV(b2).bv);
300 template <
typename S>
316 this->enable_statistics,
318 this->num_leaf_tests,
324 template <
typename S>
328 if(this->enable_statistics) this->num_bv_tests++;
332 this->model1->getBV(b1).bv.extent,
333 this->model2->getBV(b2).bv.extent);
337 template <
typename S>
341 if(this->enable_statistics) this->num_bv_tests++;
344 this->model1->getBV(b1).bv.extent,
345 this->model2->getBV(b2).bv.extent);
349 template <
typename S>
369 this->enable_statistics,
371 this->num_leaf_tests,
377 template <
typename S>
393 this->enable_statistics,
395 this->num_leaf_tests,
401 template <
typename S>
410 template <
typename S>
413 if(this->enable_statistics) this->num_bv_tests++;
415 return !
overlap(R, T, this->model1->getBV(b1).bv, this->model2->getBV(b2).bv);
419 template <
typename S>
435 this->enable_statistics,
437 this->num_leaf_tests,
443 template <
typename S>
452 template <
typename S>
455 if(this->enable_statistics) this->num_bv_tests++;
457 return !
overlap(R, T, this->model1->getBV(b1).bv, this->model2->getBV(b2).bv);
461 template <
typename S>
477 this->enable_statistics,
479 this->num_leaf_tests,
485 template <
typename S>
494 template <
typename S>
497 if(this->enable_statistics) this->num_bv_tests++;
499 return !
overlap(R, T, this->model1->getBV(b1).bv, this->model2->getBV(b2).bv);
503 template <
typename S>
519 this->enable_statistics,
521 this->num_leaf_tests,
526 template <
typename BV>
539 bool enable_statistics,
540 typename BV::S cost_density,
545 using S =
typename BV::S;
547 if(enable_statistics) num_leaf_tests++;
555 const Triangle& tri_id1 = tri_indices1[primitive_id1];
556 const Triangle& tri_id2 = tri_indices2[primitive_id2];
567 bool is_intersect =
false;
582 unsigned int n_contacts;
597 for(
unsigned int i = 0; i < n_contacts; ++i)
599 result.
addContact(
Contact<S>(model1, model2, primitive_id1, primitive_id2, tf1 * contacts[i], tf1.linear() * normal, penetration));
623 template <
typename BV>
636 bool enable_statistics,
637 typename BV::S cost_density,
642 using S =
typename BV::S;
644 if(enable_statistics) num_leaf_tests++;
652 const Triangle& tri_id1 = tri_indices1[primitive_id1];
653 const Triangle& tri_id2 = tri_indices2[primitive_id2];
664 bool is_intersect =
false;
679 unsigned int n_contacts;
683 p1, p2, p3, q1, q2, q3, tf, contacts, &n_contacts, &penetration, &normal))
690 for(
unsigned int i = 0; i < n_contacts; ++i)
692 result.
addContact(
Contact<S>(model1, model2, primitive_id1, primitive_id2, tf1 * contacts[i], tf1.linear() * normal, penetration));
715 template<
typename BV,
typename OrientedNode>
732 node.model1 = &model1;
734 node.model2 = &model2;
737 node.request = request;
738 node.result = &result;
742 relativeTransform(tf1.linear(), tf1.translation(), tf2.linear(), tf2.translation(), node.R, node.T);
748 template <
typename S>
759 node, model1, tf1, model2, tf2, request, result);
763 template <
typename S>
774 node, model1, tf1, model2, tf2, request, result);
778 template <
typename S>
789 node, model1, tf1, model2, tf2, request, result);
793 template <
typename S>
804 node, model1, tf1, model2, tf2, request, result);