See if the camera view is occluded by certain objects, and move the camera closer to the subject in that case
| 658 | // See if the camera view is occluded by certain objects, |
| 659 | // and move the camera closer to the subject in that case |
| 660 | bool afxCamera::avoid_blocked_view(const Point3F& startpos, const Point3F& endpos, Point3F& newpos) |
| 661 | { |
| 662 | // cast ray to check for intersection with potential blocker objects |
| 663 | RayInfo hit_info; |
| 664 | if (!getContainer()->castRay(startpos, endpos, afxCameraData::sCameraCollisionMask, &hit_info)) |
| 665 | { |
| 666 | // no hit: just return original endpos |
| 667 | newpos = endpos; |
| 668 | return false; |
| 669 | } |
| 670 | |
| 671 | // did hit: return the hit location nudged forward slightly |
| 672 | // to avoid seeing clipped portions of blocking object. |
| 673 | Point3F sight_line = startpos - hit_info.point; |
| 674 | sight_line.normalize(); |
| 675 | newpos = hit_info.point + sight_line*0.4f; |
| 676 | |
| 677 | return true; |
| 678 | } |
| 679 | |
| 680 | bool afxCamera::test_blocked_line(const Point3F& startpos, const Point3F& endpos) |
| 681 | { |
nothing calls this directly
no test coverage detected