Changed texture offset behavior of 3D floors to match with SRB2

This commit is contained in:
MascaraSnake 2016-01-03 15:54:29 +01:00
parent 0489386e7a
commit 8b5a2916b8
3 changed files with 98 additions and 29 deletions

View file

@ -1521,15 +1521,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
else else
{ {
//mxd. Apply classic offsets //mxd. Apply classic offsets
Sidedef.OffsetX = (Sidedef.OffsetX - horizontal); int newOffsetX = ChangeOffsetX(horizontal);
if(Texture != null) Sidedef.OffsetX %= Texture.Width; int newOffsetY = ChangeOffsetY(vertical);
Sidedef.OffsetY = (Sidedef.OffsetY - vertical);
if(geometrytype != VisualGeometryType.WALL_MIDDLE && Texture != null) Sidedef.OffsetY %= Texture.Height;
mode.SetActionResult("Changed texture offsets to " + Sidedef.OffsetX + ", " + Sidedef.OffsetY + "."); mode.SetActionResult("Changed texture offsets to " + newOffsetX + ", " + newOffsetY + ".");
} }
// Update sidedef geometry // Update sidedef geometry
UpdateAfterTextureOffsetChange();
}
protected virtual int ChangeOffsetX(int amount)
{
Sidedef.OffsetX -= amount;
if (Texture != null) Sidedef.OffsetX %= Texture.Width;
return Sidedef.OffsetX;
}
protected virtual int ChangeOffsetY(int amount)
{
Sidedef.OffsetY -= amount;
if (geometrytype != VisualGeometryType.WALL_MIDDLE && Texture != null) Sidedef.OffsetY %= Texture.Height;
return Sidedef.OffsetY;
}
protected virtual void UpdateAfterTextureOffsetChange()
{
VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef); VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);
parts.SetupAllParts(); parts.SetupAllParts();
} }

View file

@ -143,7 +143,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
tsz = tsz / tscale; tsz = tsz / tscale;
// Get texture offsets // Get texture offsets
Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY) + new Vector2D(sourceside.OffsetX, sourceside.OffsetY); // MascaraSnake: In SRB2, take only the X offset of the target sidedef and the Y offset of the source sidedef. Yes, this is silly.
Vector2D tof = new Vector2D(Sidedef.OffsetX, General.Map.SRB2 ? 0.0f : Sidedef.OffsetY) + new Vector2D(General.Map.SRB2 ? 0.0f : sourceside.OffsetX, sourceside.OffsetY);
tof = tof + toffset1 + toffset2; tof = tof + toffset1 + toffset2;
tof = tof / tscale; tof = tof / tscale;
if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning)
@ -309,6 +310,31 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion #endregion
#region ================== Methods #region ================== Methods
protected override int ChangeOffsetY(int amount)
{
if (General.Map.SRB2)
{
Sidedef sourceside = extrafloor.Linedef.Front;
sourceside.OffsetY -= amount;
if (geometrytype != VisualGeometryType.WALL_MIDDLE && Texture != null) sourceside.OffsetY %= Texture.Height;
return sourceside.OffsetY;
}
else return base.ChangeOffsetY(amount);
}
protected override void UpdateAfterTextureOffsetChange()
{
if (General.Map.SRB2)
{
//Update all sidedefs in the sector, since the Y offset of the 3D floor may have changed.
foreach (Sidedef sd in Sidedef.Sector.Sidedefs)
{
VisualSidedefParts parts = Sector.GetSidedefParts(sd);
parts.SetupAllParts();
}
}
else base.UpdateAfterTextureOffsetChange();
}
// This performs a fast test in object picking (mxd) // This performs a fast test in object picking (mxd)
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir) public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)

View file

@ -120,7 +120,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
tsz = tsz / tscale; tsz = tsz / tscale;
// Get texture offsets // Get texture offsets
Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY) + new Vector2D(sourceside.OffsetX, sourceside.OffsetY); // MascaraSnake: In SRB2, take only the X offset of the target sidedef and the Y offset of the source sidedef. Yes, this is silly.
Vector2D tof = new Vector2D(Sidedef.OffsetX, General.Map.SRB2 ? 0.0f : Sidedef.OffsetY) + new Vector2D(General.Map.SRB2 ? 0.0f : sourceside.OffsetX, sourceside.OffsetY);
tof = tof + toffset1 + toffset2; tof = tof + toffset1 + toffset2;
tof = tof / tscale; tof = tof / tscale;
if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning)
@ -283,6 +284,31 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion #endregion
#region ================== Methods #region ================== Methods
protected override int ChangeOffsetY(int amount)
{
if (General.Map.SRB2)
{
Sidedef sourceside = extrafloor.Linedef.Front;
sourceside.OffsetY -= amount;
if (geometrytype != VisualGeometryType.WALL_MIDDLE && Texture != null) sourceside.OffsetY %= Texture.Height;
return sourceside.OffsetY;
}
else return base.ChangeOffsetY(amount);
}
protected override void UpdateAfterTextureOffsetChange()
{
if (General.Map.SRB2)
{
//Update all sidedefs in the sector, since the Y offset of the 3D floor may have changed.
foreach (Sidedef sd in Sidedef.Sector.Sidedefs)
{
VisualSidedefParts parts = Sector.GetSidedefParts(sd);
parts.SetupAllParts();
}
}
else base.UpdateAfterTextureOffsetChange();
}
// Return texture name // Return texture name
public override string GetTextureName() public override string GetTextureName()