| 396 | } |
| 397 | |
| 398 | inline bool RectF::intersectTriangle(const Point2F &a, const Point2F &b, const Point2F &c) |
| 399 | { |
| 400 | const Point2F topLeft = point; |
| 401 | const Point2F topRight = Point2F( point.x + extent.x, point.y ); |
| 402 | const Point2F bottomLeft = Point2F( point.x, point.y + extent.y ); |
| 403 | const Point2F bottomRight = point + extent; |
| 404 | |
| 405 | // 3 point plus 12 edge tests. |
| 406 | |
| 407 | // Check each triangle point to see if it's in us. |
| 408 | if(contains(a) || contains(b) || contains(c)) |
| 409 | return true; |
| 410 | |
| 411 | // Check a-b against the rect. |
| 412 | if(lineToLineIntersect(topLeft, topRight, a, b)) |
| 413 | return true; |
| 414 | |
| 415 | if(lineToLineIntersect(topRight, bottomRight, a, b)) |
| 416 | return true; |
| 417 | |
| 418 | if(lineToLineIntersect(bottomRight, bottomLeft, a, b)) |
| 419 | return true; |
| 420 | |
| 421 | if(lineToLineIntersect(bottomLeft, topLeft, a, b)) |
| 422 | return true; |
| 423 | |
| 424 | // Check b-c |
| 425 | if(lineToLineIntersect(topLeft, topRight, b, c)) |
| 426 | return true; |
| 427 | |
| 428 | if(lineToLineIntersect(topRight, bottomRight, b, c)) |
| 429 | return true; |
| 430 | |
| 431 | if(lineToLineIntersect(bottomRight, bottomLeft, b, c)) |
| 432 | return true; |
| 433 | |
| 434 | if(lineToLineIntersect(bottomLeft, topLeft, b, c)) |
| 435 | return true; |
| 436 | |
| 437 | // Check c-a |
| 438 | if(lineToLineIntersect(topLeft, topRight, c, a)) |
| 439 | return true; |
| 440 | |
| 441 | if(lineToLineIntersect(topRight, bottomRight, c, a)) |
| 442 | return true; |
| 443 | |
| 444 | if(lineToLineIntersect(bottomRight, bottomLeft, c, a)) |
| 445 | return true; |
| 446 | |
| 447 | if(lineToLineIntersect(bottomLeft, topLeft, c, a)) |
| 448 | return true; |
| 449 | |
| 450 | return false; |
| 451 | } |
| 452 | |
| 453 | inline bool RectF::contains(const RectF& R) const |
| 454 | { |
nothing calls this directly
no test coverage detected