private static SurfaceCell UpdateCell(SurfaceCell surfaceCell, int x, int z) { var surfaceItem = SurfaceManager.instance.GetSurfaceItem(z, x); if (!surfaceItem.overrideExisting && (surfaceCell.m_field >= byte.MaxValue / 2 || surfaceCell.m_gravel >= byte.MaxValue / 2 || surfaceCell.m_pavementA >= byte.MaxValue / 2 || surfaceCell.m_pavementB >= byte.MaxValue / 2 || surfaceCell.m_ruined >= byte.MaxValue / 2 || surfaceCell.m_clipped >= byte.MaxValue / 2)) { return(surfaceCell); } if (surfaceItem.surface == TerrainModify.Surface.Gravel) { surfaceCell.m_gravel = byte.MaxValue; surfaceCell.m_field = 0; surfaceCell.m_pavementB = 0; surfaceCell.m_ruined = 0; surfaceCell.m_pavementA = 0; } if (surfaceItem.surface == TerrainModify.Surface.PavementA) { surfaceCell.m_pavementA = byte.MaxValue; surfaceCell.m_field = 0; surfaceCell.m_pavementB = 0; surfaceCell.m_ruined = 0; surfaceCell.m_gravel = 0; } if (surfaceItem.surface == TerrainModify.Surface.PavementB) { surfaceCell.m_pavementB = byte.MaxValue; surfaceCell.m_field = 0; surfaceCell.m_gravel = 0; surfaceCell.m_ruined = 0; surfaceCell.m_pavementA = 0; } if (surfaceItem.surface == TerrainModify.Surface.Field) { surfaceCell.m_field = byte.MaxValue; surfaceCell.m_gravel = 0; surfaceCell.m_pavementB = 0; surfaceCell.m_ruined = 0; surfaceCell.m_pavementA = 0; } if (surfaceItem.surface == TerrainModify.Surface.Ruined) { surfaceCell.m_ruined = byte.MaxValue; surfaceCell.m_field = 0; surfaceCell.m_pavementB = 0; surfaceCell.m_gravel = 0; surfaceCell.m_pavementA = 0; } if (surfaceItem.surface == TerrainModify.Surface.Clip) { surfaceCell.m_ruined = 0; surfaceCell.m_field = 0; surfaceCell.m_pavementB = 0; surfaceCell.m_gravel = 0; surfaceCell.m_pavementA = 0; } return(surfaceCell); }
private void TurnPoints() { var angleX = MathUtils.GradToRad(XTurnTrb.Value); var angleY = MathUtils.GradToRad(YTurnTrb.Value); var angleZ = MathUtils.GradToRad(ZTurnTrb.Value); coordinates.Turn(angleX, angleY, angleZ); var p = startPoints as IEnumerable <IEnumerable <Point3> >; p = p.TurnObject(Point3.Axes.X, angleX); p = p.TurnObject(Point3.Axes.Y, angleY); p = p.TurnObject(Point3.Axes.Z, angleZ); points = p.Select(row => row.ToList()).ToList(); if (startSurfaceGrid != null && startSurfaceGrid.Count != 0) { p = startSurfaceGrid as IEnumerable <IEnumerable <Point3> >; p = p.TurnObject(Point3.Axes.X, angleX); p = p.TurnObject(Point3.Axes.Y, angleY); p = p.TurnObject(Point3.Axes.Z, angleZ); surfaceGridPoints = p.Select(row => row.ToList()).ToList(); } if (startSurfaceCells != null && startSurfaceCells.Count != 0) { p = startSurfaceCells.Select(cell => cell.ToList()); p = p.TurnObject(Point3.Axes.X, angleX); p = p.TurnObject(Point3.Axes.Y, angleY); p = p.TurnObject(Point3.Axes.Z, angleZ); surfaceCells = p.Select(cell => SurfaceCell.FromList(cell)).ToList(); } }
bool UniqueSurfaceCellsBufferContainsCurrentCell(NativeList <SurfaceCell> UniqueCellList, SurfaceCell currentCell) { for (int i = 0; i < UniqueCellList.Length; i++) { SurfaceCell checkCell = UniqueCellList[i]; if (checkCell.indexInBuffer.Equals(currentCell.indexInBuffer)) { return(true); } } return(false); }
public SurfaceCell CellFromIndex(int2 cellIndex) { float2 vec = cell_2D [Hash2D(TerrainSettings.seed, cellIndex.x, cellIndex.y) & 255]; float cellX = cellIndex.x + vec.x * TerrainSettings.cellularJitter; float cellY = cellIndex.y + vec.y * TerrainSettings.cellularJitter; SurfaceCell cell = new SurfaceCell { indexInBuffer = cellIndex, position = new float3(cellX, 0, cellY) / TerrainSettings.cellFrequency, surfaceGenValue = To01(ValCoord2D(TerrainSettings.seed, cellIndex.x, cellIndex.y)) }; return(cell); }
public void Execute(Entity sectorEntity, int index, ref Sector sector, ref Translation sectorWPos) { DynamicBuffer <SurfaceCell> surfaceCellBuffer = SurfaceCellBufferFrom [sectorEntity]; DynamicBuffer <WorleySurfaceNoise> surfaceNoiseBuffer = SurfaceNoiseBufferFrom [sectorEntity]; if (surfaceCellBuffer.Length < surfaceNoiseBuffer.Length) { surfaceCellBuffer.ResizeUninitialized(surfaceNoiseBuffer.Length); } for (int c = 0; c < surfaceNoiseBuffer.Length; c++) { WorleySurfaceNoise worleyNoise = surfaceNoiseBuffer [c]; SurfaceCell cell = new SurfaceCell { surfaceGenValue = worleyNoise.currentSurfaceCellValue, indexInBuffer = worleyNoise.currentCellIndexInMap, position = worleyNoise.currentCellPosition }; surfaceCellBuffer [c] = cell; } SectorEntities.Enqueue(sectorEntity); }
public void Execute() { for (int e = 0; e < Entities.Length; e++) { Entity sectorEntity = Entities[e]; DynamicBuffer <SurfaceCell> surfaceCellBuffer = SurfaceCellBufferFrom[sectorEntity]; for (int i = 0; i < surfaceCellBuffer.Length; i++) { SurfaceCell currentCell = surfaceCellBuffer[i]; if (!UniqueSurfaceCellsBufferContainsCurrentCell(UniqueCellList, currentCell)) { UniqueCellList.Add(currentCell); } } surfaceCellBuffer.CopyFrom(UniqueCellList); UniqueCellList.Clear(); EntitiesForTagRemoval.Enqueue(sectorEntity); } }