Fixed text bounds
Former-commit-id: 9339ed907125ecf5186a86e8c943bf3197e11571
This commit is contained in:
parent
e30c447bd5
commit
c2ac3281bf
|
|
@ -380,7 +380,11 @@ void NzTextSprite::UpdateBoundingVolume() const
|
|||
NzVector3f down = m_scene->GetDown();
|
||||
NzVector3f right = m_scene->GetRight();
|
||||
|
||||
m_boundingVolume.Set(NzVector3f(0.f), static_cast<float>(m_localBounds.width)*right + static_cast<float>(m_localBounds.height)*down);
|
||||
NzRectf bounds(m_localBounds);
|
||||
NzVector2f max = bounds.GetMaximum();
|
||||
NzVector2f min = bounds.GetMinimum();
|
||||
|
||||
m_boundingVolume.Set(min.x*right + min.y*down, max.x*right + max.y*down);
|
||||
}
|
||||
|
||||
if (!m_transformMatrixUpdated)
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ void NzSimpleTextDrawer::UpdateGlyphs() const
|
|||
|
||||
// "Curseur" de dessin
|
||||
NzVector2ui drawPos(0, m_characterSize);
|
||||
NzVector2ui lastPos(0, 0);
|
||||
|
||||
m_glyphs.reserve(size);
|
||||
nzUInt32 previousCharacter = 0;
|
||||
|
|
@ -294,9 +293,25 @@ void NzSimpleTextDrawer::UpdateGlyphs() const
|
|||
|
||||
m_glyphs.push_back(glyph);
|
||||
|
||||
lastPos = drawPos;
|
||||
drawPos.x += advance;
|
||||
}
|
||||
|
||||
m_bounds.ExtendTo(lastPos);
|
||||
// Calcul des bornes
|
||||
if (!m_glyphs.empty())
|
||||
{
|
||||
for (unsigned int i = 0; i < m_glyphs.size(); ++i)
|
||||
{
|
||||
Glyph& glyph = m_glyphs[i];
|
||||
|
||||
for (unsigned int j = 0; j < 4; ++j)
|
||||
{
|
||||
NzVector2ui corner(std::ceil(glyph.corners[j].x), std::ceil(glyph.corners[j].y));
|
||||
|
||||
if (i == 0 && j == 0)
|
||||
m_bounds.Set(corner.x, corner.y, 0, 0);
|
||||
else
|
||||
m_bounds.ExtendTo(corner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue