Visual Mode, UDMF: "Auto-align Textures Y" action now takes surface peg type into account.

Visual Mode, UDMF: "Auto-align Textures Y" action now applies vertical scale of first (highlighted) surface to the rest of aligned surfaces.
Linedef Edit Form, UDMF: lower sidedef texture offsets were never displayed.
Some more changes in auto texture alignment of newly drawn lines.
BuilderEffects plugin should compile now.
This commit is contained in:
MaxED 2013-04-03 14:50:41 +00:00
parent 60682dab1c
commit b104e88a1d
4 changed files with 102 additions and 35 deletions

View file

@ -818,7 +818,7 @@ namespace CodeImp.DoomBuilder.Map
nsd.Marked = front.Marked; nsd.Marked = front.Marked;
// Make texture offset adjustments // Make texture offset adjustments
if(nsd.OffsetX != 0 || !General.Map.UDMF) //mxd if(!General.Map.UDMF) //mxd
nsd.OffsetX += (int)Vector2D.Distance(this.start.Position, this.end.Position); nsd.OffsetX += (int)Vector2D.Distance(this.start.Position, this.end.Position);
} }
@ -833,7 +833,7 @@ namespace CodeImp.DoomBuilder.Map
// Make texture offset adjustments // Make texture offset adjustments
//mxd //mxd
int distance = (int)Vector2D.Distance(nl.start.Position, nl.end.Position); int distance = (int)Vector2D.Distance(nl.start.Position, nl.end.Position);
if(back.OffsetX != 0 || General.Map.UDMF) if(General.Map.UDMF)
if(distance != 0) applyTextureOffsetUDMF(back, distance); if(distance != 0) applyTextureOffsetUDMF(back, distance);
else else
back.OffsetX += distance; back.OffsetX += distance;

View file

@ -324,8 +324,8 @@ namespace CodeImp.DoomBuilder.Windows
if(frontOffsetTopY.Text != getUDMFTextureOffset(l.Front.Fields, "offsety_top").ToString()) frontOffsetTopY.Text = ""; if(frontOffsetTopY.Text != getUDMFTextureOffset(l.Front.Fields, "offsety_top").ToString()) frontOffsetTopY.Text = "";
if(frontOffsetMidX.Text != getUDMFTextureOffset(l.Front.Fields, "offsetx_mid").ToString()) frontOffsetMidX.Text = ""; if(frontOffsetMidX.Text != getUDMFTextureOffset(l.Front.Fields, "offsetx_mid").ToString()) frontOffsetMidX.Text = "";
if(frontOffsetMidY.Text != getUDMFTextureOffset(l.Front.Fields, "offsety_mid").ToString()) frontOffsetMidY.Text = ""; if(frontOffsetMidY.Text != getUDMFTextureOffset(l.Front.Fields, "offsety_mid").ToString()) frontOffsetMidY.Text = "";
if(frontOffsetLowX.Text != getUDMFTextureOffset(l.Front.Fields, "offsetx_bottom ").ToString()) frontOffsetLowX.Text = ""; if(frontOffsetLowX.Text != getUDMFTextureOffset(l.Front.Fields, "offsetx_bottom").ToString()) frontOffsetLowX.Text = "";
if(frontOffsetLowY.Text != getUDMFTextureOffset(l.Front.Fields, "offsety_bottom ").ToString()) frontOffsetLowY.Text = ""; if(frontOffsetLowY.Text != getUDMFTextureOffset(l.Front.Fields, "offsety_bottom").ToString()) frontOffsetLowY.Text = "";
} }
if (frontoffsetx.Text != l.Front.OffsetX.ToString()) frontoffsetx.Text = ""; if (frontoffsetx.Text != l.Front.OffsetX.ToString()) frontoffsetx.Text = "";
@ -349,8 +349,8 @@ namespace CodeImp.DoomBuilder.Windows
if(backOffsetTopY.Text != getUDMFTextureOffset(l.Back.Fields, "offsety_top").ToString()) backOffsetTopY.Text = ""; if(backOffsetTopY.Text != getUDMFTextureOffset(l.Back.Fields, "offsety_top").ToString()) backOffsetTopY.Text = "";
if(backOffsetMidX.Text != getUDMFTextureOffset(l.Back.Fields, "offsetx_mid").ToString()) backOffsetMidX.Text = ""; if(backOffsetMidX.Text != getUDMFTextureOffset(l.Back.Fields, "offsetx_mid").ToString()) backOffsetMidX.Text = "";
if(backOffsetMidY.Text != getUDMFTextureOffset(l.Back.Fields, "offsety_mid").ToString()) backOffsetMidY.Text = ""; if(backOffsetMidY.Text != getUDMFTextureOffset(l.Back.Fields, "offsety_mid").ToString()) backOffsetMidY.Text = "";
if(backOffsetLowX.Text != getUDMFTextureOffset(l.Back.Fields, "offsetx_bottom ").ToString()) backOffsetLowX.Text = ""; if(backOffsetLowX.Text != getUDMFTextureOffset(l.Back.Fields, "offsetx_bottom").ToString()) backOffsetLowX.Text = "";
if(backOffsetLowY.Text != getUDMFTextureOffset(l.Back.Fields, "offsety_bottom ").ToString()) backOffsetLowY.Text = ""; if(backOffsetLowY.Text != getUDMFTextureOffset(l.Back.Fields, "offsety_bottom").ToString()) backOffsetLowY.Text = "";
} }
if (backoffsetx.Text != l.Back.OffsetX.ToString()) backoffsetx.Text = ""; if (backoffsetx.Text != l.Back.OffsetX.ToString()) backoffsetx.Text = "";
@ -421,8 +421,7 @@ namespace CodeImp.DoomBuilder.Windows
//mxd //mxd
private float getUDMFTextureOffset(UniFields fields, string key) { private float getUDMFTextureOffset(UniFields fields, string key) {
if (fields != null && fields.ContainsKey(key)) if(fields != null) return fields.GetValue(key, 0f);
return (float)fields[key].Value;
return 0; return 0;
} }

View file

@ -55,7 +55,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BuilderPlug.cs" /> <Compile Include="BuilderPlug.cs" />
<Compile Include="ClassicModes\ArrayDuplicateMode.cs" />
<Compile Include="Controls\NumericUpDownEx.cs"> <Compile Include="Controls\NumericUpDownEx.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>

View file

@ -108,6 +108,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public Sidedef controlSide; //mxd public Sidedef controlSide; //mxd
public float offsetx; public float offsetx;
public float scaleY; //mxd
// When this is true, the previous sidedef was on the left of // When this is true, the previous sidedef was on the left of
// this one and the texture X offset of this sidedef can be set // this one and the texture X offset of this sidedef can be set
@ -2448,11 +2449,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Add sidedefs forward (connected to the right vertex) // Add sidedefs forward (connected to the right vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start; v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start;
AddSidedefsForAlignment(todo, v, true, forwardoffset, texture.LongName, false); AddSidedefsForAlignment(todo, v, true, forwardoffset, 1.0f, texture.LongName, false);
// Add sidedefs backward (connected to the left vertex) // Add sidedefs backward (connected to the left vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End; v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End;
AddSidedefsForAlignment(todo, v, false, backwardoffset, texture.LongName, false); AddSidedefsForAlignment(todo, v, false, backwardoffset, 1.0f, texture.LongName, false);
} else { } else {
Vertex v; Vertex v;
int forwardoffset; int forwardoffset;
@ -2479,11 +2480,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Add sidedefs backward (connected to the left vertex) // Add sidedefs backward (connected to the left vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End; v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End;
AddSidedefsForAlignment(todo, v, false, backwardoffset, texture.LongName, false); AddSidedefsForAlignment(todo, v, false, backwardoffset, 1.0f, texture.LongName, false);
// Add sidedefs forward (connected to the right vertex) // Add sidedefs forward (connected to the right vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start; v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start;
AddSidedefsForAlignment(todo, v, true, forwardoffset, texture.LongName, false); AddSidedefsForAlignment(todo, v, true, forwardoffset, 1.0f, texture.LongName, false);
} }
} }
} }
@ -2510,13 +2511,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
float ystartalign = start.OffsetY; float ystartalign = start.OffsetY;
switch(part) { switch(part) {
case SidedefPart.Upper: case SidedefPart.Upper:
ystartalign += start.Fields.GetValue("offsety_top", 0.0f); ystartalign += getTopOffsetY(start, start.Fields.GetValue("offsety_top", 0.0f), false);//mxd
break; break;
case SidedefPart.Middle: case SidedefPart.Middle:
ystartalign += start.Fields.GetValue("offsety_mid", 0.0f); ystartalign += getMiddleOffsetY(start, start.Fields.GetValue("offsety_mid", 0.0f), false);//mxd
break; //mxd break;
case SidedefPart.Lower: case SidedefPart.Lower:
ystartalign += start.Fields.GetValue("offsety_bottom", 0.0f); ystartalign += getBottomOffsetY(start, start.Fields.GetValue("offsety_bottom", 0.0f), false);//mxd
break; break;
} }
@ -2530,7 +2531,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
break; break;
case SidedefPart.Middle: case SidedefPart.Middle:
first.offsetx += start.Fields.GetValue("offsetx_mid", 0.0f); first.offsetx += start.Fields.GetValue("offsetx_mid", 0.0f);
break; //mxd break;
case SidedefPart.Lower: case SidedefPart.Lower:
first.offsetx += start.Fields.GetValue("offsetx_bottom", 0.0f); first.offsetx += start.Fields.GetValue("offsetx_bottom", 0.0f);
break; break;
@ -2551,6 +2552,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
first.controlSide = start; first.controlSide = start;
} }
//mxd. scaleY
switch(part) {
case SidedefPart.Upper:
first.scaleY = start.Fields.GetValue("scaley_top", 1.0f);
break;
case SidedefPart.Middle:
first.scaleY = start.Fields.GetValue("scaley_mid", 1.0f);
break;
case SidedefPart.Lower:
first.scaleY = start.Fields.GetValue("scaley_bottom", 1.0f);
break;
}
todo.Push(first); todo.Push(first);
// Continue until nothing more to align // Continue until nothing more to align
@ -2574,6 +2588,24 @@ namespace CodeImp.DoomBuilder.BuilderModes
else if(matchmid) else if(matchmid)
offsetscalex = j.sidedef.Fields.GetValue("scalex_mid", 1.0f); offsetscalex = j.sidedef.Fields.GetValue("scalex_mid", 1.0f);
//mxd. Apply scaleY
j.sidedef.Fields.BeforeFieldsChange();
if(j.scaleY == 1.0f) {
if(matchtop && j.sidedef.Fields.GetValue("scaley_top", 1.0f) != 1.0f)
j.sidedef.Fields.Remove("scaley_top");
else if(matchmid && j.sidedef.Fields.GetValue("scaley_mid", 1.0f) != 1.0f)
j.sidedef.Fields.Remove("scaley_mid");
else if(matchbottom && j.sidedef.Fields.GetValue("scaley_bottom", 1.0f) != 1.0f)
j.sidedef.Fields.Remove("scaley_bottom");
} else {
if(matchtop && j.sidedef.Fields.GetValue("scaley_top", 1.0f) != j.scaleY)
j.sidedef.Fields["scaley_top"] = new UniValue(UniversalType.Float, j.scaleY);
if(matchmid && j.sidedef.Fields.GetValue("scaley_mid", 1.0f) != j.scaleY)
j.sidedef.Fields["scaley_mid"] = new UniValue(UniversalType.Float, j.scaleY);
if(matchbottom && j.sidedef.Fields.GetValue("scaley_bottom", 1.0f) != j.scaleY)
j.sidedef.Fields["scaley_bottom"] = new UniValue(UniversalType.Float, j.scaleY);
}
if(j.forward) { if(j.forward) {
// Apply alignment // Apply alignment
if(alignx) { if(alignx) {
@ -2591,22 +2623,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
if(aligny) { if(aligny) {
float offset = ((float)(start.Sector.CeilHeight - j.sidedef.Sector.CeilHeight) / scaley) + ystartalign; float offset = ((float)(start.Sector.CeilHeight - j.sidedef.Sector.CeilHeight) / scaley) + ystartalign;
offset %= (float)texture.Height;
offset -= j.sidedef.OffsetY; offset -= j.sidedef.OffsetY;
j.sidedef.Fields.BeforeFieldsChange(); j.sidedef.Fields.BeforeFieldsChange();
if(matchtop) if(matchtop)
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getTopOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
if(matchbottom) if(matchbottom)
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getBottomOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
if(matchmid) { if(matchmid) {
//mxd. Side is part of a 3D floor? //mxd. Side is part of a 3D floor?
if(j.sidedef.Index != j.controlSide.Index) { if(j.sidedef.Index != j.controlSide.Index) {
offset = ((float)(start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign; offset = ((float)(start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign;
offset %= (float)texture.Height;
offset -= j.sidedef.OffsetY; offset -= j.sidedef.OffsetY;
} }
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getMiddleOffsetY(j.sidedef, offset, true) % (float)texture.Height);//mxd
} }
} }
forwardoffset = j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex * offsetscalex); forwardoffset = j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex * offsetscalex);
@ -2617,11 +2647,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Add sidedefs backward (connected to the left vertex) // Add sidedefs backward (connected to the left vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End; v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End;
AddSidedefsForAlignment(todo, v, false, backwardoffset, texture.LongName, true); AddSidedefsForAlignment(todo, v, false, backwardoffset, j.scaleY, texture.LongName, true);
// Add sidedefs forward (connected to the right vertex) // Add sidedefs forward (connected to the right vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start; v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start;
AddSidedefsForAlignment(todo, v, true, forwardoffset, texture.LongName, true); AddSidedefsForAlignment(todo, v, true, forwardoffset, j.scaleY, texture.LongName, true);
} else { } else {
// Apply alignment // Apply alignment
if(alignx) { if(alignx) {
@ -2639,22 +2669,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
if(aligny) { if(aligny) {
float offset = ((float)(start.Sector.CeilHeight - j.sidedef.Sector.CeilHeight) / scaley) + ystartalign; float offset = ((float)(start.Sector.CeilHeight - j.sidedef.Sector.CeilHeight) / scaley) + ystartalign;
offset %= (float)texture.Height;
offset -= j.sidedef.OffsetY; offset -= j.sidedef.OffsetY;
j.sidedef.Fields.BeforeFieldsChange(); j.sidedef.Fields.BeforeFieldsChange();
if(matchtop) if(matchtop)
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getTopOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
if(matchbottom) if(matchbottom)
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getBottomOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
if(matchmid) { if(matchmid) {
//mxd. Side is part of a 3D floor? //mxd. Side is part of a 3D floor?
if(j.sidedef.Index != j.controlSide.Index) { if(j.sidedef.Index != j.controlSide.Index) {
offset = ((float)(start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign; offset = ((float)(start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign;
offset %= (float)texture.Height;
offset -= j.sidedef.OffsetY; offset -= j.sidedef.OffsetY;
} }
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getMiddleOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
} }
} }
forwardoffset = j.offsetx; forwardoffset = j.offsetx;
@ -2665,17 +2693,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Add sidedefs forward (connected to the right vertex) // Add sidedefs forward (connected to the right vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start; v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start;
AddSidedefsForAlignment(todo, v, true, forwardoffset, texture.LongName, true); AddSidedefsForAlignment(todo, v, true, forwardoffset, j.scaleY, texture.LongName, true);
// Add sidedefs backward (connected to the left vertex) // Add sidedefs backward (connected to the left vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End; v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End;
AddSidedefsForAlignment(todo, v, false, backwardoffset, texture.LongName, true); AddSidedefsForAlignment(todo, v, false, backwardoffset, j.scaleY, texture.LongName, true);
} }
} }
} }
// This adds the matching, unmarked sidedefs from a vertex for texture alignment // This adds the matching, unmarked sidedefs from a vertex for texture alignment
private void AddSidedefsForAlignment(Stack<SidedefAlignJob> stack, Vertex v, bool forward, float offsetx, long texturelongname, bool udmf) { private void AddSidedefsForAlignment(Stack<SidedefAlignJob> stack, Vertex v, bool forward, float offsetx, float scaleY, long texturelongname, bool udmf) {
foreach(Linedef ld in v.Linedefs) { foreach(Linedef ld in v.Linedefs) {
Sidedef side1 = forward ? ld.Front : ld.Back; Sidedef side1 = forward ? ld.Front : ld.Back;
Sidedef side2 = forward ? ld.Back : ld.Front; Sidedef side2 = forward ? ld.Back : ld.Front;
@ -2687,8 +2715,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
SidedefAlignJob nj = new SidedefAlignJob(); SidedefAlignJob nj = new SidedefAlignJob();
nj.forward = forward; nj.forward = forward;
nj.offsetx = offsetx; nj.offsetx = offsetx;
nj.scaleY = scaleY; //mxd
nj.sidedef = side1; nj.sidedef = side1;
nj.controlSide = s; nj.controlSide = s; //mxd
stack.Push(nj); stack.Push(nj);
break; break;
} }
@ -2701,8 +2730,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
SidedefAlignJob nj = new SidedefAlignJob(); SidedefAlignJob nj = new SidedefAlignJob();
nj.forward = forward; nj.forward = forward;
nj.offsetx = offsetx; nj.offsetx = offsetx;
nj.scaleY = scaleY; //mxd
nj.sidedef = side2; nj.sidedef = side2;
nj.controlSide = s; nj.controlSide = s; //mxd
stack.Push(nj); stack.Push(nj);
break; break;
} }
@ -2711,6 +2741,45 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
} }
//mxd. This converts offsetY from/to "normalized" offset for given upper wall
private float getTopOffsetY(Sidedef side, float offset, bool fromNormalized) {
if(side.Line.IsFlagSet(General.Map.Config.UpperUnpeggedFlag) || side.Other == null || side.Other.Sector == null)
return offset;
//if we don't have UpperUnpegged flag, normalize offset
float scale = side.Fields.GetValue("scaley_top", 1.0f);
float surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.CeilHeight) * scale;
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
return (float)Math.Round(offset - surfaceHeight);
}
//mxd. This converts offsetY from/to "normalized" offset for given middle wall
private float getMiddleOffsetY(Sidedef side, float offset, bool fromNormalized) {
if(!side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Sector == null)
return offset;
//if we have LowerUnpegged flag, normalize offset
float scale = side.Fields.GetValue("scaley_mid", 1.0f);
float surfaceHeight = (side.Sector.CeilHeight - side.Sector.FloorHeight) * scale;
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
return (float)Math.Round(offset - surfaceHeight);
}
//mxd. This converts offsetY from/to "normalized" offset for given lower wall
private float getBottomOffsetY(Sidedef side, float offset, bool fromNormalized) {
if(side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Other == null || side.Other.Sector == null)
return offset;
//if we don't have LowerUnpegged flag, normalize offset
float scale = side.Fields.GetValue("scaley_bottom", 1.0f);
float surfaceHeight = (side.Sector.CeilHeight - (side.Other.Sector.FloorHeight - side.Sector.FloorHeight)) * scale;
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
return (float)Math.Round(offset - surfaceHeight);
}
//mxd //mxd
private List<Sidedef> getControlSides(Sidedef side, bool udmf) { private List<Sidedef> getControlSides(Sidedef side, bool udmf) {
if(side.Other == null) return new List<Sidedef>() { side }; if(side.Other == null) return new List<Sidedef>() { side };