# Generate vertices for top and bottom rings verts_top = [] verts_bottom = [] for i in range(segments): angle = 2 * math.pi * i / segments x = radius * math.cos(angle) y = radius * math.sin(angle) # Top ring with gentle undulation (z varies with angle) z_top = height * (0.5 + 0.3 * math.sin(4 * angle)) # 4 lobes v_top = bm.verts.new((x, y, z_top)) verts_top.append(v_top) # Bottom ring (flat) v_bottom = bm.verts.new((x, y, -height/2)) verts_bottom.append(v_bottom)

# Add inner ring of vertices at a smaller radius to form a top surface with an inner void. inner_radius = 0.5 inner_verts = [] for i in range(segments): angle = 2 * math.pi * i / segments x = inner_radius * math.cos(angle) y = inner_radius * math.sin(angle) z = height * (0.5 + 0.3 * math.sin(4 * angle)) # same undulation v = bm.verts.new((x, y, z)) inner_verts.append(v)

# Now the mesh is closed (bottom cap, outer walls, top ring, inner cap) # But to make it "solid piece" we need all faces pointing outward. BMesh handles normals but we can recalc.

# Connect outer top ring to inner ring for i in range(segments): i_next = (i + 1) % segments bm.faces.new((verts_top[i], verts_top[i_next], inner_verts[i_next], inner_verts[i]))

# Remove any double vertices bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001)