private static void BuildCylinderBottomCap(float bottomRadius, float height, int sliceCount, ref MeshData ret) {
var baseIndex = ret.Vertices.Count;
var y = -0.5f * height;
var dTheta = 2.0f * MathF.PI / sliceCount;
for (var i = 0; i <= sliceCount; i++) {
var x = bottomRadius * MathF.Cos(i * dTheta);
var z = bottomRadius * MathF.Sin(i * dTheta);
var u = x / height + 0.5f;
var v = z / height + 0.5f;
ret.Vertices.Add(new Vertex(x, y, z, 0, -1, 0, 1, 0, 0, u, v));
}
ret.Vertices.Add(new Vertex(0, y, 0, 0, -1, 0, 1, 0, 0, 0.5f, 0.5f));
var centerIndex = ret.Vertices.Count - 1;
for (var i = 0; i < sliceCount; i++) {
ret.Indices.Add(centerIndex);
ret.Indices.Add(baseIndex + i);
ret.Indices.Add(baseIndex + i + 1);
}
}