static public void CalculateVertices(int index, CellInfo info, CellVertices verts, NativeArray <float3> vertices, int colNum, float cellSize, float heightOffset, float sideOffsetScale, NativeArray <EdgeNormals> edgeNormalsArray) { float3 pos = BasicVertexCalculator.CalculatePosition(index, colNum, cellSize, heightOffset); EdgeNormals normals = edgeNormalsArray[index]; if (verts.corner >= 0) { vertices[verts.corner] = pos; } if (verts.leftEdge >= 0) { float edgeLerp = cellSize * VcLerpT(info); float2 offset = math.normalize(normals.leftEdgeDir) * sideOffsetScale; vertices[verts.leftEdge] = new float3(pos.x + offset.x, pos.y, pos.z + edgeLerp + offset.y); } if (verts.bottomEdge >= 0) { float edgeLerp = cellSize * HzLerpT(info); float2 offset = math.normalize(normals.bottomEdgeDir) * sideOffsetScale; vertices[verts.bottomEdge] = new float3(pos.x + edgeLerp + offset.x, pos.y, pos.z + offset.y); } }
static public void CalculateVertices(int index, CellInfo info, CellVertices verts, NativeArray <float3> vertices, int colNum, float heightOffset, float cellSize, float lerpToEdge) { float3 pos = BasicVertexCalculator.CalculatePosition(index, colNum, cellSize, heightOffset); if (verts.corner >= 0) { vertices[verts.corner] = pos; } if (verts.leftEdge >= 0) { vertices[verts.leftEdge] = new float3(pos.x, pos.y, pos.z + cellSize * VcLerpT(info, lerpToEdge)); } if (verts.bottomEdge >= 0) { vertices[verts.bottomEdge] = new float3(pos.x + cellSize * HzLerpT(info, lerpToEdge), pos.y, pos.z); } }
public static JobHandle ScheduleCalculateVerticesJob(Data data, Info info, bool useHeightData, float cellSize, NativeArray <TopCellInfo> infoArray, NativeList <float3> vertices, JobHandle lastHandle) { if (useHeightData) { if (info.LerpToExactEdge == 1f) { var vertexCalculator = new BasicHeightVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, heightOffset = info.OffsetY, heights = data.HeightsRawData, heightScale = info.HeightScale }; return(ScheduleCalculateVerticesJob(vertexCalculator, infoArray, vertices, lastHandle)); } else { var vertexCalculator = new LerpedHeightVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, lerpToEdge = info.LerpToExactEdge, heightOffset = info.OffsetY, heights = data.HeightsRawData, heightScale = info.HeightScale }; return(ScheduleCalculateVerticesJob(vertexCalculator, infoArray, vertices, lastHandle)); } } else { if (info.LerpToExactEdge == 1f) { var vertexCalculator = new BasicVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, heightOffset = info.OffsetY }; return(ScheduleCalculateVerticesJob(vertexCalculator, infoArray, vertices, lastHandle)); } else { var vertexCalculator = new LerpedVertexCalculator() { colNum = data.ColNum, cellSize = cellSize, lerpToEdge = info.LerpToExactEdge, heightOffset = info.OffsetY }; return(ScheduleCalculateVerticesJob(vertexCalculator, infoArray, vertices, lastHandle)); } } }
public void CalculateVertices(int index, CellInfo info, CellVertices verts, NativeArray <float3> vertices) => BasicVertexCalculator.CalculateVertices(index, info, verts, vertices, colNum, heightOffset + heightScale * heights[index], cellSize);
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); }