public void MarkBoxForAddition(BoundingBoxD box) { ProfilerShort.Begin("VoxelNavMesh.MarkBoxForAddition"); Vector3I pos, end; MyVoxelCoordSystems.WorldPositionToVoxelCoord(m_voxelMap.PositionLeftBottomCorner, ref box.Min, out pos); MyVoxelCoordSystems.WorldPositionToVoxelCoord(m_voxelMap.PositionLeftBottomCorner, ref box.Max, out end); m_voxelMap.Storage.ClampVoxelCoord(ref pos); m_voxelMap.Storage.ClampVoxelCoord(ref end); MyVoxelCoordSystems.VoxelCoordToGeometryCellCoord(ref pos, out pos); MyVoxelCoordSystems.VoxelCoordToGeometryCellCoord(ref end, out end); Vector3 center = pos + end; center = center * 0.5f; pos /= 1 << NAVMESH_LOD; end /= 1 << NAVMESH_LOD; for (var it = new Vector3I.RangeIterator(ref pos, ref end); it.IsValid(); it.GetNext(out pos)) { if (!m_processedCells.Contains(ref pos) && !m_markedForAddition.Contains(ref pos)) { float weight = 1.0f / (0.01f + Vector3.RectangularDistance(pos, center)); if (!m_toAdd.Full) { m_toAdd.Insert(pos, weight); m_markedForAddition.Add(ref pos); } else { float min = m_toAdd.MinKey(); if (weight > min) { Vector3I posRemoved = m_toAdd.RemoveMin(); m_markedForAddition.Remove(ref posRemoved); m_toAdd.Insert(pos, weight); m_markedForAddition.Add(ref pos); } } } } ProfilerShort.End(); }
private void RemoveExplored(ulong packedCoord) { MyCellCoord coord = new MyCellCoord(); coord.SetUnpack(packedCoord); m_exploredCells.Remove(ref coord.CoordInLod); }
private void RemoveBlock(Vector3I min, Vector3I max, bool eraseCubeSet) { Vector3I pos = min; for (var it = new Vector3I.RangeIterator(ref pos, ref max); it.IsValid(); it.GetNext(out pos)) { Debug.Assert(m_cubeSet.Contains(ref pos)); if (eraseCubeSet) { m_cubeSet.Remove(ref pos); } EraseCubeTriangles(pos); } }
private bool RemoveCell(Vector3I cell) { if (!MyFakes.REMOVE_VOXEL_NAVMESH_CELLS) { return(true); } Debug.Assert(m_processedCells.Contains(cell), "Removing a non-existent cell from the navmesh!"); if (!m_processedCells.Contains(cell)) { return(false); } MyTrace.Send(TraceWindow.Ai, "Removing cell " + cell); ProfilerShort.Begin("Removing navmesh links"); MyVoxelPathfinding.CellId cellId = new MyVoxelPathfinding.CellId() { VoxelMap = m_voxelMap, Pos = cell }; m_navmeshCoordinator.RemoveVoxelNavmeshLinks(cellId); ProfilerShort.End(); ProfilerShort.Begin("Removing triangles"); MyCellCoord coord = new MyCellCoord(NAVMESH_LOD, cell); ulong packedCoord = coord.PackId64(); MyIntervalList triangleList = m_higherLevelHelper.TryGetTriangleList(packedCoord); if (triangleList != null) { foreach (var triangleIndex in triangleList) { RemoveTerrainTriangle(GetTriangle(triangleIndex)); } m_higherLevelHelper.ClearCachedCell(packedCoord); } ProfilerShort.End(); Debug.Assert(m_processedCells.Contains(ref cell)); m_processedCells.Remove(ref cell); return(triangleList != null); }