diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index d9f7b53..c336b01 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -1572,8 +1572,12 @@ namespace CodeImp.DoomBuilder.Geometry texture = General.Map.Data.GetTextureImage(l.Front.LongLowTexture); if(texture != null) - l.Front.OffsetX = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)) % texture.Width; - } + { + int repeatmidtexoffset = General.Map.SRB2 && l.IsFlagSet(General.Map.Config.RepeatMidtextureFlag) ? (l.Front.OffsetX / 4096) * 4096 : 0; + l.Front.OffsetX = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)) % texture.Width + repeatmidtexoffset; + + } + } if(l.Back != null) { @@ -1587,8 +1591,11 @@ namespace CodeImp.DoomBuilder.Geometry texture = General.Map.Data.GetTextureImage(l.Back.LongLowTexture); if(texture != null) - l.Back.OffsetX = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)) % texture.Width; - } + { + int repeatmidtexoffset = General.Map.SRB2 && l.IsFlagSet(General.Map.Config.RepeatMidtextureFlag) ? (l.Back.OffsetX / 4096) * 4096 : 0; + l.Back.OffsetX = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)) % texture.Width + repeatmidtexoffset; + } + } curLength += l.Length; } diff --git a/Source/Core/Map/Linedef.cs b/Source/Core/Map/Linedef.cs index c874b1c..23660dc 100644 --- a/Source/Core/Map/Linedef.cs +++ b/Source/Core/Map/Linedef.cs @@ -1510,8 +1510,13 @@ namespace CodeImp.DoomBuilder.Map else if(newline.front.LowRequired() && newline.front.LongLowTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(newline.front.LongLowTexture)) texture = General.Map.Data.GetTextureImage(newline.front.LowTexture); - //clamp offsetX - if(texture != null) newline.front.OffsetX %= texture.Width; + //clamp offsetX + if (texture != null) + { + int repeatmidtexoffset = General.Map.SRB2 && newline.IsFlagSet(General.Map.Config.RepeatMidtextureFlag) ? (newline.front.OffsetX / 4096) * 4096 : 0; + newline.front.OffsetX %= texture.Width; + newline.front.OffsetX += repeatmidtexoffset; + } } if((oldline.back != null) && (newline.back != null)) @@ -1526,8 +1531,13 @@ namespace CodeImp.DoomBuilder.Map else if(newline.back.LowRequired() && newline.back.LongLowTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(newline.back.LongLowTexture)) texture = General.Map.Data.GetTextureImage(newline.back.LowTexture); - //clamp offsetX - if(texture != null) newline.back.OffsetX %= texture.Width; + //clamp offsetX + if (texture != null) + { + int repeatmidtexoffset = General.Map.SRB2 && newline.IsFlagSet(General.Map.Config.RepeatMidtextureFlag) ? (newline.back.OffsetX / 4096) * 4096 : 0; + newline.back.OffsetX %= texture.Width; + newline.back.OffsetX += repeatmidtexoffset; + } } break; diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index 305b777..8536afa 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -257,7 +257,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } else { - offset.x %= texture.Width / s.Fields.GetValue((alignFloors ? "xscalefloor" : "xscaleceiling"), 1.0f); + offset.x %= texture.Width / s.Fields.GetValue((alignFloors ? "xscalefloor" : "xscaleceiling"), 1.0f); offset.y %= texture.Height / s.Fields.GetValue((alignFloors ? "yscalefloor" : "yscaleceiling"), 1.0f); } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs index 4cbfac9..ba9deff 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -1455,7 +1455,12 @@ namespace CodeImp.DoomBuilder.BuilderModes protected virtual int ChangeOffsetX(int amount) { Sidedef.OffsetX -= amount; - if (Texture != null) Sidedef.OffsetX %= Texture.Width; + if (Texture != null) + { + int repeatmidtexoffset = General.Map.SRB2 && Sidedef.Line.IsFlagSet(General.Map.Config.RepeatMidtextureFlag) ? (Sidedef.OffsetX / 4096) * 4096 : 0; + Sidedef.OffsetX %= Texture.Width; + Sidedef.OffsetX += repeatmidtexoffset; + } return Sidedef.OffsetX; } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 8ffc250..dacd3ab 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -3963,7 +3963,12 @@ namespace CodeImp.DoomBuilder.BuilderModes // NOTE: We don't use ScaledWidth here because the texture offset is in pixels, not mappixels if(texture.IsImageLoaded && Tools.SidedefTextureMatch(j.sidedef, texture.LongName)) { - if(alignx) j.sidedef.OffsetX %= texture.Width; + if (alignx) + { + int repeatmidtexoffset = General.Map.SRB2 && j.sidedef.Line.IsFlagSet(General.Map.Config.RepeatMidtextureFlag) ? (j.sidedef.OffsetX / 4096) * 4096 : 0; + j.sidedef.OffsetX %= texture.Width; + j.sidedef.OffsetX += repeatmidtexoffset; + } if (aligny) { if (General.Map.SRB2) j.controlSide.OffsetY %= texture.Height;