38 #ifndef FCL_TRAVERSAL_MESHSHAPECONSERVATIVEADVANCEMENTTRAVERSALNODE_INL_H
39 #define FCL_TRAVERSAL_MESHSHAPECONSERVATIVEADVANCEMENTTRAVERSALNODE_INL_H
52 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
68 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
73 if(this->enable_statistics) this->num_bv_tests++;
75 S d = this->model2_bv.distance(this->model1->getBV(b1).bv, &P2, &P1);
77 stack.emplace_back(P1, P2, b1, b2, d);
83 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
89 if(this->enable_statistics) this->num_leaf_tests++;
91 const BVNode<BV>& node = this->model1->getBV(b1);
95 const Triangle& tri_id = this->tri_indices[primitive_id];
97 const Vector3<S>& p1 = this->vertices[tri_id[0]];
98 const Vector3<S>& p2 = this->vertices[tri_id[1]];
99 const Vector3<S>& p3 = this->vertices[tri_id[2]];
103 this->nsolver->shapeTriangleDistance(*(this->model2), this->tf2, p1, p2, p3, &d, &P2, &P1);
105 if(d < this->min_distance)
107 this->min_distance = d;
112 last_tri_id = primitive_id;
115 Vector3<S> n = this->tf2 * p2 - P1; n.normalize();
119 S bound1 = motion1->computeMotionBound(mb_visitor1);
120 S bound2 = motion2->computeMotionBound(mb_visitor2);
122 S bound = bound1 + bound2;
125 if(
bound <= d) cur_delta_t = 1;
126 else cur_delta_t = d /
bound;
128 if(cur_delta_t < delta_t)
129 delta_t = cur_delta_t;
133 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
137 if((c >= w * (this->min_distance - this->abs_err))
138 && (c * (1 + this->rel_err) >= w * this->min_distance))
140 const auto& data = stack.back();
142 Vector3<S> n = this->tf2 * data.P2 - data.P1; n.normalize();
147 S bound1 = motion1->computeMotionBound(mb_visitor1);
148 S bound2 = motion2->computeMotionBound(mb_visitor2);
150 S bound = bound1 + bound2;
153 if(
bound < c) cur_delta_t = 1;
154 else cur_delta_t = c /
bound;
156 if(cur_delta_t < delta_t)
157 delta_t = cur_delta_t;
172 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
179 const NarrowPhaseSolver* nsolver,
184 using S =
typename BV::S;
186 std::vector<Vector3<S>> vertices_transformed(model1.
num_vertices);
191 vertices_transformed[i] = new_v;
216 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
229 const NarrowPhaseSolver* nsolver,
230 bool enable_statistics,
231 typename BV::S& min_distance,
235 typename BV::S& delta_t,
238 using S =
typename BV::S;
240 if(enable_statistics) num_leaf_tests++;
245 const Triangle& tri_id = tri_indices[primitive_id];
253 nsolver->shapeTriangleDistance(model2, tf2, t1, t2, t3, tf1, &
distance, &P2, &P1);
262 last_tri_id = primitive_id;
273 S
bound = bound1 + bound2;
279 if(cur_delta_t < delta_t)
280 delta_t = cur_delta_t;
284 template <
typename BV,
typename Shape>
287 typename BV::S min_distance,
288 typename BV::S abs_err,
289 typename BV::S rel_err,
297 typename BV::S& delta_t)
301 using S =
typename BV::S;
303 if((c >= w * (min_distance - abs_err)) && (c * (1 + rel_err) >= w * min_distance))
305 const auto& data = stack.back();
306 Vector3<S> n = data.P2 - data.P1; n.normalize();
315 S
bound = bound1 + bound2;
318 if(
bound <= c) cur_delta_t = 1;
319 else cur_delta_t = c /
bound;
321 if(cur_delta_t < delta_t)
322 delta_t = cur_delta_t;
336 template <
typename Shape,
typename NarrowPhaseSolver>
337 MeshShapeConservativeAdvancementTraversalNodeRSS<Shape, NarrowPhaseSolver>::
338 MeshShapeConservativeAdvancementTraversalNodeRSS(
typename Shape::S w_)
340 RSS<
S>, Shape, NarrowPhaseSolver>(w_)
346 template <
typename Shape,
typename NarrowPhaseSolver>
351 if(this->enable_statistics) this->num_bv_tests++;
353 S d =
distance(this->tf1.linear(), this->tf1.translation(), this->model1->getBV(b1).bv, this->model2_bv, &P1, &P2);
355 this->stack.emplace_back(P1, P2, b1, b2, d);
361 template <
typename Shape,
typename NarrowPhaseSolver>
379 this->enable_statistics,
385 this->num_leaf_tests);
389 template <
typename Shape,
typename NarrowPhaseSolver>
410 template <
typename Shape,
typename NarrowPhaseSolver>
417 const NarrowPhaseSolver* nsolver,
420 using S =
typename Shape::S;
436 template <
typename Shape,
typename NarrowPhaseSolver>
439 typename Shape::S w_)
441 OBBRSS<
S>, Shape, NarrowPhaseSolver>(w_)
447 template <
typename Shape,
typename NarrowPhaseSolver>
452 if(this->enable_statistics) this->num_bv_tests++;
454 S d =
distance(this->tf1.linear(), this->tf1.translation(), this->model1->getBV(b1).bv, this->model2_bv, &P1, &P2);
456 this->stack.emplace_back(P1, P2, b1, b2, d);
462 template <
typename Shape,
typename NarrowPhaseSolver>
480 this->enable_statistics,
486 this->num_leaf_tests);
490 template <
typename Shape,
typename NarrowPhaseSolver>
511 template <
typename Shape,
typename NarrowPhaseSolver>
518 const NarrowPhaseSolver* nsolver,
521 using S =
typename Shape::S;