Add scale parameter to DebugDraw text drawing to rescale text without reducing font size

This commit is contained in:
Wojtek Figat
2023-04-29 12:09:36 +02:00
parent 7c0d1ab977
commit ba319d8499
2 changed files with 10 additions and 3 deletions

View File

@@ -454,7 +454,12 @@ inline void DrawText3D(const DebugText3D& t, const RenderContext& renderContext,
{
Matrix w, fw, m;
if (t.FaceCamera)
Matrix::CreateWorld(t.Transform.Translation, renderContext.View.Direction, viewUp, w);
{
Matrix s, ss;
Matrix::Scaling(t.Transform.Scale.X, s);
Matrix::CreateWorld(t.Transform.Translation, renderContext.View.Direction, viewUp, ss);
Matrix::Multiply(s, ss, w);
}
else
t.Transform.GetWorld(w);
Matrix::Multiply(f, w, fw);
@@ -1993,7 +1998,7 @@ void DebugDraw::DrawText(const StringView& text, const Float2& position, const C
t.TimeLeft = duration;
}
void DebugDraw::DrawText(const StringView& text, const Vector3& position, const Color& color, int32 size, float duration)
void DebugDraw::DrawText(const StringView& text, const Vector3& position, const Color& color, int32 size, float duration, float scale)
{
if (text.Length() == 0 || size < 4)
return;
@@ -2003,6 +2008,7 @@ void DebugDraw::DrawText(const StringView& text, const Vector3& position, const
Platform::MemoryCopy(t.Text.Get(), text.Get(), text.Length() * sizeof(Char));
t.Text[text.Length()] = 0;
t.Transform = position - Context->Origin;
t.Transform.Scale.X = scale;
t.FaceCamera = true;
t.Size = size;
t.Color = color;