In some cases, texture offsets were adjusted when it wasn't required when splitting linedefs.

Replicated Doom texture vertical offset glitch when front and back sector's ceilings are sky.
This commit is contained in:
MaxED 2014-03-12 10:39:24 +00:00
parent e0179f79a6
commit 417cdde4be
4 changed files with 37 additions and 29 deletions

View file

@ -251,10 +251,6 @@ namespace CodeImp.DoomBuilder
public void TestAtSkill(int skill)
{
Cursor oldcursor = Cursor.Current;
ProcessStartInfo processinfo;
Process process;
TimeSpan deltatime;
string args;
// Check if configuration is OK
if(General.Map.ConfigSettings.TestProgram == "" || !File.Exists(General.Map.ConfigSettings.TestProgram))
@ -299,10 +295,10 @@ namespace CodeImp.DoomBuilder
if(General.Map.Errors.Count == 0)
{
// Make arguments
args = ConvertParameters(General.Map.ConfigSettings.TestParameters, skill, General.Map.ConfigSettings.TestShortPaths);
string args = ConvertParameters(General.Map.ConfigSettings.TestParameters, skill, General.Map.ConfigSettings.TestShortPaths);
// Setup process info
processinfo = new ProcessStartInfo();
ProcessStartInfo processinfo = new ProcessStartInfo();
processinfo.Arguments = args;
processinfo.FileName = General.Map.ConfigSettings.TestProgram;
processinfo.CreateNoWindow = false;
@ -321,7 +317,7 @@ namespace CodeImp.DoomBuilder
try
{
// Start the program
process = Process.Start(processinfo);
Process process = Process.Start(processinfo);
// Wait for program to complete
while(!process.WaitForExit(10))
@ -330,7 +326,7 @@ namespace CodeImp.DoomBuilder
}
// Done
deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks);
TimeSpan deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks);
General.WriteLogLine("Test program has finished.");
General.WriteLogLine("Run time: " + deltatime.TotalSeconds.ToString("###########0.00") + " seconds");
}

View file

@ -796,11 +796,10 @@ namespace CodeImp.DoomBuilder.Map
// Returns the new line resulting from the split, or null when it failed
public Linedef Split(Vertex v)
{
Linedef nl;
Sidedef nsd;
// Copy linedef and change vertices
nl = map.CreateLinedef(v, end);
Linedef nl = map.CreateLinedef(v, end);
if(nl == null) return null;
CopyPropertiesTo(nl);
SetEndVertex(v);
@ -815,10 +814,6 @@ namespace CodeImp.DoomBuilder.Map
if(nsd == null) return null;
front.CopyPropertiesTo(nsd);
nsd.Marked = front.Marked;
// Make texture offset adjustments
if(!General.Map.UDMF) //mxd
nsd.OffsetX += (int)Vector2D.Distance(this.start.Position, this.end.Position);
}
// Copy back sidedef if exists
@ -830,19 +825,24 @@ namespace CodeImp.DoomBuilder.Map
nsd.Marked = back.Marked;
//mxd. Make texture offset adjustments
int distance = (int)Vector2D.Distance(nl.start.Position, nl.end.Position);
if(General.Map.UDMF) {
if (distance != 0)
back.SetUdmfTextureOffsetX(distance);
} else {
back.OffsetX += distance;
if((back.MiddleRequired() && back.LongMiddleTexture != MapSet.EmptyLongName) || back.HighRequired() || back.LowRequired()) {
int distance = (int) Vector2D.Distance(nl.start.Position, nl.end.Position);
if (General.Map.UDMF) {
if (distance != 0) back.SetUdmfTextureOffsetX(distance);
} else {
back.OffsetX += distance;
}
}
}
//mxd. Both sides of line are required, so we do it here...
if(nl.Front != null && General.Map.UDMF) {
//mxd. Make texture offset adjustments. Both sides of the new line are required, so we do it here...
if(nl.front != null && ((nl.front.MiddleRequired() || nl.front.LongMiddleTexture != MapSet.EmptyLongName) || nl.front.HighRequired() || nl.front.LowRequired())) {
int distance = (int)Vector2D.Distance(this.start.Position, this.end.Position);
if(distance != 0) nl.Front.SetUdmfTextureOffsetX(distance);
if(General.Map.UDMF) {
if(distance != 0) nl.front.SetUdmfTextureOffsetX(distance);
} else {
nl.front.OffsetX += distance;
}
}
// Return result

View file

@ -3508,11 +3508,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. This converts offsetY from/to "normalized" offset for given lower wall
internal float GetBottomOffsetY(Sidedef side, float offset, float scaleY, bool fromNormalized) {
if(side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Other == null || side.Other.Sector == null)
return offset;
float surfaceHeight;
if (side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag)) {
if (side.Other == null || side.Other.Sector == null || side.Sector.CeilTexture != General.Map.Config.SkyFlatName ||
side.Other.Sector.CeilTexture != General.Map.Config.SkyFlatName)
return offset;
//normalize offset
float surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.FloorHeight) * scaleY;
//normalize offset the way Doom does it when front and back sector's ceiling is sky
surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.CeilHeight) * scaleY;
} else {
//normalize offset
surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.FloorHeight) * scaleY;
}
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
return (float)Math.Round(offset - surfaceHeight);

View file

@ -134,8 +134,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
float floorbias = (Sidedef.Other.Sector.FloorHeight == Sidedef.Sector.FloorHeight) ? 1.0f : 0.0f;
if(Sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
{
// When lower unpegged is set, the lower texture is bound to the bottom
tp.tlt.y = (float)Sidedef.Sector.CeilHeight - Sidedef.Other.Sector.FloorHeight;
if(Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName && Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName) {
// mxd. Replicate Doom texture offset glitch when front and back sector's ceilings are sky
tp.tlt.y = (float)Sidedef.Other.Sector.CeilHeight - Sidedef.Other.Sector.FloorHeight;
} else {
// When lower unpegged is set, the lower texture is bound to the bottom
tp.tlt.y = (float) Sidedef.Sector.CeilHeight - Sidedef.Other.Sector.FloorHeight;
}
}
tp.trb.x = tp.tlt.x + Sidedef.Line.Length;
tp.trb.y = tp.tlt.y + (Sidedef.Other.Sector.FloorHeight - (Sidedef.Sector.FloorHeight + floorbias));