diff --git a/radiantcore/brush/Face.cpp b/radiantcore/brush/Face.cpp index 90ea7378eb..cacfe60667 100644 --- a/radiantcore/brush/Face.cpp +++ b/radiantcore/brush/Face.cpp @@ -470,23 +470,12 @@ ShiftScaleRotation Face::getShiftScaleRotation() const void Face::setShiftScaleRotation(const ShiftScaleRotation& ssr) { - // We need to do the opposite adjustments as in Face::getShiftScaleRotation() - // The incoming values are scaled up and down, respectively. - ShiftScaleRotation corrected = ssr; - - // Scale the pixel value in SSR to relative UV coords - corrected.shift[0] = ssr.shift[0] / _shader.getWidth(); - corrected.shift[1] = ssr.shift[1] / _shader.getHeight(); - - // Add the texture dimensions to the scale. - corrected.scale[0] = ssr.scale[0] * _shader.getWidth(); - corrected.scale[1] = ssr.scale[1] * _shader.getHeight(); - + undoSave(); + // Construct the matrix from the adjusted shift/scale/rotate values - TextureProjection projection; - projection.setFromShiftScaleRotate(corrected); + _texdef.setFromShiftScaleRotate(ssr, _shader.getWidth(), _shader.getHeight()); - SetTexdef(projection); + texdefChanged(); } Vector2 Face::getTexelScale() const diff --git a/radiantcore/brush/TextureProjection.cpp b/radiantcore/brush/TextureProjection.cpp index 59147601c6..025842612e 100644 --- a/radiantcore/brush/TextureProjection.cpp +++ b/radiantcore/brush/TextureProjection.cpp @@ -72,9 +72,13 @@ ShiftScaleRotation TextureProjection::getShiftScaleRotation(std::size_t width, s return _matrix.getShiftScaleRotation(width, height); } -void TextureProjection::setFromShiftScaleRotate(const ShiftScaleRotation& ssr) +void TextureProjection::setFromShiftScaleRotate(const ShiftScaleRotation& ssr, std::size_t width, std::size_t height) { _matrix = TextureMatrix(ssr); + + // We need to do the opposite adjustments as in getShiftScaleRotation() + // The incoming values need to be scaled down, respectively. + _matrix.addScale(width, height); } Matrix4 TextureProjection::getMatrix4() const diff --git a/radiantcore/brush/TextureProjection.h b/radiantcore/brush/TextureProjection.h index c415272068..30b856cf00 100644 --- a/radiantcore/brush/TextureProjection.h +++ b/radiantcore/brush/TextureProjection.h @@ -39,7 +39,7 @@ class TextureProjection final // Returns the Shift/Scale/Rotation values scaled to the given image dimensions ShiftScaleRotation getShiftScaleRotation(std::size_t width, std::size_t height) const; - void setFromShiftScaleRotate(const ShiftScaleRotation& ssr); + void setFromShiftScaleRotate(const ShiftScaleRotation& ssr, std::size_t width, std::size_t height); Matrix3 getMatrix() const;