| 156 | }; |
| 157 | |
| 158 | InternalZoneWithProjections findSignedDistanceOneWay( const MeshPart & a, const MeshPart & b, |
| 159 | const std::vector<FaceFace>& collisions, |
| 160 | bool bIsRef = false, |
| 161 | const AffineXf3f* rigidB2A = nullptr ) |
| 162 | { |
| 163 | const auto& ref = bIsRef ? b : a; |
| 164 | const auto& test = bIsRef ? a : b; |
| 165 | |
| 166 | FaceBitSet refFaces; |
| 167 | refFaces.resize( ref.mesh.topology.edgePerFace().size() ); |
| 168 | |
| 169 | for ( const auto& ff : collisions ) |
| 170 | refFaces.set( bIsRef ? ff.bFace : ff.aFace ); |
| 171 | |
| 172 | auto ref2Test = rigidB2A ? ( bIsRef ? *rigidB2A : rigidB2A->inverse() ) : AffineXf3f(); |
| 173 | VertBitSet refRegionVerts; |
| 174 | if ( ref.region ) |
| 175 | refRegionVerts = getIncidentVerts( ref.mesh.topology, *ref.region ); |
| 176 | VertBitSet queue = getIncidentVerts( ref.mesh.topology, refFaces ); |
| 177 | |
| 178 | InternalZoneWithProjections res; |
| 179 | res.projectons.resize( ref.mesh.points.size(), { {}, 0.0f } ); |
| 180 | |
| 181 | while ( queue.any() ) |
| 182 | { |
| 183 | tbb::enumerable_thread_specific<std::vector<VertId>> threadData; |
| 184 | BitSetParallelFor( queue, threadData, [&]( VertId id, auto& localData ) |
| 185 | { |
| 186 | const auto point = rigidB2A ? ref2Test( ref.mesh.points[id] ) : ref.mesh.points[id]; |
| 187 | auto projectRes = findProjection( point, test.mesh ); |
| 188 | if ( !contains( test.region, projectRes.proj.face ) ) |
| 189 | return; |
| 190 | const auto distance = test.mesh.signedDistance( point, projectRes ); |
| 191 | if ( distance > 0.0f ) |
| 192 | return; |
| 193 | res.projectons[id] = std::make_pair( projectRes.proj, distance ); |
| 194 | |
| 195 | for ( EdgeId e : orgRing( ref.mesh.topology, id ) ) |
| 196 | { |
| 197 | const auto v = ref.mesh.topology.dest( e ); |
| 198 | if ( !ref.region || refRegionVerts.test( v ) ) |
| 199 | localData.push_back( v ); |
| 200 | } |
| 201 | } ); |
| 202 | res.vertBS |= queue; |
| 203 | queue.reset(); |
| 204 | for ( const auto& verts : threadData ) |
| 205 | for ( auto v : verts ) |
| 206 | queue.set( v ); |
| 207 | queue -= res.vertBS; |
| 208 | } |
| 209 | |
| 210 | return res; |
| 211 | } |
| 212 | |
| 213 | MeshMeshSignedDistanceResult findSignedDistance( const MeshPart & a, const MeshPart & b, const AffineXf3f* rigidB2A, float upDistLimitSq ) |
| 214 | { |
no test coverage detected