mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
Merge branch 'visual-slope2'
This commit is contained in:
commit
58d5bfd59b
20 changed files with 1624 additions and 563 deletions
|
@ -252,6 +252,8 @@
|
|||
<Compile Include="Rendering\Vector3.cs" />
|
||||
<Compile Include="Rendering\Vector4.cs" />
|
||||
<Compile Include="Rendering\VertexBuffer.cs" />
|
||||
<Compile Include="Rendering\VisualSlopeHandle.cs" />
|
||||
<Compile Include="VisualModes\VisualSlope.cs" />
|
||||
<Compile Include="Windows\ThingStatisticsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -2181,6 +2181,7 @@ namespace CodeImp.DoomBuilder
|
|||
// Update settings
|
||||
renderer3d.CreateProjection();
|
||||
renderer3d.UpdateVertexHandle(); //mxd
|
||||
renderer3d.UpdateVisualSlopeHandle();
|
||||
|
||||
// Things filters
|
||||
General.MainWindow.UpdateThingsFilters();
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
void AddSectorGeometry(VisualGeometry g);
|
||||
void AddThingGeometry(VisualThing t);
|
||||
void SetVisualVertices(List<VisualVertex> verts);
|
||||
void SetVisualSlopeHandles(List<VisualSlope> handles);
|
||||
void SetEventLines(List<Line3D> lines);
|
||||
void RenderCrosshair();
|
||||
void SetFogMode(bool usefog);
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
DeclareUniform(UniformName.fogcolor, "fogcolor", UniformType.Vec4f);
|
||||
DeclareUniform(UniformName.sectorfogcolor, "sectorfogcolor", UniformType.Vec4f);
|
||||
DeclareUniform(UniformName.lightsEnabled, "lightsEnabled", UniformType.Float);
|
||||
DeclareUniform(UniformName.slopeHandleLength, "slopeHandleLength", UniformType.Float);
|
||||
|
||||
// 2d fsaa
|
||||
CompileShader(ShaderName.display2d_fsaa, "display2d.shader", "display2d_fsaa");
|
||||
|
@ -100,6 +101,9 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
CompileShader(ShaderName.world3d_main_fog_vertexcolor, "world3d.shader", "world3d_main_fog_vertexcolor");
|
||||
CompileShader(ShaderName.world3d_main_highlight_fog_vertexcolor, "world3d.shader", "world3d_main_highlight_fog_vertexcolor");
|
||||
|
||||
// Slope handle
|
||||
CompileShader(ShaderName.world3d_slope_handle, "world3d.shader", "world3d_slope_handle");
|
||||
|
||||
SetupSettings();
|
||||
}
|
||||
|
||||
|
@ -730,7 +734,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
world3d_p13,
|
||||
world3d_main_highlight_fog_vertexcolor,
|
||||
world3d_vertex_color,
|
||||
world3d_constant_color
|
||||
world3d_constant_color,
|
||||
world3d_slope_handle
|
||||
}
|
||||
|
||||
public enum UniformType : int
|
||||
|
@ -772,7 +777,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
fogsettings,
|
||||
fogcolor,
|
||||
sectorfogcolor,
|
||||
lightsEnabled
|
||||
lightsEnabled,
|
||||
slopeHandleLength
|
||||
}
|
||||
|
||||
public enum VertexFormat : int { Flat, World }
|
||||
|
|
|
@ -65,6 +65,9 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private VisualVertexHandle vertexhandle;
|
||||
private int[] lightOffsets;
|
||||
|
||||
// Slope handle
|
||||
private VisualSlopeHandle visualslopehandle;
|
||||
|
||||
// Crosshair
|
||||
private FlatVertex[] crosshairverts;
|
||||
private bool crosshairbusy;
|
||||
|
@ -112,6 +115,9 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
//mxd. Visual vertices
|
||||
private List<VisualVertex> visualvertices;
|
||||
|
||||
// Visual slope handles
|
||||
private List<VisualSlope> visualslopehandles;
|
||||
|
||||
//mxd. Event lines
|
||||
private List<Line3D> eventlines;
|
||||
|
||||
|
@ -166,6 +172,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
{
|
||||
// Clean up
|
||||
if(vertexhandle != null) vertexhandle.Dispose(); //mxd
|
||||
if (visualslopehandle != null) visualslopehandle.Dispose();
|
||||
|
||||
// Done
|
||||
base.Dispose();
|
||||
|
@ -232,6 +239,15 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
}
|
||||
|
||||
internal void UpdateVisualSlopeHandle()
|
||||
{
|
||||
if (visualslopehandle != null)
|
||||
{
|
||||
visualslopehandle.UnloadResource();
|
||||
visualslopehandle.ReloadResource();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Presentation
|
||||
|
@ -345,6 +361,9 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
//mxd. Crate vertex handle
|
||||
if(vertexhandle == null) vertexhandle = new VisualVertexHandle();
|
||||
|
||||
// Create slope handle
|
||||
if (visualslopehandle == null) visualslopehandle = new VisualSlopeHandle();
|
||||
|
||||
// Ready
|
||||
return true;
|
||||
}
|
||||
|
@ -447,6 +466,10 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
//mxd. Visual vertices
|
||||
RenderVertices();
|
||||
|
||||
// Slope handles
|
||||
if (General.Map.UDMF /* && General.Settings.ShowVisualSlopeHandles */)
|
||||
RenderSlopeHandles();
|
||||
|
||||
//mxd. Event lines
|
||||
if (General.Settings.GZShowEventLines) RenderArrows(eventlines);
|
||||
|
||||
|
@ -615,6 +638,45 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
}
|
||||
|
||||
private void RenderSlopeHandles()
|
||||
{
|
||||
if (visualslopehandles == null || !showselection) return;
|
||||
|
||||
graphics.SetAlphaBlendEnable(true);
|
||||
graphics.SetAlphaTestEnable(false);
|
||||
graphics.SetZWriteEnable(false);
|
||||
graphics.SetSourceBlend(Blend.SourceAlpha);
|
||||
graphics.SetDestinationBlend(Blend.InverseSourceAlpha);
|
||||
|
||||
graphics.SetShader(ShaderName.world3d_slope_handle);
|
||||
|
||||
foreach (VisualSlope handle in visualslopehandles)
|
||||
{
|
||||
PixelColor color = General.Colors.Vertices;
|
||||
|
||||
if (handle.Pivot)
|
||||
color = General.Colors.Guideline;
|
||||
else if (handle.Selected)
|
||||
color = General.Colors.Selection3D;
|
||||
else if (handle == highlighted)
|
||||
color = General.Colors.Highlight3D;
|
||||
else if (handle.SmartPivot)
|
||||
color = General.Colors.Vertices;
|
||||
|
||||
world = handle.Position;
|
||||
graphics.SetUniform(UniformName.world, ref world);
|
||||
graphics.SetUniform(UniformName.slopeHandleLength, handle.Length);
|
||||
graphics.SetUniform(UniformName.vertexColor, color.ToColorValue());
|
||||
|
||||
graphics.SetVertexBuffer(visualslopehandle.Geometry);
|
||||
graphics.Draw(PrimitiveType.TriangleList, 0, 2);
|
||||
|
||||
}
|
||||
|
||||
// Done
|
||||
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
|
||||
}
|
||||
|
||||
//mxd
|
||||
private void RenderArrows(ICollection<Line3D> lines)
|
||||
{
|
||||
|
@ -1755,6 +1817,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
//mxd
|
||||
public void SetVisualVertices(List<VisualVertex> verts) { visualvertices = verts; }
|
||||
|
||||
public void SetVisualSlopeHandles(List<VisualSlope> handles) { visualslopehandles = handles; }
|
||||
|
||||
//mxd
|
||||
public void SetEventLines(List<Line3D> lines) { eventlines = lines; }
|
||||
|
||||
|
|
89
Source/Core/Rendering/VisualSlopeHandle.cs
Normal file
89
Source/Core/Rendering/VisualSlopeHandle.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
internal sealed class VisualSlopeHandle : IDisposable, IRenderResource
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private VertexBuffer geometry;
|
||||
private bool isdisposed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public VertexBuffer Geometry { get { return geometry; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
public VisualSlopeHandle()
|
||||
{
|
||||
// Create geometry
|
||||
ReloadResource();
|
||||
|
||||
// Register as source
|
||||
General.Map.Graphics.RegisterResource(this);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if (!isdisposed)
|
||||
{
|
||||
if (geometry != null)
|
||||
geometry.Dispose();
|
||||
|
||||
// Unregister resource
|
||||
General.Map.Graphics.UnregisterResource(this);
|
||||
|
||||
// Done
|
||||
isdisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This is called resets when the device is reset
|
||||
// (when resized or display adapter was changed)
|
||||
public void ReloadResource()
|
||||
{
|
||||
WorldVertex v0 = new WorldVertex(0.0f, -8.0f, 0.1f);
|
||||
WorldVertex v1 = new WorldVertex(0.0f, 0.0f, 0.1f);
|
||||
WorldVertex v2 = new WorldVertex(1.0f, 0.0f, 0.1f);
|
||||
WorldVertex v3 = new WorldVertex(1.0f, -8.0f, 0.1f);
|
||||
|
||||
v1.c = v2.c = PixelColor.INT_WHITE;
|
||||
v0.c = v3.c = PixelColor.INT_WHITE_NO_ALPHA;
|
||||
|
||||
WorldVertex[] vertices = new[]
|
||||
{
|
||||
v0, v1, v2,
|
||||
v0, v2, v3
|
||||
};
|
||||
|
||||
geometry = new VertexBuffer();
|
||||
General.Map.Graphics.SetBufferData(geometry, vertices);
|
||||
}
|
||||
|
||||
// This is called before a device is reset
|
||||
// (when resized or display adapter was changed)
|
||||
public void UnloadResource()
|
||||
{
|
||||
if (geometry != null)
|
||||
geometry.Dispose();
|
||||
|
||||
geometry = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -25,6 +25,9 @@ uniforms
|
|||
float ignoreNormals;
|
||||
float lightsEnabled;
|
||||
|
||||
// Slope handle length
|
||||
float slopeHandleLength;
|
||||
|
||||
}
|
||||
|
||||
functions
|
||||
|
@ -356,3 +359,15 @@ shader world3d_main_highlight_fog_vertexcolor extends world3d_main_highlight_fog
|
|||
v2f.Normal = normalize((modelnormal * vec4(in.Normal, 1.0)).xyz);
|
||||
}
|
||||
}
|
||||
|
||||
// Slope handle shader
|
||||
shader world3d_slope_handle extends world3d_vertex_color
|
||||
{
|
||||
vertex
|
||||
{
|
||||
v2f.viewpos = view * world * vec4(in.Position.x * slopeHandleLength, in.Position.y, in.Position.z, 1.0);
|
||||
gl_Position = projection * v2f.viewpos;
|
||||
v2f.Color = in.Color * vertexColor;
|
||||
v2f.UV = in.TextureCoordinate;
|
||||
}
|
||||
}
|
|
@ -30,6 +30,12 @@ using CodeImp.DoomBuilder.Editing;
|
|||
|
||||
namespace CodeImp.DoomBuilder.VisualModes
|
||||
{
|
||||
public enum PickingMode
|
||||
{
|
||||
Default,
|
||||
SlopeHandles
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides specialized functionality for a visual (3D) Doom Builder editing mode.
|
||||
/// </summary>
|
||||
|
@ -68,10 +74,14 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
private Vector3D playerStartPosition;
|
||||
private float playerStartAngle;
|
||||
|
||||
// For picking
|
||||
protected PickingMode pickingmode;
|
||||
|
||||
// Map
|
||||
protected VisualBlockMap blockmap;
|
||||
protected Dictionary<Thing, VisualThing> allthings;
|
||||
protected Dictionary<Sector, VisualSector> allsectors;
|
||||
protected Dictionary<Sector, List<VisualSlope>> allslopehandles;
|
||||
protected List<VisualBlockEntry> visibleblocks;
|
||||
protected List<VisualThing> visiblethings;
|
||||
protected List<VisualSector> visiblesectors;
|
||||
|
@ -85,6 +95,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public bool ProcessThings { get { return processthings; } set { processthings = value; } }
|
||||
public VisualBlockMap BlockMap { get { return blockmap; } }
|
||||
public Dictionary<Vertex, VisualVertexPair> VisualVertices { get { return vertices; } } //mxd
|
||||
public Dictionary<Sector, List<VisualSlope>> AllSlopeHandles { get { return allslopehandles; } }
|
||||
|
||||
// Rendering
|
||||
public IRenderer3D Renderer { get { return renderer; } }
|
||||
|
@ -103,6 +114,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
this.blockmap = new VisualBlockMap();
|
||||
this.allsectors = new Dictionary<Sector, VisualSector>(General.Map.Map.Sectors.Count);
|
||||
this.allthings = new Dictionary<Thing, VisualThing>(General.Map.Map.Things.Count);
|
||||
this.allslopehandles = new Dictionary<Sector, List<VisualSlope>>(General.Map.Map.Sectors.Count);
|
||||
this.visibleblocks = new List<VisualBlockEntry>();
|
||||
this.visiblesectors = new List<VisualSector>(50);
|
||||
this.visiblegeometry = new List<VisualGeometry>(200);
|
||||
|
@ -110,6 +122,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
this.processgeometry = true;
|
||||
this.processthings = true;
|
||||
this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd
|
||||
this.pickingmode = PickingMode.Default;
|
||||
|
||||
//mxd. Synch camera position to cursor position or center of the screen in 2d-mode
|
||||
if(General.Settings.GZSynchCameras && General.Editing.Mode is ClassicMode)
|
||||
|
@ -720,6 +733,10 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
VisualSector vs = allsectors[General.Map.VisualCamera.Sector];
|
||||
sectors.Add(General.Map.VisualCamera.Sector, vs);
|
||||
foreach(VisualGeometry g in vs.FixedGeometry) pickables.Add(g);
|
||||
|
||||
// Add slope handles
|
||||
if (General.Map.UDMF && pickingmode == PickingMode.SlopeHandles && allslopehandles.ContainsKey(General.Map.VisualCamera.Sector))
|
||||
pickables.AddRange(allslopehandles[General.Map.VisualCamera.Sector]);
|
||||
}
|
||||
|
||||
// Go for all lines to see which ones we intersect
|
||||
|
@ -764,6 +781,10 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
if (g.Triangles > 0)
|
||||
pickables.Add(g);
|
||||
}
|
||||
|
||||
// Add slope handles
|
||||
if (General.Map.UDMF && pickingmode == PickingMode.SlopeHandles && allslopehandles.ContainsKey(ld.Front.Sector))
|
||||
pickables.AddRange(allslopehandles[ld.Front.Sector]);
|
||||
}
|
||||
|
||||
// Add sidedef if on the front side
|
||||
|
@ -801,6 +822,10 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
if (g.Triangles > 0)
|
||||
pickables.Add(g);
|
||||
}
|
||||
|
||||
// Add slope handles
|
||||
if (General.Map.UDMF && pickingmode == PickingMode.SlopeHandles && allslopehandles.ContainsKey(ld.Back.Sector))
|
||||
pickables.AddRange(allslopehandles[ld.Back.Sector]);
|
||||
}
|
||||
|
||||
// Add sidedef if on the front side
|
||||
|
@ -864,6 +889,11 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// Setup final result
|
||||
result.hitpos = from + to * result.u_ray;
|
||||
|
||||
// If picking mode is for slope handles only return slope handles. We have to do it this
|
||||
// way because otherwise it's possible to pick slope handles through other geometry
|
||||
if (pickingmode == PickingMode.SlopeHandles && !(result.picked is VisualSlope))
|
||||
result.picked = null;
|
||||
|
||||
// Done
|
||||
return result;
|
||||
}
|
||||
|
|
138
Source/Core/VisualModes/VisualSlope.cs
Normal file
138
Source/Core/VisualModes/VisualSlope.cs
Normal file
|
@ -0,0 +1,138 @@
|
|||
using System;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
namespace CodeImp.DoomBuilder.VisualModes
|
||||
{
|
||||
public abstract class VisualSlope : IVisualPickable
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
// Disposing
|
||||
private bool isdisposed;
|
||||
|
||||
// Selected?
|
||||
protected bool selected;
|
||||
|
||||
// Pivot?
|
||||
protected bool pivot;
|
||||
|
||||
// Smart Pivot?
|
||||
protected bool smartpivot;
|
||||
|
||||
// Was changed?
|
||||
private bool changed;
|
||||
|
||||
protected float length;
|
||||
|
||||
private Matrix position;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
/// <summary>
|
||||
/// Selected or not? This is only used by the core to determine what color to draw it with.
|
||||
/// </summary>
|
||||
public bool Selected { get { return selected; } set { selected = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Pivot or not? This is only used by the core to determine what color to draw it with.
|
||||
/// </summary>
|
||||
public bool Pivot { get { return pivot; } set { pivot = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Disposed or not?
|
||||
/// </summary>
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
public bool SmartPivot { get { return smartpivot; } set { smartpivot = value; } }
|
||||
|
||||
public bool Changed { get { return changed; } set { changed = value; } }
|
||||
|
||||
public float Length { get { return length; } }
|
||||
|
||||
public Matrix Position { get { return position; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
public VisualSlope()
|
||||
{
|
||||
pivot = false;
|
||||
smartpivot = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This is called before a device is reset (when resized or display adapter was changed)
|
||||
public void UnloadResource()
|
||||
{
|
||||
}
|
||||
|
||||
// This is called resets when the device is reset
|
||||
// (when resized or display adapter was changed)
|
||||
public void ReloadResource()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called when the thing must be tested for line intersection. This should reject
|
||||
/// as fast as possible to rule out all geometry that certainly does not touch the line.
|
||||
/// </summary>
|
||||
public virtual bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called when the thing must be tested for line intersection. This should perform
|
||||
/// accurate hit detection and set u_ray to the position on the ray where this hits the geometry.
|
||||
/// </summary>
|
||||
public virtual bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Update() {}
|
||||
|
||||
public void SetPosition(Line2D line, Plane plane)
|
||||
{
|
||||
Line3D line3d = new Line3D(new Vector3D(line.v1, plane.GetZ(line.v1)), new Vector3D(line.v2, plane.GetZ(line.v2)));
|
||||
|
||||
// This vector is perpendicular to the line, with a 90° angle between it and the plane normal
|
||||
Vector3D perpendicularvector = Vector3D.CrossProduct(line3d.GetDelta().GetNormal(), plane.Normal) * (-1);
|
||||
|
||||
// This vector is on the plane, with a 90° angle to the perpendicular vector (so effectively
|
||||
// it's on the line, but in 3D
|
||||
Vector3D linevector = Vector3D.CrossProduct(plane.Normal, perpendicularvector) * (-1);
|
||||
|
||||
Matrix m = Matrix.Null;
|
||||
|
||||
m.M11 = linevector.x;
|
||||
m.M12 = linevector.y;
|
||||
m.M13 = linevector.z;
|
||||
|
||||
m.M21 = perpendicularvector.x;
|
||||
m.M22 = perpendicularvector.y;
|
||||
m.M23 = perpendicularvector.z;
|
||||
|
||||
m.M31 = plane.Normal.x;
|
||||
m.M32 = plane.Normal.y;
|
||||
m.M33 = plane.Normal.z;
|
||||
|
||||
m.M44 = 1.0f;
|
||||
|
||||
// The matrix is at the 0,0 origin, so move it to the start vertex of the line
|
||||
Vector3D tp = new Vector3D(line.v1, plane.GetZ(line.v1));
|
||||
|
||||
position = Matrix.Multiply(m, Matrix.Translation(RenderDevice.V3(tp)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -495,6 +495,7 @@
|
|||
<Compile Include="VisualModes\VisualMiddleDouble.cs" />
|
||||
<Compile Include="VisualModes\VisualMiddleSingle.cs" />
|
||||
<Compile Include="VisualModes\VisualSidedefParts.cs" />
|
||||
<Compile Include="VisualModes\VisualSidedefSlope.cs" />
|
||||
<Compile Include="VisualModes\VisualUpper.cs" />
|
||||
<Compile Include="VisualModes\WallPolygon.cs" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -170,6 +170,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private ICollection<Vertex> unselectedvertices;
|
||||
private ICollection<Linedef> unselectedlines;
|
||||
private ICollection<Linedef> unstablelines; //mxd
|
||||
private Dictionary<Sector, float[]> slopeheights;
|
||||
|
||||
// Modification
|
||||
private float rotation;
|
||||
|
@ -1326,6 +1327,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
thingangle.Add(t.Angle);
|
||||
}
|
||||
|
||||
// Get z heights of floor and ceiling slopes (from the center of the sector). This is used
|
||||
// to easily compute the new slope after moving and rotating. We can't simply use the sector
|
||||
// heights, since they might be wrong (as sector heights are technically irrelevant for slopes)
|
||||
// Floor/ceiling heights are stored if there is no slope, but they won't get used anyway
|
||||
// Important: this has to be done before the first call to UpdateGeometry, since that will change
|
||||
// the sector and subsequently the bounding box, but not the slope
|
||||
slopeheights = new Dictionary<Sector, float[]>();
|
||||
|
||||
foreach(Sector s in sectors)
|
||||
{
|
||||
// Make sure the sector has a valid bounding box
|
||||
s.UpdateCache();
|
||||
|
||||
Vector2D center = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2);
|
||||
float floorz = s.FloorHeight;
|
||||
float ceilingz = s.CeilHeight;
|
||||
|
||||
if (!float.IsNaN(s.FloorSlopeOffset))
|
||||
floorz = new Plane(s.FloorSlope, s.FloorSlopeOffset).GetZ(center);
|
||||
|
||||
if (!float.IsNaN(s.CeilSlopeOffset))
|
||||
ceilingz = new Plane(s.CeilSlope, s.CeilSlopeOffset).GetZ(center);
|
||||
|
||||
slopeheights.Add(s, new float[] { floorz, ceilingz });
|
||||
}
|
||||
|
||||
// Calculate size
|
||||
size = right - offset;
|
||||
|
||||
|
@ -1550,7 +1577,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Update floor slope?
|
||||
if(s.FloorSlope.GetLengthSq() > 0 && !float.IsNaN(s.FloorSlopeOffset / s.FloorSlope.z))
|
||||
{
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, s.FloorHeight);
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, slopeheights[s][0]);
|
||||
Plane p = new Plane(center, s.FloorSlope.GetAngleXY() + rotation + Angle2D.PIHALF, -s.FloorSlope.GetAngleZ(), true);
|
||||
s.FloorSlope = p.Normal;
|
||||
s.FloorSlopeOffset = p.Offset;
|
||||
|
@ -1559,7 +1586,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Update ceiling slope?
|
||||
if(s.CeilSlope.GetLengthSq() > 0 && !float.IsNaN(s.CeilSlopeOffset / s.CeilSlope.z))
|
||||
{
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, s.CeilHeight);
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, slopeheights[s][1]);
|
||||
Plane p = new Plane(center, s.CeilSlope.GetAngleXY() + rotation + Angle2D.PIHALF, -s.CeilSlope.GetAngleZ(), false);
|
||||
s.CeilSlope = p.Normal;
|
||||
s.CeilSlopeOffset = p.Offset;
|
||||
|
|
|
@ -136,6 +136,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private bool alphabasedtexturehighlighting; //mxd
|
||||
private bool showlightradii; //mxd
|
||||
private bool showsoundradii; //mxd
|
||||
private int scaletexturesonslopes; // 0 = base scale of 1, 1 = use current scale as base, 2 = don't scale
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -189,6 +190,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public bool AlphaBasedTextureHighlighting { get { return alphabasedtexturehighlighting; } internal set { alphabasedtexturehighlighting = value; } } //mxd
|
||||
public bool ShowLightRadii { get { return showlightradii; } internal set { showlightradii = value; } } //mxd
|
||||
public bool ShowSoundRadii { get { return showsoundradii; } internal set { showsoundradii = value; } } //mxd
|
||||
public int ScaleTexturesOnSlopes { get { return scaletexturesonslopes; } internal set { scaletexturesonslopes = value; } }
|
||||
|
||||
//mxd. "Make Door" action persistent settings
|
||||
internal MakeDoorSettings MakeDoor;
|
||||
|
@ -291,6 +293,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
autoAlignTextureOffsetsOnCreate = General.Settings.ReadPluginSetting("autoaligntextureoffsetsoncreate", false); //mxd
|
||||
dontMoveGeometryOutsideMapBoundary = General.Settings.ReadPluginSetting("dontmovegeometryoutsidemapboundary", false); //mxd
|
||||
syncSelection = General.Settings.ReadPluginSetting("syncselection", false); //mxd
|
||||
scaletexturesonslopes = General.Settings.ReadPluginSetting("scaletexturesonslopes", 0);
|
||||
}
|
||||
|
||||
//mxd. Load settings, which can be changed via UI
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.defaultbrightness = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
|
||||
this.label11 = new System.Windows.Forms.Label();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.additivepaintselect = new System.Windows.Forms.CheckBox();
|
||||
this.switchviewmodes = new System.Windows.Forms.CheckBox();
|
||||
this.autodrawonedit = new System.Windows.Forms.CheckBox();
|
||||
this.syncSelection = new System.Windows.Forms.CheckBox();
|
||||
|
@ -72,7 +73,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.label10 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.heightbysidedef = new System.Windows.Forms.ComboBox();
|
||||
this.additivepaintselect = new System.Windows.Forms.CheckBox();
|
||||
this.label18 = new System.Windows.Forms.Label();
|
||||
this.scaletexturesonslopes = new System.Windows.Forms.ComboBox();
|
||||
this.tabs.SuspendLayout();
|
||||
this.taboptions.SuspendLayout();
|
||||
this.groupBox4.SuspendLayout();
|
||||
|
@ -120,7 +122,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.groupBox4.Controls.Add(this.label12);
|
||||
this.groupBox4.Controls.Add(this.defaultbrightness);
|
||||
this.groupBox4.Controls.Add(this.label11);
|
||||
this.groupBox4.Location = new System.Drawing.Point(6, 300);
|
||||
this.groupBox4.Location = new System.Drawing.Point(6, 335);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(272, 136);
|
||||
this.groupBox4.TabIndex = 2;
|
||||
|
@ -240,13 +242,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.groupBox3.Controls.Add(this.editnewthing);
|
||||
this.groupBox3.Controls.Add(this.editnewsector);
|
||||
this.groupBox3.Controls.Add(this.additiveselect);
|
||||
this.groupBox3.Location = new System.Drawing.Point(284, 104);
|
||||
this.groupBox3.Location = new System.Drawing.Point(284, 139);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(379, 332);
|
||||
this.groupBox3.TabIndex = 3;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = " Options ";
|
||||
//
|
||||
// additivepaintselect
|
||||
//
|
||||
this.additivepaintselect.AutoSize = true;
|
||||
this.additivepaintselect.Location = new System.Drawing.Point(13, 135);
|
||||
this.additivepaintselect.Name = "additivepaintselect";
|
||||
this.additivepaintselect.Size = new System.Drawing.Size(233, 17);
|
||||
this.additivepaintselect.TabIndex = 11;
|
||||
this.additivepaintselect.Text = "Additive paint selecting without holding Shift";
|
||||
this.additivepaintselect.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// switchviewmodes
|
||||
//
|
||||
this.switchviewmodes.AutoSize = true;
|
||||
|
@ -375,7 +387,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.groupBox2.Controls.Add(this.label6);
|
||||
this.groupBox2.Controls.Add(this.label4);
|
||||
this.groupBox2.Controls.Add(this.label7);
|
||||
this.groupBox2.Location = new System.Drawing.Point(6, 104);
|
||||
this.groupBox2.Location = new System.Drawing.Point(6, 139);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(272, 190);
|
||||
this.groupBox2.TabIndex = 1;
|
||||
|
@ -569,13 +581,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.scaletexturesonslopes);
|
||||
this.groupBox1.Controls.Add(this.label18);
|
||||
this.groupBox1.Controls.Add(this.splitbehavior);
|
||||
this.groupBox1.Controls.Add(this.label10);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Controls.Add(this.heightbysidedef);
|
||||
this.groupBox1.Location = new System.Drawing.Point(6, 6);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(657, 92);
|
||||
this.groupBox1.Size = new System.Drawing.Size(657, 127);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = " Behavior ";
|
||||
|
@ -607,7 +621,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(9, 22);
|
||||
this.label1.Location = new System.Drawing.Point(15, 22);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(308, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
|
@ -628,15 +642,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.heightbysidedef.Size = new System.Drawing.Size(309, 21);
|
||||
this.heightbysidedef.TabIndex = 0;
|
||||
//
|
||||
// additivepaintselect
|
||||
// label18
|
||||
//
|
||||
this.additivepaintselect.AutoSize = true;
|
||||
this.additivepaintselect.Location = new System.Drawing.Point(13, 135);
|
||||
this.additivepaintselect.Name = "additivepaintselect";
|
||||
this.additivepaintselect.Size = new System.Drawing.Size(233, 17);
|
||||
this.additivepaintselect.TabIndex = 11;
|
||||
this.additivepaintselect.Text = "Additive paint selecting without holding Shift";
|
||||
this.additivepaintselect.UseVisualStyleBackColor = true;
|
||||
this.label18.AutoSize = true;
|
||||
this.label18.Location = new System.Drawing.Point(133, 94);
|
||||
this.label18.Name = "label18";
|
||||
this.label18.Size = new System.Drawing.Size(190, 13);
|
||||
this.label18.TabIndex = 2;
|
||||
this.label18.Text = "When auto-aligning textures on slopes:";
|
||||
this.label18.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// scaletexturesonslopes
|
||||
//
|
||||
this.scaletexturesonslopes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.scaletexturesonslopes.FormattingEnabled = true;
|
||||
this.scaletexturesonslopes.Items.AddRange(new object[] {
|
||||
"Use a scale of 1 as base",
|
||||
"Use current scale as base",
|
||||
"Don\'t scale"});
|
||||
this.scaletexturesonslopes.Location = new System.Drawing.Point(342, 91);
|
||||
this.scaletexturesonslopes.Name = "scaletexturesonslopes";
|
||||
this.scaletexturesonslopes.Size = new System.Drawing.Size(309, 21);
|
||||
this.scaletexturesonslopes.TabIndex = 3;
|
||||
//
|
||||
// PreferencesForm
|
||||
//
|
||||
|
@ -710,5 +737,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private System.Windows.Forms.Label label16;
|
||||
private System.Windows.Forms.Label label17;
|
||||
private System.Windows.Forms.CheckBox additivepaintselect;
|
||||
private System.Windows.Forms.ComboBox scaletexturesonslopes;
|
||||
private System.Windows.Forms.Label label18;
|
||||
}
|
||||
}
|
|
@ -64,6 +64,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
defaultbrightness.Text = General.Settings.DefaultBrightness.ToString(); //mxd
|
||||
defaultceilheight.Text = General.Settings.DefaultCeilingHeight.ToString();//mxd
|
||||
defaultfloorheight.Text = General.Settings.DefaultFloorHeight.ToString(); //mxd
|
||||
scaletexturesonslopes.SelectedIndex = General.Settings.ReadPluginSetting("scaletexturesonslopes", 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -91,9 +92,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Settings.WritePluginSetting("autoaligntextureoffsetsoncreate", autoaligntexturesoncreate.Checked);//mxd
|
||||
General.Settings.WritePluginSetting("dontmovegeometryoutsidemapboundary", dontMoveGeometryOutsideBounds.Checked);//mxd
|
||||
General.Settings.WritePluginSetting("syncselection", syncSelection.Checked);//mxd
|
||||
General.Settings.WritePluginSetting("scaletexturesonslopes", scaletexturesonslopes.SelectedIndex);
|
||||
General.Settings.SwitchViewModes = switchviewmodes.Checked; //mxd
|
||||
General.Settings.SplitLineBehavior = (SplitLineBehavior)splitbehavior.SelectedIndex;//mxd
|
||||
|
||||
|
||||
//default sector values
|
||||
General.Settings.DefaultBrightness = General.Clamp(defaultbrightness.GetResult(192), 0, 255);
|
||||
|
||||
|
|
|
@ -1405,3 +1405,25 @@ visualpaintselect
|
|||
disregardcontrol = true;
|
||||
disregardalt = true;
|
||||
}
|
||||
|
||||
togglevisualslopepicking
|
||||
{
|
||||
title = "Toggle Visual Slope Picking";
|
||||
category = "visual";
|
||||
description = "Toggles picking visual slope handles.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = false;
|
||||
default = 65623; // Shift-W
|
||||
}
|
||||
|
||||
slopebetweenhandles
|
||||
{
|
||||
title = "Slope Between Handles";
|
||||
category = "visual";
|
||||
description = "Slopes the selected floors and ceilings between the selected slope handles.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = false;
|
||||
default = 131142; // Ctrl-F
|
||||
}
|
|
@ -298,6 +298,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//update angle
|
||||
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "rotationfloor" : "rotationceiling"), sourceAngle, 0f);
|
||||
|
||||
// Scale texture if it's a slope and the appropriate option is set
|
||||
if (level.plane.Normal.z != 1.0f && BuilderPlug.Me.ScaleTexturesOnSlopes != 2)
|
||||
{
|
||||
Vector2D basescale = new Vector2D(1.0f, 1.0f);
|
||||
|
||||
// User wants to use the current scale as a base?
|
||||
if(BuilderPlug.Me.ScaleTexturesOnSlopes == 1)
|
||||
{
|
||||
basescale.x = scaleX;
|
||||
basescale.y = scaleY;
|
||||
}
|
||||
|
||||
// Create a unit vector of the direction of the target line in 3D space
|
||||
Vector3D targetlinevector = new Line3D(new Vector3D(targetLine.Start.Position, level.plane.GetZ(targetLine.Start.Position)), new Vector3D(targetLine.End.Position, level.plane.GetZ(targetLine.End.Position))).GetDelta().GetNormal();
|
||||
|
||||
// Get a perpendicular vector of the target line in 3D space. This is used to get the slope angle relative to the target line
|
||||
Vector3D targetlineperpendicular = Vector3D.CrossProduct(targetlinevector, level.plane.Normal);
|
||||
|
||||
if (alignx)
|
||||
scaleX = Math.Abs(basescale.x * (1.0f / (float)Math.Cos(targetlinevector.GetAngleZ())));
|
||||
|
||||
if (aligny)
|
||||
scaleY = Math.Abs(basescale.y * (1.0f / (float)Math.Cos(targetlineperpendicular.GetAngleZ())));
|
||||
|
||||
}
|
||||
|
||||
//set scale
|
||||
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "xscalefloor" : "xscaleceiling"), scaleX, 1.0f);
|
||||
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "yscalefloor" : "yscaleceiling"), scaleY, 1.0f);
|
||||
|
@ -323,96 +349,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Sector.UpdateSectorGeometry(false);
|
||||
}
|
||||
|
||||
//mxd
|
||||
protected void AlignTextureToSlopeLine(Linedef slopeSource, float slopeAngle, bool isFront, bool alignx, bool aligny)
|
||||
{
|
||||
bool isFloor = (geometrytype == VisualGeometryType.FLOOR);
|
||||
Sector.Sector.Fields.BeforeFieldsChange();
|
||||
float sourceAngle = (float)Math.Round(General.ClampAngle(isFront ? -Angle2D.RadToDeg(slopeSource.Angle) + 90 : -Angle2D.RadToDeg(slopeSource.Angle) - 90), 1);
|
||||
|
||||
if(isFloor)
|
||||
{
|
||||
if((isFront && slopeSource.Front.Sector.FloorHeight > slopeSource.Back.Sector.FloorHeight) ||
|
||||
(!isFront && slopeSource.Front.Sector.FloorHeight < slopeSource.Back.Sector.FloorHeight))
|
||||
{
|
||||
sourceAngle = General.ClampAngle(sourceAngle + 180);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((isFront && slopeSource.Front.Sector.CeilHeight < slopeSource.Back.Sector.CeilHeight) ||
|
||||
(!isFront && slopeSource.Front.Sector.CeilHeight > slopeSource.Back.Sector.CeilHeight))
|
||||
{
|
||||
sourceAngle = General.ClampAngle(sourceAngle + 180);
|
||||
}
|
||||
}
|
||||
|
||||
//update angle
|
||||
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "rotationfloor" : "rotationceiling"), sourceAngle, 0f);
|
||||
|
||||
//update scaleY
|
||||
string xScaleKey = (isFloor ? "xscalefloor" : "xscaleceiling");
|
||||
string yScaleKey = (isFloor ? "yscalefloor" : "yscaleceiling");
|
||||
|
||||
float scaleX = Sector.Sector.Fields.GetValue(xScaleKey, 1.0f);
|
||||
float scaleY;
|
||||
|
||||
//set scale
|
||||
if(aligny)
|
||||
{
|
||||
scaleY = (float)Math.Round(scaleX * (1 / (float)Math.Cos(slopeAngle)), 2);
|
||||
UniFields.SetFloat(Sector.Sector.Fields, yScaleKey, scaleY, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
scaleY = Sector.Sector.Fields.GetValue(yScaleKey, 1.0f);
|
||||
}
|
||||
|
||||
//update texture offsets
|
||||
Vector2D offset;
|
||||
if(isFloor)
|
||||
{
|
||||
if((isFront && slopeSource.Front.Sector.FloorHeight < slopeSource.Back.Sector.FloorHeight) ||
|
||||
(!isFront && slopeSource.Front.Sector.FloorHeight > slopeSource.Back.Sector.FloorHeight))
|
||||
{
|
||||
offset = slopeSource.End.Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = slopeSource.Start.Position;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((isFront && slopeSource.Front.Sector.CeilHeight > slopeSource.Back.Sector.CeilHeight) ||
|
||||
(!isFront && slopeSource.Front.Sector.CeilHeight < slopeSource.Back.Sector.CeilHeight))
|
||||
{
|
||||
offset = slopeSource.End.Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = slopeSource.Start.Position;
|
||||
}
|
||||
}
|
||||
|
||||
offset = offset.GetRotated(Angle2D.DegToRad(sourceAngle));
|
||||
|
||||
if(alignx)
|
||||
{
|
||||
if(Texture != null && Texture.IsImageLoaded) offset.x %= Texture.Width / scaleX;
|
||||
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "xpanningfloor" : "xpanningceiling"), (float)Math.Round(-offset.x), 0f);
|
||||
}
|
||||
|
||||
if(aligny)
|
||||
{
|
||||
if(Texture != null && Texture.IsImageLoaded) offset.y %= Texture.Height / scaleY;
|
||||
UniFields.SetFloat(Sector.Sector.Fields, (isFloor ? "ypanningfloor" : "ypanningceiling"), (float)Math.Round(offset.y), 0f);
|
||||
}
|
||||
|
||||
//update geometry
|
||||
Sector.UpdateSectorGeometry(false);
|
||||
}
|
||||
|
||||
//mxd
|
||||
protected void ClearFields(IEnumerable<string> keys, string undodescription, string resultdescription)
|
||||
{
|
||||
|
@ -878,6 +814,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
if(vs != null) vs.UpdateSectorGeometry(true);
|
||||
|
||||
// Visual slope handles need to be updated, too
|
||||
if (General.Map.UDMF)
|
||||
{
|
||||
if (mode.AllSlopeHandles.ContainsKey(level.sector))
|
||||
foreach (VisualSidedefSlope handle in mode.AllSlopeHandles[level.sector])
|
||||
handle.Changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sector brightness change
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.BuilderModes.Interface;
|
||||
using CodeImp.DoomBuilder.Windows;
|
||||
|
@ -392,6 +394,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
if (General.Map.UDMF)
|
||||
{
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
{
|
||||
foreach (VisualSlope handle in kvp.Value)
|
||||
if (handle.Selected) selectedobjects.Add((VisualSidedefSlope)handle);
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
UpdateSelectionInfo();
|
||||
}
|
||||
|
@ -412,6 +423,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
return vs;
|
||||
}
|
||||
|
||||
internal VisualSlope CreateVisualSlopeHandle(SectorLevel level, Sidedef sd, bool up)
|
||||
{
|
||||
VisualSidedefSlope handle = new VisualSidedefSlope(this, level, sd, up);
|
||||
|
||||
if (!allslopehandles.ContainsKey(sd.Sector))
|
||||
allslopehandles.Add(sd.Sector, new List<VisualSlope>());
|
||||
|
||||
allslopehandles[sd.Sector].Add(handle);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
// This creates a visual thing
|
||||
protected override VisualThing CreateVisualThing(Thing t)
|
||||
{
|
||||
|
@ -449,11 +472,31 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Should we update the info on panels?
|
||||
bool updateinfo = (newtarget.picked != target.picked);
|
||||
|
||||
if (updateinfo)
|
||||
{
|
||||
if (newtarget.picked is VisualSidedefSlope)
|
||||
{
|
||||
// Get the smart pivot handle for the targeted slope handle, so that it can be drawn
|
||||
VisualSidedefSlope handle = VisualSidedefSlope.GetSmartPivotHandle((VisualSidedefSlope)newtarget.picked, this);
|
||||
if (handle != null)
|
||||
handle.SmartPivot = true;
|
||||
}
|
||||
else if(target.picked is VisualSidedefSlope)
|
||||
{
|
||||
|
||||
// Clear smart pivot handles, otherwise it will keep being displayed
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
foreach (VisualSidedefSlope checkhandle in kvp.Value)
|
||||
checkhandle.SmartPivot = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply new target
|
||||
target = newtarget;
|
||||
|
||||
// Show target info
|
||||
if(updateinfo) ShowTargetInfo();
|
||||
if (updateinfo)
|
||||
ShowTargetInfo();
|
||||
}
|
||||
|
||||
// This shows the picked target information
|
||||
|
@ -512,7 +555,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(vs.Value != null)
|
||||
{
|
||||
BaseVisualSector bvs = (BaseVisualSector)vs.Value;
|
||||
if(bvs.Changed) bvs.Rebuild();
|
||||
if(bvs.Changed)
|
||||
{
|
||||
bvs.Rebuild();
|
||||
|
||||
// Also update slope handles
|
||||
if (allslopehandles.ContainsKey(vs.Key))
|
||||
foreach (VisualSidedefSlope handle in allslopehandles[vs.Key])
|
||||
handle.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1121,6 +1172,42 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Visual slope handles
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
{
|
||||
foreach (VisualSlope handle in kvp.Value)
|
||||
if (handle != null)
|
||||
if (handle.Selected) RemoveSelectedObject((VisualSidedefSlope)handle);
|
||||
|
||||
kvp.Value.Clear();
|
||||
}
|
||||
allslopehandles.Clear();
|
||||
|
||||
if (General.Map.UDMF /* && General.Settings.ShowVisualSlopeHandles */)
|
||||
{
|
||||
foreach (Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
SectorData sectordata = GetSectorData(s);
|
||||
|
||||
sectordata.Update();
|
||||
|
||||
foreach (Sidedef sidedef in s.Sidedefs)
|
||||
{
|
||||
VisualSlope handle = CreateVisualSlopeHandle(sectordata.Floor, sidedef, true);
|
||||
handle = CreateVisualSlopeHandle(sectordata.Ceiling, sidedef, false);
|
||||
|
||||
if (sectordata.ExtraFloors.Count > 0)
|
||||
{
|
||||
foreach (Effect3DFloor floor in sectordata.ExtraFloors)
|
||||
{
|
||||
handle = CreateVisualSlopeHandle(floor.Floor, sidedef, false);
|
||||
handle = CreateVisualSlopeHandle(floor.Ceiling, sidedef, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1362,6 +1449,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
renderer.SetVisualVertices(verts);
|
||||
}
|
||||
|
||||
// Visual slope handles
|
||||
List<VisualSlope> handles = new List<VisualSlope>();
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
foreach (VisualSlope handle in kvp.Value)
|
||||
if (handle.Selected || handle.Pivot || handle.SmartPivot || target.picked == handle)
|
||||
handles.Add(handle);
|
||||
|
||||
renderer.SetVisualSlopeHandles(handles);
|
||||
|
||||
// Done rendering geometry
|
||||
renderer.FinishGeometry();
|
||||
|
||||
|
@ -1660,7 +1756,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Apply texture offsets
|
||||
public void ApplyTextureOffsetChange(int dx, int dy)
|
||||
{
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false, false);
|
||||
|
||||
//mxd. Because Upper/Middle/Lower textures offsets should be threated separately in UDMF
|
||||
//MaxW. But they're not for Eternity, so this needs its own config setting
|
||||
|
@ -1702,7 +1798,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void ApplyFlatOffsetChange(int dx, int dy)
|
||||
{
|
||||
HashSet<int> donesectors = new HashSet<int>();
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, false, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, false, false, false, false);
|
||||
foreach(IVisualEventReceiver i in objs)
|
||||
{
|
||||
BaseVisualGeometrySector bvs = (BaseVisualGeometrySector)i;
|
||||
|
@ -1759,7 +1855,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Apply upper unpegged flag
|
||||
public void ApplyUpperUnpegged(bool set)
|
||||
{
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false, false);
|
||||
foreach(IVisualEventReceiver i in objs)
|
||||
{
|
||||
i.ApplyUpperUnpegged(set);
|
||||
|
@ -1769,7 +1865,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Apply lower unpegged flag
|
||||
public void ApplyLowerUnpegged(bool set)
|
||||
{
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false, false);
|
||||
foreach(IVisualEventReceiver i in objs)
|
||||
{
|
||||
i.ApplyLowerUnpegged(set);
|
||||
|
@ -1784,12 +1880,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(General.Map.Config.MixTexturesFlats)
|
||||
{
|
||||
// Apply on all compatible types
|
||||
objs = GetSelectedObjects(true, true, false, false);
|
||||
objs = GetSelectedObjects(true, true, false, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't want to mix textures and flats, so apply only on the appropriate type
|
||||
objs = GetSelectedObjects(flat, !flat, false, false);
|
||||
objs = GetSelectedObjects(flat, !flat, false, false, false);
|
||||
}
|
||||
|
||||
foreach(IVisualEventReceiver i in objs)
|
||||
|
@ -1799,7 +1895,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// This returns all selected objects
|
||||
internal List<IVisualEventReceiver> GetSelectedObjects(bool includesectors, bool includesidedefs, bool includethings, bool includevertices)
|
||||
internal List<IVisualEventReceiver> GetSelectedObjects(bool includesectors, bool includesidedefs, bool includethings, bool includevertices, bool includeslopehandles)
|
||||
{
|
||||
List<IVisualEventReceiver> objs = new List<IVisualEventReceiver>();
|
||||
foreach(IVisualEventReceiver i in selectedobjects)
|
||||
|
@ -1808,6 +1904,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
else if(includesidedefs && (i is BaseVisualGeometrySidedef)) objs.Add(i);
|
||||
else if(includethings && (i is BaseVisualThing)) objs.Add(i);
|
||||
else if(includevertices && (i is BaseVisualVertex)) objs.Add(i); //mxd
|
||||
else if (includeslopehandles && (i is VisualSlope)) objs.Add(i); // biwa
|
||||
}
|
||||
|
||||
// Add highlight?
|
||||
|
@ -1818,6 +1915,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
else if(includesidedefs && (i is BaseVisualGeometrySidedef)) objs.Add(i);
|
||||
else if(includethings && (i is BaseVisualThing)) objs.Add(i);
|
||||
else if(includevertices && (i is BaseVisualVertex)) objs.Add(i); //mxd
|
||||
else if (includeslopehandles && (i is VisualSlope)) objs.Add(i); // biwa
|
||||
}
|
||||
|
||||
return objs;
|
||||
|
@ -2003,12 +2101,38 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
return verts;
|
||||
}
|
||||
|
||||
// This returns all selected slope handles, no doubles
|
||||
private List<VisualSidedefSlope> GetSelectedSlopeHandles()
|
||||
{
|
||||
HashSet<VisualSidedefSlope> added = new HashSet<VisualSidedefSlope>();
|
||||
List<VisualSidedefSlope> handles = new List<VisualSidedefSlope>();
|
||||
|
||||
foreach(IVisualEventReceiver i in selectedobjects)
|
||||
{
|
||||
VisualSidedefSlope handle = i as VisualSidedefSlope;
|
||||
if(handle != null && !added.Contains(handle))
|
||||
{
|
||||
handles.Add(handle);
|
||||
added.Add(handle);
|
||||
}
|
||||
}
|
||||
|
||||
// Add highlight?
|
||||
if((selectedobjects.Count == 0) && (target.picked is VisualSidedefSlope))
|
||||
{
|
||||
VisualSidedefSlope handle = (VisualSidedefSlope)target.picked;
|
||||
if (!added.Contains(handle)) handles.Add(handle);
|
||||
}
|
||||
|
||||
return handles;
|
||||
}
|
||||
|
||||
// This returns the IVisualEventReceiver on which the action must be performed
|
||||
private IVisualEventReceiver GetTargetEventReceiver(bool targetonly)
|
||||
{
|
||||
if(target.picked != null)
|
||||
{
|
||||
if(singleselection || target.picked.Selected || targetonly)
|
||||
if(singleselection || target.picked.Selected || targetonly || target.picked is VisualSlope)
|
||||
{
|
||||
return (IVisualEventReceiver)target.picked;
|
||||
}
|
||||
|
@ -2068,14 +2192,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
#region ================== Actions
|
||||
|
||||
// [ZZ] I moved this out of ClearSelection because "cut selection" action needs this to only affect things.
|
||||
private void ClearSelection(bool clearsectors, bool clearsidedefs, bool clearthings, bool clearvertices, bool displaystatus)
|
||||
private void ClearSelection(bool clearsectors, bool clearsidedefs, bool clearthings, bool clearvertices, bool clearslopehandles, bool displaystatus)
|
||||
{
|
||||
selectedobjects.RemoveAll(obj =>
|
||||
{
|
||||
return ((obj is BaseVisualGeometrySector && clearsectors) ||
|
||||
(obj is BaseVisualGeometrySidedef && clearsidedefs) ||
|
||||
(obj is BaseVisualThing && clearthings) ||
|
||||
(obj is BaseVisualVertex && clearvertices));
|
||||
(obj is BaseVisualVertex && clearvertices) ||
|
||||
(obj is VisualSlope && clearslopehandles));
|
||||
});
|
||||
|
||||
//
|
||||
|
@ -2126,6 +2251,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// biwa
|
||||
if (clearslopehandles)
|
||||
{
|
||||
if (General.Map.UDMF)
|
||||
{
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
{
|
||||
foreach (VisualSidedefSlope handle in kvp.Value)
|
||||
{
|
||||
handle.Selected = false;
|
||||
handle.Pivot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
if (displaystatus)
|
||||
{
|
||||
|
@ -2136,7 +2277,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("clearselection", BaseAction = true)]
|
||||
public void ClearSelection()
|
||||
{
|
||||
ClearSelection(true, true, true, true, true);
|
||||
ClearSelection(true, true, true, true, true, true);
|
||||
}
|
||||
|
||||
[BeginAction("visualselect", BaseAction = true)]
|
||||
|
@ -2196,8 +2337,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void RaiseSector8()
|
||||
{
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(8);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true, true);
|
||||
bool hasvisualslopehandles = objs.Any(o => o is VisualSlope);
|
||||
foreach (IVisualEventReceiver i in objs) // If slope handles are selected only apply the action to them
|
||||
if (!hasvisualslopehandles || (hasvisualslopehandles && i is VisualSlope))
|
||||
i.OnChangeTargetHeight(8);
|
||||
PostAction();
|
||||
}
|
||||
|
||||
|
@ -2205,16 +2349,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void LowerSector8()
|
||||
{
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(-8);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true, true);
|
||||
bool hasvisualslopehandles = objs.Any(o => o is VisualSlope);
|
||||
foreach (IVisualEventReceiver i in objs) // If slope handles are selected only apply the action to them
|
||||
if (!hasvisualslopehandles || (hasvisualslopehandles && i is VisualSlope))
|
||||
i.OnChangeTargetHeight(-8);
|
||||
PostAction();
|
||||
}
|
||||
|
||||
[BeginAction("raisesector1")]
|
||||
public void RaiseSector1() {
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true);
|
||||
foreach (IVisualEventReceiver i in objs)
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true, true);
|
||||
bool hasvisualslopehandles = objs.Any(o => o is VisualSlope);
|
||||
foreach (IVisualEventReceiver i in objs) // If slope handles are selected only apply the action to them
|
||||
if (!hasvisualslopehandles || (hasvisualslopehandles && i is VisualSlope))
|
||||
i.OnChangeTargetHeight(1);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2222,8 +2371,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("lowersector1")]
|
||||
public void LowerSector1() {
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true);
|
||||
foreach (IVisualEventReceiver i in objs)
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true, true);
|
||||
bool hasvisualslopehandles = objs.Any(o => o is VisualSlope);
|
||||
foreach (IVisualEventReceiver i in objs) // If slope handles are selected only apply the action to them
|
||||
if (!hasvisualslopehandles || (hasvisualslopehandles && i is VisualSlope))
|
||||
i.OnChangeTargetHeight(-1);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2231,8 +2382,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("raisesector128")]
|
||||
public void RaiseSector128() {
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true);
|
||||
foreach (IVisualEventReceiver i in objs)
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true, true);
|
||||
bool hasvisualslopehandles = objs.Any(o => o is VisualSlope);
|
||||
foreach (IVisualEventReceiver i in objs) // If slope handles are selected only apply the action to them
|
||||
if (!hasvisualslopehandles || (hasvisualslopehandles && i is VisualSlope))
|
||||
i.OnChangeTargetHeight(128);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2240,8 +2393,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("lowersector128")]
|
||||
public void LowerSector128() {
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true);
|
||||
foreach (IVisualEventReceiver i in objs)
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true, true);
|
||||
bool hasvisualslopehandles = objs.Any(o => o is VisualSlope);
|
||||
foreach (IVisualEventReceiver i in objs) // If slope handles are selected only apply the action to them
|
||||
if (!hasvisualslopehandles || (hasvisualslopehandles && i is VisualSlope))
|
||||
i.OnChangeTargetHeight(-128);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2250,6 +2405,46 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
[BeginAction("raisesectortonearest")]
|
||||
public void RaiseSectorToNearest()
|
||||
{
|
||||
List<VisualSidedefSlope> selectedhandles = GetSelectedSlopeHandles();
|
||||
|
||||
if (selectedhandles.Count > 0)
|
||||
{
|
||||
if (selectedhandles.Count > 1)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Can only raise to nearest when one visual slope handle is selected");
|
||||
return;
|
||||
}
|
||||
|
||||
int startheight = (int)Math.Round(selectedhandles[0].GetCenterPoint().z);
|
||||
int targetheight = int.MaxValue;
|
||||
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
{
|
||||
foreach (VisualSidedefSlope handle in kvp.Value)
|
||||
{
|
||||
if (handle != selectedhandles[0] && handle.Sidedef.Line == selectedhandles[0].Sidedef.Line)
|
||||
{
|
||||
int z = (int)Math.Round(handle.GetCenterPoint().z);
|
||||
|
||||
if (z > startheight && z < targetheight)
|
||||
targetheight = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetheight != int.MaxValue)
|
||||
{
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
selectedhandles[0].OnChangeTargetHeight(targetheight - startheight);
|
||||
PostAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Can't raise: already at the highest level");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<Sector, VisualFloor> floors = new Dictionary<Sector, VisualFloor>();
|
||||
Dictionary<Sector, VisualCeiling> ceilings = new Dictionary<Sector, VisualCeiling>();
|
||||
|
@ -2262,12 +2457,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if (target.picked is VisualFloor)
|
||||
{
|
||||
VisualFloor vf = (VisualFloor)target.picked;
|
||||
floors.Add(vf.Level.sector, vf);
|
||||
floors[vf.Level.sector] = vf;
|
||||
}
|
||||
else if (target.picked is VisualCeiling)
|
||||
{
|
||||
VisualCeiling vc = (VisualCeiling)target.picked;
|
||||
ceilings.Add(vc.Level.sector, vc);
|
||||
ceilings[vc.Level.sector] = vc;
|
||||
}
|
||||
else if (target.picked is BaseVisualThing)
|
||||
{
|
||||
|
@ -2281,12 +2476,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if (i is VisualFloor)
|
||||
{
|
||||
VisualFloor vf = (VisualFloor)i;
|
||||
floors.Add(vf.Level.sector, vf);
|
||||
floors[vf.Level.sector] = vf;
|
||||
}
|
||||
else if (i is VisualCeiling)
|
||||
{
|
||||
VisualCeiling vc = (VisualCeiling)i;
|
||||
ceilings.Add(vc.Level.sector, vc);
|
||||
ceilings[vc.Level.sector] = vc;
|
||||
}
|
||||
else if (i is BaseVisualThing)
|
||||
{
|
||||
|
@ -2446,10 +2641,51 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
PostAction();
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
[BeginAction("lowersectortonearest")]
|
||||
public void LowerSectorToNearest()
|
||||
{
|
||||
List<VisualSidedefSlope> selectedhandles = GetSelectedSlopeHandles();
|
||||
|
||||
if (selectedhandles.Count > 0)
|
||||
{
|
||||
if (selectedhandles.Count > 1)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Can only lower to nearest when one visual slope handle is selected");
|
||||
return;
|
||||
}
|
||||
|
||||
int startheight = (int)Math.Round(selectedhandles[0].GetCenterPoint().z);
|
||||
int targetheight = int.MinValue;
|
||||
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
{
|
||||
foreach (VisualSidedefSlope handle in kvp.Value)
|
||||
{
|
||||
if (handle != selectedhandles[0] && handle.Sidedef.Line == selectedhandles[0].Sidedef.Line)
|
||||
{
|
||||
int z = (int)Math.Round(handle.GetCenterPoint().z);
|
||||
|
||||
if (z < startheight && z > targetheight)
|
||||
targetheight = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetheight != int.MinValue)
|
||||
{
|
||||
PreAction(UndoGroup.SectorHeightChange);
|
||||
selectedhandles[0].OnChangeTargetHeight(-(startheight - targetheight));
|
||||
PostAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Can't lower: already at the lowest level");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<Sector, VisualFloor> floors = new Dictionary<Sector, VisualFloor>();
|
||||
Dictionary<Sector, VisualCeiling> ceilings = new Dictionary<Sector, VisualCeiling>();
|
||||
|
@ -2462,12 +2698,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if (target.picked is VisualFloor)
|
||||
{
|
||||
VisualFloor vf = (VisualFloor)target.picked;
|
||||
floors.Add(vf.Level.sector, vf);
|
||||
floors[vf.Level.sector] = vf;
|
||||
}
|
||||
else if (target.picked is VisualCeiling)
|
||||
{
|
||||
VisualCeiling vc = (VisualCeiling)target.picked;
|
||||
ceilings.Add(vc.Level.sector, vc);
|
||||
ceilings[vc.Level.sector] = vc;
|
||||
}
|
||||
else if (target.picked is BaseVisualThing)
|
||||
{
|
||||
|
@ -2481,12 +2717,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if (i is VisualFloor)
|
||||
{
|
||||
VisualFloor vf = (VisualFloor)i;
|
||||
floors.Add(vf.Level.sector, vf);
|
||||
floors[vf.Level.sector] = vf;
|
||||
}
|
||||
else if (i is VisualCeiling)
|
||||
{
|
||||
VisualCeiling vc = (VisualCeiling)i;
|
||||
ceilings.Add(vc.Level.sector, vc);
|
||||
ceilings[vc.Level.sector] = vc;
|
||||
}
|
||||
else if (i is BaseVisualThing)
|
||||
{
|
||||
|
@ -2643,6 +2879,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
PostAction();
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
[BeginAction("matchbrightness")]
|
||||
|
@ -2800,7 +3037,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void RaiseBrightness8()
|
||||
{
|
||||
PreAction(UndoGroup.SectorBrightnessChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetBrightness(true);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2809,7 +3046,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void LowerBrightness8()
|
||||
{
|
||||
PreAction(UndoGroup.SectorBrightnessChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetBrightness(false);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2831,7 +3068,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private void MoveTextureByOffset(int ox, int oy)
|
||||
{
|
||||
PreAction(UndoGroup.TextureOffsetChange);
|
||||
IEnumerable<IVisualEventReceiver> objs = RemoveDuplicateSidedefs(GetSelectedObjects(true, true, false, false));
|
||||
IEnumerable<IVisualEventReceiver> objs = RemoveDuplicateSidedefs(GetSelectedObjects(true, true, false, false, false));
|
||||
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(ox, oy, true);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2848,7 +3085,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private void ScaleTexture(int incrementx, int incrementy)
|
||||
{
|
||||
PreAction(UndoGroup.TextureScaleChange);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnChangeScale(incrementx, incrementy);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2878,7 +3115,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void TexturePaste()
|
||||
{
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnPasteTexture();
|
||||
PostAction();
|
||||
}
|
||||
|
@ -2980,7 +3217,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.Map.ClearMarkedSidedefs(false);
|
||||
|
||||
//get selection
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false, false);
|
||||
|
||||
//align
|
||||
foreach(IVisualEventReceiver i in objs)
|
||||
|
@ -3016,7 +3253,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PreAction(UndoGroup.None);
|
||||
|
||||
// Get selection
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false, false, false);
|
||||
List<BaseVisualGeometrySidedef> sides = new List<BaseVisualGeometrySidedef>();
|
||||
foreach(IVisualEventReceiver i in objs)
|
||||
{
|
||||
|
@ -3068,7 +3305,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void ResetTexture()
|
||||
{
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnResetTextureOffset();
|
||||
PostAction();
|
||||
}
|
||||
|
@ -3077,7 +3314,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void ResetLocalOffsets()
|
||||
{
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnResetLocalTextureOffset();
|
||||
PostAction();
|
||||
}
|
||||
|
@ -3102,7 +3339,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void TexturePasteOffsets()
|
||||
{
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnPasteTextureOffsets();
|
||||
PostAction();
|
||||
}
|
||||
|
@ -3119,7 +3356,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void PasteProperties()
|
||||
{
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true, false);
|
||||
foreach(IVisualEventReceiver i in objs) i.OnPasteProperties(false);
|
||||
PostAction();
|
||||
}
|
||||
|
@ -3134,7 +3371,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
var selection = new List<IVisualEventReceiver>();
|
||||
|
||||
// Sectors selected?
|
||||
var obj = GetSelectedObjects(true, false, false, false);
|
||||
var obj = GetSelectedObjects(true, false, false, false, false);
|
||||
if(obj.Count > 0)
|
||||
{
|
||||
targettypes.Add(MapElementType.SECTOR);
|
||||
|
@ -3153,7 +3390,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Sidedefs selected?
|
||||
obj = GetSelectedObjects(false, true, false, false);
|
||||
obj = GetSelectedObjects(false, true, false, false, false);
|
||||
if(obj.Count > 0)
|
||||
{
|
||||
targettypes.Add(MapElementType.SIDEDEF);
|
||||
|
@ -3172,7 +3409,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Things selected?
|
||||
obj = GetSelectedObjects(false, false, true, false);
|
||||
obj = GetSelectedObjects(false, false, true, false, false);
|
||||
if(obj.Count > 0)
|
||||
{
|
||||
targettypes.Add(MapElementType.THING);
|
||||
|
@ -3191,7 +3428,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Vertices selected?
|
||||
obj = GetSelectedObjects(false, false, false, true);
|
||||
obj = GetSelectedObjects(false, false, false, true, false);
|
||||
if(obj.Count > 0)
|
||||
{
|
||||
targettypes.Add(MapElementType.VERTEX);
|
||||
|
@ -3267,7 +3504,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void Delete()
|
||||
{
|
||||
PreAction(UndoGroup.None);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true, true, false);
|
||||
foreach (IVisualEventReceiver i in objs)
|
||||
{
|
||||
if (i is BaseVisualThing)
|
||||
|
@ -3283,7 +3520,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("copyselection", BaseAction = true)]
|
||||
public void CopySelection()
|
||||
{
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, false, true, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, false, true, false, false);
|
||||
if(objs.Count == 0) return;
|
||||
|
||||
copybuffer.Clear();
|
||||
|
@ -3308,7 +3545,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
CreateUndo("Cut " + rest);
|
||||
General.Interface.DisplayStatus(StatusType.Info, "Cut " + rest);
|
||||
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, false, true, false);
|
||||
List<IVisualEventReceiver> objs = GetSelectedObjects(false, false, true, false, false);
|
||||
foreach(IVisualEventReceiver i in objs)
|
||||
{
|
||||
BaseVisualThing thing = (BaseVisualThing)i;
|
||||
|
@ -3322,7 +3559,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.ThingsFilter.Update();
|
||||
|
||||
// [ZZ] Clear selected things.
|
||||
ClearSelection(false, false, true, false, false);
|
||||
ClearSelection(false, false, true, false, false, false);
|
||||
|
||||
// Update event lines
|
||||
renderer.SetEventLines(LinksCollector.GetHelperShapes(General.Map.ThingsFilter.VisibleThings, blockmap));
|
||||
|
@ -3398,7 +3635,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
PreAction(UndoGroup.ThingAngleChange);
|
||||
|
||||
List<IVisualEventReceiver> selection = GetSelectedObjects(true, false, true, false);
|
||||
List<IVisualEventReceiver> selection = GetSelectedObjects(true, false, true, false, false);
|
||||
if(selection.Count == 0) return;
|
||||
|
||||
foreach(IVisualEventReceiver obj in selection)
|
||||
|
@ -3460,7 +3697,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
PreAction(UndoGroup.ThingPitchChange);
|
||||
|
||||
List<IVisualEventReceiver> selection = GetSelectedObjects(false, false, true, false);
|
||||
List<IVisualEventReceiver> selection = GetSelectedObjects(false, false, true, false, false);
|
||||
if(selection.Count == 0) return;
|
||||
|
||||
foreach(IVisualEventReceiver obj in selection)
|
||||
|
@ -3491,7 +3728,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
PreAction(UndoGroup.ThingRollChange);
|
||||
|
||||
List<IVisualEventReceiver> selection = GetSelectedObjects(false, false, true, false);
|
||||
List<IVisualEventReceiver> selection = GetSelectedObjects(false, false, true, false, false);
|
||||
if(selection.Count == 0) return;
|
||||
|
||||
foreach(IVisualEventReceiver obj in selection)
|
||||
|
@ -3862,6 +4099,105 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
GetTargetEventReceiver(true).OnPaintSelectEnd();
|
||||
}
|
||||
|
||||
[BeginAction("togglevisualslopepicking")]
|
||||
public void ToggleVisualSlopePicking()
|
||||
{
|
||||
if (pickingmode != PickingMode.SlopeHandles)
|
||||
pickingmode = PickingMode.SlopeHandles;
|
||||
else
|
||||
{
|
||||
pickingmode = PickingMode.Default;
|
||||
|
||||
// Clear smart pivot handles, otherwise it will keep being displayed
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
|
||||
foreach (VisualSidedefSlope checkhandle in kvp.Value)
|
||||
checkhandle.SmartPivot = false;
|
||||
}
|
||||
}
|
||||
|
||||
[BeginAction("slopebetweenhandles")]
|
||||
public void SlopeBetweenHandles()
|
||||
{
|
||||
List<IVisualEventReceiver> selectedsectors = GetSelectedObjects(true, false, false, false, false);
|
||||
if (selectedsectors.Count == 0)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "You need to select floors or ceilings to slope between slope handles.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<VisualSidedefSlope> handles = GetSelectedSlopeHandles();
|
||||
|
||||
// No handles selected, try to slope between highlighted handle and it smart pivot
|
||||
if (handles.Count == 0 && HighlightedTarget is VisualSidedefSlope)
|
||||
{
|
||||
VisualSidedefSlope handle = VisualSidedefSlope.GetSmartPivotHandle((VisualSidedefSlope)HighlightedTarget, this);
|
||||
if (handle == null)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Couldn't find a smart pivot handle.");
|
||||
return;
|
||||
}
|
||||
|
||||
handles.Add((VisualSidedefSlope)HighlightedTarget);
|
||||
handles.Add(handle);
|
||||
}
|
||||
// One handle selected, try to slope between it and the highlighted handle or the selected one's smart pivot
|
||||
else if (handles.Count == 1)
|
||||
{
|
||||
if (HighlightedTarget == handles[0] || !(HighlightedTarget is VisualSidedefSlope))
|
||||
{
|
||||
VisualSidedefSlope handle;
|
||||
|
||||
if(HighlightedTarget is VisualSidedefSlope)
|
||||
handle = VisualSidedefSlope.GetSmartPivotHandle((VisualSidedefSlope)HighlightedTarget, this);
|
||||
else
|
||||
handle = VisualSidedefSlope.GetSmartPivotHandle(handles[0], this);
|
||||
|
||||
if (handle == null)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Couldn't find a smart pivot handle.");
|
||||
return;
|
||||
}
|
||||
|
||||
handles.Add(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
handles.Add((VisualSidedefSlope)HighlightedTarget);
|
||||
}
|
||||
}
|
||||
// Return if more than two handles are selected
|
||||
else if(handles.Count > 2)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "Too many slope handles selected.");
|
||||
return;
|
||||
}
|
||||
// Everything else
|
||||
else if(handles.Count != 2)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "No slope handles selected or highlighted.");
|
||||
return;
|
||||
}
|
||||
|
||||
General.Map.UndoRedo.CreateUndo("Slope between slope handles");
|
||||
|
||||
// Create the new plane
|
||||
Vector3D p1 = new Vector3D(handles[0].Sidedef.Line.Start.Position, handles[0].Level.plane.GetZ(handles[0].Sidedef.Line.Start.Position));
|
||||
Vector3D p2 = new Vector3D(handles[0].Sidedef.Line.End.Position, handles[0].Level.plane.GetZ(handles[0].Sidedef.Line.End.Position));
|
||||
Vector3D p3 = new Vector3D(handles[1].Sidedef.Line.Line.GetCoordinatesAt(0.5f), handles[1].Level.plane.GetZ(handles[1].Sidedef.Line.Line.GetCoordinatesAt(0.5f)));
|
||||
Plane plane = new Plane(p1, p2, p3, true);
|
||||
|
||||
// Apply slope
|
||||
foreach (BaseVisualGeometrySector bvgs in selectedsectors)
|
||||
{
|
||||
VisualSidedefSlope.ApplySlope(bvgs.Level, plane, this);
|
||||
bvgs.Sector.UpdateSectorGeometry(true);
|
||||
}
|
||||
|
||||
UpdateChangedObjects();
|
||||
|
||||
General.Interface.DisplayStatus(StatusType.Action, "Sloped between slope handles.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Texture Alignment
|
||||
|
|
|
@ -391,6 +391,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd. Modify slope offset?
|
||||
if(level.sector.CeilSlope.GetLengthSq() > 0)
|
||||
{
|
||||
/*
|
||||
Vector3D center = new Vector3D(level.sector.BBox.X + level.sector.BBox.Width / 2,
|
||||
level.sector.BBox.Y + level.sector.BBox.Height / 2,
|
||||
level.sector.CeilHeight);
|
||||
|
@ -401,6 +402,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
false);
|
||||
|
||||
level.sector.CeilSlopeOffset = p.Offset;
|
||||
*/
|
||||
|
||||
level.sector.CeilSlopeOffset -= level.sector.CeilSlope.z * amount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -650,43 +654,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
if(!General.Map.UDMF) return;
|
||||
|
||||
//is is a surface with line slope?
|
||||
float slopeAngle = level.plane.Normal.GetAngleZ() - Angle2D.PIHALF;
|
||||
|
||||
if(slopeAngle == 0) //it's a horizontal plane
|
||||
{
|
||||
AlignTextureToClosestLine(alignx, aligny);
|
||||
}
|
||||
else //it can be a surface with line slope
|
||||
{
|
||||
Linedef slopeSource = null;
|
||||
bool isFront = false;
|
||||
|
||||
foreach(Sidedef side in Sector.Sector.Sidedefs)
|
||||
{
|
||||
if(side.Line.Action == 181)
|
||||
{
|
||||
if(side.Line.Args[1] == 1 && side.Line.Front != null && side.Line.Front == side)
|
||||
{
|
||||
slopeSource = side.Line;
|
||||
isFront = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(side.Line.Args[1] == 2 && side.Line.Back != null && side.Line.Back == side)
|
||||
{
|
||||
slopeSource = side.Line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(slopeSource != null && slopeSource.Front != null && slopeSource.Front.Sector != null && slopeSource.Back != null && slopeSource.Back.Sector != null)
|
||||
AlignTextureToSlopeLine(slopeSource, slopeAngle, isFront, alignx, aligny);
|
||||
else
|
||||
AlignTextureToClosestLine(alignx, aligny);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -351,6 +351,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd. Modify slope offset?
|
||||
if(level.sector.FloorSlope.GetLengthSq() > 0)
|
||||
{
|
||||
/*
|
||||
Vector3D center = new Vector3D(level.sector.BBox.X + level.sector.BBox.Width / 2,
|
||||
level.sector.BBox.Y + level.sector.BBox.Height / 2,
|
||||
level.sector.FloorHeight);
|
||||
|
@ -361,6 +362,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
true);
|
||||
|
||||
level.sector.FloorSlopeOffset = p.Offset;
|
||||
*/
|
||||
|
||||
level.sector.FloorSlopeOffset -= level.sector.FloorSlope.z * amount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,43 +586,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
if(!General.Map.UDMF) return;
|
||||
|
||||
//is is a surface with line slope?
|
||||
float slopeAngle = level.plane.Normal.GetAngleZ() - Angle2D.PIHALF;
|
||||
|
||||
if(slopeAngle == 0) //it's a horizontal plane
|
||||
{
|
||||
AlignTextureToClosestLine(alignx, aligny);
|
||||
}
|
||||
else //it can be a surface with line slope
|
||||
{
|
||||
Linedef slopeSource = null;
|
||||
bool isFront = false;
|
||||
|
||||
foreach(Sidedef side in Sector.Sector.Sidedefs)
|
||||
{
|
||||
if(side.Line.Action == 181)
|
||||
{
|
||||
if(side.Line.Args[0] == 1 && side.Line.Front != null && side.Line.Front == side)
|
||||
{
|
||||
slopeSource = side.Line;
|
||||
isFront = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(side.Line.Args[0] == 2 && side.Line.Back != null && side.Line.Back == side)
|
||||
{
|
||||
slopeSource = side.Line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(slopeSource != null && slopeSource.Front != null && slopeSource.Front.Sector != null && slopeSource.Back != null && slopeSource.Back.Sector != null)
|
||||
AlignTextureToSlopeLine(slopeSource, slopeAngle, isFront, alignx, aligny);
|
||||
else
|
||||
AlignTextureToClosestLine(alignx, aligny);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
412
Source/Plugins/BuilderModes/VisualModes/VisualSidedefSlope.cs
Normal file
412
Source/Plugins/BuilderModes/VisualModes/VisualSidedefSlope.cs
Normal file
|
@ -0,0 +1,412 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.BuilderModes;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
namespace CodeImp.DoomBuilder.VisualModes
|
||||
{
|
||||
internal class VisualSidedefSlope : VisualSlope, IVisualEventReceiver
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private readonly BaseVisualMode mode;
|
||||
private readonly Sidedef sidedef;
|
||||
private readonly SectorLevel level;
|
||||
private readonly bool up;
|
||||
private Vector3D pickintersect;
|
||||
private float pickrayu;
|
||||
private Plane plane;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constants
|
||||
|
||||
private const int SIZE = 8;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public Sidedef Sidedef { get { return sidedef; } }
|
||||
public SectorLevel Level { get { return level; } }
|
||||
public int NormalizedAngleDeg { get { return (sidedef.Line.AngleDeg >= 180) ? (sidedef.Line.AngleDeg - 180) : sidedef.Line.AngleDeg; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
public VisualSidedefSlope(BaseVisualMode mode, SectorLevel level, Sidedef sidedef, bool up) : base()
|
||||
{
|
||||
this.mode = mode;
|
||||
this.sidedef = sidedef;
|
||||
this.level = level;
|
||||
this.up = up;
|
||||
|
||||
// length = sidedef.Line.Length;
|
||||
|
||||
Update();
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
public Vector3D GetCenterPoint()
|
||||
{
|
||||
Vector2D p = sidedef.Line.GetCenterPoint();
|
||||
return new Vector3D(p, level.plane.GetZ(p));
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
plane = new Plane(level.plane.Normal, level.plane.Offset - 0.1f);
|
||||
|
||||
if (!up)
|
||||
plane = plane.GetInverted();
|
||||
|
||||
UpdatePosition();
|
||||
|
||||
length = new Line3D(new Vector3D(sidedef.Line.Line.v1, plane.GetZ(sidedef.Line.Line.v1)), new Vector3D(sidedef.Line.Line.v2, plane.GetZ(sidedef.Line.Line.v2))).GetDelta().GetLength();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called when the thing must be tested for line intersection. This should reject
|
||||
/// as fast as possible to rule out all geometry that certainly does not touch the line.
|
||||
/// </summary>
|
||||
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
|
||||
{
|
||||
RectangleF bbox = sidedef.Sector.BBox;
|
||||
|
||||
if ((up && plane.Distance(from) > 0.0f) || (!up && plane.Distance(from) < 0.0f))
|
||||
{
|
||||
if (plane.GetIntersection(from, to, ref pickrayu))
|
||||
{
|
||||
if (pickrayu > 0.0f)
|
||||
{
|
||||
pickintersect = from + (to - from) * pickrayu;
|
||||
|
||||
return ((pickintersect.x >= bbox.Left) && (pickintersect.x <= bbox.Right) &&
|
||||
(pickintersect.y >= bbox.Top) && (pickintersect.y <= bbox.Bottom));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called when the thing must be tested for line intersection. This should perform
|
||||
/// accurate hit detection and set u_ray to the position on the ray where this hits the geometry.
|
||||
/// </summary>
|
||||
public override bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
|
||||
{
|
||||
u_ray = pickrayu;
|
||||
|
||||
Sidedef sd = MapSet.NearestSidedef(sidedef.Sector.Sidedefs, pickintersect);
|
||||
if (sd == sidedef) {
|
||||
float side = sd.Line.SideOfLine(pickintersect);
|
||||
|
||||
if ((side <= 0.0f && sd.IsFront) || (side > 0.0f && !sd.IsFront))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the position. Depending on 3D floors and which side of the linedef the slope handle is on the
|
||||
/// direction of the line used as a base has to be inverted
|
||||
/// </summary>
|
||||
public void UpdatePosition()
|
||||
{
|
||||
bool invertline = false;
|
||||
|
||||
if (up)
|
||||
{
|
||||
if (level.extrafloor && level.type == SectorLevelType.Ceiling)
|
||||
{
|
||||
if (sidedef.IsFront)
|
||||
invertline = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sidedef.IsFront)
|
||||
invertline = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (level.extrafloor && level.type == SectorLevelType.Floor)
|
||||
{
|
||||
if (!sidedef.IsFront)
|
||||
invertline = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sidedef.IsFront)
|
||||
invertline = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (invertline)
|
||||
SetPosition(new Line2D(sidedef.Line.End.Position, sidedef.Line.Start.Position), level.plane);
|
||||
else
|
||||
SetPosition(sidedef.Line.Line, level.plane);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find a slope handle to pivot around. If possible if finds the handle belonging to a line that has the
|
||||
/// same angle as the start handle, and is the furthest away. If such a handle does not exist it finds one that's
|
||||
/// closest to those specs
|
||||
/// </summary>
|
||||
/// <param name="starthandle">The slope handle to start from (the one we need to find a pivot handle for)</param>
|
||||
/// <returns></returns>
|
||||
public static VisualSidedefSlope GetSmartPivotHandle(VisualSidedefSlope starthandle, BaseVisualMode mode)
|
||||
{
|
||||
VisualSidedefSlope handle = starthandle;
|
||||
List<VisualSidedefSlope> potentialhandles = new List<VisualSidedefSlope>();
|
||||
List<IVisualEventReceiver> selectedsectors = mode.GetSelectedObjects(true, false, false, false, false);
|
||||
|
||||
if (selectedsectors.Count == 0)
|
||||
{
|
||||
// No sectors selected, so find all handles that belong to the same level
|
||||
foreach (VisualSidedefSlope checkhandle in mode.AllSlopeHandles[starthandle.Sidedef.Sector])
|
||||
if (checkhandle != starthandle && checkhandle.Level == starthandle.Level)
|
||||
potentialhandles.Add(checkhandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sectors are selected, get all handles from those sectors that have the same level
|
||||
HashSet<Sector> sectors = new HashSet<Sector>();
|
||||
|
||||
foreach (BaseVisualGeometrySector bvgs in selectedsectors)
|
||||
sectors.Add(bvgs.Sector.Sector);
|
||||
|
||||
foreach (Sector s in sectors)
|
||||
foreach (VisualSidedefSlope checkhandle in mode.AllSlopeHandles[s])
|
||||
if(checkhandle != starthandle)
|
||||
foreach (BaseVisualGeometrySector bvgs in selectedsectors)
|
||||
if (bvgs.Level == checkhandle.Level)
|
||||
potentialhandles.Add(checkhandle);
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in mode.AllSlopeHandles)
|
||||
foreach (VisualSidedefSlope checkhandle in kvp.Value)
|
||||
checkhandle.SmartPivot = false;
|
||||
|
||||
// Sort potential handles by their angle difference to the start handle. That means that handles with less angle difference will be at the beginning of the list
|
||||
List<VisualSidedefSlope> anglediffsortedhandles = potentialhandles.OrderBy(h => Math.Abs(starthandle.NormalizedAngleDeg - h.NormalizedAngleDeg)).ToList();
|
||||
|
||||
// Get all potential handles that have to same angle as the one that's closest to the start handle, then sort them by distance, and take the one that's furthest away
|
||||
if (anglediffsortedhandles.Count > 0)
|
||||
handle = anglediffsortedhandles.Where(h => h.NormalizedAngleDeg == anglediffsortedhandles[0].NormalizedAngleDeg).OrderByDescending(h => Math.Abs(starthandle.Sidedef.Line.Line.GetDistanceToLine(h.sidedef.Line.GetCenterPoint(), false))).First();
|
||||
|
||||
if (handle == starthandle)
|
||||
return null;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
public static void ApplySlope(SectorLevel level, Plane plane, BaseVisualMode mode)
|
||||
{
|
||||
bool applytoceiling = false;
|
||||
|
||||
Vector2D center = new Vector2D(level.sector.BBox.X + level.sector.BBox.Width / 2,
|
||||
level.sector.BBox.Y + level.sector.BBox.Height / 2);
|
||||
|
||||
if (level.extrafloor)
|
||||
{
|
||||
// The top side of 3D floors is the ceiling of the sector, but it's a "floor" in UDB, so the
|
||||
// ceiling of the control sector has to be modified
|
||||
if (level.type == SectorLevelType.Floor)
|
||||
applytoceiling = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (level.type == SectorLevelType.Ceiling)
|
||||
applytoceiling = true;
|
||||
}
|
||||
|
||||
if (applytoceiling)
|
||||
{
|
||||
Plane downplane = plane.GetInverted();
|
||||
level.sector.CeilSlope = downplane.Normal;
|
||||
level.sector.CeilSlopeOffset = downplane.Offset;
|
||||
level.sector.CeilHeight = (int)new Plane(level.sector.CeilSlope, level.sector.CeilSlopeOffset).GetZ(center);
|
||||
}
|
||||
else
|
||||
{
|
||||
level.sector.FloorSlope = plane.Normal;
|
||||
level.sector.FloorSlopeOffset = plane.Offset;
|
||||
level.sector.FloorHeight = (int)new Plane(level.sector.FloorSlope, level.sector.FloorSlopeOffset).GetZ(center);
|
||||
}
|
||||
|
||||
// Rebuild sector
|
||||
BaseVisualSector vs;
|
||||
if (mode.VisualSectorExists(level.sector))
|
||||
{
|
||||
vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
|
||||
}
|
||||
else
|
||||
{
|
||||
vs = mode.CreateBaseVisualSector(level.sector);
|
||||
}
|
||||
|
||||
if (vs != null) vs.UpdateSectorGeometry(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
public void OnChangeTargetHeight(int amount)
|
||||
{
|
||||
VisualSlope pivothandle = null;
|
||||
List<IVisualEventReceiver> selectedsectors = mode.GetSelectedObjects(true, false, false, false, false);
|
||||
List<SectorLevel> levels = new List<SectorLevel>();
|
||||
|
||||
if (selectedsectors.Count == 0)
|
||||
levels.Add(level);
|
||||
else
|
||||
{
|
||||
foreach (BaseVisualGeometrySector bvgs in selectedsectors)
|
||||
levels.Add(bvgs.Level);
|
||||
|
||||
if (!levels.Contains(level))
|
||||
levels.Add(level);
|
||||
}
|
||||
|
||||
// Try to find a slope handle the user set to be the pivot handle
|
||||
// TODO: doing this every time is kind of stupid. Maybe store the pivot handle in the mode?
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in mode.AllSlopeHandles)
|
||||
{
|
||||
foreach (VisualSidedefSlope handle in kvp.Value)
|
||||
{
|
||||
if (handle.Pivot)
|
||||
{
|
||||
pivothandle = handle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// User didn't set a pivot handle, try to find the smart pivot handle
|
||||
if(pivothandle == null)
|
||||
pivothandle = GetSmartPivotHandle(this, mode);
|
||||
|
||||
// Still no pivot handle, cancle
|
||||
if (pivothandle == null)
|
||||
return;
|
||||
|
||||
pivothandle.SmartPivot = true;
|
||||
|
||||
mode.CreateUndo("Change slope");
|
||||
|
||||
Plane originalplane = level.plane;
|
||||
Plane pivotplane = ((VisualSidedefSlope)pivothandle).Level.plane;
|
||||
|
||||
// Build a new plane. p1 and p2 are the points of the slope handle that is modified, p3 is on the line of the pivot handle
|
||||
Vector3D p1 = new Vector3D(sidedef.Line.Start.Position, (float)Math.Round(originalplane.GetZ(sidedef.Line.Start.Position)));
|
||||
Vector3D p2 = new Vector3D(sidedef.Line.End.Position, (float)Math.Round(originalplane.GetZ(sidedef.Line.End.Position)));
|
||||
Vector3D p3 = new Vector3D(((VisualSidedefSlope)pivothandle).Sidedef.Line.Line.GetCoordinatesAt(0.5f), (float)Math.Round(pivotplane.GetZ(((VisualSidedefSlope)pivothandle).Sidedef.Line.Line.GetCoordinatesAt(0.5f))));
|
||||
|
||||
// Move the points of the handle up/down
|
||||
p1 += new Vector3D(0f, 0f, amount);
|
||||
p2 += new Vector3D(0f, 0f, amount);
|
||||
|
||||
Plane plane = new Plane(p1, p2, p3, true);
|
||||
|
||||
// Apply slope to surfaces
|
||||
foreach (SectorLevel l in levels)
|
||||
ApplySlope(l, plane, mode);
|
||||
|
||||
mode.SetActionResult("Changed slope.");
|
||||
}
|
||||
|
||||
// Select or deselect
|
||||
public void OnSelectEnd()
|
||||
{
|
||||
if (this.selected)
|
||||
{
|
||||
this.selected = false;
|
||||
mode.RemoveSelectedObject(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.pivot)
|
||||
{
|
||||
General.Interface.DisplayStatus(Windows.StatusType.Warning, "It is not allowed to mark pivot slope handles as selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.selected = true;
|
||||
mode.AddSelectedObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEditEnd()
|
||||
{
|
||||
// We can only have one pivot handle, so remove it from all first
|
||||
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in mode.AllSlopeHandles)
|
||||
{
|
||||
foreach (VisualSlope handle in kvp.Value)
|
||||
{
|
||||
if (handle == mode.HighlightedTarget)
|
||||
{
|
||||
if (handle.Selected)
|
||||
General.Interface.DisplayStatus(Windows.StatusType.Warning, "It is not allowed to mark selected slope handles as pivot slope handles.");
|
||||
else
|
||||
handle.Pivot = !handle.Pivot;
|
||||
}
|
||||
else
|
||||
handle.Pivot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return texture name
|
||||
public string GetTextureName() { return ""; }
|
||||
|
||||
// Unused
|
||||
public void OnSelectBegin() { }
|
||||
public void OnEditBegin() { }
|
||||
public void OnChangeTargetBrightness(bool up) { }
|
||||
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
|
||||
public void OnSelectTexture() { }
|
||||
public void OnCopyTexture() { }
|
||||
public void OnPasteTexture() { }
|
||||
public void OnCopyTextureOffsets() { }
|
||||
public void OnPasteTextureOffsets() { }
|
||||
public void OnTextureAlign(bool alignx, bool aligny) { }
|
||||
public void OnToggleUpperUnpegged() { }
|
||||
public void OnToggleLowerUnpegged() { }
|
||||
public void OnProcess(long deltatime) { }
|
||||
public void OnTextureFloodfill() { }
|
||||
public void OnInsert() { }
|
||||
public void OnTextureFit(FitTextureOptions options) { } //mxd
|
||||
public void ApplyTexture(string texture) { }
|
||||
public void ApplyUpperUnpegged(bool set) { }
|
||||
public void ApplyLowerUnpegged(bool set) { }
|
||||
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
|
||||
public virtual void OnPaintSelectEnd() { } // biwa
|
||||
public void OnChangeScale(int x, int y) { }
|
||||
public void OnResetTextureOffset() { }
|
||||
public void OnResetLocalTextureOffset() { }
|
||||
public void OnCopyProperties() { }
|
||||
public void OnPasteProperties(bool usecopysetting) { }
|
||||
public void OnDelete() { }
|
||||
public void OnPaintSelectBegin() { }
|
||||
public void OnMouseMove(MouseEventArgs e) { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue