diff --git a/Source/BuilderModes/General/BuilderPlug.cs b/Source/BuilderModes/General/BuilderPlug.cs index 95b92751..46d4098a 100644 --- a/Source/BuilderModes/General/BuilderPlug.cs +++ b/Source/BuilderModes/General/BuilderPlug.cs @@ -57,6 +57,9 @@ namespace CodeImp.DoomBuilder.BuilderModes private FindReplaceForm findreplaceform; private ErrorCheckForm errorcheckform; + // Settings + private int showvisualthings; // 0 = none, 1 = sprite only, 2 = sprite caged + #endregion #region ================== Properties @@ -68,6 +71,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public CurveLinedefsForm CurveLinedefsForm { get { return curvelinedefsform; } } public FindReplaceForm FindReplaceForm { get { return findreplaceform; } } public ErrorCheckForm ErrorCheckForm { get { return errorcheckform; } } + public int ShowVisualThings { get { return showvisualthings; } set { showvisualthings = value; } } #endregion @@ -79,6 +83,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // Setup me = this; + // Settings + this.showvisualthings = 2; + // Load menus form and register it menusform = new MenusForm(); menusform.Register(); diff --git a/Source/BuilderModes/Resources/Actions.cfg b/Source/BuilderModes/Resources/Actions.cfg index 54035140..75334511 100644 --- a/Source/BuilderModes/Resources/Actions.cfg +++ b/Source/BuilderModes/Resources/Actions.cfg @@ -307,3 +307,13 @@ raisesector1 allowmouse = true; allowscroll = true; } + +showvisualthings +{ + title = "Show Things"; + category = "visual"; + description = "Cycles through the different ways the things are shown in Visual Mode."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} diff --git a/Source/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/BuilderModes/VisualModes/BaseVisualMode.cs index fb59b82c..dfeea780 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualMode.cs @@ -211,6 +211,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // Processing public override void OnProcess(double deltatime) { + // Process things? + base.ProcessThings = (BuilderPlug.Me.ShowVisualThings != 0); + // Do processing base.OnProcess(deltatime); @@ -233,9 +236,20 @@ namespace CodeImp.DoomBuilder.BuilderModes // Begin with geometry renderer.StartGeometry(); - - // This adds all visible geometry for rendering - AddGeometry(); + + // Render all visible sectors + foreach(VisualGeometry g in visiblegeometry) + renderer.AddSectorGeometry(g); + + if(BuilderPlug.Me.ShowVisualThings != 0) + { + // Render things in cages? + renderer.DrawThingCages = ((BuilderPlug.Me.ShowVisualThings & 2) != 0); + + // Render all visible things + foreach(VisualThing t in visiblethings) + renderer.AddThingGeometry(t); + } // Done rendering geometry renderer.FinishGeometry(); @@ -306,6 +320,13 @@ namespace CodeImp.DoomBuilder.BuilderModes { ChangeTargetHeight(-1); } + + [BeginAction("showvisualthings")] + public void ShowVisualThings() + { + BuilderPlug.Me.ShowVisualThings++; + if(BuilderPlug.Me.ShowVisualThings > 2) BuilderPlug.Me.ShowVisualThings = 0; + } #endregion } diff --git a/Source/Rendering/IRenderer3D.cs b/Source/Rendering/IRenderer3D.cs index 349009c2..aec26620 100644 --- a/Source/Rendering/IRenderer3D.cs +++ b/Source/Rendering/IRenderer3D.cs @@ -43,7 +43,8 @@ namespace CodeImp.DoomBuilder.Rendering { // Properties ProjectedFrustum2D Frustum2D { get; } - + bool DrawThingCages { get; set; } + // General methods void PositionAndLookAt(Vector3D pos, Vector3D lookat); diff --git a/Source/Rendering/Renderer3D.cs b/Source/Rendering/Renderer3D.cs index 40e2e076..4c210c18 100644 --- a/Source/Rendering/Renderer3D.cs +++ b/Source/Rendering/Renderer3D.cs @@ -67,6 +67,7 @@ namespace CodeImp.DoomBuilder.Rendering // Thing cage private VertexBuffer thingcage; + private bool renderthingcages; // Crosshair private FlatVertex[] crosshairverts; @@ -92,7 +93,8 @@ namespace CodeImp.DoomBuilder.Rendering #region ================== Properties public ProjectedFrustum2D Frustum2D { get { return frustum; } } - + public bool DrawThingCages { get { return renderthingcages; } set { renderthingcages = value; } } + #endregion #region ================== Constructor / Disposer @@ -104,6 +106,7 @@ namespace CodeImp.DoomBuilder.Rendering CreateProjection(); CreateMatrices2D(); SetupThingCage(); + renderthingcages = true; // Dummy frustum frustum = new ProjectedFrustum2D(new Vector2D(), 0.0f, 0.0f, PROJ_NEAR_PLANE, @@ -441,7 +444,7 @@ namespace CodeImp.DoomBuilder.Rendering graphics.Shaders.World3D.EndPass(); // THINGS - RenderThingCages(); + if(renderthingcages) RenderThingCages(); // ADDITIVE PASS world = Matrix.Identity; diff --git a/Source/VisualModes/VisualMode.cs b/Source/VisualModes/VisualMode.cs index 018fa447..8df97da6 100644 --- a/Source/VisualModes/VisualMode.cs +++ b/Source/VisualModes/VisualMode.cs @@ -67,6 +67,10 @@ namespace CodeImp.DoomBuilder.VisualModes private float camanglexy, camanglez; private Sector camsector; + // Options + private bool processgeometry; + private bool processthings; + // Input private bool keyforward; private bool keybackward; @@ -90,6 +94,8 @@ namespace CodeImp.DoomBuilder.VisualModes public Vector3D CameraPosition { get { return campos; } set { campos = value; } } public Vector3D CameraTarget { get { return camtarget; } } public Sector CameraSector { get { return camsector; } } + public bool ProcessGeometry { get { return processgeometry; } set { processgeometry = value; } } + public bool ProcessThings { get { return processthings; } set { processthings = value; } } #endregion @@ -112,6 +118,8 @@ namespace CodeImp.DoomBuilder.VisualModes this.visiblesectors = new Dictionary(50); this.visiblegeometry = new List(200); this.visiblethings = new List(100); + this.processgeometry = true; + this.processthings = true; } // Disposer @@ -329,99 +337,110 @@ namespace CodeImp.DoomBuilder.VisualModes Vector2D campos2d = (Vector2D)campos; float viewdist = General.Settings.ViewDistance; - // Get the blocks within view range - visibleblocks = blockmap.GetFrustumRange(renderer.Frustum2D); - - // Fill visiblity collections + // Make collections visiblesectors = new Dictionary(visiblesectors.Count); visiblegeometry = new List(visiblegeometry.Capacity); visiblethings = new List(visiblethings.Capacity); + + // Get the blocks within view range + visibleblocks = blockmap.GetFrustumRange(renderer.Frustum2D); + + // Fill collections with geometry and things foreach(VisualBlockEntry block in visibleblocks) { - // Lines - foreach(Linedef ld in block.Lines) + if(processgeometry) { - // Line not already processed? - if(!visiblelines.ContainsKey(ld)) + // Lines + foreach(Linedef ld in block.Lines) { - // Add line if not added yet - visiblelines.Add(ld, ld); - - // Which side of the line is the camera on? - if(ld.SideOfLine(campos2d) < 0) + // Line not already processed? + if(!visiblelines.ContainsKey(ld)) { - // Do front of line - if(ld.Front != null) ProcessSidedefCulling(ld.Front); + // Add line if not added yet + visiblelines.Add(ld, ld); + + // Which side of the line is the camera on? + if(ld.SideOfLine(campos2d) < 0) + { + // Do front of line + if(ld.Front != null) ProcessSidedefCulling(ld.Front); + } + else + { + // Do back of line + if(ld.Back != null) ProcessSidedefCulling(ld.Back); + } + } + } + } + + if(processthings) + { + // Things + foreach(Thing t in block.Things) + { + VisualThing vt; + + if(allthings.ContainsKey(t)) + { + vt = allthings[t]; } else { - // Do back of line - if(ld.Back != null) ProcessSidedefCulling(ld.Back); + // Create new visual thing + vt = CreateVisualThing(t); + if(vt != null) allthings.Add(t, vt); + } + + if(vt != null) + { + visiblethings.Add(vt); } } } - - // Things - foreach(Thing t in block.Things) - { - VisualThing vt; - - if(allthings.ContainsKey(t)) - { - vt = allthings[t]; - } - else - { - // Create new visual thing - vt = CreateVisualThing(t); - if(vt != null) allthings.Add(t, vt); - } - - if(vt != null) - { - visiblethings.Add(vt); - } - } } - - // Find camera sector - Linedef nld = MapSet.NearestLinedef(visiblelines.Values, campos2d); - if(nld != null) + + if(processgeometry) { - camsector = GetCameraSectorFromLinedef(nld); - } - else - { - // Exceptional case: no lines found in any nearby blocks! - // This could happen in the middle of an extremely large sector and in this case - // the above code will not have found any sectors/sidedefs for rendering. - // Here we handle this special case with brute-force. Let's find the sector - // the camera is in by searching the entire map and render that sector only. - nld = General.Map.Map.NearestLinedef(campos2d); + // Find camera sector + Linedef nld = MapSet.NearestLinedef(visiblelines.Values, campos2d); if(nld != null) { camsector = GetCameraSectorFromLinedef(nld); - if(camsector != null) + } + else + { + // Exceptional case: no lines found in any nearby blocks! + // This could happen in the middle of an extremely large sector and in this case + // the above code will not have found any sectors/sidedefs for rendering. + // Here we handle this special case with brute-force. Let's find the sector + // the camera is in by searching the entire map and render that sector only. + nld = General.Map.Map.NearestLinedef(campos2d); + if(nld != null) { - foreach(Sidedef sd in camsector.Sidedefs) + camsector = GetCameraSectorFromLinedef(nld); + if(camsector != null) { - float side = sd.Line.SideOfLine(campos2d); - if(((side < 0) && sd.IsFront) || - ((side > 0) && !sd.IsFront)) - ProcessSidedefCulling(sd); + foreach(Sidedef sd in camsector.Sidedefs) + { + float side = sd.Line.SideOfLine(campos2d); + if(((side < 0) && sd.IsFront) || + ((side > 0) && !sd.IsFront)) + ProcessSidedefCulling(sd); + } + } + else + { + // Too far away from the map to see anything + camsector = null; } } else { - // Too far away from the map to see anything + // Map is empty camsector = null; } } - else - { - // Map is empty - camsector = null; - } } } @@ -743,22 +762,6 @@ namespace CodeImp.DoomBuilder.VisualModes #endregion - #region ================== Rendering - - // Call this to simply render all visible sectors - protected virtual void AddGeometry() - { - // Render all visible sectors - foreach(VisualGeometry g in visiblegeometry) - renderer.AddSectorGeometry(g); - - // Render all visible things - foreach(VisualThing t in visiblethings) - renderer.AddThingGeometry(t); - } - - #endregion - #region ================== Actions #endregion