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,21 +1521,38 @@ 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
VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);
parts.SetupAllParts();
}
//mxd // Update sidedef geometry
public virtual void OnChangeScale(int incrementX, int incrementY) 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);
parts.SetupAllParts();
}
//mxd
public virtual void OnChangeScale(int incrementX, int incrementY)
{ {
if(!General.Map.UDMF || !Texture.IsImageLoaded) return; if(!General.Map.UDMF || !Texture.IsImageLoaded) return;

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)
@ -305,13 +306,38 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.SetVertices(null); //mxd base.SetVertices(null); //mxd
return false; return false;
} }
#endregion
#region ================== Methods
// This performs a fast test in object picking (mxd) #endregion
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
#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)
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{ {
// Top and bottom are swapped in Vavoom-type 3d floors // Top and bottom are swapped in Vavoom-type 3d floors
if(extrafloor.VavoomType) if(extrafloor.VavoomType)

View file

@ -118,10 +118,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Get texture scaled size // Get texture scaled size
Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight); Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight);
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.
tof = tof + toffset1 + toffset2; 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 / tscale; tof = tof / tscale;
if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning)
tof = tof * base.Texture.Scale; tof = tof * base.Texture.Scale;
@ -279,13 +280,38 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.SetVertices(null); //mxd base.SetVertices(null); //mxd
return false; return false;
} }
#endregion
#region ================== Methods
// Return texture name #endregion
public override string GetTextureName()
#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
public override string GetTextureName()
{ {
//mxd //mxd
if((extrafloor.Linedef.Args[2] & (int)Effect3DFloor.Flags.UseUpperTexture) != 0) if((extrafloor.Linedef.Args[2] & (int)Effect3DFloor.Flags.UseUpperTexture) != 0)