From 351ab764730c40f167830c5ba80a52ed5441f55e Mon Sep 17 00:00:00 2001 From: David Wursteisen Date: Sun, 14 Mar 2021 01:00:42 +0100 Subject: [PATCH 1/2] Update github workflow --- .github/workflows/build.yml | 4 ++++ .github/workflows/publish-release.yml | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50a2301..c8433b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,10 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} restore-keys: | ${{ runner.os }}-gradle- + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 - name: build run: ./gradlew ktlintCheck build diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 2ac3e27..29e4072 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -19,6 +19,9 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} restore-keys: | ${{ runner.os }}-gradle- - + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 - name: Publish artifact run: ./gradlew publishAllPublicationsToSonatypeStagingRepository -Pversion="${{github.event.release.tag_name}}" -Psigning.base64.secretKey="${{secrets.SIGNING_BASE_64_SECRET_KEY}}" -Psigning.password="${{secrets.SIGNING_PASSWORD}}" -Psonatype.username="${{secrets.SONATYPE_USERNAME}}" -Psonatype.password="${{secrets.SONATYPE_PASSWORD}}" From d2c60699c07dad0245eb26fac5e41b56c0cdce58 Mon Sep 17 00:00:00 2001 From: David Wursteisen Date: Sun, 14 Mar 2021 01:01:45 +0100 Subject: [PATCH 2/2] Fix lint --- .../com/curiouscreature/kotlin/math/Matrix.kt | 26 ++++++---- .../com/curiouscreature/kotlin/math/Vector.kt | 36 ++++++++----- .../curiouscreature/kotlin/math/MatrixTest.kt | 32 +++++++----- .../kotlin/math/LibGDXMatrixTest.kt | 52 ++++++++++++------- .../kotlin/math/LibGDXProjectionsTest.kt | 9 ++-- .../kotlin/math/LibGDXQuaternionTest.kt | 2 +- 6 files changed, 97 insertions(+), 60 deletions(-) diff --git a/src/commonMain/kotlin/com/curiouscreature/kotlin/math/Matrix.kt b/src/commonMain/kotlin/com/curiouscreature/kotlin/math/Matrix.kt index 9aa5d4a..859a75f 100644 --- a/src/commonMain/kotlin/com/curiouscreature/kotlin/math/Matrix.kt +++ b/src/commonMain/kotlin/com/curiouscreature/kotlin/math/Matrix.kt @@ -102,15 +102,17 @@ data class Mat2( } fun toFloatArray() = floatArrayOf( - x.x, y.x, - x.y, y.y + x.x, + y.x, + x.y, + y.y ) override fun toString(): String { return """ |${x.x} ${y.x}| |${x.y} ${y.y}| - """.trimIndent() + """.trimIndent() } } @@ -209,7 +211,7 @@ data class Mat3( |${x.x} ${y.x} ${z.x}| |${x.y} ${y.y} ${z.y}| |${x.z} ${y.z} ${z.z}| - """.trimIndent() + """.trimIndent() } } @@ -282,12 +284,14 @@ data class Mat4( 0f, 1f ) - return transpose(Mat4( - x = mx, - y = my, - z = mz, - w = mw - )) + return transpose( + Mat4( + x = mx, + y = my, + z = mz, + w = mw + ) + ) } } @@ -421,7 +425,7 @@ data class Mat4( [${x.y}|${y.y}|${z.y}|${w.y}] [${x.z}|${y.z}|${z.z}|${w.z}] [${x.w}|${y.w}|${z.w}|${w.w}] - """.trimIndent() + """.trimIndent() } } diff --git a/src/commonMain/kotlin/com/curiouscreature/kotlin/math/Vector.kt b/src/commonMain/kotlin/com/curiouscreature/kotlin/math/Vector.kt index 30b99b7..40c5dc0 100644 --- a/src/commonMain/kotlin/com/curiouscreature/kotlin/math/Vector.kt +++ b/src/commonMain/kotlin/com/curiouscreature/kotlin/math/Vector.kt @@ -636,25 +636,29 @@ fun refract(i: Float2, n: Float2, eta: Float): Float2 { inline fun clamp(v: Float2, min: Float, max: Float): Float2 { return Float2( clamp(v.x, min, max), - clamp(v.y, min, max)) + clamp(v.y, min, max) + ) } inline fun clamp(v: Float2, min: Float2, max: Float2): Float2 { return Float2( clamp(v.x, min.x, max.x), - clamp(v.y, min.y, max.y)) + clamp(v.y, min.y, max.y) + ) } inline fun mix(a: Float2, b: Float2, x: Float): Float2 { return Float2( mix(a.x, b.x, x), - mix(a.y, b.y, x)) + mix(a.y, b.y, x) + ) } inline fun mix(a: Float2, b: Float2, x: Float2): Float2 { return Float2( mix(a.x, b.x, x.x), - mix(a.y, b.y, x.y)) + mix(a.y, b.y, x.y) + ) } inline fun min(v: Float2) = min(v.x, v.y) @@ -727,28 +731,32 @@ inline fun clamp(v: Float3, min: Float, max: Float): Float3 { return Float3( clamp(v.x, min, max), clamp(v.y, min, max), - clamp(v.z, min, max)) + clamp(v.z, min, max) + ) } inline fun clamp(v: Float3, min: Float3, max: Float3): Float3 { return Float3( clamp(v.x, min.x, max.x), clamp(v.y, min.y, max.y), - clamp(v.z, min.z, max.z)) + clamp(v.z, min.z, max.z) + ) } inline fun mix(a: Float3, b: Float3, x: Float): Float3 { return Float3( mix(a.x, b.x, x), mix(a.y, b.y, x), - mix(a.z, b.z, x)) + mix(a.z, b.z, x) + ) } inline fun mix(a: Float3, b: Float3, x: Float3): Float3 { return Float3( mix(a.x, b.x, x.x), mix(a.y, b.y, x.y), - mix(a.z, b.z, x.z)) + mix(a.z, b.z, x.z) + ) } inline fun min(v: Float3) = min(v.x, min(v.y, v.z)) @@ -807,7 +815,8 @@ inline fun clamp(v: Float4, min: Float, max: Float): Float4 { clamp(v.x, min, max), clamp(v.y, min, max), clamp(v.z, min, max), - clamp(v.w, min, max)) + clamp(v.w, min, max) + ) } inline fun clamp(v: Float4, min: Float4, max: Float4): Float4 { @@ -815,7 +824,8 @@ inline fun clamp(v: Float4, min: Float4, max: Float4): Float4 { clamp(v.x, min.x, max.x), clamp(v.y, min.y, max.y), clamp(v.z, min.z, max.z), - clamp(v.w, min.z, max.w)) + clamp(v.w, min.z, max.w) + ) } inline fun mix(a: Float4, b: Float4, x: Float): Float4 { @@ -823,7 +833,8 @@ inline fun mix(a: Float4, b: Float4, x: Float): Float4 { mix(a.x, b.x, x), mix(a.y, b.y, x), mix(a.z, b.z, x), - mix(a.w, b.w, x)) + mix(a.w, b.w, x) + ) } inline fun mix(a: Float4, b: Float4, x: Float4): Float4 { @@ -831,7 +842,8 @@ inline fun mix(a: Float4, b: Float4, x: Float4): Float4 { mix(a.x, b.x, x.x), mix(a.y, b.y, x.y), mix(a.z, b.z, x.z), - mix(a.w, b.w, x.w)) + mix(a.w, b.w, x.w) + ) } inline fun min(v: Float4) = min(v.x, min(v.y, min(v.z, v.w))) diff --git a/src/commonTest/kotlin/com/curiouscreature/kotlin/math/MatrixTest.kt b/src/commonTest/kotlin/com/curiouscreature/kotlin/math/MatrixTest.kt index e4a04bb..fb303e7 100644 --- a/src/commonTest/kotlin/com/curiouscreature/kotlin/math/MatrixTest.kt +++ b/src/commonTest/kotlin/com/curiouscreature/kotlin/math/MatrixTest.kt @@ -96,11 +96,13 @@ class MatrixTest { Float3(-2f, 1f, 1f), Float3(2f, -2f, 0f) ), - inverse(Mat3( - Float3(1f, 0f, 0.5f), - Float3(1f, 0f, 0f), - Float3(1f, 1f, 1f) - )) + inverse( + Mat3( + Float3(1f, 0f, 0.5f), + Float3(1f, 0f, 0f), + Float3(1f, 1f, 1f) + ) + ) ) } @@ -123,12 +125,14 @@ class MatrixTest { Float4(0f, 0f, 6f, 0f), Float4(0f, 0f, 0f, 1f) ), - scale(Mat4( - Float4(2f, 0f, 0f, 0f), - Float4(4f, 0f, 0f, 0f), - Float4(6f, 0f, 0f, 0f), - Float4(0f, 0f, 0f, 0f) - )) + scale( + Mat4( + Float4(2f, 0f, 0f, 0f), + Float4(4f, 0f, 0f, 0f), + Float4(6f, 0f, 0f, 0f), + Float4(0f, 0f, 0f, 0f) + ) + ) ) } @@ -179,7 +183,8 @@ class MatrixTest { Float4(1f, 1f, 0f, 0f), Float4(0f, 0f, 1f, 2f), Float4(0f, -2f, 0f, 1f) - )) + ) + ) ) } @@ -200,7 +205,8 @@ class MatrixTest { Float4(1f, 1f, 0f, 0f), Float4(0f, 0f, 1f, 2f), Float4(0f, 0f, 0f, 1f) - )).toString() + ) + ).toString() ) } diff --git a/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXMatrixTest.kt b/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXMatrixTest.kt index aa6a1fe..902ebb0 100644 --- a/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXMatrixTest.kt +++ b/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXMatrixTest.kt @@ -29,14 +29,17 @@ class LibGDXMatrixTest { @Test fun transpose() { - assertEquals(Matrix4( - floatArrayOf( - 1f, 2f, 3f, 4f, - 5f, 6f, 7f, 8f, - 9f, 10f, 11f, 12f, - 13f, 14f, 15f, 16f - ) - ).tra(), transpose(Mat4.fromColumnMajor(1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f, 16f))) + assertEquals( + Matrix4( + floatArrayOf( + 1f, 2f, 3f, 4f, + 5f, 6f, 7f, 8f, + 9f, 10f, 11f, 12f, + 13f, 14f, 15f, 16f + ) + ).tra(), + transpose(Mat4.fromColumnMajor(1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, 13f, 14f, 15f, 16f)) + ) } @Test @@ -81,25 +84,34 @@ class LibGDXMatrixTest { @Test fun multiplication() { - val expected = Matrix4(floatArrayOf( - 1f, 2f, 3f, 4f, - 5f, 6f, 7f, 8f, - 9f, 10f, 11f, 12f, - 13f, 14f, 15f, 16f)).mul(Matrix4(floatArrayOf( - 1f, 2f, 3f, 4f, - 5f, 6f, 7f, 8f, - 9f, 10f, 11f, 12f, - 13f, 14f, 15f, 16f - ))) + val expected = Matrix4( + floatArrayOf( + 1f, 2f, 3f, 4f, + 5f, 6f, 7f, 8f, + 9f, 10f, 11f, 12f, + 13f, 14f, 15f, 16f + ) + ).mul( + Matrix4( + floatArrayOf( + 1f, 2f, 3f, 4f, + 5f, 6f, 7f, 8f, + 9f, 10f, 11f, 12f, + 13f, 14f, 15f, 16f + ) + ) + ) val result = Mat4.fromColumnMajor( 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, - 13f, 14f, 15f, 16f) * Mat4.fromColumnMajor( + 13f, 14f, 15f, 16f + ) * Mat4.fromColumnMajor( 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f, 11f, 12f, - 13f, 14f, 15f, 16f) + 13f, 14f, 15f, 16f + ) assertEquals(expected, result) } diff --git a/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXProjectionsTest.kt b/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXProjectionsTest.kt index 39d9731..5c4b4cd 100644 --- a/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXProjectionsTest.kt +++ b/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXProjectionsTest.kt @@ -8,9 +8,12 @@ class LibGDXProjectionsTest { @Test fun orhotgraphic() { val libgdx = Matrix4().setToOrtho( - 10f, 20f, - 30f, 40f, - 0f, 10f + 10f, + 20f, + 30f, + 40f, + 0f, + 10f ) val mat = ortho(10f, 20f, 30f, 40f, 0f, 10f) diff --git a/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXQuaternionTest.kt b/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXQuaternionTest.kt index 5d7c4dd..a6b8403 100644 --- a/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXQuaternionTest.kt +++ b/src/jvmTest/kotlin/com/curiouscreature/kotlin/math/LibGDXQuaternionTest.kt @@ -1,10 +1,10 @@ package com.curiouscreature.kotlin.math import com.badlogic.gdx.math.Matrix4 -import com.badlogic.gdx.math.Quaternion as Quat import com.badlogic.gdx.math.Vector3 import com.badlogic.gdx.utils.GdxNativesLoader import kotlin.test.Test +import com.badlogic.gdx.math.Quaternion as Quat class LibGDXQuaternionTest { init {