Merged in GZDB r2474.

This commit is contained in:
MascaraSnake 2016-01-23 03:53:31 +01:00
parent 5ca6994d12
commit 5cf574f42d
6 changed files with 140 additions and 115 deletions

View file

@ -155,7 +155,8 @@ namespace CodeImp.DoomBuilder.VisualModes
triangles = vertices.Length / 3; triangles = vertices.Length / 3;
CalculateNormals(); //mxd CalculateNormals(); //mxd
} PerformAutoSelection(); //mxd
}
else else
{ {
vertices = null; vertices = null;
@ -266,11 +267,14 @@ namespace CodeImp.DoomBuilder.VisualModes
return false; return false;
} }
#endregion //mxd
} protected abstract void PerformAutoSelection();
//mxd #endregion
public enum VisualGeometryType }
//mxd
public enum VisualGeometryType
{ {
FLOOR, FLOOR,
CEILING, CEILING,

View file

@ -64,16 +64,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
private int startoffsety; private int startoffsety;
protected bool uvdragging; protected bool uvdragging;
private int prevoffsetx; // We have to provide delta offsets, but I don't private int prevoffsetx; // We have to provide delta offsets, but I don't
private int prevoffsety; // want to calculate with delta offsets to prevent private int prevoffsety; // want to calculate with delta offsets to prevent
// inaccuracy in the dragging. // inaccuracy in the dragging.
private static List<BaseVisualSector> updateList; //mxd private static List<BaseVisualSector> updatelist; //mxd
protected bool performautoselection; //mxd
#endregion #endregion
#region ================== Properties #region ================== Properties
new public BaseVisualSector Sector { get { return (BaseVisualSector)base.Sector; } } new public BaseVisualSector Sector { get { return (BaseVisualSector)base.Sector; } }
public bool Changed { get { return changed; } set { changed = value; } } public bool Changed { get { return changed; } set { changed = value; } }
public SectorLevel Level { get { return level; } } public SectorLevel Level { get { return level; } }
public Effect3DFloor ExtraFloor { get { return extrafloor; } } public Effect3DFloor ExtraFloor { get { return extrafloor; } }
@ -98,8 +99,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected abstract void UpdateSkyRenderFlag(); //mxd protected abstract void UpdateSkyRenderFlag(); //mxd
public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
// This swaps triangles so that the plane faces the other way //mxd
protected static void SwapTriangleVertices(WorldVertex[] verts) override protected void PerformAutoSelection()
{
if (!performautoselection) return;
if (Triangles > 0)
{
this.selected = true;
mode.AddSelectedObject(this);
}
performautoselection = false;
}
// This swaps triangles so that the plane faces the other way
protected static void SwapTriangleVertices(WorldVertex[] verts)
{ {
// Swap some vertices to flip all triangles // Swap some vertices to flip all triangles
for(int i = 0; i < verts.Length; i += 3) for(int i = 0; i < verts.Length; i += 3)
@ -776,12 +790,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
//mxd //mxd
List<Sector> sectors = mode.GetSelectedSectors(); List<Sector> sectors = mode.GetSelectedSectors();
updateList = new List<BaseVisualSector>(); updatelist = new List<BaseVisualSector>();
foreach(Sector s in sectors) foreach(Sector s in sectors)
{ {
if(mode.VisualSectorExists(s)) if(mode.VisualSectorExists(s))
updateList.Add((BaseVisualSector)mode.GetVisualSector(s)); updatelist.Add((BaseVisualSector)mode.GetVisualSector(s));
} }
General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged; //mxd General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged; //mxd
@ -790,8 +804,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.StopRealtimeInterfaceUpdate(SelectionType.Sectors); //mxd mode.StopRealtimeInterfaceUpdate(SelectionType.Sectors); //mxd
General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged; //mxd General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged; //mxd
updateList.Clear(); //mxd updatelist.Clear(); //mxd
updateList = null; //mxd updatelist = null; //mxd
if(result == DialogResult.OK) mode.RebuildElementData(); //mxd if(result == DialogResult.OK) mode.RebuildElementData(); //mxd
} }
@ -800,7 +814,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd //mxd
private void Interface_OnEditFormValuesChanged(object sender, EventArgs e) private void Interface_OnEditFormValuesChanged(object sender, EventArgs e)
{ {
foreach(BaseVisualSector vs in updateList) vs.UpdateSectorGeometry(true); foreach(BaseVisualSector vs in updatelist) vs.UpdateSectorGeometry(true);
} }
// Sector height change // Sector height change

View file

@ -59,12 +59,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
private int startoffsety; private int startoffsety;
protected bool uvdragging; protected bool uvdragging;
private int prevoffsetx; // We have to provide delta offsets, but I don't private int prevoffsetx; // We have to provide delta offsets, but I don't
private int prevoffsety; // want to calculate with delta offsets to prevent private int prevoffsety; // want to calculate with delta offsets to prevent
// inaccuracy in the dragging. // inaccuracy in the dragging.
private static List<BaseVisualSector> updateList; //mxd private static List<BaseVisualSector> updatelist; //mxd
private bool performautoselection; //mxd
// Undo/redo // Undo/redo
private int undoticket; private int undoticket;
#endregion #endregion
@ -84,21 +85,38 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.deltaz = new Vector3D(0.0f, 0.0f, 1.0f); this.deltaz = new Vector3D(0.0f, 0.0f, 1.0f);
this.deltaxy = (sd.Line.End.Position - sd.Line.Start.Position) * sd.Line.LengthInv; this.deltaxy = (sd.Line.End.Position - sd.Line.Start.Position) * sd.Line.LengthInv;
if(!sd.IsFront) this.deltaxy = -this.deltaxy; if(!sd.IsFront) this.deltaxy = -this.deltaxy;
this.performautoselection = (mode.UseSelectionFromClassicMode && sd.Line.Selected); //mxd
}
//mxd #endregion
if(mode.UseSelectionFromClassicMode && sd.Line.Selected)
{
this.selected = true;
mode.AddSelectedObject(this);
}
}
#endregion #region ================== Methods
#region ================== Methods //mxd
override protected void PerformAutoSelection()
{
if (!performautoselection) return;
if (Triangles > 0)
{
dragstartanglexy = General.Map.VisualCamera.AngleXY;
dragstartanglez = General.Map.VisualCamera.AngleZ;
dragorigin = pickintersect;
// This sets the renderstyle from linedef information and returns the alpha value or the vertices Point texoffset = GetTextureOffset();
protected byte SetLinedefRenderstyle(bool solidasmask) startoffsetx = texoffset.X;
startoffsety = texoffset.Y;
prevoffsetx = texoffset.X;
prevoffsety = texoffset.Y;
this.selected = true;
mode.AddSelectedObject(this);
}
performautoselection = false;
}
// This sets the renderstyle from linedef information and returns the alpha value or the vertices
protected byte SetLinedefRenderstyle(bool solidasmask)
{ {
byte alpha; byte alpha;
bool canhavealpha = (this is VisualMiddleDouble || this is VisualMiddle3D || this is VisualMiddleBack); //mxd bool canhavealpha = (this is VisualMiddleDouble || this is VisualMiddle3D || this is VisualMiddleBack); //mxd
@ -1167,11 +1185,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
dragstartanglexy = General.Map.VisualCamera.AngleXY; dragstartanglexy = General.Map.VisualCamera.AngleXY;
dragstartanglez = General.Map.VisualCamera.AngleZ; dragstartanglez = General.Map.VisualCamera.AngleZ;
dragorigin = pickintersect; dragorigin = pickintersect;
startoffsetx = GetTextureOffset().X;
startoffsety = GetTextureOffset().Y; Point texoffset = GetTextureOffset(); //mxd
prevoffsetx = GetTextureOffset().X; startoffsetx = texoffset.X;
prevoffsety = GetTextureOffset().Y; startoffsety = texoffset.Y;
} prevoffsetx = texoffset.X;
prevoffsety = texoffset.Y;
}
// Select button released // Select button released
public virtual void OnSelectEnd() public virtual void OnSelectEnd()
@ -1206,13 +1226,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(General.Interface.IsActiveWindow) if(General.Interface.IsActiveWindow)
{ {
List<Linedef> linedefs = mode.GetSelectedLinedefs(); List<Linedef> linedefs = mode.GetSelectedLinedefs();
updateList = new List<BaseVisualSector>(); //mxd updatelist = new List<BaseVisualSector>(); //mxd
foreach(Linedef l in linedefs) foreach(Linedef l in linedefs)
{ {
if(l.Front != null && mode.VisualSectorExists(l.Front.Sector)) if(l.Front != null && mode.VisualSectorExists(l.Front.Sector))
updateList.Add((BaseVisualSector)mode.GetVisualSector(l.Front.Sector)); updatelist.Add((BaseVisualSector)mode.GetVisualSector(l.Front.Sector));
if(l.Back != null && mode.VisualSectorExists(l.Back.Sector)) if(l.Back != null && mode.VisualSectorExists(l.Back.Sector))
updateList.Add((BaseVisualSector)mode.GetVisualSector(l.Back.Sector)); updatelist.Add((BaseVisualSector)mode.GetVisualSector(l.Back.Sector));
} }
General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged; General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged;
@ -1221,8 +1241,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.StopRealtimeInterfaceUpdate(SelectionType.Linedefs); mode.StopRealtimeInterfaceUpdate(SelectionType.Linedefs);
General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged; General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged;
updateList.Clear(); updatelist.Clear();
updateList = null; updatelist = null;
//mxd. Effects may need updating... //mxd. Effects may need updating...
if(result == DialogResult.OK) mode.RebuildElementData(); if(result == DialogResult.OK) mode.RebuildElementData();
@ -1232,7 +1252,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd //mxd
private void Interface_OnEditFormValuesChanged(object sender, EventArgs e) private void Interface_OnEditFormValuesChanged(object sender, EventArgs e)
{ {
foreach(BaseVisualSector vs in updateList) vs.UpdateSectorGeometry(false); foreach(BaseVisualSector vs in updatelist) vs.UpdateSectorGeometry(false);
} }
// Mouse moves // Mouse moves

View file

@ -1770,24 +1770,24 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
List<IVisualEventReceiver> objs = new List<IVisualEventReceiver>(); List<IVisualEventReceiver> objs = new List<IVisualEventReceiver>();
foreach(IVisualEventReceiver i in selectedobjects) foreach(IVisualEventReceiver i in selectedobjects)
{ {
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i); if (includesectors && (i is BaseVisualGeometrySector) /*&& ((BaseVisualGeometrySector)i).Triangles > 0*/) objs.Add(i);
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i); else if (includesidedefs && (i is BaseVisualGeometrySidedef) /*&& ((BaseVisualGeometrySidedef)i).Triangles > 0*/) objs.Add(i);
else if((i is BaseVisualThing) && includethings) objs.Add(i); else if (includethings && (i is BaseVisualThing)) objs.Add(i);
else if((i is BaseVisualVertex) && includevertices) objs.Add(i);//mxd else if (includevertices && (i is BaseVisualVertex)) objs.Add(i); //mxd
} }
// Add highlight? // Add highlight?
if(selectedobjects.Count == 0) if (selectedobjects.Count == 0)
{ {
IVisualEventReceiver i = (target.picked as IVisualEventReceiver); IVisualEventReceiver i = (target.picked as IVisualEventReceiver);
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i); if (includesectors && (i is BaseVisualGeometrySector) /*&& ((BaseVisualGeometrySector)i).Triangles > 0*/) objs.Add(i);
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i); else if (includesidedefs && (i is BaseVisualGeometrySidedef) /*&& ((BaseVisualGeometrySidedef)i).Triangles > 0*/) objs.Add(i);
else if((i is BaseVisualThing) && includethings) objs.Add(i); else if (includethings && (i is BaseVisualThing)) objs.Add(i);
else if((i is BaseVisualVertex) && includevertices) objs.Add(i);//mxd else if (includevertices && (i is BaseVisualVertex)) objs.Add(i); //mxd
} }
return objs; return objs;
} }
//mxd //mxd

View file

@ -34,52 +34,46 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
internal sealed class VisualCeiling : BaseVisualGeometrySector internal sealed class VisualCeiling : BaseVisualGeometrySector
{ {
#region ================== Constants #region ================== Constants
#endregion #endregion
#region ================== Variables #region ================== Variables
public bool innerSide; //mxd private bool innerside; //mxd
#endregion #endregion
#region ================== Properties #region ================== Properties
#endregion #endregion
#region ================== Constructor / Setup #region ================== Constructor / Setup
// Constructor // Constructor
public VisualCeiling(BaseVisualMode mode, VisualSector vs) : base(mode, vs) public VisualCeiling(BaseVisualMode mode, VisualSector vs) : base(mode, vs)
{ {
//mxd //mxd
geometrytype = VisualGeometryType.CEILING; geometrytype = VisualGeometryType.CEILING;
partname = "ceiling"; partname = "ceiling";
performautoselection = mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected && (General.Map.ViewMode == ViewMode.CeilingTextures || General.Map.ViewMode == ViewMode.Normal);
//mxd // We have no destructor
if(mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected && (General.Map.ViewMode == ViewMode.CeilingTextures || General.Map.ViewMode == ViewMode.Normal)) GC.SuppressFinalize(this);
{
this.selected = true;
mode.AddSelectedObject(this);
}
// We have no destructor
GC.SuppressFinalize(this);
} }
// This builds the geometry. Returns false when no geometry created. // This builds the geometry. Returns false when no geometry created.
public override bool Setup(SectorLevel level, Effect3DFloor extrafloor) public override bool Setup(SectorLevel level, Effect3DFloor extrafloor)
{ {
return Setup(level, extrafloor, innerSide); return Setup(level, extrafloor, innerside);
} }
//mxd //mxd
public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerSide) public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerside)
{ {
Sector s = level.sector; Sector s = level.sector;
Vector2D texscale; Vector2D texscale;
this.innerSide = innerSide; //mxd this.innerside = innerside; //mxd
base.Setup(level, extrafloor); base.Setup(level, extrafloor);
@ -169,7 +163,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// The sector triangulation created clockwise triangles that // The sector triangulation created clockwise triangles that
// are right up for the floor. For the ceiling we must flip // are right up for the floor. For the ceiling we must flip
// the triangles upside down. // the triangles upside down.
if(extrafloor == null || extrafloor.VavoomType || innerSide) if(extrafloor == null || extrafloor.VavoomType || innerside)
SwapTriangleVertices(verts); SwapTriangleVertices(verts);
// Determine render pass // Determine render pass
@ -457,7 +451,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir) public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{ {
// Check if our ray starts at the correct side of the plane // Check if our ray starts at the correct side of the plane
if((innerSide && level.plane.Distance(from) < 0.0f) || (!innerSide && level.plane.Distance(from) > 0.0f)) //mxd if((innerside && level.plane.Distance(from) < 0.0f) || (!innerside && level.plane.Distance(from) > 0.0f)) //mxd
//if(level.plane.Distance(from) > 0.0f) //if(level.plane.Distance(from) > 0.0f)
{ {
// Calculate the intersection // Calculate the intersection

View file

@ -34,53 +34,46 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
internal sealed class VisualFloor : BaseVisualGeometrySector internal sealed class VisualFloor : BaseVisualGeometrySector
{ {
#region ================== Constants #region ================== Constants
#endregion #endregion
#region ================== Variables #region ================== Variables
private bool innerSide; //mxd private bool innerside; //mxd
#endregion #endregion
#region ================== Properties #region ================== Properties
#endregion #endregion
#region ================== Constructor / Setup #region ================== Constructor / Setup
// Constructor // Constructor
public VisualFloor(BaseVisualMode mode, VisualSector vs) : base(mode, vs) public VisualFloor(BaseVisualMode mode, VisualSector vs) : base(mode, vs)
{ {
//mxd //mxd
geometrytype = VisualGeometryType.FLOOR; geometrytype = VisualGeometryType.FLOOR;
partname = "floor"; partname = "floor";
performautoselection = mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected && (General.Map.ViewMode == ViewMode.FloorTextures || General.Map.ViewMode == ViewMode.Normal);
//mxd // We have no destructor
if(mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected GC.SuppressFinalize(this);
&& (General.Map.ViewMode == ViewMode.FloorTextures || General.Map.ViewMode == ViewMode.Normal))
{
this.selected = true;
mode.AddSelectedObject(this);
}
// We have no destructor
GC.SuppressFinalize(this);
} }
// This builds the geometry. Returns false when no geometry created. // This builds the geometry. Returns false when no geometry created.
public override bool Setup(SectorLevel level, Effect3DFloor extrafloor) public override bool Setup(SectorLevel level, Effect3DFloor extrafloor)
{ {
return Setup(level, extrafloor, innerSide); return Setup(level, extrafloor, innerside);
} }
//mxd //mxd
public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerSide) public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerside)
{ {
Sector s = level.sector; Sector s = level.sector;
Vector2D texscale; Vector2D texscale;
this.innerSide = innerSide; this.innerside = innerside;
base.Setup(level, extrafloor); base.Setup(level, extrafloor);
@ -171,7 +164,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// The sector triangulation created clockwise triangles that // The sector triangulation created clockwise triangles that
// are right up for the floor. For the ceiling we must flip // are right up for the floor. For the ceiling we must flip
// the triangles upside down. // the triangles upside down.
if((extrafloor != null) && !extrafloor.VavoomType && !innerSide) if((extrafloor != null) && !extrafloor.VavoomType && !innerside)
SwapTriangleVertices(verts); SwapTriangleVertices(verts);
// Determine render pass // Determine render pass
@ -411,7 +404,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir) public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{ {
// Check if our ray starts at the correct side of the plane // Check if our ray starts at the correct side of the plane
if((!innerSide && level.plane.Distance(from) > 0.0f) || (innerSide && level.plane.Distance(from) < 0.0f)) if((!innerside && level.plane.Distance(from) > 0.0f) || (innerside && level.plane.Distance(from) < 0.0f))
{ {
// Calculate the intersection // Calculate the intersection
if(level.plane.GetIntersection(from, to, ref pickrayu)) if(level.plane.GetIntersection(from, to, ref pickrayu))