| 145 | } |
| 146 | |
| 147 | void DrawDebugString(const std::string& string, const Vector3& pos, const Vector4& color, RendererDebugPage page) |
| 148 | { |
| 149 | constexpr float MIN_SCALE = 0.2f; |
| 150 | constexpr float MAX_SCALE = 0.8f; |
| 151 | |
| 152 | float distance = (Camera.pos.ToVector3() - pos).Length(); |
| 153 | float scale = 1.0f / (distance / BLOCK(2)); |
| 154 | |
| 155 | if (scale < MIN_SCALE) |
| 156 | return; |
| 157 | |
| 158 | scale = std::clamp(scale, MIN_SCALE, MAX_SCALE); |
| 159 | |
| 160 | // Get 2D label position. |
| 161 | auto labelPos = pos - Vector3(0, CLICK(0.75f), 0); |
| 162 | auto labelPos2D = g_Renderer.Get2DPosition(labelPos); |
| 163 | |
| 164 | // Draw label. |
| 165 | if (labelPos2D.has_value()) |
| 166 | DrawDebugString(string, *labelPos2D, color, scale, page); |
| 167 | } |
| 168 | |
| 169 | void DrawDebugString(const std::string& string, const Vector2& pos, const Color& color, float scale, RendererDebugPage page) |
| 170 | { |
no test coverage detected