void TriangulateWithRiverBeginOrEnd(HexDirection direction, HexCell cell) { var center = cell.Center; var closerEdge = cell.Edges[(int)direction]; if (cell.HasRiverThroughEdge(direction.Next())) { if (cell.HasRiverThroughEdge(direction.Previous())) { center += HexMetrics.GetSolidEdgeMiddle(direction) * (HexMetrics.InnerToOuter * 0.5f); } else if (cell.HasRiverThroughEdge(direction.Previous2())) { center += HexMetrics.GetLeftSolidCorner(direction) * 0.25f; } } else if (cell.HasRiverThroughEdge(direction.Previous()) && cell.HasRiverThroughEdge(direction.Next2())) { center += HexMetrics.GetRightSolidCorner(direction) * 0.25f; } var m = new EdgeVertices(Vector3.Lerp(center, closerEdge.V1, 0.5f), Vector3.Lerp(center, closerEdge.V5, 0.5f)); m.V3.y = closerEdge.V3.y; // reassign middle verticle height as it is ommited in the calculation above TriangulateEdgeStrip(m, cell.Color, closerEdge, cell.Color); TriangulateEdgeFan(center, m, cell.Color); // river segments are added only if the current segment is not under water if (!cell.IsUnderwater) { bool reversed = cell.HasIncomingRiver; // outer circle of the hex TriangulateRiverQuadUnperturbed(m.V2, m.V4, closerEdge.V2, closerEdge.V4, cell.RiverSurfaceY, 0.6f, reversed); // end (or start) triangle center.y = m.V2.y = m.V4.y = cell.RiverSurfaceY; Rivers.AddTriangleUnperturbed(center, m.V2, m.V4); if (reversed) { Rivers.AddTriangleUV(new Vector2(0.5f, 0.4f), new Vector2(1f, 0.2f), new Vector2(0f, 0.2f)); } else { Rivers.AddTriangleUV(new Vector2(0.5f, 0.4f), new Vector2(0f, 0.6f), new Vector2(1f, 0.6f)); } } }