public MyGridHighLevelHelper(MyGridNavigationMesh mesh, Dictionary <Vector3I, List <int> > triangleRegistry, Vector3I cellSize) { this.m_mesh = mesh; this.m_cellSize = cellSize; this.m_packedCoord = 0UL; this.m_currentCellConnections = new List <List <int> >(); this.m_changedCells = new MyVector3ISet(); this.m_changedCubes = new MyVector3ISet(); this.m_triangleRegistry = triangleRegistry; this.m_components = new MyNavmeshComponents(); }
public MyGridHighLevelHelper(MyGridNavigationMesh mesh, Dictionary<Vector3I, List<int>> triangleRegistry, Vector3I cellSize) { m_mesh = mesh; m_cellSize = cellSize; m_packedCoord = 0; m_currentCellConnections = new List<List<int>>(); m_changedCells = new MyVector3ISet(); m_changedCubes = new MyVector3ISet(); m_triangleRegistry = triangleRegistry; m_components = new MyNavmeshComponents(); }
public MyVoxelHighLevelHelper(MyVoxelNavigationMesh mesh) { this.m_mesh = mesh; this.m_triangleList = new MyIntervalList(); this.m_triangleLists = new Dictionary <ulong, MyIntervalList>(); this.m_exploredCells = new MyVector3ISet(); this.m_navmeshComponents = new MyNavmeshComponents(); this.m_currentCellConnections = new List <List <ConnectionInfo> >(); for (int i = 0; i < 8; i++) { this.m_currentCellConnections.Add(new List <ConnectionInfo>()); } }
public MyVoxelHighLevelHelper(MyVoxelNavigationMesh mesh) { m_mesh = mesh; m_triangleList = new MyIntervalList(); m_triangleLists = new Dictionary<ulong, MyIntervalList>(); m_exploredCells = new MyVector3ISet(); m_navmeshComponents = new MyNavmeshComponents(); m_currentCellConnections = new List<List<ConnectionInfo>>(); for (int i = 0; i < 8; ++i) { m_currentCellConnections.Add(new List<ConnectionInfo>()); } }
private void UpdateHighLevelPrimitives(ref MyNavmeshComponents.ClosedCellInfo cellInfo) { ProfilerShort.Begin("UpdateHighLevelPrimitives"); // Renumber triangles from the old indices to the newly assigned index from m_components int componentIndex = cellInfo.StartingIndex; foreach (var triangle in m_tmpComponentTriangles) { if (triangle == null) { componentIndex++; continue; } triangle.ComponentIndex = componentIndex; } m_tmpComponentTriangles.Clear(); // Remove old component primitives if (!cellInfo.NewCell && cellInfo.ComponentNum != cellInfo.OldComponentNum) { for (int i = 0; i < cellInfo.OldComponentNum; ++i) { m_mesh.HighLevelGroup.RemovePrimitive(cellInfo.OldStartingIndex + i); } } // Add new component primitives if (cellInfo.NewCell || cellInfo.ComponentNum != cellInfo.OldComponentNum) { for (int i = 0; i < cellInfo.ComponentNum; ++i) { m_mesh.HighLevelGroup.AddPrimitive(cellInfo.StartingIndex + i, m_navmeshComponents.GetComponentCenter(i)); } } // Update existing component primitives if (!cellInfo.NewCell && cellInfo.ComponentNum == cellInfo.OldComponentNum) { for (int i = 0; i < cellInfo.ComponentNum; ++i) { var primitive = m_mesh.HighLevelGroup.GetPrimitive(cellInfo.StartingIndex + i); primitive.UpdatePosition(m_navmeshComponents.GetComponentCenter(i)); } } // Connect new components with the others in the neighboring cells for (int i = 0; i < cellInfo.ComponentNum; ++i) { int compIndex = cellInfo.StartingIndex + i; var primitive = m_mesh.HighLevelGroup.GetPrimitive(compIndex); primitive.GetNeighbours(m_tmpNeighbors); // Connect to disconnected components foreach (var connectionInfo in m_currentCellConnections[i]) { if (!m_tmpNeighbors.Remove(connectionInfo.ComponentIndex)) { m_mesh.HighLevelGroup.ConnectPrimitives(compIndex, connectionInfo.ComponentIndex); } } // Disconnect neighbors that should be no longer connected foreach (var neighbor in m_tmpNeighbors) { // Only disconnect from the other cell if it is expanded and there was no connection found var neighborPrimitive = m_mesh.HighLevelGroup.TryGetPrimitive(neighbor); if (neighborPrimitive != null && neighborPrimitive.IsExpanded) { m_mesh.HighLevelGroup.DisconnectPrimitives(compIndex, neighbor); } } m_tmpNeighbors.Clear(); m_currentCellConnections[i].Clear(); } ProfilerShort.End(); }
private void MarkExploredDirections(ref MyNavmeshComponents.ClosedCellInfo cellInfo) { foreach (var direction in Base6Directions.EnumDirections) { var dirFlag = Base6Directions.GetDirectionFlag(direction); if (cellInfo.ExploredDirections.HasFlag(dirFlag)) { continue; } Vector3I dirVec = Base6Directions.GetIntVector(direction); MyCellCoord otherCoord = new MyCellCoord(); otherCoord.Lod = MyVoxelNavigationMesh.NAVMESH_LOD; otherCoord.CoordInLod = m_currentCell + dirVec; if (otherCoord.CoordInLod.X == -1 || otherCoord.CoordInLod.Y == -1 || otherCoord.CoordInLod.Z == -1) { continue; } ulong otherPackedCoord = otherCoord.PackId64(); if (m_triangleLists.ContainsKey(otherPackedCoord)) { m_navmeshComponents.MarkExplored(otherPackedCoord, Base6Directions.GetFlippedDirection(direction)); cellInfo.ExploredDirections |= Base6Directions.GetDirectionFlag(direction); } } m_navmeshComponents.SetExplored(m_packedCoord, cellInfo.ExploredDirections); }