mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
Implement FOF texture alignment
This commit is contained in:
parent
ba064bae3e
commit
ac9b6137b2
3 changed files with 99 additions and 12 deletions
|
@ -4844,8 +4844,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(start.GeometryType == VisualGeometryType.WALL_MIDDLE_3D)
|
||||
{
|
||||
first.controlSide = start.GetControlLinedef().Front;
|
||||
first.offsetx += first.controlSide.OffsetX;
|
||||
ystartalign += first.controlSide.OffsetY;
|
||||
//first.offsetx += first.controlSide.OffsetX;
|
||||
//ystartalign += first.controlSide.OffsetY;
|
||||
ystartalign = first.controlSide.OffsetY;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4889,8 +4890,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(j.forward)
|
||||
{
|
||||
// Apply alignment
|
||||
if(alignx) j.controlSide.OffsetX = (int)j.offsetx;
|
||||
if(aligny) j.sidedef.OffsetY = (int)Math.Round((first.ceilingHeight - j.ceilingHeight) / scaley) + ystartalign;
|
||||
//if(alignx) j.controlSide.OffsetX = (int)j.offsetx;
|
||||
//if(aligny) j.sidedef.OffsetY = (int)Math.Round((first.ceilingHeight - j.ceilingHeight) / scaley) + ystartalign;
|
||||
if (alignx) j.sidedef.OffsetX = (int)j.offsetx;
|
||||
if (aligny) j.controlSide.OffsetY = (int)Math.Round((first.ceilingHeight - j.ceilingHeight) / scaley) + ystartalign;
|
||||
int forwardoffset = (int)j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex);
|
||||
int backwardoffset = (int)j.offsetx;
|
||||
|
||||
|
@ -4901,7 +4904,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(texture.IsImageLoaded && BuilderModesTools.SidedefTextureMatch(this, j.sidedef, texturehashes))
|
||||
{
|
||||
if(alignx) j.sidedef.OffsetX %= texture.Width;
|
||||
if(aligny) j.sidedef.OffsetY %= texture.Height;
|
||||
//if(aligny) j.sidedef.OffsetY %= texture.Height;
|
||||
if(aligny) j.controlSide.OffsetY %= texture.Height;
|
||||
}
|
||||
|
||||
// Add sidedefs backward (connected to the left vertex)
|
||||
|
@ -4915,8 +4919,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
else
|
||||
{
|
||||
// Apply alignment
|
||||
if(alignx) j.controlSide.OffsetX = (int)j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex);
|
||||
if(aligny) j.sidedef.OffsetY = (int)Math.Round((first.ceilingHeight - j.ceilingHeight) / scaley) + ystartalign;
|
||||
//if(alignx) j.controlSide.OffsetX = (int)j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex);
|
||||
//if(aligny) j.sidedef.OffsetY = (int)Math.Round((first.ceilingHeight - j.ceilingHeight) / scaley) + ystartalign;
|
||||
if (alignx) j.sidedef.OffsetX = (int)j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex);
|
||||
if (aligny) j.controlSide.OffsetY = (int)Math.Round((first.ceilingHeight - j.ceilingHeight) / scaley) + ystartalign;
|
||||
int forwardoffset = (int)j.offsetx;
|
||||
int backwardoffset = (int)j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex);
|
||||
|
||||
|
@ -4927,7 +4933,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(texture.IsImageLoaded && BuilderModesTools.SidedefTextureMatch(this, j.sidedef, texturehashes))
|
||||
{
|
||||
if(alignx) j.sidedef.OffsetX %= texture.Width;
|
||||
if(aligny) j.sidedef.OffsetY %= texture.Height;
|
||||
//if(aligny) j.sidedef.OffsetY %= texture.Height;
|
||||
if (aligny) j.controlSide.OffsetY %= texture.Height;
|
||||
}
|
||||
|
||||
// Add sidedefs forward (connected to the right vertex)
|
||||
|
|
|
@ -564,7 +564,46 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Update the model sector to update all 3d floors
|
||||
mode.GetVisualSector(extrafloor.Linedef.Front.Sector).UpdateSectorGeometry(false);
|
||||
}
|
||||
|
||||
|
||||
// Texture offset change
|
||||
public override void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
|
||||
{
|
||||
if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
||||
undoticket = mode.CreateUndo("Change texture offsets");
|
||||
|
||||
//mxd
|
||||
if (General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets)
|
||||
{
|
||||
// Apply per-texture offsets
|
||||
MoveTextureOffset(-horizontal, -vertical);
|
||||
Point p = GetTextureOffset();
|
||||
mode.SetActionResult("Changed texture offsets to " + p.X + ", " + p.Y + ".");
|
||||
|
||||
// Update this part only
|
||||
this.Setup();
|
||||
}
|
||||
else
|
||||
{
|
||||
//mxd. Apply classic offsets
|
||||
Sidedef sourceside = extrafloor.Linedef.Front;
|
||||
bool textureloaded = (Texture != null && Texture.IsImageLoaded);
|
||||
Sidedef.OffsetX = (Sidedef.OffsetX - horizontal);
|
||||
if (textureloaded) Sidedef.OffsetX %= Texture.Width;
|
||||
sourceside.OffsetY = (sourceside.OffsetY - vertical);
|
||||
if (geometrytype != VisualGeometryType.WALL_MIDDLE && textureloaded) sourceside.OffsetY %= Texture.Height;
|
||||
|
||||
mode.SetActionResult("Changed texture offsets to " + Sidedef.OffsetX + ", " + sourceside.OffsetY + ".");
|
||||
|
||||
// Update all sidedef geometry
|
||||
VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);
|
||||
parts.SetupAllParts();
|
||||
}
|
||||
|
||||
//mxd. Update linked effects
|
||||
SectorData sd = mode.GetSectorDataEx(Sector.Sector);
|
||||
if (sd != null) sd.Reset(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
@ -101,9 +102,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Get texture scaled size. Round up, because that's apparently what GZDoom does
|
||||
Vector2D tsz = new Vector2D(Math.Ceiling(base.Texture.ScaledWidth / tscale.x), Math.Ceiling(base.Texture.ScaledHeight / tscale.y));
|
||||
|
||||
|
||||
// Get texture offsets
|
||||
Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY) + new Vector2D(sourceside.OffsetX, sourceside.OffsetY);
|
||||
//Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY) + new Vector2D(sourceside.OffsetX, sourceside.OffsetY);
|
||||
Vector2D tof = new Vector2D(Sidedef.OffsetX, 0.0f) + new Vector2D(0.0f, sourceside.OffsetY);
|
||||
tof = tof + toffset1 + toffset2;
|
||||
tof = tof / tscaleAbs;
|
||||
if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning)
|
||||
|
@ -265,7 +267,46 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.SetVertices(null); //mxd
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Texture offset change
|
||||
public override void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
|
||||
{
|
||||
if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
||||
undoticket = mode.CreateUndo("Change texture offsets");
|
||||
|
||||
//mxd
|
||||
if (General.Map.UDMF && General.Map.Config.UseLocalSidedefTextureOffsets)
|
||||
{
|
||||
// Apply per-texture offsets
|
||||
MoveTextureOffset(-horizontal, -vertical);
|
||||
Point p = GetTextureOffset();
|
||||
mode.SetActionResult("Changed texture offsets to " + p.X + ", " + p.Y + ".");
|
||||
|
||||
// Update this part only
|
||||
this.Setup();
|
||||
}
|
||||
else
|
||||
{
|
||||
//mxd. Apply classic offsets
|
||||
Sidedef sourceside = extrafloor.Linedef.Front;
|
||||
bool textureloaded = (Texture != null && Texture.IsImageLoaded);
|
||||
Sidedef.OffsetX = (Sidedef.OffsetX - horizontal);
|
||||
if (textureloaded) Sidedef.OffsetX %= Texture.Width;
|
||||
sourceside.OffsetY = (sourceside.OffsetY - vertical);
|
||||
if (geometrytype != VisualGeometryType.WALL_MIDDLE && textureloaded) sourceside.OffsetY %= Texture.Height;
|
||||
|
||||
mode.SetActionResult("Changed texture offsets to " + Sidedef.OffsetX + ", " + sourceside.OffsetY + ".");
|
||||
|
||||
// Update all sidedef geometry
|
||||
VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);
|
||||
parts.SetupAllParts();
|
||||
}
|
||||
|
||||
//mxd. Update linked effects
|
||||
SectorData sd = mode.GetSectorDataEx(Sector.Sector);
|
||||
if (sd != null) sd.Reset(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue