Visual Mode: fixed a problem that resulted in incorrect texture offsets when moving a texture by grid size, and the grid was a multiple of the texture size

This commit is contained in:
biwa 2022-02-02 19:37:43 +01:00
parent d37e2400bc
commit b369b944f9

View file

@ -570,17 +570,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
// biwa
protected static double GetNewTexutreOffset(double oldValue, double offset, double textureSize)
{
return GetRoundedTextureOffset(oldValue, offset, 1.0f, textureSize);
return GetRoundedTextureOffset(oldValue, offset, 1.0, textureSize);
}
//mxd
protected static double GetRoundedTextureOffset(double oldValue, double offset, double scale, double textureSize)
{
if(offset == 0f) return oldValue;
if(offset == 0 || offset % textureSize == 0) return oldValue;
double scaledOffset = offset * Math.Abs(scale);
double result = Math.Round(oldValue + scaledOffset);
if(textureSize > 0) result %= textureSize;
if(result == oldValue) result += (scaledOffset < 0 ? -1 : 1);
if(result == oldValue) result += (scaledOffset < 0 ? -1 : 1); // biwa. Why?
return result;
}