(e)
| 2157 | const qx = ax+abx*v+acx*w-px, qy = ay+aby*v+acy*w-py, qz = az+abz*v+acz*w-pz; |
| 2158 | return qx*qx + qy*qy + qz*qz; |
| 2159 | } |
| 2160 | |
| 2161 | /** |
| 2162 | * BFS-along-adjacency circle brush (after PrusaSlicer's TriangleSelector). |
| 2163 | * |
| 2164 | * Starts at `seedTriIdx`, walks the mesh's neighbor graph, and invokes |
| 2165 | * cb(triIdx) for every triangle that: |
| 2166 | * 1. has at least one part inside the brush "cylinder" (the projection of |
| 2167 | * a 3D distance-to-triangle test onto the plane perpendicular to |
| 2168 | * `viewDir`), AND |
| 2169 | * 2. is reachable without crossing any back-facing triangle. |
| 2170 | * |
| 2171 | * Back-face culling at the BFS expansion step is what makes this both fast |
| 2172 | * and correct: the walk can't tunnel through a thin shell to its hidden |
| 2173 | * other side because the connecting wall faces away from the camera. Work |
| 2174 | * is bounded by the painted area, not the mesh size — no spatial index |
| 2175 | * required. |
| 2176 | */ |
| 2177 | function bfsBrushSelect(seedTriIdx, hitPt, r2, viewDir, cb) { |
| 2178 | const usePrecision = precisionMaskingEnabled && precisionGeometry; |
| 2179 | const adjacency = usePrecision ? precisionAdjacency : triangleAdjacency; |
| 2180 | const faceNormals = usePrecision ? precisionFaceNormals : triangleFaceNormals; |
no test coverage detected