# HG changeset patch # User Sascha L. Teichmann # Date 1707946694 -3600 # Node ID fe83406fe7ed90ef38bd56375023bb10539a1381 # Parent c23fa3d1824ccfacf00d9aa9baf18c08d67533b4 Fix bug in sorting the vertices. diff -r c23fa3d1824c -r fe83406fe7ed pkg/mesh/meshserialize_v2.go --- a/pkg/mesh/meshserialize_v2.go Tue Feb 13 23:25:48 2024 +0100 +++ b/pkg/mesh/meshserialize_v2.go Wed Feb 14 22:38:14 2024 +0100 @@ -20,7 +20,6 @@ "io" "math" "slices" - "sort" "gemma.intevation.de/gemma/pkg/common" ) @@ -353,17 +352,17 @@ for p := indices; len(p) > 0; d1, d2 = d2, d1 { l := min(len(p), t) - slices.SortStableFunc(p[:l], d2) + slices.SortStableFunc(p[:l], d1) p = p[l:] } - // We really need to to sort the vertices actually, too. - sort.Slice(vertices, func(i, j int) bool { return indices[i] < indices[j] }) - + v2 := make([]Vertex, len(vertices)) reindices := make([]int32, len(indices)) for i, idx := range indices { + v2[i] = vertices[idx] reindices[idx] = int32(i) } + copy(vertices, v2) // Update the indices in the triangles. for _, tri := range s.tin.Triangles {