38 #ifndef FCL_TRAVERSAL_MESHSHAPECOLLISIONTRAVERSALNODE_INL_H
39 #define FCL_TRAVERSAL_MESHSHAPECOLLISIONTRAVERSALNODE_INL_H
52 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
57 tri_indices =
nullptr;
63 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
68 if(this->enable_statistics) this->num_leaf_tests++;
69 const BVNode<BV>& node = this->model1->getBV(b1);
73 const Triangle& tri_id = tri_indices[primitive_id];
79 if(this->model1->isOccupied() && this->model2->isOccupied())
81 bool is_intersect =
false;
83 if(!this->request.enable_contact)
85 if(nsolver->shapeTriangleIntersect(*(this->model2), this->tf2, p1, p2, p3,
nullptr,
nullptr,
nullptr))
88 if(this->request.num_max_contacts > this->result->numContacts())
98 if(nsolver->shapeTriangleIntersect(*(this->model2), this->tf2, p1, p2, p3, &contactp, &penetration, &normal))
101 if(this->request.num_max_contacts > this->result->numContacts())
102 this->result->addContact(
Contact<S>(this->model1, this->model2, primitive_id,
Contact<S>::NONE, contactp, -normal, penetration));
106 if(is_intersect && this->request.enable_cost)
110 computeBV(*(this->model2), this->tf2, shape_aabb);
112 this->result->addCostSource(
CostSource<S>(overlap_part, cost_density), this->request.num_max_cost_sources);
115 if((!this->model1->isFree() && !this->model2->isFree()) && this->request.enable_cost)
117 if(nsolver->shapeTriangleIntersect(*(this->model2), this->tf2, p1, p2, p3,
nullptr,
nullptr,
nullptr))
121 computeBV(*(this->model2), this->tf2, shape_aabb);
123 this->result->addCostSource(
CostSource<S>(overlap_part, cost_density), this->request.num_max_cost_sources);
129 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
132 return this->request.isSatisfied(*(this->result));
136 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
143 const NarrowPhaseSolver* nsolver,
149 using S =
typename BV::S;
154 if(!tf1.matrix().isIdentity())
156 std::vector<Vector3<S>> vertices_transformed(model1.
num_vertices);
161 vertices_transformed[i] = new_v;
191 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
198 const NarrowPhaseSolver* nsolver,
199 bool enable_statistics,
200 typename BV::S cost_density,
207 using S =
typename BV::S;
209 if(enable_statistics) num_leaf_tests++;
214 const Triangle& tri_id = tri_indices[primitive_id];
220 if(model1->
isOccupied() && model2.isOccupied())
222 bool is_intersect =
false;
226 if(nsolver->shapeTriangleIntersect(model2, tf2, p1, p2, p3, tf1,
nullptr,
nullptr,
nullptr))
239 if(nsolver->shapeTriangleIntersect(model2, tf2, p1, p2, p3, tf1, &contactp, &penetration, &normal))
252 AABB<S>(tf1 * p1, tf1 * p2, tf1 * p3).
overlap(shape_aabb, overlap_part);
258 if(nsolver->shapeTriangleIntersect(model2, tf2, p1, p2, p3, tf1,
nullptr,
nullptr,
nullptr))
263 AABB<S>(tf1 * p1, tf1 * p2, tf1 * p3).
overlap(shape_aabb, overlap_part);
270 template <
typename Shape,
typename NarrowPhaseSolver>
271 MeshShapeCollisionTraversalNodeOBB<Shape, NarrowPhaseSolver>::
272 MeshShapeCollisionTraversalNodeOBB()
278 template <
typename Shape,
typename NarrowPhaseSolver>
283 if(this->enable_statistics) this->num_bv_tests++;
285 return !
overlap(this->tf1.linear(), this->tf1.translation(), this->model2_bv, this->model1->getBV(b1).bv);
289 template <
typename Shape,
typename NarrowPhaseSolver>
293 this->tf1, this->tf2, this->nsolver, this->enable_statistics, this->cost_density, this->num_leaf_tests, this->request, *(this->result));
297 template <
typename Shape,
typename NarrowPhaseSolver>
304 template <
typename Shape,
typename NarrowPhaseSolver>
309 if(this->enable_statistics) this->num_bv_tests++;
311 return !
overlap(this->tf1.linear(), this->tf1.translation(), this->model2_bv, this->model1->getBV(b1).bv);
315 template <
typename Shape,
typename NarrowPhaseSolver>
319 this->tf1, this->tf2, this->nsolver, this->enable_statistics, this->cost_density, this->num_leaf_tests, this->request, *(this->result));
323 template <
typename Shape,
typename NarrowPhaseSolver>
331 template <
typename Shape,
typename NarrowPhaseSolver>
336 if(this->enable_statistics) this->num_bv_tests++;
338 return !
overlap(this->tf1.linear(), this->tf1.translation(), this->model2_bv, this->model1->getBV(b1).bv);
342 template <
typename Shape,
typename NarrowPhaseSolver>
346 this->tf1, this->tf2, this->nsolver, this->enable_statistics, this->cost_density, this->num_leaf_tests, this->request, *(this->result));
350 template <
typename Shape,
typename NarrowPhaseSolver>
358 template <
typename Shape,
typename NarrowPhaseSolver>
363 if(this->enable_statistics) this->num_bv_tests++;
364 return !
overlap(this->tf1.linear(), this->tf1.translation(), this->model2_bv, this->model1->getBV(b1).bv);
368 template <
typename Shape,
typename NarrowPhaseSolver>
372 this->tf1, this->tf2, this->nsolver, this->enable_statistics, this->cost_density, this->num_leaf_tests, this->request, *(this->result));
375 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver,
376 template <
typename,
typename>
class OrientedNode>
378 OrientedNode<Shape, NarrowPhaseSolver>& node,
382 const NarrowPhaseSolver* nsolver,
389 node.model1 = &model1;
391 node.model2 = &model2;
393 node.nsolver = nsolver;
400 node.request = request;
401 node.result = &result;
403 node.cost_density = model1.
cost_density * model2.cost_density;
409 template <
typename Shape,
typename NarrowPhaseSolver>
416 const NarrowPhaseSolver* nsolver,
421 node, model1, tf1, model2, tf2, nsolver, request, result);
425 template <
typename Shape,
typename NarrowPhaseSolver>
432 const NarrowPhaseSolver* nsolver,
437 node, model1, tf1, model2, tf2, nsolver, request, result);
441 template <
typename Shape,
typename NarrowPhaseSolver>
448 const NarrowPhaseSolver* nsolver,
453 node, model1, tf1, model2, tf2, nsolver, request, result);
457 template <
typename Shape,
typename NarrowPhaseSolver>
464 const NarrowPhaseSolver* nsolver,
469 node, model1, tf1, model2, tf2, nsolver, request, result);