Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-04-15 17:46:44 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-04-15 17:46:44 +1000
commit63c9e3ec8b51a9d96872a054a0d35e8591b3535d (patch)
tree7d5cfaea0e13eb34cc6db25df6054cae1a04677c /source
parent2a4bd826052102a0bb8858355e42b9cba06f2991 (diff)
only round vertices if AA is on
[skip ci]
Diffstat (limited to 'source')
-rw-r--r--source/application/StarRenderer_opengl.cpp4
-rw-r--r--source/base/StarCellularLighting.cpp2
-rw-r--r--source/base/StarMemoryAssetSource.cpp2
-rw-r--r--source/core/StarMatrix3.hpp12
-rw-r--r--source/rendering/StarDrawablePainter.cpp14
-rw-r--r--source/rendering/StarWorldCamera.cpp10
6 files changed, 27 insertions, 17 deletions
diff --git a/source/application/StarRenderer_opengl.cpp b/source/application/StarRenderer_opengl.cpp
index 401acc7..f0e4dfd 100644
--- a/source/application/StarRenderer_opengl.cpp
+++ b/source/application/StarRenderer_opengl.cpp
@@ -394,6 +394,8 @@ bool OpenGlRenderer::switchEffectConfig(String const& name) {
setupGlUniforms(effect);
m_currentEffect = &effect;
+ setEffectParameter("vertexRounding", m_multiSampling > 0);
+
return true;
}
@@ -432,7 +434,7 @@ void OpenGlRenderer::setMultiSampling(unsigned multiSampling) {
if (m_multiSampling) {
glEnable(GL_MULTISAMPLE);
glEnable(GL_SAMPLE_SHADING);
- glMinSampleShading(1.0f);
+ glMinSampleShading(1.f);
} else {
glMinSampleShading(0.f);
glDisable(GL_SAMPLE_SHADING);
diff --git a/source/base/StarCellularLighting.cpp b/source/base/StarCellularLighting.cpp
index ebca0ad..48ba265 100644
--- a/source/base/StarCellularLighting.cpp
+++ b/source/base/StarCellularLighting.cpp
@@ -223,7 +223,7 @@ void CellularLightIntensityCalculator::addSpreadLight(Vec2F const& position, flo
void CellularLightIntensityCalculator::addPointLight(Vec2F const& position, float light, float beam, float beamAngle, float beamAmbience) {
Vec2F arrayPosition = position - Vec2F(m_calculationRegion.min());
- m_lightArray.addPointLight({arrayPosition, light, beam, beamAngle, beamAmbience});
+ m_lightArray.addPointLight({arrayPosition, light, beam, beamAngle, beamAmbience, false});
}
diff --git a/source/base/StarMemoryAssetSource.cpp b/source/base/StarMemoryAssetSource.cpp
index a0c220d..a7554b6 100644
--- a/source/base/StarMemoryAssetSource.cpp
+++ b/source/base/StarMemoryAssetSource.cpp
@@ -45,7 +45,7 @@ IODevicePtr MemoryAssetSource::open(String const& path) {
String deviceName() const override { return name; }
bool atEnd() override {
- return assetPos >= assetSize;
+ return assetPos >= (StreamOffset)assetSize;
}
void seek(StreamOffset p, IOSeek mode) override {
diff --git a/source/core/StarMatrix3.hpp b/source/core/StarMatrix3.hpp
index 04d8005..8cdd2d5 100644
--- a/source/core/StarMatrix3.hpp
+++ b/source/core/StarMatrix3.hpp
@@ -110,6 +110,8 @@ public:
template <typename T2>
Vec3 operator*(Vector<T2, 3> const& v) const;
+ template <typename T2>
+ Vec2 operator*(Vector<T2, 2> const& v) const;
private:
Rows m_rows;
};
@@ -304,8 +306,7 @@ void Matrix3<T>::scale(T scale, Vec2 const& point) {
template <typename T>
template <typename T2>
Vector<T2, 2> Matrix3<T>::transformVec2(Vector<T2, 2> const& point) const {
- Vector<T2, 3> res = (*this) * Vector<T2, 3>(point, 1);
- return res.vec2();
+ return (*this) * point;
}
template <typename T>
@@ -413,6 +414,13 @@ auto Matrix3<T>::operator*(const Vector<T2, 3>& u) const -> Vec3 {
}
template <typename T>
+template <typename T2>
+auto Matrix3<T>::operator*(const Vector<T2, 2>& u) const -> Vec2 {
+ return Vec2(m_rows[0][0] * u[0] + m_rows[0][1] * u[1] + m_rows[0][2],
+ m_rows[1][0] * u[0] + m_rows[1][1] * u[1] + m_rows[1][2]);
+}
+
+template <typename T>
Matrix3<T> Matrix3<T>::operator/(const T& s) const {
return Matrix3<T>(m_rows[0] / s, m_rows[1] / s, m_rows[2] / s);
}
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;
}
}