38 #ifndef FCL_TRAVERSAL_MESHCONTINUOUSCOLLISIONTRAVERSALNODE_INL_H 39 #define FCL_TRAVERSAL_MESHCONTINUOUSCOLLISIONTRAVERSALNODE_INL_H 41 #include "fcl/narrowphase/detail/traversal/collision/mesh_continuous_collision_traversal_node.h" 43 #include "fcl/narrowphase/detail/traversal/collision/intersect.h" 53 struct BVHContinuousCollisionPair<double>;
57 BVHContinuousCollisionPair<S>::BVHContinuousCollisionPair()
64 BVHContinuousCollisionPair<S>::BVHContinuousCollisionPair(
65 int id1_,
int id2_, S time)
66 : id1(id1_), id2(id2_), collision_time(time)
72 template <
typename BV>
73 MeshContinuousCollisionTraversalNode<BV>::MeshContinuousCollisionTraversalNode()
74 : BVHCollisionTraversalNode<BV>()
78 tri_indices1 =
nullptr;
79 tri_indices2 =
nullptr;
80 prev_vertices1 =
nullptr;
81 prev_vertices2 =
nullptr;
89 template <
typename BV>
98 Vector3<S> collision_pos;
103 const Triangle& tri_id1 = tri_indices1[primitive_id1];
104 const Triangle& tri_id2 = tri_indices2[primitive_id2];
111 for(
int i = 0; i < 3; ++i)
113 S0[i] = prev_vertices1 + tri_id1[i];
114 S1[i] = vertices1 + tri_id1[i];
115 T0[i] = prev_vertices2 + tri_id2[i];
116 T1[i] = vertices2 + tri_id2[i];
123 for(
int i = 0; i < 3; ++i)
128 if(collision_time > tmp)
130 collision_time = tmp; collision_pos = tmpv;
137 if(collision_time > tmp)
139 collision_time = tmp; collision_pos = tmpv;
145 for(
int i = 0; i < 3; ++i)
149 if(S_id2 == 3) S_id2 = 0;
150 for(
int j = 0; j < 3; ++j)
154 if(T_id2 == 3) T_id2 = 0;
157 if(
Intersect<S>::intersect_EE(*(S0[S_id1]), *(S0[S_id2]), *(T0[T_id1]), *(T0[T_id2]), *(S1[S_id1]), *(S1[S_id2]), *(T1[T_id1]), *(T1[T_id2]), &tmp, &tmpv))
159 if(collision_time > tmp)
161 collision_time = tmp; collision_pos = tmpv;
167 if(!(collision_time > 1))
169 pairs.emplace_back(primitive_id1, primitive_id2, collision_time);
170 time_of_contact = std::min(time_of_contact, collision_time);
175 template <
typename BV>
182 template <
typename BV>
186 const Transform3<typename BV::S>&
tf1,
188 const Transform3<typename BV::S>&
tf2,
bool enable_statistics
Whether stores statistics.
Definition: collision_traversal_node_base.h:78
void leafTesting(int b1, int b2) const
Intersection testing between leaves (two triangles)
Definition: mesh_continuous_collision_traversal_node-inl.h:90
size_t num_max_contacts
The maximum number of contacts will return.
Definition: collision_request.h:55
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
const BVNode< BV > & getBV(int id) const
We provide getBV() and getNumBVs() because BVH may be compressed (in future), so we must provide some...
Definition: BVH_model-inl.h:160
Transform3< OBBRSS< S >::S > tf2
configuration of second object
Definition: traversal_node_base.h:88
Vector3< S > * prev_vertices
Geometry point data in previous frame.
Definition: BVH_model.h:168
Vector3< S > * vertices
Geometry point data.
Definition: BVH_model.h:162
CollisionRequest< OBBRSS< S >::S > request
request setting for collision
Definition: collision_traversal_node_base.h:72
bool canStop() const
Whether the traversal process can stop early.
Definition: mesh_continuous_collision_traversal_node-inl.h:176
const BVHModel< OBBRSS< S > > * model1
The first BVH model.
Definition: bvh_collision_traversal_node.h:86
int primitiveId() const
Return the primitive index. The index is referred to the original data (i.e. vertices or tri_indices)...
Definition: BV_node_base.cpp:50
Triangle * tri_indices
Geometry triangle index data, will be nullptr for point clouds.
Definition: BVH_model.h:165
Triangle with 3 indices for points.
Definition: triangle.h:47
request to the collision algorithm
Definition: collision_request.h:52
Traversal node for continuous collision between meshes.
Definition: mesh_continuous_collision_traversal_node.h:69
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: BVH_model.h:57
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
Definition: BV_node.h:52
Transform3< OBBRSS< S >::S > tf1
configuation of first object
Definition: traversal_node_base.h:85
CCD intersect kernel among primitives.
Definition: intersect.h:54
const BVHModel< OBBRSS< S > > * model2
The second BVH model.
Definition: bvh_collision_traversal_node.h:89