From fb9871f45b921f97d92747eafad388c208345bad Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 28 Apr 2024 20:07:23 +0700 Subject: [PATCH] Ensure counter-clockwise order of poly vertices --- .../kotlin/ru/dbotthepony/kstarbound/world/physics/Poly.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/physics/Poly.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/physics/Poly.kt index 5619ce69..3d074a7e 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/physics/Poly.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/physics/Poly.kt @@ -455,6 +455,9 @@ class Poly private constructor(val edges: ImmutableList, val vertices: I } else if (list.size == 1) { LOGGER.warn("Accepting degenerate poly with 1 points from asset ${AssetPathStack.lastFile()} to match original engine behavior") return Poly(listOf(list[0], list[0], list[0], list[0])) + } else if (list[1].cross(list[0]) > 0.0) { + // HACK: Fix clockwise specified polygons in coming from JSON + return Poly(list.asReversed()) } return Poly(list)