Use AABB grow instead of custom function
This commit is contained in:
@@ -78,7 +78,7 @@ namespace OpenVulkano::Scene
|
|||||||
double lineHeight = m_atlasData->meta.lineHeight;
|
double lineHeight = m_atlasData->meta.lineHeight;
|
||||||
|
|
||||||
textDrawable.GenerateText(text, m_position);
|
textDrawable.GenerateText(text, m_position);
|
||||||
RecalculateBbox(textDrawable.GetBoundingBox());
|
m_bbox.Grow(textDrawable.GetBoundingBox());
|
||||||
// update position for next text entry
|
// update position for next text entry
|
||||||
m_position.y = m_bbox.GetMin().y - lineHeight;
|
m_position.y = m_bbox.GetMin().y - lineHeight;
|
||||||
|
|
||||||
@@ -108,23 +108,6 @@ namespace OpenVulkano::Scene
|
|||||||
return ray.IntersectAABB(m_bbox);
|
return ray.IntersectAABB(m_bbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelDrawable::RecalculateBbox(const Math::AABB& other)
|
|
||||||
{
|
|
||||||
if (m_bbox.IsEmpty())
|
|
||||||
{
|
|
||||||
m_bbox = other;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto& currentMin = m_bbox.GetMin();
|
|
||||||
auto& currentMax = m_bbox.GetMax();
|
|
||||||
currentMin.x = std::min(currentMin.x, other.min.x);
|
|
||||||
currentMin.y = std::min(currentMin.y, other.min.y);
|
|
||||||
currentMax.x = std::max(currentMax.x, other.max.x);
|
|
||||||
currentMax.y = std::max(currentMax.y, other.max.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LabelDrawable::SetupShaders()
|
void LabelDrawable::SetupShaders()
|
||||||
{
|
{
|
||||||
SetShader(IsBillboard() ? &BACKGROUND_BILLBOARD_SHADER : &BACKGROUND_SHADER);
|
SetShader(IsBillboard() ? &BACKGROUND_BILLBOARD_SHADER : &BACKGROUND_SHADER);
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ namespace OpenVulkano::Scene
|
|||||||
std::optional<RayHit> Intersect(const Ray& ray) const override;
|
std::optional<RayHit> Intersect(const Ray& ray) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RecalculateBbox(const Math::AABB& other);
|
|
||||||
void SetupShaders();
|
void SetupShaders();
|
||||||
void SetupBuffers();
|
void SetupBuffers();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user