[Scummvm-git-logs] scummvm master -> bd9ccee50f31b4762be30a690ac06e3a94237687
sev-
noreply at scummvm.org
Fri Sep 13 22:30:50 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
bd9ccee50f QDENGINE: Fix rounding errors in scaled sprite calculations
Commit: bd9ccee50f31b4762be30a690ac06e3a94237687
https://github.com/scummvm/scummvm/commit/bd9ccee50f31b4762be30a690ac06e3a94237687
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-14T00:30:38+02:00
Commit Message:
QDENGINE: Fix rounding errors in scaled sprite calculations
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index f893c8c75c1..5a8351f1e37 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -394,8 +394,8 @@ void grTileAnimation::drawFrame_scale(const Vect2i &position, int frame_index, f
else
frameSize =_scaleArray[closest_scale]._frameSize;
- int x = position.x - (int)((float)(frameSize.x / 2) * scale);
- int y = position.y - (int)((float)(frameSize.y / 2) * scale);
+ int x = position.x - round(float(frameSize.x) * scale) / 2;
+ int y = position.y - round(float(frameSize.y) * scale) / 2;
grDispatcher::instance()->putSpr_a(x, y, frameSize.x, frameSize.y, data, mode, scale);
} else {
@@ -490,8 +490,8 @@ void grTileAnimation::drawContour(const Vect2i &pos, int frame_index, uint32 col
void grTileAnimation::addScale(int i, float scale) {
_scaleArray[i]._scale = scale;
- _scaleArray[i]._frameSize.x = (int)((float)_frameSize.x * scale);
- _scaleArray[i]._frameSize.y = (int)((float)_frameSize.y * scale);
+ _scaleArray[i]._frameSize.x = round((double)_frameSize.x * scale);
+ _scaleArray[i]._frameSize.y = round((double)_frameSize.y * scale);
_scaleArray[i]._frameTileSize.x = (_scaleArray[i]._frameSize.x + 15) / 16;
_scaleArray[i]._frameTileSize.y = (_scaleArray[i]._frameSize.y + 15) / 16;
@@ -572,8 +572,8 @@ bool grTileAnimation::wasFrameSizeChanged(int frame_index, int scaleIdx, float s
else
newScale = _scaleArray[scaleIdx]._scale;
- if ((int)((float)sx * newScale * scale == sx) &&
- (int)((float)sy * newScale * scale == sy))
+ if ((int)((float)sx * newScale * scale) == sx &&
+ (int)((float)sy * newScale * scale) == sy)
return false;
return true;
More information about the Scummvm-git-logs
mailing list