Visual mode: vertical texture offsets of double sided middle textures are no longer clamped.

Visual mode: fixed a crash when trying to move texture offsets of invisible sidedef.
This commit is contained in:
MaxED 2013-08-28 14:53:21 +00:00
parent b84b613d4b
commit 4b9f2d886c
5 changed files with 26 additions and 17 deletions

View file

@ -370,7 +370,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected float getRoundedTextureOffset(float oldValue, float offset, float scale, float textureSize) {
if(offset == 0f) return oldValue;
float scaledOffset = offset * scale;
float result = (float)Math.Round((oldValue + scaledOffset) % textureSize);
float result = (float)Math.Round(oldValue + scaledOffset);
if (textureSize > 0) result %= textureSize;
if(result == oldValue) result += (scaledOffset < 0 ? -1 : 1);
return result;
}
@ -1101,8 +1102,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.SetActionResult("Changed texture offsets to " + p.X + ", " + p.Y + ".");
} else {
//mxd. Apply classic offsets
Sidedef.OffsetX = (Sidedef.OffsetX - horizontal) % Texture.Width;
Sidedef.OffsetY = (Sidedef.OffsetY - vertical) % Texture.Height;
Sidedef.OffsetX = (Sidedef.OffsetX - horizontal);
if (Texture != null) Sidedef.OffsetX %= Texture.Width;
Sidedef.OffsetY = (Sidedef.OffsetY - vertical);
if(geoType != VisualGeometryType.WALL_MIDDLE && Texture != null) Sidedef.OffsetY %= Texture.Height;
mode.SetActionResult("Changed texture offsets to " + Sidedef.OffsetX + ", " + Sidedef.OffsetY + ".");
}

View file

@ -233,8 +233,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
float oldy = Sidedef.Fields.GetValue("offsety_bottom", 0.0f);
float scalex = Sidedef.Fields.GetValue("scalex_bottom", 1.0f);
float scaley = Sidedef.Fields.GetValue("scaley_bottom", 1.0f);
Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, xy.X, scalex, Texture.Width)); //mxd
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, xy.Y, scaley, Texture.Height)); //mxd
Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, xy.X, scalex, Texture != null ? Texture.Width : -1)); //mxd
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, xy.Y, scaley, Texture != null ? Texture.Height : -1)); //mxd
}
protected override Point GetTextureOffset()

View file

@ -302,8 +302,11 @@ namespace CodeImp.DoomBuilder.BuilderModes {
float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f);
float scalex = Sidedef.Fields.GetValue("scalex_mid", 1.0f);
float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f);
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, xy.X, scalex, Texture.Width)); //mxd
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, xy.Y, scaley, Texture.Height)); //mxd
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, xy.X, scalex, Texture != null ? Texture.Width : -1)); //mxd
//mxd. Don't clamp offsetY of clipped mid textures
bool dontClamp = (Texture == null || Sidedef.IsFlagSet("clipmidtex") || Sidedef.Line.IsFlagSet("clipmidtex"));
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, xy.Y, scaley, dontClamp ? -1 : Texture.Height));
}
protected override Point GetTextureOffset()

View file

@ -130,17 +130,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
// height is 0 then the TexturePlane doesn't work!
TexturePlane tp = new TexturePlane();
float floorbias = (Sidedef.Sector.CeilHeight == Sidedef.Sector.FloorHeight) ? 1.0f : 0.0f;
float geotop = (float)Math.Min(Sidedef.Sector.CeilHeight, Sidedef.Other.Sector.CeilHeight);
float geobottom = (float)Math.Max(Sidedef.Sector.FloorHeight, Sidedef.Other.Sector.FloorHeight);
float geotop = Math.Min(Sidedef.Sector.CeilHeight, Sidedef.Other.Sector.CeilHeight);
float geobottom = Math.Max(Sidedef.Sector.FloorHeight, Sidedef.Other.Sector.FloorHeight);
float zoffset = Sidedef.Sector.CeilHeight - Sidedef.Other.Sector.CeilHeight; //mxd
// When lower unpegged is set, the middle texture is bound to the bottom
if(Sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
tp.tlt.y = tsz.y - (float)(geotop - geobottom);
tp.tlt.y = tsz.y - (geotop - geobottom);
if (zoffset > 0) tp.tlt.y -= zoffset; //mxd
tp.trb.x = tp.tlt.x + Sidedef.Line.Length;
tp.trb.y = tp.tlt.y + ((float)Sidedef.Sector.CeilHeight - ((float)Sidedef.Sector.FloorHeight + floorbias));
tp.trb.y = tp.tlt.y + (Sidedef.Sector.CeilHeight - (Sidedef.Sector.FloorHeight + floorbias));
// Apply texture offset
tp.tlt += tof;
@ -151,8 +151,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
tp.trb /= tsz;
// Left top and right bottom of the geometry that
tp.vlt = new Vector3D(vl.x, vl.y, (float)Sidedef.Sector.CeilHeight);
tp.vrb = new Vector3D(vr.x, vr.y, (float)Sidedef.Sector.FloorHeight + floorbias);
tp.vlt = new Vector3D(vl.x, vl.y, Sidedef.Sector.CeilHeight);
tp.vrb = new Vector3D(vr.x, vr.y, Sidedef.Sector.FloorHeight + floorbias);
// Make the right-top coordinates
tp.trt = new Vector2D(tp.trb.x, tp.tlt.y);
@ -283,8 +283,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f);
float scalex = Sidedef.Fields.GetValue("scalex_mid", 1.0f);
float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f);
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, xy.X, scalex, Texture.Width)); //mxd
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, xy.Y, scaley, Texture.Height)); //mxd
Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, xy.X, scalex, Texture != null ? Texture.Width : -1)); //mxd
//mxd. Don't clamp offsetY of clipped mid textures
bool dontClamp = (Texture == null || Sidedef.IsFlagSet("clipmidtex") || Sidedef.Line.IsFlagSet("clipmidtex"));
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, xy.Y, scaley, dontClamp ? -1 : Texture.Height));
}
protected override Point GetTextureOffset()

View file

@ -232,8 +232,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
float oldy = Sidedef.Fields.GetValue("offsety_top", 0.0f);
float scalex = Sidedef.Fields.GetValue("scalex_top", 1.0f);
float scaley = Sidedef.Fields.GetValue("scaley_top", 1.0f);
Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, xy.X, scalex, Texture.Width)); //mxd
Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, xy.Y, scaley, Texture.Height)); //mxd
Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, xy.X, scalex, Texture != null ? Texture.Width : -1)); //mxd
Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, xy.Y, scaley, Texture != null ? Texture.Height : -1)); //mxd
}
protected override Point GetTextureOffset()