mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-01-31 05:00:34 +00:00
Visual Mode: almost-correct slope skewing on FOF sides
This commit is contained in:
parent
8ef05744f9
commit
03c008a174
1 changed files with 71 additions and 22 deletions
|
@ -97,7 +97,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Load sector data
|
||||
SectorData sd = mode.GetSectorData(Sidedef.Sector);
|
||||
|
||||
|
||||
//mxd. which texture we must use?
|
||||
long textureLong = 0;
|
||||
if((sourceside.Line.Args[2] & (int)Effect3DFloor.Flags.UseUpperTexture) != 0)
|
||||
|
@ -149,40 +149,89 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
tof = tof / tscale;
|
||||
if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning)
|
||||
tof = tof * base.Texture.Scale;
|
||||
|
||||
|
||||
// For Vavoom type 3D floors the ceiling is lower than floor and they are reversed.
|
||||
// We choose here.
|
||||
float sourcetopheight = extrafloor.VavoomType ? sourceside.Sector.FloorHeight : sourceside.Sector.CeilHeight;
|
||||
float sourcebottomheight = extrafloor.VavoomType ? sourceside.Sector.CeilHeight : sourceside.Sector.FloorHeight;
|
||||
|
||||
|
||||
// Determine texture coordinates plane as they would be in normal circumstances.
|
||||
// We can then use this plane to find any texture coordinate we need.
|
||||
// The logic here is the same as in the original VisualMiddleSingle (except that
|
||||
// the values are stored in a TexturePlane)
|
||||
// NOTE: I use a small bias for the floor height, because if the difference in
|
||||
// height is 0 then the TexturePlane doesn't work!
|
||||
TexturePlane tp = new TexturePlane();
|
||||
float floorbias = (sourcetopheight == sourcebottomheight) ? 1.0f : 0.0f;
|
||||
Vector3D vlt, vlb, vrt, vrb;
|
||||
Vector2D tlt, tlb, trt, trb;
|
||||
bool skew = General.Map.SRB2 && sourceside.Line.IsFlagSet(General.Map.Config.UpperUnpeggedFlag);
|
||||
|
||||
float topheight = skew ? extrafloor.Ceiling.plane.GetZ(vl) : sourcetopheight;
|
||||
float bottomheight = skew ? extrafloor.Floor.plane.GetZ(vl) : sourcebottomheight;
|
||||
float floorbias = (topheight == bottomheight) ? 1.0f : 0.0f;
|
||||
|
||||
tlt.x = tlb.x = 0;
|
||||
trt.x = trb.x = Sidedef.Line.Length;
|
||||
tlt.y = trt.y = 0;
|
||||
tlb.y = trb.y = (topheight - bottomheight) + floorbias;
|
||||
|
||||
float topheight2 = skew ? topheight : sourcetopheight;
|
||||
float bottomheight2 = skew ? bottomheight : sourcebottomheight;
|
||||
|
||||
// Correct to account for slopes
|
||||
if (General.Map.SRB2)
|
||||
{
|
||||
float slant;
|
||||
float texturevpeg;
|
||||
|
||||
if (!skew)
|
||||
{
|
||||
slant = 0;
|
||||
texturevpeg = 0;
|
||||
}
|
||||
else if (!IsLowerUnpegged())
|
||||
{
|
||||
slant = extrafloor.Floor.plane.GetZ(vr) - extrafloor.Floor.plane.GetZ(vl);
|
||||
texturevpeg = (sourcetopheight - sourcebottomheight) % Math.Abs(tsz.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
slant = extrafloor.Ceiling.plane.GetZ(vr) - extrafloor.Ceiling.plane.GetZ(vl);
|
||||
texturevpeg = 0;
|
||||
}
|
||||
|
||||
topheight2 = topheight + slant;
|
||||
bottomheight2 = bottomheight + slant;
|
||||
|
||||
tlt.y = trt.y = texturevpeg;
|
||||
tlb.y = trb.y = texturevpeg + (topheight - bottomheight) + floorbias;
|
||||
}
|
||||
|
||||
tp.trb.x = tp.tlt.x + Sidedef.Line.Length;
|
||||
tp.trb.y = tp.tlt.y + (sourcetopheight - sourcebottomheight) + floorbias;
|
||||
|
||||
// Apply texture offset
|
||||
tp.tlt += tof;
|
||||
tp.trb += tof;
|
||||
|
||||
tlt += tof;
|
||||
tlb += tof;
|
||||
trb += tof;
|
||||
trt += tof;
|
||||
|
||||
// Transform pixel coordinates to texture coordinates
|
||||
tp.tlt /= tsz;
|
||||
tp.trb /= tsz;
|
||||
|
||||
// Left top and right bottom of the geometry that
|
||||
tp.vlt = new Vector3D(vl.x, vl.y, sourcetopheight);
|
||||
tp.vrb = new Vector3D(vr.x, vr.y, sourcebottomheight + floorbias);
|
||||
|
||||
// Make the right-top coordinates
|
||||
tp.trt = new Vector2D(tp.trb.x, tp.tlt.y);
|
||||
tp.vrt = new Vector3D(tp.vrb.x, tp.vrb.y, tp.vlt.z);
|
||||
|
||||
tlt /= tsz;
|
||||
tlb /= tsz;
|
||||
trb /= tsz;
|
||||
trt /= tsz;
|
||||
|
||||
// Geometry coordinates
|
||||
vlt = new Vector3D(vl.x, vl.y, topheight + floorbias);
|
||||
vlb = new Vector3D(vl.x, vl.y, bottomheight + floorbias);
|
||||
vrb = new Vector3D(vr.x, vr.y, bottomheight2);
|
||||
vrt = new Vector3D(vr.x, vr.y, topheight2 + floorbias);
|
||||
|
||||
TexturePlane tp = new TexturePlane();
|
||||
tp.tlt = IsLowerUnpegged() ? tlb : tlt;
|
||||
tp.trb = trb;
|
||||
tp.trt = trt;
|
||||
tp.vlt = IsLowerUnpegged() ? vlb : vlt;
|
||||
tp.vrb = vrb;
|
||||
tp.vrt = vrt;
|
||||
|
||||
//mxd. Get ceiling and floor heights. Use our and neighbour sector's data
|
||||
SectorData sdo = mode.GetSectorData(Sidedef.Other.Sector);
|
||||
|
||||
|
|
Loading…
Reference in a new issue