Skip to content

Commit

Permalink
Update Kotlin, Gradle and clean up files
Browse files Browse the repository at this point in the history
  • Loading branch information
romainguy committed Jul 20, 2021
1 parent 02ca2b7 commit 28dddee
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions .idea/libraries-with-intellij-classes.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
plugins {
id "org.jetbrains.kotlin.jvm" version "1.2.10"
id "org.jetbrains.kotlin.jvm" version "1.5.21"
}

apply plugin: 'idea'
apply plugin: 'kotlin'

repositories {
jcenter()
mavenCentral()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21"

testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
testImplementation 'junit:junit:4.12'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
9 changes: 7 additions & 2 deletions src/main/kotlin/com/curiouscreature/kotlin/math/Matrix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("unused")

package com.curiouscreature.kotlin.math

import kotlin.math.*
Expand Down Expand Up @@ -355,6 +357,8 @@ fun transpose(m: Mat3) = Mat3(
Float3(m.x.y, m.y.y, m.z.y),
Float3(m.x.z, m.y.z, m.z.z)
)

@Suppress("LocalVariableName")
fun inverse(m: Mat3): Mat3 {
val a = m.x.x
val b = m.x.y
Expand Down Expand Up @@ -385,6 +389,7 @@ fun transpose(m: Mat4) = Mat4(
Float4(m.x.z, m.y.z, m.z.z, m.w.z),
Float4(m.x.w, m.y.w, m.z.w, m.w.w)
)

fun inverse(m: Mat4): Mat4 {
val result = Mat4()

Expand Down Expand Up @@ -462,8 +467,8 @@ fun translation(m: Mat4) = translation(m.translation)
fun rotation(m: Mat4) = Mat4(normalize(m.right), normalize(m.up), normalize(m.forward))
fun rotation(d: Float3): Mat4 {
val r = transform(d, ::radians)
val c = transform(r, { x -> cos(x) })
val s = transform(r, { x -> sin(x) })
val c = transform(r) { x -> cos(x) }
val s = transform(r) { x -> sin(x) }

return Mat4.of(
c.y * c.z, -c.x * s.z + s.x * s.y * c.z, s.x * s.z + c.x * s.y * c.z, 0.0f,
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/com/curiouscreature/kotlin/math/Ray.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("unused")

package com.curiouscreature.kotlin.math

data class Ray(var origin: Float3 = Float3(), var direction: Float3)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/curiouscreature/kotlin/math/Scalar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

@file:Suppress("NOTHING_TO_INLINE")
@file:Suppress("NOTHING_TO_INLINE", "unused")

package com.curiouscreature.kotlin.math

Expand Down
59 changes: 33 additions & 26 deletions src/main/kotlin/com/curiouscreature/kotlin/math/Vector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

@file:Suppress("NOTHING_TO_INLINE")
@file:Suppress("NOTHING_TO_INLINE", "unused")

package com.curiouscreature.kotlin.math

Expand Down Expand Up @@ -284,10 +284,7 @@ data class Float3(var x: Float = 0.0f, var y: Float = 0.0f, var z: Float = 0.0f)
}

operator fun set(
index1: VectorComponent,
index2: VectorComponent,
index3: VectorComponent,
v: Float) {
index1: VectorComponent, index2: VectorComponent, index3: VectorComponent, v: Float) {
set(index1, v)
set(index2, v)
set(index3, v)
Expand Down Expand Up @@ -529,14 +526,15 @@ data class Float4(
set(index2, v)
}

operator fun set(index1: VectorComponent, index2: VectorComponent, index3: VectorComponent,
v: Float) {
operator fun set(
index1: VectorComponent, index2: VectorComponent, index3: VectorComponent, v: Float) {
set(index1, v)
set(index2, v)
set(index3, v)
}

operator fun set(index1: VectorComponent, index2: VectorComponent,
operator fun set(
index1: VectorComponent, index2: VectorComponent,
index3: VectorComponent, index4: VectorComponent, v: Float) {
set(index1, v)
set(index2, v)
Expand Down Expand Up @@ -615,25 +613,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)
Expand Down Expand Up @@ -704,28 +706,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))
Expand Down Expand Up @@ -784,23 +790,26 @@ 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 {
return 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 {
return 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 {
Expand Down Expand Up @@ -1075,10 +1084,7 @@ data class Bool3(var x: Boolean = false, var y: Boolean = false, var z: Boolean
}

operator fun set(
index1: VectorComponent,
index2: VectorComponent,
index3: VectorComponent,
v: Boolean) {
index1: VectorComponent, index2: VectorComponent, index3: VectorComponent, v: Boolean) {
set(index1, v)
set(index2, v)
set(index3, v)
Expand Down Expand Up @@ -1282,14 +1288,15 @@ data class Bool4(
set(index2, v)
}

operator fun set(index1: VectorComponent, index2: VectorComponent, index3: VectorComponent,
v: Boolean) {
operator fun set(
index1: VectorComponent, index2: VectorComponent, index3: VectorComponent, v: Boolean) {
set(index1, v)
set(index2, v)
set(index3, v)
}

operator fun set(index1: VectorComponent, index2: VectorComponent,
operator fun set(
index1: VectorComponent, index2: VectorComponent,
index3: VectorComponent, index4: VectorComponent, v: Boolean) {
set(index1, v)
set(index2, v)
Expand Down

0 comments on commit 28dddee

Please sign in to comment.