38 #ifndef FCL_TRAVERSAL_SHAPECOLLISIONTRAVERSALNODE_INL_H
39 #define FCL_TRAVERSAL_SHAPECOLLISIONTRAVERSALNODE_INL_H
50 template <
typename Shape1,
typename Shape2,
typename NarrowPhaseSolver>
62 template <
typename Shape1,
typename Shape2,
typename NarrowPhaseSolver>
70 template <
typename Shape1,
typename Shape2,
typename NarrowPhaseSolver>
74 if(model1->isOccupied() && model2->isOccupied())
76 bool is_collision =
false;
77 if(this->request.enable_contact)
79 std::vector<ContactPoint<S>> contacts;
80 if(nsolver->shapeIntersect(*model1, this->tf1, *model2, this->tf2, &contacts))
83 if(this->request.num_max_contacts > this->result->numContacts())
85 const size_t free_space = this->request.num_max_contacts - this->result->numContacts();
86 size_t num_adding_contacts;
89 if (free_space < contacts.size())
91 std::partial_sort(contacts.begin(), contacts.begin() + free_space, contacts.end(), std::bind(comparePenDepth<S>, std::placeholders::_2, std::placeholders::_1));
92 num_adding_contacts = free_space;
96 num_adding_contacts = contacts.size();
99 for(
size_t i = 0; i < num_adding_contacts; ++i)
106 if(nsolver->shapeIntersect(*model1, this->tf1, *model2, this->tf2,
nullptr))
109 if(this->request.num_max_contacts > this->result->numContacts())
114 if(is_collision && this->request.enable_cost)
120 aabb1.
overlap(aabb2, overlap_part);
121 this->result->addCostSource(
CostSource<S>(overlap_part, cost_density), this->request.num_max_cost_sources);
124 else if((!model1->isFree() && !model2->isFree()) && this->request.enable_cost)
126 if(nsolver->shapeIntersect(*model1, this->tf1, *model2, this->tf2,
nullptr))
132 aabb1.
overlap(aabb2, overlap_part);
133 this->result->addCostSource(
CostSource<S>(overlap_part, cost_density), this->request.num_max_cost_sources);
139 template <
typename Shape1,
typename Shape2,
typename NarrowPhaseSolver>
142 const Shape1& shape1,
144 const Shape2& shape2,
146 const NarrowPhaseSolver* nsolver,
159 node.
cost_density = shape1.cost_density * shape2.cost_density;