Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#5768: Adjust IFace::setShiftScaleRotation() method to behave the sam…
…e as in previous releases.
  • Loading branch information
codereader committed Oct 13, 2021
1 parent d844e42 commit 72c1272
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
19 changes: 4 additions & 15 deletions radiantcore/brush/Face.cpp
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion radiantcore/brush/TextureProjection.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/brush/TextureProjection.h
Expand Up @@ -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;

Expand Down

0 comments on commit 72c1272

Please sign in to comment.