Inheritance: MonoBehaviour
Esempio n. 1
0
        /// <summary>
        /// Creates chunks on a background thread until policy changes.
        /// </summary>
        void MeshLoop()
        {
            Thread.CurrentThread.IsBackground = true;
            Thread.CurrentThread.Name         = "Meshalyzer - " + _game.World.Title;
            var meshalyzer = _currentMeshalyzer;

            if (meshalyzer == null)
            {
                Debug.Assert(false);
                return;
            }

            // TODO: Meshalyzer should be refactored to spit out basic info (coords, colors) only.
            // An intermediate object would package it into a buffer
            while (Policy == ChunkCreationPolicy.Run)
            {
                ChunkPosition pos;
                if (!_prioritizer.GetNextDesiredChunk(_game.Camera.ChunkPosition, out pos))
                {
                    Thread.Sleep(1000);
                    continue;
                }

                var box         = new BoxSelection(pos, new ChunkSize(16, 256, 16));
                var chunkVolume = new BlockSelection(box, _game.Dimension, _game.World);
                var buffer      = meshalyzer.Meshalyze(_game, chunkVolume);

                var mesh = new ChunkMesh(chunkVolume.Selection.Lesser.AsVector3(), _vertexLit, buffer);
                _chunksToIntegrate.Enqueue(new ChunkMeshPositionPair(mesh, pos));
            }
        }
Esempio n. 2
0
        protected override void OnActivated(Session aSession)
        {
            iShowSelected = true;

            string selectedProduct = aSession.Model.SelectedProduct;
            string modelSelected   = "";

            if (selectedProduct == "KlimaxDsm")
            {
                modelSelected = "Klimax DSM";
            }
            else if (selectedProduct == "AkurateDsm")
            {
                modelSelected = "Akurate DSM";
            }
            else if (selectedProduct == "MajikDsm")
            {
                modelSelected = "Majik DSM";
            }
            else if (selectedProduct == "KikoDsm")
            {
                modelSelected = "Kiko DSM";
            }
            iBoxSelection = new BoxSelection(aSession, modelSelected);

            base.OnActivated(aSession);
            ShowDeviceList();
            SetSelected(aSession);
            if (aSession.Tracking)
            {
                aSession.Send("BoxTrackingData", GetBoxTracking(ModelInstance.Instance.Network.BoxList()));
            }
        }
 // Start is called before the first frame update
 void Start()
 {
     _boxSelection    = FindObjectOfType <BoxSelection>();
     _resourceManager = FindObjectOfType <ResourceManager>();
     _endGameEvent    = FindObjectOfType <EndGameEvent>();
     _sender          = GetComponent <PubSubSender>();
 }
Esempio n. 4
0
        public static Cuboid GetCuboid(this BoxSelection box)
        {
            // lengths of the cuboid are floored at 1
            var left    = box.Left;
            var bot     = box.Bottom;
            var forward = box.Forward;

            return(new Cuboid(left, bot, forward, box.Right - left + 1, box.Top - bot + 1, box.Backward - forward + 1));
        }
Esempio n. 5
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
     mainCam = Camera.main;
 }
Esempio n. 6
0
        private BoxSelection CreateCurrentRowToleranceSelection(int tableIndex)
        {
            IBox toleranceBox = GetCurrentRowToleranceBox(tableIndex);

            if (toleranceBox == null)
            {
                return(null);
            }

            var boxSelection = new BoxSelection();

            boxSelection.Box = toleranceBox;

            return(boxSelection);
        }
Esempio n. 7
0
    private void Start()
    {
        mainCam      = Camera.main;
        singleSelect = SingleSelection.instance;
        boxSelect    = BoxSelection.instance;
        singleSelect.OnAddSelection   += Select;
        singleSelect.OnClearSelection += Deselect;
        boxSelect.OnBoxSelection      += CheckBoxLocation;
        boxSelect.OnClearSelection    += Deselect;

        foreach (var marker in selectionMarkers)
        {
            marker.SetActive(false);
        }
    }
Esempio n. 8
0
        // TODO: Highlight face that mouse is over when _selectionState == SelectionState.Set
        void NewSelection(BlockPosition pos1, BlockPosition pos2, SelectionState newState)
        {
            _cornerOne = pos1;
            _cornerTwo = pos2;
            var selection = new BoxSelection(pos1, pos2);

            _selectionState = newState;

            // notify only if selection is set.
            if (newState != SelectionState.Set)
            {
                return;
            }

            // use variables on the stack to avoid modified closure.
            var dim   = Dimension;
            var world = World;

            _aggregator.Publish(new BoxSelectionUpdatedMessage(selection, box => new BlockSelection(selection, dim, world)));
        }
Esempio n. 9
0
 void Awake()
 {
     instance = (BoxSelection)Singleton.Setup(this, instance);
     selectionBox.SetActive(false);
     boxCollider = selectionBox.GetComponent <Collider2D>();
 }
Esempio n. 10
0
        private List <BoxTree <CachedRow> .TileEntry> SearchList(
            [NotNull] IGeometry searchGeometry, int tableIndex)
        {
            Assert.ArgumentNotNull(searchGeometry, nameof(searchGeometry));

            IBox searchGeometryBox = QaGeometryUtils.CreateBox(searchGeometry,
                                                               GetXYTolerance(tableIndex));

            BoxTree <CachedRow> boxTree = _rowBoxTrees[tableIndex];

            if (_currentRowNeighbors == null)
            {
                _currentRowNeighbors = new BoxSelection[_cachedTableCount];
            }

            BoxSelection currentRowBoxSelection = _currentRowNeighbors[tableIndex];

            if (currentRowBoxSelection == null)
            {
                currentRowBoxSelection = CreateCurrentRowToleranceSelection(tableIndex);

                _currentRowNeighbors[tableIndex] = currentRowBoxSelection;
            }

            IBox searchBox = null;
            var  isWithin  = false;

            if (currentRowBoxSelection != null)
            {
                isWithin = currentRowBoxSelection.Box.Contains(searchGeometryBox);
            }

            if (!isWithin)
            {
                searchBox = searchGeometryBox;
            }
            else if (currentRowBoxSelection.Selection == null)
            {
                searchBox = currentRowBoxSelection.Box;
            }

            List <BoxTree <CachedRow> .TileEntry> tileEntries;

            if (searchBox != null)
            {
                tileEntries = new List <BoxTree <CachedRow> .TileEntry>();

                foreach (
                    BoxTree <CachedRow> .TileEntry tileEntry in boxTree.Search(searchBox))
                {
                    tileEntries.Add(tileEntry);
                }

                if (isWithin)
                {
                    currentRowBoxSelection.Selection = tileEntries;
                }
            }
            else
            {
                tileEntries = currentRowBoxSelection.Selection;
            }

            if (!isWithin || searchGeometryBox.Contains(currentRowBoxSelection.Box))
            {
                return(tileEntries);
            }

            // drop non intersection lines
            Assert.NotNull(tileEntries, "tileEntries");

            var reducedList
                = new List <BoxTree <CachedRow> .TileEntry>(tileEntries.Count);

            foreach (BoxTree <CachedRow> .TileEntry tileEntry in tileEntries)
            {
                if (tileEntry.Box.Intersects(searchGeometryBox))
                {
                    reducedList.Add(tileEntry);
                }
            }

            return(reducedList);
        }
Esempio n. 11
0
        public void OnGUI()
        {
            // *********************** Set Rect
            var rect = EditorGUILayout.GetControlRect(GUILayout.ExpandHeight(true));

            if (Event.current.type != EventType.Layout)
            {
                WindowRect = rect;
            }


            // ********************** Draw background
            if (Event.current.type == EventType.Repaint)
            {
                GridBackground.Draw(this);
            }

            // *************** Exit if no graph
            if (Graph == null)
            {
                return;
            }

            //*************** Process Events

            if (
                Event.current.type != EventType.Repaint &&
                Event.current.type != EventType.Layout)
            {
                //
                // Zoom & pan
                CordinationSystem.HandleZoomAndPan();

                // Process Events
                EventProcessor.ProcessEvents();
            }
            else
            if (Event.current.type == EventType.Repaint ||
                Event.current.type == EventType.Layout)
            {
                // ************** Draw Shapes

                CordinationSystem.BeginDraw();

                if (Event.current.type == EventType.Repaint)
                {
                    // Draw Groups
                    Graph.GroupList.ForEach(@group => @group.Editor().Draw());

                    // Draw Box selection
                    BoxSelection.Draw();

                    // Draw Edges
                    DrawEdges();

                    // Draw Nodes
                    Graph.NodeList.ForEach(node => node.Editor().Draw());

                    // Draw Sockets
                    DrawSockets();
                }

                CordinationSystem.EndDraw();
            }
        }
Esempio n. 12
0
 public BoxSelectionUpdatedMessage(BoxSelection selection, Func <BoxSelection, IBlockSelection> blockSelectionCallback)
 {
     Selection = selection;
     _blockSelectionCallback = blockSelectionCallback;
 }