| 696 | } |
| 697 | |
| 698 | void InGameUI::DrawCursor(const Camera& camera, EntityAI* vehicle, Vector3Val dir, float size, Texture* texture, |
| 699 | float width, float height, PackedColor color, bool drawInTD, CursorTexts texts) |
| 700 | { |
| 701 | // width/height assume fovLeft/fovTop = 1/0.75 |
| 702 | AspectSettings asp; |
| 703 | GEngine->GetAspectSettings(asp); |
| 704 | width *= 1.0f / asp.leftFOV; |
| 705 | height *= 0.75f / asp.topFOV; |
| 706 | |
| 707 | const int w3d = GLOB_ENGINE->Width(); |
| 708 | const int h3d = GLOB_ENGINE->Height(); |
| 709 | |
| 710 | const int w2d = GLOB_ENGINE->Width2D(); |
| 711 | const int h2d = GLOB_ENGINE->Height2D(); |
| 712 | |
| 713 | Matrix4Val camInvTransform = camera.GetInvTransform(); |
| 714 | Vector3Val dirCam = camInvTransform.Rotate(dir); |
| 715 | if (drawInTD) |
| 716 | { |
| 717 | float xAngle = atan2(dirCam.X(), dirCam.Z()); |
| 718 | float yAngle = atan2(dirCam.Y(), dirCam.SizeXZ()); |
| 719 | if (xAngle >= MIN_X && xAngle <= MAX_X && yAngle >= MIN_Y && yAngle <= MAX_Y) |
| 720 | { |
| 721 | float xScreen = toInt((tdX + 0.5 * tdW + xAngle * tdW * INV_W - 0.5 * tdCurW) * w2d); |
| 722 | float yScreen = toInt((tdY + 0.5 * tdH - yAngle * tdH * INV_H - 0.5 * tdCurH) * h2d); |
| 723 | MipInfo mip = GLOB_ENGINE->TextBank()->UseMipmap(texture, 0, 0); |
| 724 | GLOB_ENGINE->Draw2D(mip, color, Rect2DPixel(xScreen, yScreen, tdCurW * w2d, tdCurH * h2d), |
| 725 | Rect2DPixel(tdX * w2d, tdY * w2d, tdW * w2d, tdH * h2d)); |
| 726 | // GLOB_ENGINE->TextBank()->ReleaseMipmap(); |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | float invSize = dirCam.InvSize(); |
| 731 | float coef; |
| 732 | if (size > 0) |
| 733 | { |
| 734 | coef = size * invSize * camera.InvLeft(); |
| 735 | saturate(coef, actMin, actMax); |
| 736 | } |
| 737 | else if (size > -0.1) |
| 738 | { |
| 739 | coef = actMin; |
| 740 | } |
| 741 | else |
| 742 | { |
| 743 | coef = 1; |
| 744 | } |
| 745 | |
| 746 | float xMax = 1 - width * coef; |
| 747 | float yMax = 1 - height * coef; |
| 748 | float xScreen = 0, yScreen = 0; |
| 749 | bool visibleX = true; |
| 750 | bool visibleY = true; |
| 751 | bool rightEdge = false; |
| 752 | if (dirCam.Z() > 0) |
| 753 | { |
| 754 | float invZ = 1 / dirCam.Z(); |
| 755 | xScreen = 0.5 * (1.0 + dirCam.X() * invZ * camera.InvLeft() - width * coef); |
nothing calls this directly
no test coverage detected