Optimize label size calculation
This commit is contained in:
@@ -15,8 +15,6 @@
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
using namespace Math;
|
||||
|
||||
namespace
|
||||
{
|
||||
Shader MakeLabelBgShader(const bool billboard)
|
||||
@@ -45,7 +43,6 @@ namespace OpenVulkano::Scene
|
||||
Shader MakeLabelTextShader(const FontAtlasType type, const bool billboard)
|
||||
{
|
||||
Shader shader = TextDrawable::MakeDefaultShader(type);
|
||||
shader.depthTest = false;
|
||||
shader.depthCompareOp = CompareOp::LESS_OR_EQUAL;
|
||||
if (billboard)
|
||||
{
|
||||
@@ -117,20 +114,12 @@ namespace OpenVulkano::Scene
|
||||
// update position for next text entry
|
||||
m_position.y = m_bbox.GetMin().y - lineHeight;
|
||||
|
||||
const auto& min = m_bbox.GetMin();
|
||||
const auto& max = m_bbox.GetMax();
|
||||
Vertex v, v2, v3, v4;
|
||||
const float offset = 0.001;
|
||||
const float yOffset = m_settings.hasArrow ? m_settings.arrowLength : 0;
|
||||
v.position = Vector3f(min.x - m_settings.horizontalOffset, min.y - m_settings.verticalOffset - yOffset, min.z - offset);
|
||||
v2.position = Vector3f(max.x + m_settings.horizontalOffset, min.y - m_settings.verticalOffset - yOffset, min.z - offset);
|
||||
v3.position = Vector3f(max.x + m_settings.horizontalOffset, max.y + m_settings.verticalOffset, min.z - offset);
|
||||
v4.position = Vector3f(min.x - m_settings.horizontalOffset, max.y + m_settings.verticalOffset, min.z - offset);
|
||||
Math::Vector2f padding = m_settings.padding * 2;
|
||||
if (m_settings.hasArrow) padding.y += m_settings.arrowLength;
|
||||
|
||||
m_labelData.textSize.x = v2.position.x - v.position.x;
|
||||
m_labelData.textSize.y = v3.position.y - v.position.y;
|
||||
m_labelData.bboxCenter.x = (v2.position.x + v.position.x) / 2;
|
||||
m_labelData.bboxCenter.y = (v3.position.y + v.position.y) / 2;
|
||||
m_labelData.textSize = Math::Vector2f(m_bbox.GetSize()) + padding * 2;
|
||||
m_labelData.bboxCenter = { m_bbox.GetCenter() };
|
||||
if (m_settings.hasArrow) m_labelData.bboxCenter.y -= m_settings.arrowLength;
|
||||
}
|
||||
|
||||
void LabelDrawable::SetBillboardSettings(const BillboardControlBlock& settings)
|
||||
|
||||
Reference in New Issue
Block a user