Retain the settings for repeating midtextures when clamping a sidedef's X offset to the texture width

This commit is contained in:
MascaraSnake 2017-01-28 19:11:49 +01:00
parent 8e068aad5b
commit 72fcc68ba3
5 changed files with 38 additions and 11 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;