Upgrade to Gradle 8.10, Kotlin 2.0.20, reduce warnings

This commit is contained in:
Edwin Jakobs
2024-08-25 09:39:18 +02:00
parent 5b6f2ec1ff
commit 8a4a85d333
37 changed files with 133 additions and 81 deletions

View File

@@ -5,6 +5,8 @@ import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
val libs = the<LibrariesForLibs>() val libs = the<LibrariesForLibs>()
@@ -22,8 +24,6 @@ if (shouldPublish) {
apply(plugin = "maven-publish") apply(plugin = "maven-publish")
} }
//apply(plugin = "nebula.release")
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
@@ -57,8 +57,6 @@ dependencies {
"demoRuntimeOnly"(libs.slf4j.simple) "demoRuntimeOnly"(libs.slf4j.simple)
} }
tasks { tasks {
@Suppress("UNUSED_VARIABLE") @Suppress("UNUSED_VARIABLE")
val test by getting(Test::class) { val test by getting(Test::class) {
@@ -76,12 +74,14 @@ tasks {
addBooleanOption("Xdoclint:none", true) addBooleanOption("Xdoclint:none", true)
} }
} }
withType<KotlinCompile>() { withType<KotlinCompile> {
kotlinOptions.jvmTarget = libs.versions.jvmTarget.get() compilerOptions {
kotlinOptions.apiVersion = libs.versions.kotlinApi.get() jvmTarget.set(JvmTarget.valueOf("JVM_${libs.versions.jvmTarget.get()}"))
kotlinOptions.languageVersion = libs.versions.kotlinLanguage.get() freeCompilerArgs.add("-Xexpect-actual-classes")
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" freeCompilerArgs.add("-Xjdk-release=${libs.versions.jvmTarget.get()}")
kotlinOptions.freeCompilerArgs += "-Xjdk-release=${libs.versions.jvmTarget.get()}" apiVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.versions.kotlinApi.get().replace(".", "_")}"))
languageVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.versions.kotlinApi.get().replace(".", "_")}"))
}
} }
} }

View File

@@ -4,11 +4,12 @@ import CollectScreenshotsTask
import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
val libs = the<LibrariesForLibs>() val libs = the<LibrariesForLibs>()
val shouldPublish = project.name !in setOf("openrndr-demos") val shouldPublish = project.name !in setOf("openrndr-demos")
@@ -31,14 +32,19 @@ repositories {
group = "org.openrndr.extra" group = "org.openrndr.extra"
tasks.withType<KotlinCompile<*>> { tasks.withType<KotlinCompilationTask<*>> {
kotlinOptions.apiVersion = libs.versions.kotlinApi.get() compilerOptions {
kotlinOptions.languageVersion = libs.versions.kotlinLanguage.get() apiVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.versions.kotlinApi.get().replace(".", "_")}"))
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" languageVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.versions.kotlinApi.get().replace(".", "_")}"))
kotlinOptions.freeCompilerArgs += "-Xjdk-release=${libs.versions.jvmTarget.get()}" freeCompilerArgs.add("-Xexpect-actual-classes")
} }
}
tasks.withType<KotlinJvmCompile>().configureEach { tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(libs.versions.jvmTarget.get())) compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(libs.versions.jvmTarget.get()))
freeCompilerArgs.add("-Xjdk-release=${libs.versions.jvmTarget.get()}")
}
} }
kotlin { kotlin {
@@ -46,7 +52,6 @@ kotlin {
compilations { compilations {
val main by getting val main by getting
@Suppress("UNUSED_VARIABLE")
val demo by creating { val demo by creating {
associateWith(main) associateWith(main)
tasks.register<CollectScreenshotsTask>("collectScreenshots") { tasks.register<CollectScreenshotsTask>("collectScreenshots") {
@@ -74,7 +79,6 @@ kotlin {
} }
sourceSets { sourceSets {
@Suppress("UNUSED_VARIABLE")
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {
implementation(libs.kotlin.stdlib) implementation(libs.kotlin.stdlib)
@@ -82,14 +86,12 @@ kotlin {
} }
} }
@Suppress("UNUSED_VARIABLE")
val commonTest by getting { val commonTest by getting {
dependencies { dependencies {
implementation(libs.kotlin.test) implementation(libs.kotlin.test)
} }
} }
@Suppress("UNUSED_VARIABLE")
val jvmTest by getting { val jvmTest by getting {
dependencies { dependencies {
runtimeOnly(libs.bundles.jupiter) runtimeOnly(libs.bundles.jupiter)
@@ -97,7 +99,6 @@ kotlin {
} }
} }
@Suppress("UNUSED_VARIABLE")
val jvmDemo by getting { val jvmDemo by getting {
dependencies { dependencies {
implementation(libs.openrndr.application) implementation(libs.openrndr.application)
@@ -181,6 +182,7 @@ if (shouldPublish) {
} }
kotlin { kotlin {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
jvm().mainRun { jvm().mainRun {
classpath(kotlin.jvm().compilations.getByName("demo").output.allOutputs) classpath(kotlin.jvm().compilations.getByName("demo").output.allOutputs)
classpath(kotlin.jvm().compilations.getByName("demo").configurations.runtimeDependencyConfiguration!!) classpath(kotlin.jvm().compilations.getByName("demo").configurations.runtimeDependencyConfiguration!!)

View File

@@ -1,7 +1,7 @@
[versions] [versions]
kotlinApi = "2.0" kotlinApi = "2.0"
kotlinLanguage = "2.0" kotlinLanguage = "2.0"
kotlin = "2.0.10" kotlin = "2.0.20"
jvmTarget = "17" jvmTarget = "17"
openrndr = { require = "[0.4.2, 0.5.0)" } openrndr = { require = "[0.4.2, 0.5.0)" }
kotlinxCoroutines = "1.8.1" kotlinxCoroutines = "1.8.1"

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

2
gradlew vendored
View File

@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.

View File

@@ -10,8 +10,7 @@ fun main() = application {
program { program {
val shader = Shader.createFromCode(vsCode = val shader = Shader.createFromCode(vsCode =
""" """${Driver.instance.shaderConfiguration()}
#version 430
in vec3 a_position; in vec3 a_position;
in vec2 a_texCoord0; in vec2 a_texCoord0;
in vec3 a_normal; in vec3 a_normal;
@@ -22,16 +21,15 @@ void main() {
gl_Position = projMatrix * vec4(a_position, 1.0); gl_Position = projMatrix * vec4(a_position, 1.0);
} }
""", """,
fsCode = """ fsCode = """${Driver.instance.shaderConfiguration()}
#version 430
out vec4 o_color; out vec4 o_color;
layout(rgba8) uniform image2D bla; layout(rgba8) uniform writeonly image2D bla;
void main() { void main() {
imageStore(bla, ivec2(30,30), vec4(1.0, 0.0, 0.0, 1.0)); imageStore(bla, ivec2(30,30), vec4(1.0, 0.0, 0.0, 1.0));
o_color = vec4(1.0); o_color = vec4(1.0);
} }
""", name = "ils") """, name = "ils")
val cb = colorBuffer(128, 128) val cb = colorBuffer(128, 128, type = ColorType.UINT8)
val mesh = planeMesh(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_Y, -Vector3.UNIT_Z, 100.0, 100.0) val mesh = planeMesh(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_Y, -Vector3.UNIT_Z, 100.0, 100.0)
extend { extend {

View File

@@ -1,25 +1,25 @@
import org.openrndr.application import org.openrndr.application
import org.openrndr.color.ColorRGBa import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ImageAccess import org.openrndr.draw.*
import org.openrndr.draw.colorBuffer
import org.openrndr.draw.imageBinding
import org.openrndr.draw.shadeStyle
fun main() = application { fun main() = application {
program { program {
val cb = colorBuffer(128, 128) val cb = colorBuffer(128, 128, type = ColorType.UINT8)
extend { cb.fill(ColorRGBa.BLACK)
val ss = shadeStyle { val ss = shadeStyle {
fragmentTransform = """ fragmentTransform = """
imageStore(p_image, ivec2(30.0, 30.0), vec4(1.0, 0.0, 0.0, 1.0)); imageStore(p_image, ivec2(30, 30), vec4(1.0, 0.0, 0.0, 1.0));
""".trimIndent() """.trimIndent()
parameter("image", cb.imageBinding(0, ImageAccess.READ_WRITE)) image("image", cb.imageBinding(0, ImageAccess.WRITE))
} }
extend {
drawer.shadeStyle = ss drawer.shadeStyle = ss
drawer.clear(ColorRGBa.PINK) drawer.clear(ColorRGBa.PINK)
drawer.rectangle(0.0, 0.0, 100.0, 100.0) drawer.rectangle(0.0, 0.0, 100.0, 100.0)
drawer.shadeStyle = null
drawer.image(cb, 0.0, 200.0) drawer.image(cb, 0.0, 200.0)
} }
} }

View File

@@ -1,13 +1,10 @@
import org.openrndr.application import org.openrndr.application
import org.openrndr.color.ColorRGBa import org.openrndr.color.ColorRGBa
import org.openrndr.draw.VolumeTexture import org.openrndr.draw.*
import org.openrndr.draw.colorBuffer
import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.renderTarget
fun main() = application { fun main() = application {
program { program {
val volumeTexture = VolumeTexture.create(128,128,32) val volumeTexture = VolumeTexture.create(128,128,32, type = ColorType.UINT8)
val rt = renderTarget(128, 128) { val rt = renderTarget(128, 128) {
volumeTexture(volumeTexture, 0) volumeTexture(volumeTexture, 0)
} }

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.camera package org.openrndr.extra.camera
import org.openrndr.Extension import org.openrndr.Extension

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.compositor package org.openrndr.extra.compositor
import org.openrndr.Extension import org.openrndr.Extension

View File

@@ -18,6 +18,7 @@ internal fun vec2(x: Any): Vector2 {
is List<*> -> { is List<*> -> {
when (x.size) { when (x.size) {
2 -> { 2 -> {
@Suppress("UNCHECKED_CAST")
x as List<Double>; Vector2(x[0], x[1]) x as List<Double>; Vector2(x[0], x[1])
} }
@@ -172,6 +173,7 @@ internal fun translate(translation: Any): Matrix44 {
internal fun mat4(x: Any): Matrix44 { internal fun mat4(x: Any): Matrix44 {
return when (x) { return when (x) {
is List<*> -> { is List<*> -> {
@Suppress("UNCHECKED_CAST")
when (x.size) { when (x.size) {
16 -> Matrix44.fromDoubleArray((x as List<Double>).toDoubleArray()) 16 -> Matrix44.fromDoubleArray((x as List<Double>).toDoubleArray())
4 -> { 4 -> {

View File

@@ -20,32 +20,44 @@ internal fun List<*>.memberFunctions(n: String): ((Array<Any>) -> Any)? {
"drop" -> { n -> this.drop((n[0] as Number).toInt()) } "drop" -> { n -> this.drop((n[0] as Number).toInt()) }
"takeLast" -> { n -> this.takeLast((n[0] as Number).toInt()) } "takeLast" -> { n -> this.takeLast((n[0] as Number).toInt()) }
"dropLast" -> { n -> this.takeLast((n[0] as Number).toInt()) } "dropLast" -> { n -> this.takeLast((n[0] as Number).toInt()) }
"map" -> { n -> val lambda = (n[0] as (Any) -> Any); this.map { lambda(it!!) } } "map" -> { n -> @Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.map { lambda(it!!) } }
"filter" -> { n -> "filter" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.filter { (lambda(it!!) as Double).roundToInt() != 0 } val lambda = (n[0] as (Any) -> Any); this.filter { (lambda(it!!) as Double).roundToInt() != 0 }
} }
"max" -> { n -> (this as List<Comparable<Any>>).max() } "max" -> { n ->
"min" -> { n -> (this as List<Comparable<Any>>).min() } @Suppress("UNCHECKED_CAST")
(this as List<Comparable<Any>>).max()
}
"min" -> { n ->
@Suppress("UNCHECKED_CAST")
(this as List<Comparable<Any>>).min()
}
"maxBy" -> { n -> "maxBy" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.maxByOrNull { lambda(it!!) as Comparable<Any> } ?: error("no max") @Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.maxByOrNull { lambda(it!!) as Comparable<Any> } ?: error("no max")
} }
"minBy" -> { n -> "minBy" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.minByOrNull { lambda(it!!) as Comparable<Any> } ?: error("no max") @Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.minByOrNull { lambda(it!!) as Comparable<Any> } ?: error("no max")
} }
"sorted" -> { n -> (this as List<Comparable<Any>>).sorted() } "sorted" -> { n ->
@Suppress("UNCHECKED_CAST")
(this as List<Comparable<Any>>).sorted()
}
"sortedBy" -> { n -> "sortedBy" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.sortedBy { lambda(it!!) as Comparable<Any> } @Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.sortedBy { lambda(it!!) as Comparable<Any> }
} }
"sortedByDescending" -> { n -> "sortedByDescending" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.sortedByDescending { lambda(it!!) as Comparable<Any> } @Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.sortedByDescending { lambda(it!!) as Comparable<Any> }
} }
"reversed" -> { n -> this.reversed() } "reversed" -> { n -> this.reversed() }
"zip" -> { n -> this.zip(n[0] as List<Any>).map { listOf(it.first, it.second) } } "zip" -> { n ->
@Suppress("UNCHECKED_CAST")
this.zip(n[0] as List<Any>).map { listOf(it.first, it.second) }
}
else -> null else -> null
} }

View File

@@ -156,7 +156,7 @@ abstract class TypedExpressionListenerBase(
val index = (s.valueStack.pop() as? Double)?.roundToInt() ?: error("index is not a number") val index = (s.valueStack.pop() as? Double)?.roundToInt() ?: error("index is not a number")
val listValue = s.valueStack.pop() val listValue = s.valueStack.pop()
val value = when (listValue) { @Suppress("UNCHECKED_CAST") val value = when (listValue) {
is List<*> -> listValue[index] ?: error("got null") is List<*> -> listValue[index] ?: error("got null")
is Function<*> -> (listValue as (Int) -> Any)(index) is Function<*> -> (listValue as (Int) -> Any)(index)
else -> error("can't index on '$listValue'") else -> error("can't index on '$listValue'")
@@ -216,6 +216,7 @@ abstract class TypedExpressionListenerBase(
) )
} }
@Suppress("IMPLICIT_CAST_TO_ANY")
override fun exitBinaryOperation1(ctx: KeyLangParser.BinaryOperation1Context) { override fun exitBinaryOperation1(ctx: KeyLangParser.BinaryOperation1Context) {
val s = state val s = state
if (s.inFunctionLiteral > 0) { if (s.inFunctionLiteral > 0) {
@@ -759,6 +760,7 @@ abstract class TypedExpressionListenerBase(
} }
@Suppress("MoveLambdaOutsideParentheses")
override fun visitTerminal(node: TerminalNode) { override fun visitTerminal(node: TerminalNode) {
val s = state val s = state
if (s.inFunctionLiteral > 0) { if (s.inFunctionLiteral > 0) {
@@ -835,26 +837,30 @@ abstract class TypedExpressionListenerBase(
is Function<*> -> { is Function<*> -> {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
receiver as (String) -> Any receiver as (String) -> Any
@Suppress("UNCHECKED_CAST") val function = val function =
receiver.invoke(name) ?: error("no such function $name") receiver.invoke(name)
when (idType) { when (idType) {
IDType.MEMBER_FUNCTION0 -> { IDType.MEMBER_FUNCTION0 -> {
@Suppress("UNCHECKED_CAST")
function as () -> Any function as () -> Any
s.functionStack.push({ function() }) s.functionStack.push({ function() })
} }
IDType.MEMBER_FUNCTION1 -> { IDType.MEMBER_FUNCTION1 -> {
@Suppress("UNCHECKED_CAST")
function as (Any) -> Any function as (Any) -> Any
s.functionStack.push({ x -> function(x[0]) }) s.functionStack.push({ x -> function(x[0]) })
} }
IDType.MEMBER_FUNCTION2 -> { IDType.MEMBER_FUNCTION2 -> {
@Suppress("UNCHECKED_CAST")
function as (Any, Any) -> Any function as (Any, Any) -> Any
s.functionStack.push({ x -> function(x[0], x[1]) }) s.functionStack.push({ x -> function(x[0], x[1]) })
} }
IDType.MEMBER_FUNCTION3 -> { IDType.MEMBER_FUNCTION3 -> {
@Suppress("UNCHECKED_CAST")
function as (Any, Any, Any) -> Any function as (Any, Any, Any) -> Any
s.functionStack.push({ x -> function(x[0], x[1], x[2]) }) s.functionStack.push({ x -> function(x[0], x[1], x[2]) })
} }
@@ -873,13 +879,13 @@ abstract class TypedExpressionListenerBase(
} }
IDType.FUNCTION1 -> { IDType.FUNCTION1 -> {
val s = state val localState = state
val function: (Array<Any>) -> Any = val function: (Array<Any>) -> Any =
dispatchFunction1(name, functions.functions1) dispatchFunction1(name, functions.functions1)
?: errorValue( ?: errorValue(
"unresolved function: '${name}(x0)'" "unresolved function: '${name}(x0)'"
) { _ -> error("this is the error function") } ) { _ -> error("this is the error function") }
s.functionStack.push(function) localState.functionStack.push(function)
} }
IDType.FUNCTION2 -> { IDType.FUNCTION2 -> {

View File

@@ -11,12 +11,12 @@ class TestTypedExpression {
fun funTestFunction() { fun funTestFunction() {
run { run {
val r = evaluateTypedExpression("{ x -> 2.0 + x }") val r = evaluateTypedExpression("{ x -> 2.0 + x }")
val f = r as (Double) -> Double @Suppress("UNCHECKED_CAST") val f = r as (Double) -> Double
println(f(3.0)) println(f(3.0))
} }
run { run {
val r = evaluateTypedExpression("{ { 2.0 + it } }") val r = evaluateTypedExpression("{ { 2.0 + it } }")
val f0 = r as (Any) -> ((Any) -> Any) @Suppress("UNCHECKED_CAST") val f0 = r as (Any) -> ((Any) -> Any)
val f1 = f0(0.0) val f1 = f0(0.0)
println(f1(3.0)) println(f1(3.0))
} }
@@ -102,6 +102,7 @@ class TestTypedExpression {
return fun(p: String): Any? { return fun(p: String): Any? {
val v = this[p] val v = this[p]
if (v is Map<*, *>) { if (v is Map<*, *>) {
@Suppress("UNCHECKED_CAST")
return (v as Map<String, Any>).function() return (v as Map<String, Any>).function()
} else { } else {
return v return v

View File

@@ -1,5 +1,5 @@
import com.strumenta.antlrkotlin.gradle.AntlrKotlinTask import com.strumenta.antlrkotlin.gradle.AntlrKotlinTask
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
plugins { plugins {
org.openrndr.extra.convention.`kotlin-multiplatform` org.openrndr.extra.convention.`kotlin-multiplatform`
@@ -55,7 +55,7 @@ kotlin {
} }
} }
tasks.withType<KotlinCompile<*>> { tasks.withType<KotlinCompilationTask<*>> {
dependsOn(generateKotlinGrammarSource) dependsOn(generateKotlinGrammarSource)
} }

View File

@@ -81,7 +81,7 @@ class HashGrid(val radius: Double) {
private set private set
val cellSize = radius / sqrt(2.0) val cellSize = radius / sqrt(2.0)
private inline fun coords(v: Vector2): GridCoords { private fun coords(v: Vector2): GridCoords {
val x = (v.x / cellSize).fastFloor() val x = (v.x / cellSize).fastFloor()
val y = (v.y / cellSize).fastFloor() val y = (v.y / cellSize).fastFloor()
return GridCoords(x, y) return GridCoords(x, y)

View File

@@ -87,7 +87,7 @@ class HashGrid3D(val radius: Double) {
private set private set
val cellSize = radius / sqrt(3.0) val cellSize = radius / sqrt(3.0)
private inline fun coords(v: Vector3): GridCoords3D { private fun coords(v: Vector3): GridCoords3D {
val x = (v.x / cellSize).fastFloor() val x = (v.x / cellSize).fastFloor()
val y = (v.y / cellSize).fastFloor() val y = (v.y / cellSize).fastFloor()
val z = (v.z / cellSize).fastFloor() val z = (v.z / cellSize).fastFloor()

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.jumpfill.fx package org.openrndr.extra.jumpfill.fx
import org.openrndr.draw.* import org.openrndr.draw.*

View File

@@ -90,7 +90,6 @@ fun GltfFile.buildSceneNodes(): GltfSceneData {
val localBuffer = buffers[localBufferView.buffer].contents(this@buildSceneNodes) val localBuffer = buffers[localBufferView.buffer].contents(this@buildSceneNodes)
require(localBufferView.byteOffset != null) require(localBufferView.byteOffset != null)
require(localBufferView.byteLength != null)
localBuffer.position(localBufferView.byteOffset) localBuffer.position(localBufferView.byteOffset)
localBuffer.limit(localBufferView.byteOffset + localBufferView.byteLength) localBuffer.limit(localBufferView.byteOffset + localBufferView.byteLength)
@@ -321,7 +320,6 @@ fun GltfFile.buildSceneNodes(): GltfSceneData {
val scenes = scenes.map { scene -> val scenes = scenes.map { scene ->
scene.nodes.map { node -> scene.nodes.map { node ->
val gltfNode = nodes.getOrNull(node) ?: error("node not found: $node") val gltfNode = nodes.getOrNull(node) ?: error("node not found: $node")
require(gltfNode != null)
val sceneNode = gltfNode.createSceneNode() val sceneNode = gltfNode.createSceneNode()
sceneNode sceneNode
} }

View File

@@ -19,12 +19,12 @@ fun Mesh.collapse() {
} }
grouped.map { grouped.map {
val vertexCount = it.value.sumBy { primitive -> val vertexCount = it.value.sumOf { primitive ->
primitive.geometry.vertexCount primitive.geometry.vertexCount
} }
val indexCount = if (it.key.hasIndexBuffer) val indexCount = if (it.key.hasIndexBuffer)
it.value.sumBy { primitive -> it.value.sumOf { primitive ->
primitive.geometry.indexBuffer?.indexCount ?: 0 primitive.geometry.indexBuffer?.indexCount ?: 0
} }
else 0 else 0

View File

@@ -5,7 +5,9 @@ plugins {
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
} }
dependencies { dependencies {

View File

@@ -5,7 +5,9 @@ plugins {
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
} }
dependencies { dependencies {

View File

@@ -11,7 +11,9 @@ tasks.generateGrammarSource {
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
} }
dependencies { dependencies {

View File

@@ -5,7 +5,9 @@ plugins {
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
} }
tasks.test { tasks.test {

View File

@@ -5,6 +5,7 @@ import java.io.File
import java.io.InputStream import java.io.InputStream
import java.io.Reader import java.io.Reader
import java.net.MalformedURLException import java.net.MalformedURLException
import java.net.URI
import java.net.URL import java.net.URL
import javax.script.ScriptEngineManager import javax.script.ScriptEngineManager

View File

@@ -5,7 +5,9 @@ plugins {
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
} }
tasks.test { tasks.test {

View File

@@ -88,7 +88,7 @@ fun Element.div(vararg classes: String, init: Div.() -> Unit): Div {
} }
inline fun <reified T : TextElement> Element.textElement(classes: Array<out String>, init: T.() -> String): T { inline fun <reified T : TextElement> Element.textElement(classes: Array<out String>, init: T.() -> String): T {
val te = T::class.java.newInstance() @Suppress("DEPRECATION") val te = T::class.java.newInstance()
te.classes.addAll(classes.map { ElementClass(it) }) te.classes.addAll(classes.map { ElementClass(it) })
te.text(te.init()) te.text(te.init())
append(te) append(te)

View File

@@ -7,7 +7,7 @@ import kotlin.reflect.full.declaredMemberProperties
fun watchHash(toHash: Any): Int { fun watchHash(toHash: Any): Int {
var hash = 0 var hash = 0
for (property in toHash::class.declaredMemberProperties) { for (property in toHash::class.declaredMemberProperties) {
val v = ((property as KProperty1<Any, Any?>).getter).invoke(toHash) @Suppress("UNCHECKED_CAST") val v = ((property as KProperty1<Any, Any?>).getter).invoke(toHash)
if (v is KProperty0<*>) { if (v is KProperty0<*>) {
val pv = v.get() val pv = v.get()
hash = 31 * hash + (pv?.hashCode() ?: 0) hash = 31 * hash + (pv?.hashCode() ?: 0)

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.noise.filters package org.openrndr.extra.noise.filters
import org.openrndr.draw.Filter import org.openrndr.draw.Filter

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.noise.filters package org.openrndr.extra.noise.filters
import org.openrndr.draw.Filter import org.openrndr.draw.Filter

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.noise.filters package org.openrndr.extra.noise.filters
import org.openrndr.draw.Filter import org.openrndr.draw.Filter

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.noise.filters package org.openrndr.extra.noise.filters
import org.openrndr.color.ColorRGBa import org.openrndr.color.ColorRGBa

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.noise.filters package org.openrndr.extra.noise.filters
import org.openrndr.draw.Filter import org.openrndr.draw.Filter

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.noise.filters package org.openrndr.extra.noise.filters
import org.openrndr.draw.Filter import org.openrndr.draw.Filter

View File

@@ -219,7 +219,7 @@ class PaletteStudio(
fun randomPalette() { fun randomPalette() {
val comparison = palette.colors.toMutableList() val comparison = palette.colors.toMutableList()
val colors = Random.pick(palettes, comparison) as MutableList<ColorRGBa> @Suppress("UNCHECKED_CAST") val colors = Random.pick(palettes, comparison) as MutableList<ColorRGBa>
paletteIndex = palettes.indexOf(colors) paletteIndex = palettes.indexOf(colors)
palette = createPalette(colors) palette = createPalette(colors)

View File

@@ -224,7 +224,7 @@ class Quadtree<T>(val bounds: Rectangle, val maxObjects: Int = 10, val mapper: (
} }
private fun intersect(rect: Rectangle): List<Quadtree<T>>? { private fun intersect(rect: Rectangle): List<Quadtree<T>>? {
val intersects = intersects(bounds, rect) val intersects = bounds.intersects(rect)
if (!intersects) return null if (!intersects) return null

View File

@@ -5,6 +5,9 @@ import org.openrndr.draw.Drawer
import org.openrndr.draw.FontImageMap import org.openrndr.draw.FontImageMap
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle import org.openrndr.shape.Rectangle
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
class Cursor(var x: Double = 0.0, var y: Double = 0.0) { class Cursor(var x: Double = 0.0, var y: Double = 0.0) {
constructor(cursor: Cursor) : this(cursor.x, cursor.y) constructor(cursor: Cursor) : this(cursor.x, cursor.y)
@@ -205,7 +208,11 @@ class TextWriter(val drawerRef: Drawer?) {
} }
} }
@OptIn(ExperimentalContracts::class)
fun <T> writer(drawer: Drawer, f: TextWriter.() -> T): T { fun <T> writer(drawer: Drawer, f: TextWriter.() -> T): T {
contract {
callsInPlace(f, InvocationKind.EXACTLY_ONCE)
}
val textWriter = TextWriter(drawer) val textWriter = TextWriter(drawer)
return textWriter.f() return textWriter.f()
} }