  */
 __global__ void SortNeighbourIds(uint* p_neighbour_ids, uint* p_neighbour_ids_offset, bool* p_valid_z_values,
     const uint* p_vertex_edge_offset_depth, const int* p_vertex_type, uint p_vertex_cnt, uint p_edge_cnt) {
-    const uint idx = GetThreadIndex();
+    const uint idx = GetCurThreadIndex();
     if (idx >= p_vertex_cnt) return;
     if (!p_valid_z_values[idx]) return;
 

__global__ void GetNeighbourIds(uint* p_neighbour_ids, bool* p_valid_z_values,
    const SombreroKernels::Edge* p_vertex_edge_offset, const uint* p_vertex_edge_offset_depth, uint p_vertex_cnt,
    uint p_edge_cnt) {
    const uint idx = GetThreadIndex();
    if (idx >= p_vertex_cnt) return;
    if (!p_valid_z_values[idx]) return;


 * @param p_face_cnt The number of faces in the mesh.
 */
__global__ void InitEdges(const uint3* p_faces, SombreroKernels::Edge* p_edges, uint p_face_cnt) {
    const uint idx = GetCurThreadIndex();
    if (idx >= p_face_cnt) return;

    // First edge.
