private void GetBorderingBioms(VoronoiDiagram.GraphEdge edge, out int biomeA, out int biomeB) { double x = edge.x2 - edge.x1; double y = edge.y2 - edge.y1; Vector2 normal = Vector2.Perpendicular(new Vector2((float)x, (float)y)).normalized; Vector2 middle = new Vector2((float)((edge.x2 + edge.x1) / 2), (float)((edge.y2 + edge.y1) / 2)); Vector2 A = middle + (normal * world.WorldAttributes.CheckBiomeDistance); Vector2 B = middle + (normal * -world.WorldAttributes.CheckBiomeDistance); if (world.IsVoxelInWorld(A)) { biomeA = world.Bioms[Mathf.FloorToInt(A.x), Mathf.FloorToInt(A.y)]; } else { biomeA = 0; } if (world.IsVoxelInWorld(B)) { biomeB = world.Bioms[Mathf.FloorToInt(B.x), Mathf.FloorToInt(B.y)]; } else { biomeB = 0; } }
private void DrawLine(VoronoiDiagram.GraphEdge edge, int biome) { Vector2 A = new Vector2((float)edge.x1, (float)edge.y1); Vector2 B = new Vector2((float)edge.x2, (float)edge.y2); do { DrawPoint(Vector2Int.FloorToInt(A), world.WorldAttributes.BoarderBrushRadius, biome); A = Vector2.MoveTowards(A, B, 1f); } while (A != B); }