oligarchokapi
06/14/2025, 10:53 PMval sortedFaces: List<Pair<Int, List<Int>>> get() {
return faces.mapIndexed { i, it ->
Pair(i, it)
}.sortedByDescending { indexedFace ->
indexedFace.second.minByOrNull {
vertices[it].z
}
}.also {
it.forEach {
println("${it.first}: ${it.second.map { vertices[it].z }.min() }")
}
println()
}
}
and prints something like this:
5: 0.535865025190621
3: -1.1402821230261972
0: -1.3581312119491156
2: -1.3581312119491156
4: -1.3581312119491156
1: -0.7537141141135403
how can it possibly print a wrongly sorted list here?Riccardo Lippolis
06/15/2025, 3:45 PMminByOrNull
is the issue... It returns the value of the face
with the smallest value for vertices[it].z
, instead of the smallest z
value. If you use minOfOrNull
instead, the output is probably what you expect it to be.Youssef Shoaib [MOD]
06/15/2025, 7:13 PMoligarchokapi
06/15/2025, 9:23 PM