MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / DrawDebugString

Function DrawDebugString

TombEngine/Game/debug/debug.cpp:147–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 2

DrawItemPathfindingFunction · 0.85
DrawSectorFlagLabelFunction · 0.85

Calls 6

Get2DPositionMethod · 0.80
AddDebugStringMethod · 0.80
Vector3Function · 0.50
LengthMethod · 0.45
ToVector3Method · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected