support mat_ids in merge_mesh()