Exemple #1
0
        private void FetchSceneData()
        {
            List <SceneData> new_scene_data = new List <SceneData>();

            //using (new Nav.Profiler("[Nav.D3.Navigation] Navmesh data aquired [%t]", 70))
            {
                int scenes_available = 0;

                foreach (var scene in m_MemoryContext.DataSegment.ObjectManager.Scenes)
                {
                    if (scene == null || scene.ID == -1)
                    {
                        continue;
                    }

                    ++scenes_available;

                    SceneData scene_data = new SceneData(scene);

                    if (m_AllowedAreasSnoId.Count > 0 && !m_AllowedAreasSnoId.Contains(scene_data.AreaSnoId) && !m_AllowedGridCellsId.Contains(scene_data.SceneSnoId))
                    {
                        continue;
                    }

                    if (m_ProcessedSceneId.Contains(scene_data.SceneUid))
                    {
                        continue;
                    }

                    new_scene_data.Add(scene_data);
                }
            }

            //using (new Nav.Profiler("[Nav.D3.Navigation] Navmesh data added [%t]"))
            {
                int grid_cells_added = 0;

                foreach (SceneData scene_data in new_scene_data)
                {
                    SceneSnoNavData sno_nav_data = null;

                    m_SnoCache.TryGetValue(scene_data.SceneSnoId, out sno_nav_data);

                    if (sno_nav_data == null)
                    {
                        //wait for navigation data to be fetched before processing this scene
                        continue;
                    }

                    GridCell grid_cell = new GridCell(scene_data.Min, scene_data.Max, scene_data.SceneSnoId, scene_data.AreaSnoId);
                    grid_cell.UserData = scene_data.AreaSnoId;

                    if (sno_nav_data != null)
                    {
                        int cell_id = 0;

                        foreach (Cell cell in sno_nav_data.Cells)
                        {
                            grid_cell.Add(new Cell(cell.Min + scene_data.Min, cell.Max + scene_data.Min, cell.Flags, cell_id++));
                        }
                    }
                    else
                    {
                        Log("[Nav.D3] Couldn't find SNO data for scene " + scene_data.SceneSnoId);
                    }

                    if (Add(grid_cell, false))
                    {
                        ++grid_cells_added;
                    }

                    m_ProcessedSceneId.Add(scene_data.SceneUid);
                }

                if (grid_cells_added > 0)
                {
                    Log("[Nav.D3] " + grid_cells_added + " grid cells added.");

                    NotifyOnNavDataChanged();
                }
                else if (new_scene_data.Count > 0)
                {
                    Log("[Nav.D3] New scene data found but no grid cells added!");
                }
            }
        }
Exemple #2
0
        private void FetchSceneData()
        {
            List <SceneData> new_scene_data = new List <SceneData>();

            //using (new Nav.Profiler("[Nav.D3.Navigation] Navmesh data aquired [{t}]", 70))
            {
                foreach (Enigma.D3.Scene scene in m_Engine.ObjectManager.x998_Scenes.Dereference())
                {
                    if (scene == null || scene.x000_Id < 0)
                    {
                        continue;
                    }

                    SceneData scene_data = new SceneData(scene);

                    if (m_AllowedAreasSnoId.Count > 0 && !m_AllowedAreasSnoId.Contains(scene_data.AreaSnoId) && !m_AllowedGridCellsId.Contains(scene_data.SceneSnoId))
                    {
                        continue;
                    }

                    if (m_ProcessedSceneId.Contains(scene_data.SceneUid))
                    {
                        continue;
                    }

                    new_scene_data.Add(scene_data);
                }
            }

            //using (new Nav.Profiler("[Nav.D3.Navigation] Navmesh data added [{t}]"))
            {
                int grid_cells_added = 0;

                foreach (SceneData scene_data in new_scene_data)
                {
                    SceneSnoNavData sno_nav_data = null;

                    // allow empty grids
                    m_SnoCache.TryGetValue(scene_data.SceneSnoId, out sno_nav_data);

                    GridCell grid_cell = new GridCell(scene_data.Min, scene_data.Max, scene_data.SceneSnoId, scene_data.AreaSnoId);
                    grid_cell.UserData = scene_data.AreaSnoId;

                    if (sno_nav_data != null)
                    {
                        int cell_id = 0;

                        foreach (Cell cell in sno_nav_data.Cells)
                        {
                            grid_cell.Add(new Cell(cell.Min + scene_data.Min, cell.Max + scene_data.Min, cell.Flags, cell_id++));
                        }
                    }

                    if (Add(grid_cell, false))
                    {
                        ++grid_cells_added;
                    }

                    m_ProcessedSceneId.Add(scene_data.SceneUid);
                }

                if (grid_cells_added > 0)
                {
                    Log("[Nav.D3] " + grid_cells_added + " grid cells added" + (Explorator == null ? " (EXPLORATOR NOT PRESENT!!!)" : "") + ".");

                    if (Explorator != null)
                    {
                        Explorator.OnNavDataChange();
                    }
                }
            }
        }
Exemple #3
0
        private void FetchSceneData()
        {
            List<SceneData> new_scene_data = new List<SceneData>();

            //using (new Nav.Profiler("[Nav.D3.Navigation] Navmesh data aquired [{t}]", 70))
            {
                foreach (Enigma.D3.Scene scene in m_Engine.ObjectManager.x998_Scenes.Dereference())
                {
                    if (scene == null || scene.x000_Id < 0)
                        continue;
                    
                    SceneData scene_data = new SceneData(scene);

                    if (m_AllowedAreasSnoId.Count > 0 && !m_AllowedAreasSnoId.Contains(scene_data.AreaSnoId) && !m_AllowedGridCellsId.Contains(scene_data.SceneSnoId))
                        continue;

                    if (m_ProcessedSceneId.Contains(scene_data.SceneUid))
                        continue;

                    new_scene_data.Add(scene_data);
                }
            }

            //using (new Nav.Profiler("[Nav.D3.Navigation] Navmesh data added [{t}]"))
            {
                int grid_cells_added = 0;

                foreach (SceneData scene_data in new_scene_data)
                {
                    SceneSnoNavData sno_nav_data = null;

                    // allow empty grids
                    m_SnoCache.TryGetValue(scene_data.SceneSnoId, out sno_nav_data);
                    
                    GridCell grid_cell = new GridCell(scene_data.Min, scene_data.Max, scene_data.SceneSnoId, scene_data.AreaSnoId);
                    grid_cell.UserData = scene_data.AreaSnoId;

                    if (sno_nav_data != null)
                    {
                        int cell_id = 0;

                        foreach (Cell cell in sno_nav_data.Cells)
                            grid_cell.Add(new Cell(cell.Min + scene_data.Min, cell.Max + scene_data.Min, cell.Flags, cell_id++));
                    }

                    if (Add(grid_cell, false))
                        ++grid_cells_added;
                        
                    m_ProcessedSceneId.Add(scene_data.SceneUid);
                }

                if (grid_cells_added > 0)
                {
                    Log("[Nav.D3] " + grid_cells_added + " grid cells added" + (Explorator == null ? " (EXPLORATOR NOT PRESENT!!!)" : "") + ".");

                    if (Explorator != null)
                        Explorator.OnNavDataChange();
                }
            }
        }