Skip to content

Commit 2918f96

Browse files
committed
fix point selection optimum mode. Was calculating average vector hit pos with integers 💀
1 parent 0ecb949 commit 2918f96

File tree

1 file changed

+4
-4
lines changed
  • common/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty

1 file changed

+4
-4
lines changed

common/src/main/kotlin/com/lambda/interaction/request/rotating/visibilty/PointSelection.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ import com.lambda.interaction.request.rotating.RotationManager
2222
import com.lambda.util.math.distSq
2323
import com.lambda.util.math.times
2424

25-
enum class PointSelection(val select: (MutableList<VisibilityChecker.CheckedHit>) -> VisibilityChecker.CheckedHit?) {
25+
enum class PointSelection(val select: (Collection<VisibilityChecker.CheckedHit>) -> VisibilityChecker.CheckedHit?) {
2626
ByRotation({ hits ->
2727
hits.minByOrNull {
2828
RotationManager.activeRotation dist it.targetRotation
2929
}
3030
}),
3131
Optimum({ hits ->
3232
val optimum = hits
33-
.map { it.hit.pos }
34-
.reduceOrNull { acc, pos -> pos?.let { acc?.add(it) } }
35-
?.times(1 / hits.size)
33+
.mapNotNull { it.hit.pos }
34+
.reduceOrNull { acc, pos -> acc.add(pos) }
35+
?.times(1 / hits.size.toDouble())
3636

3737
optimum?.let {
3838
hits.minByOrNull { it.hit.pos distSq optimum }

0 commit comments

Comments
 (0)