@par All vertices are projected onto the xz-plane, so the y-values are ignored.
| 292 | /// |
| 293 | /// All vertices are projected onto the xz-plane, so the y-values are ignored. |
| 294 | bool dtOverlapPolyPoly2D(const float* polya, const int npolya, |
| 295 | const float* polyb, const int npolyb) |
| 296 | { |
| 297 | const float eps = 1e-4f; |
| 298 | |
| 299 | for (int i = 0, j = npolya-1; i < npolya; j=i++) |
| 300 | { |
| 301 | const float* va = &polya[j*3]; |
| 302 | const float* vb = &polya[i*3]; |
| 303 | const float n[3] = { vb[2]-va[2], 0, -(vb[0]-va[0]) }; |
| 304 | float amin,amax,bmin,bmax; |
| 305 | projectPoly(n, polya, npolya, amin,amax); |
| 306 | projectPoly(n, polyb, npolyb, bmin,bmax); |
| 307 | if (!overlapRange(amin,amax, bmin,bmax, eps)) |
| 308 | { |
| 309 | // Found separating axis |
| 310 | return false; |
| 311 | } |
| 312 | } |
| 313 | for (int i = 0, j = npolyb-1; i < npolyb; j=i++) |
| 314 | { |
| 315 | const float* va = &polyb[j*3]; |
| 316 | const float* vb = &polyb[i*3]; |
| 317 | const float n[3] = { vb[2]-va[2], 0, -(vb[0]-va[0]) }; |
| 318 | float amin,amax,bmin,bmax; |
| 319 | projectPoly(n, polya, npolya, amin,amax); |
| 320 | projectPoly(n, polyb, npolyb, bmin,bmax); |
| 321 | if (!overlapRange(amin,amax, bmin,bmax, eps)) |
| 322 | { |
| 323 | // Found separating axis |
| 324 | return false; |
| 325 | } |
| 326 | } |
| 327 | return true; |
| 328 | } |
| 329 | |
| 330 | // Returns a random point in a convex polygon. |
| 331 | // Adapted from Graphics Gems article. |
no test coverage detected