From 158df426f4e12ed6205445d112166f9e05eb1fc5 Mon Sep 17 00:00:00 2001 From: MaxED Date: Mon, 1 Aug 2016 08:08:57 +0000 Subject: [PATCH] Fixed, Visual mode: thing argument helper shapes were rendered at incorrect height. --- Source/Core/Controls/ResourceListEditor.cs | 54 +++++++++---------- Source/Core/GZBuilder/Data/LinksCollector.cs | 56 +++++++++++--------- 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/Source/Core/Controls/ResourceListEditor.cs b/Source/Core/Controls/ResourceListEditor.cs index 401f5fa7..b9b3cb35 100644 --- a/Source/Core/Controls/ResourceListEditor.cs +++ b/Source/Core/Controls/ResourceListEditor.cs @@ -387,45 +387,43 @@ namespace CodeImp.DoomBuilder.Controls // Item dropped private void resourceitems_DragDrop(object sender, DragEventArgs e) { - if(!e.Data.GetDataPresent(DataFormats.FileDrop)) - { - //mxd. Items were rearranged. Raise content changed event - if(OnContentChanged != null) OnContentChanged(); - return; - } - //mxd. Accept filesystem drop - string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop); - int addedfiles = 0; - foreach(string path in paths) + if(e.Data.GetDataPresent(DataFormats.FileDrop)) { - if(File.Exists(path)) + string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop); + int addedfiles = 0; + foreach(string path in paths) { - string ext = Path.GetExtension(path); - if(string.IsNullOrEmpty(ext)) continue; - switch(ext.ToLower()) + if(File.Exists(path)) { - case ".wad": - if(AddItem(new DataLocation(DataLocation.RESOURCE_WAD, path, false, false, false))) - addedfiles++; - break; - case ".pk7": - case ".pk3": - if(AddItem(new DataLocation(DataLocation.RESOURCE_PK3, path, false, false, false))) - addedfiles++; - break; + string ext = Path.GetExtension(path); + if(string.IsNullOrEmpty(ext)) continue; + switch(ext.ToLower()) + { + case ".wad": + if(AddItem(new DataLocation(DataLocation.RESOURCE_WAD, path, false, false, false))) addedfiles++; + break; + case ".pk7": + case ".pk3": + if(AddItem(new DataLocation(DataLocation.RESOURCE_PK3, path, false, false, false))) addedfiles++; + break; + } + } + else if(Directory.Exists(path)) + { + if(AddItem(new DataLocation(DataLocation.RESOURCE_DIRECTORY, path, false, false, false))) addedfiles++; } } - else if(Directory.Exists(path)) + + if(addedfiles == 0) { - if(AddItem(new DataLocation(DataLocation.RESOURCE_DIRECTORY, path, false, false, false))) - addedfiles++; + General.Interface.DisplayStatus(StatusType.Warning, "Invalid or duplicate resources!"); + return; } } // Raise content changed event - if(addedfiles > 0 && OnContentChanged != null) OnContentChanged(); - if(addedfiles == 0) General.Interface.DisplayStatus(StatusType.Warning, "Invalid or duplicate resources!"); //mxd + if(OnContentChanged != null) OnContentChanged(); } // Client size changed diff --git a/Source/Core/GZBuilder/Data/LinksCollector.cs b/Source/Core/GZBuilder/Data/LinksCollector.cs index 91c150d9..e5113980 100644 --- a/Source/Core/GZBuilder/Data/LinksCollector.cs +++ b/Source/Core/GZBuilder/Data/LinksCollector.cs @@ -50,7 +50,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data public PathNode(Thing t, VisualBlockMap blockmap) { thing = t; - position = new Vector3D(t.Position, (blockmap != null ? t.Position.z + GetCorrectHeight(t, blockmap) : t.Position.z)); + position = t.Position; + position.z += GetCorrectHeight(t, blockmap, true); nextnodes = new Dictionary(); prevnodes = new Dictionary(); } @@ -73,15 +74,15 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data } } - public static IEnumerable MakeCircleLines(Vector2D pos, PixelColor color, float radius, int numsides) + public static IEnumerable MakeCircleLines(Vector3D pos, PixelColor color, float radius, int numsides) { List result = new List(numsides); - Vector2D start = new Vector2D(pos.x, pos.y + radius); + Vector3D start = new Vector3D(pos.x, pos.y + radius, pos.z); float anglestep = Angle2D.PI2 / numsides; for(int i = 1; i < numsides + 1; i++) { - Vector2D end = pos + new Vector2D((float)Math.Sin(anglestep * i) * radius, (float)Math.Cos(anglestep * i) * radius); + Vector3D end = pos + new Vector3D((float)Math.Sin(anglestep * i) * radius, (float)Math.Cos(anglestep * i) * radius, 0f); result.Add(new Line3D(start, end, color, false)); start = end; } @@ -89,13 +90,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data return result; } - public static IEnumerable MakeRectangleLines(Vector2D pos, PixelColor color, float size) + public static IEnumerable MakeRectangleLines(Vector3D pos, PixelColor color, float size) { float halfsize = size / 2; - Vector2D tl = new Vector2D(pos.x - halfsize, pos.y - halfsize); - Vector2D tr = new Vector2D(pos.x + halfsize, pos.y - halfsize); - Vector2D bl = new Vector2D(pos.x - halfsize, pos.y + halfsize); - Vector2D br = new Vector2D(pos.x + halfsize, pos.y + halfsize); + Vector3D tl = new Vector3D(pos.x - halfsize, pos.y - halfsize, pos.z); + Vector3D tr = new Vector3D(pos.x + halfsize, pos.y - halfsize, pos.z); + Vector3D bl = new Vector3D(pos.x - halfsize, pos.y + halfsize, pos.z); + Vector3D br = new Vector3D(pos.x + halfsize, pos.y + halfsize, pos.z); return new List { @@ -214,12 +215,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data if(!result.PatrolPoints.ContainsKey(t.Args[0])) continue; start = t.Position; - start.z += GetCorrectHeight(t, blockmap); + start.z += GetCorrectHeight(t, blockmap, true); foreach(Thing tt in result.PatrolPoints[t.Args[0]]) { end = tt.Position; - end.z += GetCorrectHeight(tt, blockmap); + end.z += GetCorrectHeight(tt, blockmap, true); lines.Add(new Line3D(start, end)); } } @@ -231,12 +232,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data if(!result.PatrolPoints.ContainsKey(t.Args[1])) continue; start = t.Position; - start.z += GetCorrectHeight(t, blockmap); + start.z += GetCorrectHeight(t, blockmap, true); foreach(Thing tt in result.PatrolPoints[t.Args[1]]) { end = tt.Position; - end.z += GetCorrectHeight(tt, blockmap); + end.z += GetCorrectHeight(tt, blockmap, true); lines.Add(new Line3D(start, end, General.Colors.Selection)); } @@ -246,11 +247,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data foreach(Thing t in result.Cameras) { int targettag = t.Args[0] + (t.Args[1] << 8); - if(targettag == 0 || !result.InterpolationPoints.ContainsKey(targettag)) continue; //no target / target desn't exist + if(targettag == 0 || !result.InterpolationPoints.ContainsKey(targettag)) continue; //no target / target doesn't exist bool interpolatepath = ((t.Args[2] & 1) != 1); start = t.Position; - start.z += GetCorrectHeight(t, blockmap); + start.z += GetCorrectHeight(t, blockmap, true); foreach(PathNode node in result.InterpolationPoints[targettag]) { @@ -271,7 +272,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data { bool interpolatepath = ((t.Args[2] & 1) != 1); start = t.Position; - start.z += GetCorrectHeight(t, blockmap); + start.z += GetCorrectHeight(t, blockmap, true); foreach(PathNode node in result.InterpolationPoints[targettag]) { @@ -284,12 +285,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data if(actormovertargets.ContainsKey(t.Args[3])) { start = t.Position; - start.z += GetCorrectHeight(t, blockmap); + start.z += GetCorrectHeight(t, blockmap, true); foreach(Thing tt in actormovertargets[t.Args[3]]) { end = tt.Position; - end.z += GetCorrectHeight(tt, blockmap); + end.z += GetCorrectHeight(tt, blockmap, true); lines.Add(new Line3D(start, end, General.Colors.Selection)); } } @@ -300,11 +301,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data foreach(Thing t in result.PathFollowers) { int targettag = t.Args[0] + (t.Args[1] << 8); - if(targettag == 0 || !result.InterpolationPoints.ContainsKey(targettag)) continue; //no target / target desn't exist + if(targettag == 0 || !result.InterpolationPoints.ContainsKey(targettag)) continue; //no target / target doesn't exist bool interpolatepath = (t.Args[2] & 1) != 1; start = t.Position; - start.z += GetCorrectHeight(t, blockmap); + start.z += GetCorrectHeight(t, blockmap, true); foreach(PathNode node in result.InterpolationPoints[targettag]) { @@ -320,12 +321,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data foreach(Thing anchor in group.Value) { start = anchor.Position; - start.z += GetCorrectHeight(anchor, blockmap); + start.z += GetCorrectHeight(anchor, blockmap, true); foreach(Thing startspot in result.PolyobjectStartSpots[group.Key]) { end = startspot.Position; - end.z += GetCorrectHeight(startspot, blockmap); + end.z += GetCorrectHeight(startspot, blockmap, true); lines.Add(new Line3D(start, end, General.Colors.Selection)); } } @@ -410,6 +411,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data ThingTypeInfo tti = General.Map.Data.GetThingInfoEx(t.Type); if(tti == null) continue; + Vector3D pos = t.Position; + pos.z += GetCorrectHeight(t, blockmap, false); + for(int i = 0; i < t.Args.Length; i++) { if(t.Args[i] != 0 && tti.Args[i].RenderStyle != ArgumentInfo.ArgumentRenderStyle.NONE) @@ -417,11 +421,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data switch(tti.Args[i].RenderStyle) { case ArgumentInfo.ArgumentRenderStyle.CIRCLE: - lines.AddRange(MakeCircleLines(t.Position, tti.Args[i].RenderColor, t.Args[i], numsides)); + lines.AddRange(MakeCircleLines(pos, tti.Args[i].RenderColor, t.Args[i], numsides)); break; case ArgumentInfo.ArgumentRenderStyle.RECTANGLE: - lines.AddRange(MakeRectangleLines(t.Position, tti.Args[i].RenderColor, t.Args[i])); + lines.AddRange(MakeRectangleLines(pos, tti.Args[i].RenderColor, t.Args[i])); break; default: throw new NotImplementedException("Unknown ArgumentRenderStyle"); @@ -447,10 +451,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data } // Required only when called from VisualMode - private static float GetCorrectHeight(Thing thing, VisualBlockMap blockmap) + private static float GetCorrectHeight(Thing thing, VisualBlockMap blockmap, bool usethingcenter) { if(blockmap == null) return 0f; - float height = thing.Height / 2f; + float height = (usethingcenter ? thing.Height / 2f : 0f); if(thing.Sector == null) thing.DetermineSector(blockmap); if(thing.Sector != null) height += thing.Sector.FloorHeight; return height;