public static JobHandle ScheduleCalculateVerticesJob(Data data, ScaledInfo info, bool useHeightData, float cellSize, NativeArray <TopCellInfo> infoArray, NativeList <float3> vertices, NativeArray <EdgeNormals> edgeNormalsArray, JobHandle lastHandle) { if (!edgeNormalsArray.IsCreated) { return(TopCellMesher.ScheduleCalculateVerticesJob(data, info, useHeightData, cellSize, infoArray, vertices, lastHandle)); } if (useHeightData) { if (info.LerpToExactEdge == 1f) { var vertexCalculator = new ScaledBasicHeightVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, heightOffset = info.OffsetY, heights = data.HeightsRawData, heightScale = info.HeightScale, edgeNormalsArray = edgeNormalsArray, sideOffsetScale = info.ScaledOffset }; return(TopCellMesher.ScheduleCalculateVerticesJob(vertexCalculator, infoArray, vertices, lastHandle)); } else { var vertexCalculator = new ScaledLerpedHeightVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, lerpToEdge = info.LerpToExactEdge, heightOffset = info.OffsetY, heights = data.HeightsRawData, heightScale = info.HeightScale, edgeNormalsArray = edgeNormalsArray, sideOffsetScale = info.ScaledOffset }; return(TopCellMesher.ScheduleCalculateVerticesJob(vertexCalculator, infoArray, vertices, lastHandle)); } } else { if (info.LerpToExactEdge == 1f) { var vertexCalculator = new ScaledBasicVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, heightOffset = info.OffsetY, edgeNormalsArray = edgeNormalsArray, sideOffsetScale = info.ScaledOffset }; return(TopCellMesher.ScheduleCalculateVerticesJob(vertexCalculator, infoArray, vertices, lastHandle)); } else { var vertexCalculator = new ScaledLerpedVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, lerpToEdge = info.LerpToExactEdge, heightOffset = info.OffsetY, edgeNormalsArray = edgeNormalsArray, sideOffsetScale = info.ScaledOffset }; return(TopCellMesher.ScheduleCalculateVerticesJob(vertexCalculator, infoArray, vertices, lastHandle)); } } }
private static IVertexCalculator SelectVertexCalculator(Data data, bool useHeightData, float heightOffset, float heightScale, float lerpToEdge, float cellSize, float sideOffset, NativeArray <EdgeNormals> edgeNormals) { IVertexCalculator selected; if (sideOffset > 0) { if (useHeightData) { if (lerpToEdge == 1f) { selected = new ScaledBasicHeightVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, heightOffset = heightOffset, heights = data.HeightsRawData, heightScale = heightScale, sideOffsetScale = sideOffset, edgeNormalsArray = edgeNormals }; } else { selected = new ScaledLerpedHeightVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, lerpToEdge = lerpToEdge, heightOffset = heightOffset, heights = data.HeightsRawData, heightScale = heightScale, sideOffsetScale = sideOffset, edgeNormalsArray = edgeNormals }; } } else { if (lerpToEdge == 1f) { selected = new ScaledBasicVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, heightOffset = heightOffset, sideOffsetScale = sideOffset, edgeNormalsArray = edgeNormals }; } else { selected = new ScaledLerpedVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, lerpToEdge = lerpToEdge, heightOffset = heightOffset, sideOffsetScale = sideOffset, edgeNormalsArray = edgeNormals }; } } } else { if (useHeightData) { if (lerpToEdge == 1f) { selected = new BasicHeightVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, heightOffset = heightOffset, heights = data.HeightsRawData, heightScale = heightScale }; } else { selected = new LerpedHeightVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, lerpToEdge = lerpToEdge, heightOffset = heightOffset, heights = data.HeightsRawData, heightScale = heightScale }; } } else { if (lerpToEdge == 1f) { selected = new BasicVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, heightOffset = heightOffset }; } else { selected = new LerpedVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, lerpToEdge = lerpToEdge, heightOffset = heightOffset }; } } } return(selected); }
public void CalculateVertices(int index, CellInfo info, CellVertices verts, NativeArray <float3> vertices) => ScaledLerpedVertexCalculator.CalculateVertices(index, info, verts, vertices, colNum, cellSize, heightOffset + heightScale * heights[index], lerpToEdge, sideOffsetScale, edgeNormalsArray);