示例#1
0
        /// <summary>
        /// Create a blockmap containing linedefs. This is used to speed up determining the closest line
        /// to the mouse cursor
        /// </summary>
        private void CreateBlockmap()
        {
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            blockmap = new BlockMap <BlockEntry>(area);
            blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
        }
示例#2
0
        private BlockMap <BlockEntry> CreateBlockmap(bool ignorecontrolsectors)
        {
            // Make blockmap
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            area = MapSet.IncreaseArea(area, new Vector2D(outerleft, outertop));
            area = MapSet.IncreaseArea(area, new Vector2D(outerright, outerbottom));
            area = AlignAreaToGrid(area);

            BlockMap <BlockEntry> blockmap = new BlockMap <BlockEntry>(area, (int)gridsize);

            if (ignorecontrolsectors)
            {
                foreach (Sector s in General.Map.Map.Sectors)
                {
                    // Managed control sectors have the custom UDMF field "user_managed_3d_floor" set to true
                    // So if the field is NOT set, add the sector to the blockmap
                    if (s.Fields.GetValue("user_managed_3d_floor", false) == false)
                    {
                        blockmap.AddSector(s);
                    }
                }
            }
            else
            {
                blockmap.AddSectorsSet(General.Map.Map.Sectors);
            }

            return(blockmap);
        }
        // Mode engages
        public override void OnEngage()
        {
            base.OnEngage();

            // Nothing highlighted
            highlighted = null;
            hx          = -1;
            hy          = -1;

            // Custom presentation to hide the grid
            CustomPresentation p = new CustomPresentation();

            p.AddLayer(new PresentLayer(RendererLayer.Background, BlendingMode.Mask, General.Settings.BackgroundAlpha));
            p.AddLayer(new PresentLayer(RendererLayer.Surface, BlendingMode.Mask));
            p.AddLayer(new PresentLayer(RendererLayer.Overlay, BlendingMode.Alpha, 1f, true));
            p.AddLayer(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, 1.0f));
            p.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
            renderer.SetPresentation(p);

            // Make the blockmap
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            area     = MapSet.IncreaseArea(area, General.Map.Map.Things);
            blockmap = new BlockMap <BlockEntry>(area);
            blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
            blockmap.AddSectorsSet(General.Map.Map.Sectors);
            blockmap.AddThingsSet(General.Map.Map.Things);
        }
        private BlockMap <BlockEntry> CreateBlockmap(bool ignorecontrolsectors)
        {
            // Make blockmap
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            area = MapSet.IncreaseArea(area, new Vector2D(outerleft, outertop));
            area = MapSet.IncreaseArea(area, new Vector2D(outerright, outerbottom));
            area = AlignAreaToGrid(area);

            BlockMap <BlockEntry> blockmap = new BlockMap <BlockEntry>(area, (int)gridsize);

            if (ignorecontrolsectors)
            {
                foreach (Sector s in General.Map.Map.Sectors)
                {
                    // Managed control sectors have the custom UDMF field "user_managed_3d_floor" set to true
                    // So if the field is NOT set, add the sector to the blockmap
                    bool managed = s.Fields.GetValue("user_managed_3d_floor", false);

                    if (managed == false)
                    {
                        blockmap.AddSector(s);
                    }
                    else                     // When a tag was manually removed a control sector still might have the user_managed_3d_floor field, but not be
                    {                        // recognized as a 3D floor control sector. In that case also add the sector to the blockmap
                        bool orphaned = true;

                        foreach (ThreeDFloor tdf in ((ThreeDFloorHelperMode)General.Editing.Mode).ThreeDFloors)
                        {
                            if (tdf.Sector == s)
                            {
                                orphaned = false;
                                break;
                            }
                        }

                        if (orphaned)
                        {
                            blockmap.AddSector(s);
                        }
                    }
                }
            }
            else
            {
                blockmap.AddSectorsSet(General.Map.Map.Sectors);
            }

            return(blockmap);
        }
        // This starts checking
        private void StartChecking()
        {
            if (running)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            // Make blockmap
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            area     = MapSet.IncreaseArea(area, General.Map.Map.Things);
            blockmap = new BlockMap <BlockEntry>(area);
            blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
            blockmap.AddSectorsSet(General.Map.Map.Sectors);
            blockmap.AddThingsSet(General.Map.Map.Things);
            blockmap.AddVerticesSet(General.Map.Map.Vertices);             //mxd

            //mxd. Open the results panel
            if (!resultspanel.Visible)
            {
                this.MinimumSize     = new Size();
                this.MaximumSize     = new Size();
                this.Size            = initialsize;
                resultspanel.Size    = new Size(resultspanel.Width, this.ClientSize.Height - resultspanel.Top);
                resultspanel.Visible = true;
            }
            progress.Value = 0;
            results.Items.Clear();
            results.Enabled = true;
            resultslist     = new List <ErrorResult>();        //mxd
            ClearSelectedResult();
            buttoncheck.Text = "Abort Analysis";
            General.Interface.RedrawDisplay();

            // Start checking
            running               = true;
            checksthread          = new Thread(RunChecks);
            checksthread.Name     = "Error Checking Management";
            checksthread.Priority = ThreadPriority.Normal;
            checksthread.Start();

            Cursor.Current = Cursors.Default;
        }
        // Mode starts
        public override void OnEngage()
        {
            Cursor.Current = Cursors.WaitCursor;
            base.OnEngage();
            General.Interface.DisplayStatus(StatusType.Busy, "Setting up test environment...");

            BuilderPlug.InitVPO();             //mxd

            CleanUp();

            BuilderPlug.InterfaceForm.AddToInterface();
            BuilderPlug.InterfaceForm.OnOpenDoorsChanged += OnOpenDoorsChanged;             //mxd
            lastviewstats = BuilderPlug.InterfaceForm.ViewStats;

            // Export the current map to a temporary WAD file
            tempfile = BuilderPlug.MakeTempFilename(".wad");
            if (!General.Map.ExportToFile(tempfile))
            {
                //mxd. Abort on export fail
                Cursor.Current = Cursors.Default;
                General.Interface.DisplayStatus(StatusType.Warning, "Unable to set test environment...");
                OnCancel();
                return;
            }

            // Load the map in VPO_DLL
            BuilderPlug.VPO.Start(tempfile, General.Map.Options.LevelName);

            // Determine map boundary
            mapbounds = Rectangle.Round(MapSet.CreateArea(General.Map.Map.Vertices));

            // Create tiles for all points inside the map
            CreateTiles();             //mxd

            QueuePoints(0);

            // Make an image to draw on.
            // The BitmapImage for Doom Builder's resources must be Format32bppArgb and NOT using color correction,
            // otherwise DB will make a copy of the bitmap when LoadImage() is called! This is normally not a problem,
            // but we want to keep drawing to the same bitmap.
            int width  = General.NextPowerOf2(General.Interface.Display.ClientSize.Width);
            int height = General.NextPowerOf2(General.Interface.Display.ClientSize.Height);

            canvas = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            image  = new DynamicBitmapImage(canvas, "_CANVAS_");
            image.UseColorCorrection = false;
            image.MipMapLevels       = 1;
            image.LoadImageNow();

            // Make custom presentation
            CustomPresentation p = new CustomPresentation();

            p.AddLayer(new PresentLayer(RendererLayer.Overlay, BlendingMode.Mask, 1f, false));
            p.AddLayer(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
            p.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
            renderer.SetPresentation(p);

            // Setup processing
            nextupdate = Clock.CurrentTime + 100;
            General.Interface.EnableProcessing();
            processingenabled = true;

            RedrawAllTiles();
            Cursor.Current = Cursors.Default;
            General.Interface.SetCursor(Cursors.Cross);
            General.Interface.DisplayReady();
        }
示例#7
0
        // Mode starts
        public override void OnEngage()
        {
            Cursor.Current = Cursors.WaitCursor;
            base.OnEngage();
            General.Interface.DisplayStatus(StatusType.Busy, "Setting up test environment...");

            CleanUp();

            BuilderPlug.InterfaceForm.AddToInterface();
            lastviewstats = BuilderPlug.InterfaceForm.ViewStats;

            // Export the current map to a temporary WAD file
            tempfile = BuilderPlug.MakeTempFilename(".wad");
            General.Map.ExportToFile(tempfile);

            // Load the map in VPO_DLL
            BuilderPlug.VPO.Start(tempfile, General.Map.Options.LevelName);

            // Determine map boundary
            mapbounds = Rectangle.Round(MapSet.CreateArea(General.Map.Map.Vertices));

            // Create tiles for all points inside the map
            Point               lt        = TileForPoint(mapbounds.Left - Tile.TILE_SIZE, mapbounds.Top - Tile.TILE_SIZE);
            Point               rb        = TileForPoint(mapbounds.Right + Tile.TILE_SIZE, mapbounds.Bottom + Tile.TILE_SIZE);
            Rectangle           tilesrect = new Rectangle(lt.X, lt.Y, rb.X - lt.X, rb.Y - lt.Y);
            NearestLineBlockmap blockmap  = new NearestLineBlockmap(tilesrect);

            for (int x = tilesrect.X; x <= tilesrect.Right; x += Tile.TILE_SIZE)
            {
                for (int y = tilesrect.Y; y <= tilesrect.Bottom; y += Tile.TILE_SIZE)
                {
                    // If the tile is obviously outside the map, don't create it
                    Vector2D pc         = new Vector2D(x + (Tile.TILE_SIZE >> 1), y + (Tile.TILE_SIZE >> 1));
                    Linedef  ld         = MapSet.NearestLinedef(blockmap.GetBlockAt(pc).Lines, pc);
                    float    distancesq = ld.DistanceToSq(pc, true);
                    if (distancesq > (Tile.TILE_SIZE * Tile.TILE_SIZE))
                    {
                        float side = ld.SideOfLine(pc);
                        if ((side > 0.0f) && (ld.Back == null))
                        {
                            continue;
                        }
                    }

                    Point tp = new Point(x, y);
                    tiles.Add(tp, new Tile(tp));
                }
            }

            QueuePoints(0);

            // Make an image to draw on.
            // The BitmapImage for Doom Builder's resources must be Format32bppArgb and NOT using color correction,
            // otherwise DB will make a copy of the bitmap when LoadImage() is called! This is normally not a problem,
            // but we want to keep drawing to the same bitmap.
            int width  = General.NextPowerOf2(General.Interface.Display.ClientSize.Width);
            int height = General.NextPowerOf2(General.Interface.Display.ClientSize.Height);

            canvas = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            image  = new DynamicBitmapImage(canvas, "_CANVAS_");
            image.UseColorCorrection = false;
            image.MipMapLevels       = 1;
            image.LoadImage();
            image.CreateTexture();

            // Make custom presentation
            CustomPresentation p = new CustomPresentation();

            p.AddLayer(new PresentLayer(RendererLayer.Overlay, BlendingMode.Mask, 1f, false));
            p.AddLayer(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
            p.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
            renderer.SetPresentation(p);

            // Setup processing
            nextupdate = DateTime.Now + new TimeSpan(0, 0, 0, 0, 100);
            General.Interface.EnableProcessing();
            processingenabled = true;

            RedrawAllTiles();
            Cursor.Current = Cursors.Default;
            General.Interface.SetCursor(Cursors.Cross);
            General.Interface.DisplayReady();
        }