From 2e17c74f91f4219fc42868124ea4b124d2f050e1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 12 Aug 2025 20:35:46 +0300 Subject: [PATCH] fix text 3d position and culling --- src/graphics/core/Batch3D.cpp | 10 +++++++++- src/graphics/render/TextsRenderer.cpp | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/graphics/core/Batch3D.cpp b/src/graphics/core/Batch3D.cpp index 8f222a51..df6fdef7 100644 --- a/src/graphics/core/Batch3D.cpp +++ b/src/graphics/core/Batch3D.cpp @@ -126,7 +126,15 @@ void Batch3D::sprite( float scale = 1.0f / static_cast(atlasRes); float u = (index % atlasRes) * scale; float v = 1.0f - ((index / atlasRes) * scale) - scale; - sprite(pos, up, right, w, h, UVRegion(u, v, u+scale, v+scale), tint); + sprite( + pos + right * w + up * h, // revert centering + up, + right, + w, + h, + UVRegion(u, v, u + scale, v + scale), + tint + ); } void Batch3D::sprite( diff --git a/src/graphics/render/TextsRenderer.cpp b/src/graphics/render/TextsRenderer.cpp index 9e4210df..4b905e13 100644 --- a/src/graphics/render/TextsRenderer.cpp +++ b/src/graphics/render/TextsRenderer.cpp @@ -51,6 +51,7 @@ void TextsRenderer::renderNote( glm::vec3 yvec = note.getAxisY(); int width = font.calcWidth(text, text.length()); + int height = font.getLineHeight(); if (preset.displayMode == NoteDisplayMode::Y_FREE_BILLBOARD || preset.displayMode == NoteDisplayMode::XY_FREE_BILLBOARD) { xvec = camera.position - pos; @@ -96,8 +97,11 @@ void TextsRenderer::renderNote( pos = screenPos / screenPos.w; } - } else if (!frustum.isBoxVisible(pos - xvec * (width * 0.5f * preset.scale), - pos + xvec * (width * 0.5f * preset.scale))) { + } else if (!frustum.isBoxVisible( + pos - xvec * (width * 0.5f) * preset.scale, + pos + xvec * (width * 0.5f) * preset.scale + + yvec * static_cast(height) * preset.scale + )) { return; } auto color = preset.color;