diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-15 17:46:44 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-15 17:46:44 +1000 |
commit | 63c9e3ec8b51a9d96872a054a0d35e8591b3535d (patch) | |
tree | 7d5cfaea0e13eb34cc6db25df6054cae1a04677c /source/rendering | |
parent | 2a4bd826052102a0bb8858355e42b9cba06f2991 (diff) |
only round vertices if AA is on
[skip ci]
Diffstat (limited to 'source/rendering')
-rw-r--r-- | source/rendering/StarDrawablePainter.cpp | 14 | ||||
-rw-r--r-- | source/rendering/StarWorldCamera.cpp | 10 |
2 files changed, 12 insertions, 12 deletions
diff --git a/source/rendering/StarDrawablePainter.cpp b/source/rendering/StarDrawablePainter.cpp index 5f9fd79..88ca651 100644 --- a/source/rendering/StarDrawablePainter.cpp +++ b/source/rendering/StarDrawablePainter.cpp @@ -36,15 +36,13 @@ void DrawablePainter::drawDrawable(Drawable const& drawable) { } else if (auto imagePart = drawable.part.ptr<Drawable::ImagePart>()) { TexturePtr texture = m_textureGroup->loadTexture(imagePart->image); + Vec2F position = drawable.position; Vec2F textureSize(texture->size()); - RectF imageRect(Vec2F(), textureSize); - - Mat3F transformation = Mat3F::translation(drawable.position) * imagePart->transformation; - - Vec2F lowerLeft = transformation.transformVec2(Vec2F(imageRect.xMin(), imageRect.yMin())); - Vec2F lowerRight = transformation.transformVec2(Vec2F(imageRect.xMax(), imageRect.yMin())); - Vec2F upperRight = transformation.transformVec2(Vec2F(imageRect.xMax(), imageRect.yMax())); - Vec2F upperLeft = transformation.transformVec2(Vec2F(imageRect.xMin(), imageRect.yMax())); + Mat3F transformation = imagePart->transformation; + Vec2F lowerLeft = { transformation[0][2] += position.x(), transformation[1][2] += position.y() }; + Vec2F lowerRight = transformation * Vec2F(textureSize.x(), 0.f); + Vec2F upperRight = transformation * textureSize; + Vec2F upperLeft = transformation * Vec2F(0.f, textureSize.y()); float param1 = drawable.fullbright ? 0.0f : 1.0f; diff --git a/source/rendering/StarWorldCamera.cpp b/source/rendering/StarWorldCamera.cpp index c0bc645..de23f3e 100644 --- a/source/rendering/StarWorldCamera.cpp +++ b/source/rendering/StarWorldCamera.cpp @@ -26,15 +26,17 @@ void WorldCamera::setCenterWorldPosition(Vec2F const& position, bool force) { // elements drawn in world space that are aligned with TilePixels will // eventually also be aligned to real screen pixels. + float ratio = TilePixels * m_pixelRatio; + if (m_screenSize[0] % 2 == 0) - m_worldCenter[0] = round(m_worldCenter[0] * (TilePixels * m_pixelRatio)) / (TilePixels * m_pixelRatio); + m_worldCenter[0] = round(m_worldCenter[0] * ratio) / ratio; else - m_worldCenter[0] = (round(m_worldCenter[0] * (TilePixels * m_pixelRatio) + 0.5f) - 0.5f) / (TilePixels * m_pixelRatio); + m_worldCenter[0] = (round(m_worldCenter[0] * ratio + 0.5f) - 0.5f) / ratio; if (m_screenSize[1] % 2 == 0) - m_worldCenter[1] = round(m_worldCenter[1] * (TilePixels * m_pixelRatio)) / (TilePixels * m_pixelRatio); + m_worldCenter[1] = round(m_worldCenter[1] * ratio) / ratio; else - m_worldCenter[1] = (round(m_worldCenter[1] * (TilePixels * m_pixelRatio) + 0.5f) - 0.5f) / (TilePixels * m_pixelRatio); + m_worldCenter[1] = (round(m_worldCenter[1] * ratio + 0.5f) - 0.5f) / ratio; } } |