2014-09-23 21:34:50 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
using CodeImp.DoomBuilder.VisualModes;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-09-30 12:02:41 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2015-01-10 11:45:25 +00:00
|
|
|
|
[ErrorChecker("Check texture alignment", false, 1000)]
|
2014-09-23 21:34:50 +00:00
|
|
|
|
public class CheckTextureAlignment : ErrorChecker
|
|
|
|
|
{
|
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
|
|
private const int PROGRESS_STEP = 100;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
2014-09-29 20:49:41 +00:00
|
|
|
|
// Now THAT'S what I call a collection! :)
|
|
|
|
|
private Dictionary<VisualGeometryType, Dictionary<int, Dictionary<VisualGeometryType, Dictionary<int, bool>>>> donesides;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-09-23 21:34:50 +00:00
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
|
public CheckTextureAlignment()
|
|
|
|
|
{
|
|
|
|
|
// Total progress is done when all lines are checked
|
|
|
|
|
SetTotalProgress(General.Map.Map.Linedefs.Count / PROGRESS_STEP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
|
|
// This runs the check
|
|
|
|
|
public override void Run()
|
|
|
|
|
{
|
2014-09-29 20:49:41 +00:00
|
|
|
|
donesides = new Dictionary<VisualGeometryType, Dictionary<int, Dictionary<VisualGeometryType, Dictionary<int, bool>>>>(3);
|
|
|
|
|
donesides.Add(VisualGeometryType.WALL_UPPER, new Dictionary<int, Dictionary<VisualGeometryType, Dictionary<int, bool>>>());
|
|
|
|
|
donesides.Add(VisualGeometryType.WALL_MIDDLE, new Dictionary<int, Dictionary<VisualGeometryType, Dictionary<int, bool>>>());
|
|
|
|
|
donesides.Add(VisualGeometryType.WALL_LOWER, new Dictionary<int, Dictionary<VisualGeometryType, Dictionary<int, bool>>>());
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
2014-09-23 21:34:50 +00:00
|
|
|
|
int progress = 0;
|
|
|
|
|
int stepprogress = 0;
|
|
|
|
|
|
|
|
|
|
// Go for all the liendefs
|
|
|
|
|
foreach(Linedef l in General.Map.Map.Linedefs)
|
|
|
|
|
{
|
|
|
|
|
// Check if we need to align any part of the front sidedef
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(l.Front != null)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(!donesides[VisualGeometryType.WALL_UPPER].ContainsKey(l.Front.Index))
|
|
|
|
|
CheckTopAlignment(l.Front);
|
|
|
|
|
if(!donesides[VisualGeometryType.WALL_MIDDLE].ContainsKey(l.Front.Index))
|
|
|
|
|
CheckMiddleAlignment(l.Front);
|
|
|
|
|
if(!donesides[VisualGeometryType.WALL_LOWER].ContainsKey(l.Front.Index))
|
|
|
|
|
CheckBottomAlignment(l.Front);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if we need to align any part of the back sidedef
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(l.Back != null)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(!donesides[VisualGeometryType.WALL_UPPER].ContainsKey(l.Back.Index))
|
|
|
|
|
CheckTopAlignment(l.Back);
|
|
|
|
|
if(!donesides[VisualGeometryType.WALL_MIDDLE].ContainsKey(l.Back.Index))
|
|
|
|
|
CheckMiddleAlignment(l.Back);
|
|
|
|
|
if(!donesides[VisualGeometryType.WALL_LOWER].ContainsKey(l.Back.Index))
|
|
|
|
|
CheckBottomAlignment(l.Back);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle thread interruption
|
2014-09-29 14:05:38 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(0);
|
|
|
|
|
}
|
2016-02-01 22:04:00 +00:00
|
|
|
|
catch(ThreadInterruptedException)
|
2014-09-29 14:05:38 +00:00
|
|
|
|
{
|
|
|
|
|
// Clear collection
|
|
|
|
|
donesides.Clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
// We are making progress!
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if((++progress / PROGRESS_STEP) > stepprogress)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
|
|
|
|
stepprogress = (progress / PROGRESS_STEP);
|
|
|
|
|
AddProgress(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
|
|
|
|
// Clear collection
|
|
|
|
|
donesides.Clear();
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
#region ================== Alignment checks
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
private void CheckTopAlignment(Sidedef sidedef)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if(!sidedef.HighRequired() || sidedef.LongHighTexture == MapSet.EmptyLongName) return;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
2020-05-22 19:39:18 +00:00
|
|
|
|
double scaleX = sidedef.Fields.GetValue("scalex_top", 1.0);
|
|
|
|
|
double scaleY = sidedef.Fields.GetValue("scaley_top", 1.0);
|
|
|
|
|
int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_top", 0.0));
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2020-05-22 19:39:18 +00:00
|
|
|
|
int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_top", 0.0));
|
2014-09-29 14:05:38 +00:00
|
|
|
|
int y = (int)Tools.GetSidedefTopOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false);
|
|
|
|
|
CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_UPPER, sidedef.HighTexture);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
private void CheckMiddleAlignment(Sidedef sidedef)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if(!sidedef.MiddleRequired() || sidedef.LongMiddleTexture == MapSet.EmptyLongName) return;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
2020-05-22 19:39:18 +00:00
|
|
|
|
double scaleX = sidedef.Fields.GetValue("scalex_mid", 1.0);
|
|
|
|
|
double scaleY = sidedef.Fields.GetValue("scaley_mid", 1.0);
|
|
|
|
|
int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_mid", 0.0));
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2020-05-22 19:39:18 +00:00
|
|
|
|
int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_mid", 0.0));
|
2014-09-29 14:05:38 +00:00
|
|
|
|
int y = (int)Tools.GetSidedefMiddleOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false);
|
|
|
|
|
CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_MIDDLE, sidedef.MiddleTexture);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
private void CheckBottomAlignment(Sidedef sidedef)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(!sidedef.LowRequired() || sidedef.LongLowTexture == MapSet.EmptyLongName) return;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2020-05-22 19:39:18 +00:00
|
|
|
|
double scaleX = sidedef.Fields.GetValue("scalex_bottom", 1.0);
|
|
|
|
|
double scaleY = sidedef.Fields.GetValue("scaley_bottom", 1.0);
|
|
|
|
|
int localY = (int)Math.Round(sidedef.Fields.GetValue("offsety_bottom", 0.0));
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2020-05-22 19:39:18 +00:00
|
|
|
|
int x = sidedef.OffsetX + (int)Math.Round(sidedef.Fields.GetValue("offsetx_bottom", 0.0));
|
2014-09-29 14:05:38 +00:00
|
|
|
|
int y = (int)Tools.GetSidedefBottomOffsetY(sidedef, sidedef.OffsetY + localY, scaleY, false);
|
|
|
|
|
CheckAlignment(sidedef, x, y, scaleX, scaleY, VisualGeometryType.WALL_LOWER, sidedef.LowTexture);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
#region ================== Methods
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2020-05-21 12:20:02 +00:00
|
|
|
|
private void CheckAlignment(Sidedef sidedef, int offsetx, int offsety, double linescalex, double linescaley, VisualGeometryType parttype, string texturename)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
|
|
|
|
ImageData texture = General.Map.Data.GetTextureImage(texturename);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(!texture.IsImageLoaded) return;
|
|
|
|
|
Rectangle partsize = BuilderModesTools.GetSidedefPartSize(sidedef, parttype);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2020-05-21 12:20:02 +00:00
|
|
|
|
double scalex = ((General.Map.Config.ScaledTextureOffsets && !texture.WorldPanning) ? texture.Scale.x : 1.0f);
|
|
|
|
|
double scaley = ((General.Map.Config.ScaledTextureOffsets && !texture.WorldPanning) ? texture.Scale.y : 1.0f);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
// Move offsets to proper range
|
|
|
|
|
offsetx %= texture.Width;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(offsetx < 0) offsetx += texture.Width;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
offsety %= texture.Height;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(offsety < 0) offsety += texture.Height;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
// Check if current line is aligned to other sides
|
|
|
|
|
ICollection<Linedef> lines = (sidedef.IsFront ? sidedef.Line.Start.Linedefs : sidedef.Line.End.Linedefs);
|
|
|
|
|
Vertex v = sidedef.IsFront ? sidedef.Line.Start : sidedef.Line.End;
|
|
|
|
|
|
|
|
|
|
foreach(Linedef line in lines)
|
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(line.Index == sidedef.Line.Index) continue;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
Sidedef target = null;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(line.Front != null && line.End == v) target = line.Front;
|
|
|
|
|
else if(line.Back != null && line.Start == v) target = line.Back;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2014-09-29 20:49:41 +00:00
|
|
|
|
// No target?
|
|
|
|
|
if(target == null) continue;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
// Get expected texture offsets
|
2014-09-29 20:49:41 +00:00
|
|
|
|
VisualGeometryType targetparttype;
|
|
|
|
|
int alignedY = GetExpectedOffsetY(sidedef, target, texturename, texture.Height, scaley, linescaley, partsize, out targetparttype);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(targetparttype == VisualGeometryType.UNKNOWN) continue;
|
|
|
|
|
|
2014-09-29 20:49:41 +00:00
|
|
|
|
// Already added?
|
|
|
|
|
if(donesides[parttype].ContainsKey(sidedef.Index) && donesides[parttype][sidedef.Index][targetparttype].ContainsKey(target.Index))
|
|
|
|
|
continue;
|
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
// Not aligned if scaley is not equal
|
2020-05-22 20:30:32 +00:00
|
|
|
|
double targetscaley = GetSidedefValue(target, targetparttype, "scaley", 1.0);
|
2014-09-29 20:49:41 +00:00
|
|
|
|
if(targetscaley != linescaley)
|
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename));
|
|
|
|
|
}
|
2015-04-16 13:03:12 +00:00
|
|
|
|
|
2020-05-22 20:30:32 +00:00
|
|
|
|
double targetscalex = GetSidedefValue(target, targetparttype, "scalex", 1.0);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
2014-09-23 21:34:50 +00:00
|
|
|
|
alignedY %= texture.Height;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(alignedY < 0) alignedY += texture.Height;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
int alignedX = (target.OffsetX + (int)GetSidedefValue(target, targetparttype, "offsetx", 0f) + (int)Math.Round(target.Line.Length / scalex * targetscalex)) % texture.Width;
|
|
|
|
|
if(alignedX < 0) alignedX += texture.Width;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
// Submit result if target offsets don't match expected ones
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(offsetx != alignedX || offsety != alignedY)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
|
|
|
|
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename));
|
|
|
|
|
}
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
|
|
|
|
// Add to collection
|
|
|
|
|
AddProcessedSides(sidedef, parttype, target, targetparttype);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if other sides are aligned to current side
|
|
|
|
|
lines = (sidedef.IsFront ? sidedef.Line.End.Linedefs : sidedef.Line.Start.Linedefs);
|
|
|
|
|
v = (sidedef.IsFront ? sidedef.Line.End : sidedef.Line.Start);
|
|
|
|
|
|
|
|
|
|
foreach(Linedef line in lines)
|
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(line.Index == sidedef.Line.Index) continue;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
Sidedef target = null;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(line.Front != null && line.Start == v) target = line.Front;
|
|
|
|
|
else if(line.Back != null && line.End == v) target = line.Back;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
// No target or laready processed?
|
2014-09-29 20:49:41 +00:00
|
|
|
|
if(target == null) continue;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
// Get expected texture offsets
|
2014-09-29 20:49:41 +00:00
|
|
|
|
VisualGeometryType targetparttype;
|
|
|
|
|
int alignedY = GetExpectedOffsetY(sidedef, target, texturename, texture.Height, scaley, linescaley, partsize, out targetparttype);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(targetparttype == VisualGeometryType.UNKNOWN) continue;
|
|
|
|
|
|
2014-09-29 20:49:41 +00:00
|
|
|
|
// Already added?
|
|
|
|
|
if(donesides[parttype].ContainsKey(sidedef.Index) && donesides[parttype][sidedef.Index][targetparttype].ContainsKey(target.Index))
|
|
|
|
|
continue;
|
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
// Not aligned if scaley is not equal
|
2020-05-22 20:30:32 +00:00
|
|
|
|
double targetscaley = GetSidedefValue(target, targetparttype, "scaley", 1.0);
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if(targetscaley != linescaley)
|
2014-09-29 14:05:38 +00:00
|
|
|
|
{
|
|
|
|
|
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename));
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-23 21:34:50 +00:00
|
|
|
|
alignedY %= texture.Height;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(alignedY < 0) alignedY += texture.Height;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
2020-05-22 20:30:32 +00:00
|
|
|
|
int alignedX = (target.OffsetX + (int)GetSidedefValue(target, targetparttype, "offsetx", 0.0) - (int)Math.Round(sidedef.Line.Length / scalex * linescalex)) % texture.Width;
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(alignedX < 0) alignedX += texture.Width;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
|
|
|
|
|
// Submit result if target offsets don't match expected ones
|
2014-09-29 14:05:38 +00:00
|
|
|
|
if(offsetx != alignedX || offsety != alignedY)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename));
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
|
|
|
|
// Add to collection
|
|
|
|
|
AddProcessedSides(sidedef, parttype, target, targetparttype);
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-22 20:30:32 +00:00
|
|
|
|
private static double GetSidedefValue(Sidedef target, VisualGeometryType targetparttype, string key, double defaultvalue)
|
2014-09-29 14:05:38 +00:00
|
|
|
|
{
|
2015-12-28 15:01:53 +00:00
|
|
|
|
switch(targetparttype)
|
2014-09-29 14:05:38 +00:00
|
|
|
|
{
|
|
|
|
|
case VisualGeometryType.WALL_UPPER:
|
2020-05-22 20:30:32 +00:00
|
|
|
|
return Math.Round(UniFields.GetFloat(target.Fields, key + "_top", defaultvalue), 3);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
|
|
|
|
case VisualGeometryType.WALL_MIDDLE:
|
2020-05-22 20:30:32 +00:00
|
|
|
|
return Math.Round(UniFields.GetFloat(target.Fields, key + "_mid", defaultvalue), 3);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
|
|
|
|
case VisualGeometryType.WALL_LOWER:
|
2020-05-22 20:30:32 +00:00
|
|
|
|
return Math.Round(UniFields.GetFloat(target.Fields, key + "_bottom", defaultvalue), 3);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddProcessedSides(Sidedef s1, VisualGeometryType type1, Sidedef s2, VisualGeometryType type2)
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
// Add them both ways
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if(!donesides[type1].ContainsKey(s1.Index))
|
2014-09-29 20:49:41 +00:00
|
|
|
|
{
|
|
|
|
|
donesides[type1].Add(s1.Index, new Dictionary<VisualGeometryType, Dictionary<int, bool>>());
|
|
|
|
|
donesides[type1][s1.Index].Add(VisualGeometryType.WALL_UPPER, new Dictionary<int, bool>());
|
|
|
|
|
donesides[type1][s1.Index].Add(VisualGeometryType.WALL_MIDDLE, new Dictionary<int, bool>());
|
|
|
|
|
donesides[type1][s1.Index].Add(VisualGeometryType.WALL_LOWER, new Dictionary<int, bool>());
|
|
|
|
|
}
|
|
|
|
|
donesides[type1][s1.Index][type2].Add(s2.Index, false);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
|
2015-12-28 15:01:53 +00:00
|
|
|
|
if(!donesides[type2].ContainsKey(s2.Index))
|
2014-09-29 20:49:41 +00:00
|
|
|
|
{
|
|
|
|
|
donesides[type2].Add(s2.Index, new Dictionary<VisualGeometryType, Dictionary<int, bool>>());
|
|
|
|
|
donesides[type2][s2.Index].Add(VisualGeometryType.WALL_UPPER, new Dictionary<int, bool>());
|
|
|
|
|
donesides[type2][s2.Index].Add(VisualGeometryType.WALL_MIDDLE, new Dictionary<int, bool>());
|
|
|
|
|
donesides[type2][s2.Index].Add(VisualGeometryType.WALL_LOWER, new Dictionary<int, bool>());
|
|
|
|
|
}
|
|
|
|
|
donesides[type2][s2.Index][type1].Add(s1.Index, false);
|
2014-09-29 14:05:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-21 12:20:02 +00:00
|
|
|
|
private static int GetExpectedOffsetY(Sidedef source, Sidedef target, string texturename, int textureheight, double texturescaley, double linescaley, Rectangle partsize, out VisualGeometryType matchingparttype)
|
2014-09-29 14:05:38 +00:00
|
|
|
|
{
|
|
|
|
|
if(target.MiddleTexture == texturename
|
|
|
|
|
&& partsize.IntersectsWith(BuilderModesTools.GetSidedefPartSize(target, VisualGeometryType.WALL_MIDDLE)))
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
matchingparttype = VisualGeometryType.WALL_MIDDLE;
|
|
|
|
|
int partheight = (int)Math.Round(((target.Sector.CeilHeight - source.Sector.CeilHeight) / texturescaley) * linescaley);
|
|
|
|
|
return ((int)Tools.GetSidedefMiddleOffsetY(target, target.OffsetY + GetSidedefValue(target, matchingparttype, "offsety", 0f), linescaley, false) + partheight) % textureheight;
|
|
|
|
|
}
|
2021-02-23 15:26:31 +00:00
|
|
|
|
|
|
|
|
|
// Only check upper and lower textures if the sidedef as an other side. See https://github.com/jewalky/UltimateDoomBuilder/issues/533
|
|
|
|
|
if (target.Other != null && target.HighTexture == texturename
|
|
|
|
|
&& partsize.IntersectsWith(BuilderModesTools.GetSidedefPartSize(target, VisualGeometryType.WALL_UPPER)))
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
matchingparttype = VisualGeometryType.WALL_UPPER;
|
|
|
|
|
int partheight = (int) Math.Round(((target.Sector.CeilHeight - source.Sector.CeilHeight) / texturescaley) * linescaley);
|
|
|
|
|
return ((int)Tools.GetSidedefTopOffsetY(target, target.OffsetY + GetSidedefValue(target, matchingparttype, "offsety", 0f), linescaley, false) + partheight) % textureheight;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-23 15:26:31 +00:00
|
|
|
|
if (target.Other != null && target.LowTexture == texturename
|
|
|
|
|
&& partsize.IntersectsWith(BuilderModesTools.GetSidedefPartSize(target, VisualGeometryType.WALL_LOWER)))
|
2014-09-23 21:34:50 +00:00
|
|
|
|
{
|
2014-09-29 14:05:38 +00:00
|
|
|
|
matchingparttype = VisualGeometryType.WALL_LOWER;
|
|
|
|
|
int partheight = (int)Math.Round(((target.Sector.CeilHeight - source.Sector.CeilHeight) / texturescaley) * linescaley);
|
|
|
|
|
return ((int)Tools.GetSidedefBottomOffsetY(target, target.OffsetY + GetSidedefValue(target, matchingparttype, "offsety", 0f), linescaley, false) + partheight) % textureheight;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 14:05:38 +00:00
|
|
|
|
matchingparttype = VisualGeometryType.UNKNOWN;
|
2014-09-23 21:34:50 +00:00
|
|
|
|
return int.MinValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|