The origin and evolution of segmentation