| 162 | } |
| 163 | |
| 164 | void multiRayMeshIntersect( |
| 165 | const MeshPart& meshPart, |
| 166 | const std::vector<Vector3f>& origins, |
| 167 | const std::vector<Vector3f>& dirs, |
| 168 | const MultiRayMeshIntersectResult& result, |
| 169 | float rayStart, float rayEnd, |
| 170 | bool closestIntersect, |
| 171 | const FacePredicate & validFaces |
| 172 | ) |
| 173 | { |
| 174 | MR_TIMER; |
| 175 | |
| 176 | const auto sz = origins.size(); |
| 177 | assert( dirs.size() == sz ); |
| 178 | if ( result.intersectingRays ) |
| 179 | { |
| 180 | result.intersectingRays->clear(); |
| 181 | result.intersectingRays->resize( sz, false ); |
| 182 | } |
| 183 | constexpr float cQuietNan = std::numeric_limits<float>::quiet_NaN(); |
| 184 | if ( result.rayDistances ) |
| 185 | { |
| 186 | result.rayDistances->clear(); |
| 187 | result.rayDistances->resize( sz, cQuietNan ); |
| 188 | } |
| 189 | if ( result.isectFaces ) |
| 190 | { |
| 191 | result.isectFaces->clear(); |
| 192 | result.isectFaces->resize( sz ); |
| 193 | } |
| 194 | if ( result.isectBary ) |
| 195 | { |
| 196 | result.isectBary->clear(); |
| 197 | result.isectBary->resize( sz, TriPointf( cQuietNan, cQuietNan ) ); |
| 198 | } |
| 199 | if ( result.isectPts ) |
| 200 | { |
| 201 | result.isectPts->clear(); |
| 202 | result.isectPts->resize( sz, Vector3f( cQuietNan, cQuietNan, cQuietNan ) ); |
| 203 | } |
| 204 | |
| 205 | meshPart.mesh.getAABBTree(); // prepare tree before parallel region |
| 206 | |
| 207 | auto processRay = [&]( size_t i ) |
| 208 | { |
| 209 | auto res = rayMeshIntersect( meshPart, Line3f( origins[i], dirs[i] ), rayStart, rayEnd, nullptr, closestIntersect, validFaces ); |
| 210 | if ( !res ) |
| 211 | return; |
| 212 | if ( result.intersectingRays ) |
| 213 | result.intersectingRays->set( i ); |
| 214 | if ( result.rayDistances ) |
| 215 | ( *result.rayDistances )[i] = res.distanceAlongLine; |
| 216 | if ( result.isectFaces ) |
| 217 | (*result.isectFaces)[i] = res.proj.face; |
| 218 | if ( result.isectBary ) |
| 219 | (*result.isectBary)[i] = res.mtp.bary; |
| 220 | if ( result.isectPts ) |
| 221 | (*result.isectPts)[i] = res.proj.point; |
nothing calls this directly
no test coverage detected