mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
Visual mode: fixed incorrect sidedef texture mouse dragging when texture was scaled in TEXTURES.
Visual mode: texture offsets are now clamped to texture size when dragging textures with mouse. Visual mode, UDMF: when gravity is enabled, sector gravity now affects camera movement.
This commit is contained in:
parent
b39dcdcb9a
commit
82722e546c
11 changed files with 46 additions and 34 deletions
|
@ -147,13 +147,13 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
}
|
||||
|
||||
//mxd
|
||||
public bool IntersectPoint(Vector2D point) {
|
||||
/*public bool IntersectPoint(Vector2D point) {
|
||||
for (int i = 0; i < lines.Length; i++) {
|
||||
if (lines[i].GetSideOfLine(point) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
private Vector3D movemultiplier;
|
||||
private float anglexy, anglez;
|
||||
private Sector sector;
|
||||
private float gravity = 1.0f; //mxd
|
||||
private bool udmf; //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -38,8 +40,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public Vector3D Target { get { return target; } }
|
||||
public float AngleXY { get { return anglexy; } set { anglexy = value; } }
|
||||
public float AngleZ { get { return anglez; } set { anglez = value; } }
|
||||
public Sector Sector { get { return sector; } internal set { sector = value; } }
|
||||
public Sector Sector { get { return sector; } internal set { sector = value; updateGravity(); } } //mxd
|
||||
public Vector3D MoveMultiplier { get { return movemultiplier; } set { movemultiplier = value; } }
|
||||
public float Gravity { get { return gravity; } } //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -49,11 +52,11 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public VisualCamera()
|
||||
{
|
||||
// Initialize
|
||||
this.movemultiplier = new Vector3D(1.0f, 1.0f, 1.0f);
|
||||
//this.position = position;
|
||||
this.anglexy = 0.0f;
|
||||
this.anglez = Angle2D.PI;
|
||||
this.sector = null;
|
||||
movemultiplier = new Vector3D(1.0f, 1.0f, 1.0f);
|
||||
anglexy = 0.0f;
|
||||
anglez = Angle2D.PI;
|
||||
sector = null;
|
||||
udmf = General.Map.UDMF; //mxd
|
||||
|
||||
PositionAtThing();
|
||||
}
|
||||
|
@ -160,6 +163,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
private void updateGravity() {
|
||||
if(!udmf || sector == null) return;
|
||||
gravity = sector.Fields.GetValue("gravity", 1.0f);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -369,10 +369,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd
|
||||
protected float getRoundedTextureOffset(float oldValue, float offset, float scale) {
|
||||
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);
|
||||
float result = (float)Math.Round((oldValue + scaledOffset) % textureSize);
|
||||
if(result == oldValue) result += (scaledOffset < 0 ? -1 : 1);
|
||||
return result;
|
||||
}
|
||||
|
@ -1102,9 +1102,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Point p = GetTextureOffset();
|
||||
mode.SetActionResult("Changed texture offsets to " + p.X + ", " + p.Y + ".");
|
||||
} else {
|
||||
// Apply classic offsets
|
||||
Sidedef.OffsetX -= horizontal;
|
||||
Sidedef.OffsetY -= vertical;
|
||||
//mxd. Apply classic offsets
|
||||
Sidedef.OffsetX = (Sidedef.OffsetX - horizontal) % Texture.Width;
|
||||
Sidedef.OffsetY = (Sidedef.OffsetY - vertical) % Texture.Height;
|
||||
|
||||
mode.SetActionResult("Changed texture offsets to " + Sidedef.OffsetX + ", " + Sidedef.OffsetY + ".");
|
||||
}
|
||||
|
||||
|
|
|
@ -1008,7 +1008,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
else
|
||||
{
|
||||
// Fall down
|
||||
gravity.z += GRAVITY * deltatime;
|
||||
gravity.z += GRAVITY * General.Map.VisualCamera.Gravity * deltatime;
|
||||
if(gravity.z > 3.0f) gravity.z = 3.0f;
|
||||
|
||||
// Test if we don't go through a floor
|
||||
|
@ -1324,13 +1324,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
Dictionary<Sidedef, int> donesides = new Dictionary<Sidedef, int>(selectedobjects.Count);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
foreach(IVisualEventReceiver i in objs)
|
||||
{
|
||||
if(i is BaseVisualGeometrySidedef)
|
||||
{
|
||||
if(!donesides.ContainsKey((i as BaseVisualGeometrySidedef).Sidedef))
|
||||
foreach(IVisualEventReceiver i in objs) {
|
||||
BaseVisualGeometrySidedef vs = i as BaseVisualGeometrySidedef; //mxd
|
||||
|
||||
if(i is BaseVisualGeometrySidedef) {
|
||||
if(!donesides.ContainsKey(vs.Sidedef))
|
||||
{
|
||||
i.OnChangeTextureOffset(dx, dy, false);
|
||||
//mxd. added scaling by texture scale
|
||||
if(vs.Texture.UsedInMap) //mxd. Otherwise it's MissingTexture3D and we probably don't want to drag that
|
||||
vs.OnChangeTextureOffset((int)(dx / vs.Texture.Scale.x), (int)(dy / vs.Texture.Scale.y), false);
|
||||
donesides.Add((i as BaseVisualGeometrySidedef).Sidedef, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,8 +178,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
Sector s = GetControlSector();
|
||||
s.Fields.BeforeFieldsChange();
|
||||
float nx = s.Fields.GetValue("xpanningceiling", 0.0f) + (float)xy.X;
|
||||
float ny = s.Fields.GetValue("ypanningceiling", 0.0f) + (float)xy.Y;
|
||||
float nx = (s.Fields.GetValue("xpanningceiling", 0.0f) + xy.X) % (Texture.ScaledWidth / s.Fields.GetValue("xscaleceiling", 1.0f));
|
||||
float ny = (s.Fields.GetValue("ypanningceiling", 0.0f) + xy.Y) % (Texture.ScaledHeight / s.Fields.GetValue("yscaleceiling", 1.0f));
|
||||
s.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, nx);
|
||||
s.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, ny);
|
||||
s.UpdateNeeded = true;
|
||||
|
|
|
@ -181,8 +181,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
Sector s = GetControlSector();
|
||||
s.Fields.BeforeFieldsChange();
|
||||
float nx = s.Fields.GetValue("xpanningfloor", 0.0f) + (float)xy.X;
|
||||
float ny = s.Fields.GetValue("ypanningfloor", 0.0f) + (float)xy.Y;
|
||||
float nx = (s.Fields.GetValue("xpanningfloor", 0.0f) + xy.X) % (Texture.ScaledWidth / s.Fields.GetValue("xscalefloor", 1.0f));
|
||||
float ny = (s.Fields.GetValue("ypanningfloor", 0.0f) + xy.Y) % (Texture.ScaledHeight / s.Fields.GetValue("yscalefloor", 1.0f));
|
||||
s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, nx);
|
||||
s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, ny);
|
||||
s.UpdateNeeded = true;
|
||||
|
|
|
@ -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, (float)xy.X, scalex)); //mxd
|
||||
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
|
||||
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
|
||||
}
|
||||
|
||||
protected override Point GetTextureOffset()
|
||||
|
|
|
@ -302,8 +302,8 @@ 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, (float)xy.X, scalex)); //mxd
|
||||
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
|
||||
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
|
||||
}
|
||||
|
||||
protected override Point GetTextureOffset()
|
||||
|
|
|
@ -281,8 +281,8 @@ 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, (float)xy.X, scalex)); //mxd
|
||||
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
|
||||
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
|
||||
}
|
||||
|
||||
protected override Point GetTextureOffset()
|
||||
|
|
|
@ -229,8 +229,8 @@ 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, (float)xy.X, scalex)); //mxd
|
||||
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
|
||||
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
|
||||
}
|
||||
|
||||
protected override Point GetTextureOffset()
|
||||
|
|
|
@ -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, (float)xy.X, scalex)); //mxd
|
||||
Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd
|
||||
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
|
||||
}
|
||||
|
||||
protected override Point GetTextureOffset()
|
||||
|
|
Loading…
Reference in a new issue