public void FillFirstRowCache(ArrayGrid <MapElement> mesh_input) { CacheFirstCorner(mesh_input[0, 0], Vector2Int.zero); int i = 0; for (; i < ChunkSize.x - 1; i++) { CacheNextEdgeAndCorner(i * 2, mesh_input[i], mesh_input[i + 1], mesh_input.GetPositionFromIndex(i), mesh_input.GetPositionFromIndex(i + 1)); } if (xNeighbor != null) { Vector3 offsetx = new Vector3(ChunkSize.x, 0, 0); CacheNextEdgeAndCornerWithOffset(i * 2, mesh_input[i], xNeighbor.MapData[0], offsetx, mesh_input.GetPositionFromIndex(i), xNeighbor.MapData.GetPositionFromIndex(0)); } }
private void TriangulateGapRow(ArrayGrid <MapElement> mesh_input) { Vector3 offset = new Vector3(0, 0, ChunkSize.y); SwapRowCaches(); MapElement ta = mesh_input[0, (int)mesh_input.ValidArea.size.y]; MapElement tb = mesh_input[1, (int)mesh_input.ValidArea.size.y]; MapElement tc = yNeighbor.MapData[0, 0]; MapElement td = yNeighbor.MapData[1, 0]; //-----CacheFirstCornerWithOffset( tc, offset ); //-----CacheNextMiddleEdgeWithOffset( mesh_input[ (int)mesh_input.ValidArea.size.y * Resolution ], tc, offset ); CacheFirstCornerWithOffset(tc, offset, new Vector2Int(0, 0)); CacheNextMiddleEdge(mesh_input[(int)mesh_input.ValidArea.size.y * ChunkSize.y], tc, mesh_input.GetPositionFromIndex((int)mesh_input.ValidArea.size.y * ChunkSize.y), new Vector2Int(0, 0)); //-----CacheFirstCornerWithOffset( yNeighbor.map.First[ 0, 0 ], offset ); //-----CacheNextMiddleEdgeWithOffset( yNeighbor.map.First[ 1, 0 ], yNeighbor.map.First[ 0, 0 ], offset ); for (int i = 0; i < (int)mesh_input.ValidArea.size.y; ++i) { MapElement a = mesh_input[i, (int)mesh_input.ValidArea.size.y]; MapElement b = mesh_input[i + 1, (int)mesh_input.ValidArea.size.y]; MapElement c = yNeighbor.MapData[i, 0]; MapElement d = yNeighbor.MapData[i + 1, 0]; int cacheIndex = i * 2; CacheNextEdgeAndCornerWithOffset(cacheIndex, c, d, offset, offset, new Vector2Int(i, 0), new Vector2Int(i + 1, 0)); CacheNextMiddleEdge(b, d, new Vector2Int(i + 1, (int)mesh_input.ValidArea.size.y), new Vector2Int(i + 1, 0)); TriangulateCell(cacheIndex, a, b, c, d); //-----TriangulateCellWithOffset( a, b, c, d, Vector3.zero, Vector3.zero, offset, offset); } if (xyNeighbor != null) { MapElement ax = mesh_input[(int)mesh_input.ValidArea.size.y, (int)mesh_input.ValidArea.size.y]; MapElement bx = xNeighbor.MapData[0, (int)mesh_input.ValidArea.size.y]; MapElement cx = yNeighbor.MapData[(int)mesh_input.ValidArea.size.y, 0]; MapElement dx = xyNeighbor.MapData[0, 0]; Vector3 offsetx = new Vector3(ChunkSize.x, 0, 0); Vector3 offsetz = new Vector3(0, 0, ChunkSize.y); int cacheIndex = ((int)mesh_input.ValidArea.size.y) * 2; CacheNextEdgeAndCornerWithOffset(cacheIndex, cx, dx, offsetz, offsetx + offsetz, new Vector2Int((int)mesh_input.ValidArea.size.y, 0), new Vector2Int(0, 0)); CacheNextMiddleEdgeWithOffset(bx, dx, offsetx, new Vector2Int(0, (int)mesh_input.ValidArea.size.y), new Vector2Int(0, 0)); //-----TriangulateCellWithOffset( ax, bx, cx, dx, Vector3.zero, offsetx, offsetz, offsetx + offsetz ); TriangulateCell(cacheIndex, ax, bx, cx, dx); } }