diff --git a/orx-compositor/src/main/kotlin/Compositor.kt b/orx-compositor/src/main/kotlin/Compositor.kt index 83ace9e7..de285530 100644 --- a/orx-compositor/src/main/kotlin/Compositor.kt +++ b/orx-compositor/src/main/kotlin/Compositor.kt @@ -4,7 +4,6 @@ import org.openrndr.Extension import org.openrndr.Program import org.openrndr.color.ColorRGBa import org.openrndr.draw.* -import org.openrndr.extra.fx.blend.DestinationOut import org.openrndr.extra.fx.blend.SourceIn import org.openrndr.extra.fx.blend.SourceOut import org.openrndr.extra.parameters.BooleanParameter @@ -140,10 +139,10 @@ open class Layer internal constructor() { val layerPost = postFilters.let { filters -> val targets = postBufferCache val result = filters.foldIndexed(target.colorBuffer(0)) { i, source, filter -> - val target = targets[i % targets.size] + val localTarget = targets[i % targets.size] filter.first.apply(filter.second) - filter.first.apply(source, target) - target + filter.first.apply(source, localTarget) + localTarget } result } diff --git a/orx-file-watcher/src/main/kotlin/FileWatcher.kt b/orx-file-watcher/src/main/kotlin/FileWatcher.kt index b6f9f734..9cb1202f 100644 --- a/orx-file-watcher/src/main/kotlin/FileWatcher.kt +++ b/orx-file-watcher/src/main/kotlin/FileWatcher.kt @@ -91,7 +91,7 @@ fun (() -> T).watch(transducer: (T) -> R):()->R { var result = transducer(this()) - watchers[this as () -> Any?]!!.watchers.add { + watchers[this]!!.watchers.add { result = transducer(this()) } diff --git a/orx-gui/src/main/kotlin/Gui.kt b/orx-gui/src/main/kotlin/Gui.kt index 0e7d07c1..bcdbe7d7 100644 --- a/orx-gui/src/main/kotlin/Gui.kt +++ b/orx-gui/src/main/kotlin/Gui.kt @@ -214,7 +214,7 @@ class GUI : Extension { layout { div("container") { id = "container" - val header = div("toolbar") { + @Suppress("UNUSED_VARIABLE") val header = div("toolbar") { randomizeButton = button { label = "Randomize" clicked { @@ -266,7 +266,7 @@ class GUI : Extension { for ((labeledObject, binding) in trackedObjects) { val (label, _) = labeledObject - val header = h3 { label } + val h3Header = h3 { label } val collapsible = div("compartment") { for (parameter in binding.parameters) { val element = addControl(labeledObject, parameter) @@ -282,10 +282,10 @@ class GUI : Extension { collapsible.classes.add(collapseClass) } - header.mouse.pressed.listen { + h3Header.mouse.pressed.listen { it.cancelPropagation() } - header.mouse.clicked.listen { + h3Header.mouse.clicked.listen { if (KeyModifier.CTRL in it.modifiers) { collapsible.classes.remove(collapseClass) diff --git a/orx-noise/src/main/kotlin/Fractal.kt b/orx-noise/src/main/kotlin/Fractal.kt index f9fe863e..cf1d6205 100644 --- a/orx-noise/src/main/kotlin/Fractal.kt +++ b/orx-noise/src/main/kotlin/Fractal.kt @@ -8,17 +8,17 @@ inline fun fbm(seed: Int, x: Double, y: Double, z: Double, w: Double, crossinlin var sum = noise(seed, x, y, z, w) var amp = 1.0 - var x = x - var y = y - var z = z - var w = w + var lx = x + var ly = y + var lz = z + var lw = w for (i in 1 until octaves) { - x *= lacunarity - y *= lacunarity - z *= lacunarity - w *= lacunarity + lx *= lacunarity + ly *= lacunarity + lz *= lacunarity + lw *= lacunarity amp *= gain - sum += noise(seed + i, x, y, z, w) * amp + sum += noise(seed + i, lx, ly, lz, lw) * amp } return sum } @@ -28,15 +28,15 @@ inline fun fbm(seed: Int, x: Double, y: Double, z: Double, crossinline noise: (I var sum = noise(seed, x, y, z) var amp = 1.0 - var x = x - var y = y - var z = z + var lx = x + var ly = y + var lz = z for (i in 1 until octaves) { - x *= lacunarity - y *= lacunarity - z *= lacunarity + lx *= lacunarity + ly *= lacunarity + lz *= lacunarity amp *= gain - sum += noise(seed + i, x, y, z) * amp + sum += noise(seed + i, lx, ly, lz) * amp } return sum } @@ -46,13 +46,13 @@ inline fun fbm(seed: Int, x: Double, y: Double, crossinline noise: (Int, Double, var sum = noise(seed, x, y) var amp = 1.0 - var x = x - var y = y + var lx = x + var ly = y for (i in 1 until octaves) { - x *= lacunarity - y *= lacunarity + lx *= lacunarity + ly *= lacunarity amp *= gain - sum += noise(seed + i, x, y) * amp + sum += noise(seed + i, lx, ly) * amp } return sum } @@ -62,11 +62,11 @@ inline fun fbm(seed: Int, x: Double, crossinline noise: (Int, Double) -> Double, var sum = noise(seed, x) var amp = 1.0 - var x = x + var lx = x for (i in 1 until octaves) { - x *= lacunarity + lx *= lacunarity amp *= gain - sum += noise(seed + i, x) * amp + sum += noise(seed + i, lx) * amp } return sum } diff --git a/orx-noise/src/main/kotlin/SimplexNoise3D.kt b/orx-noise/src/main/kotlin/SimplexNoise3D.kt index 5bb0ae18..04402c8a 100644 --- a/orx-noise/src/main/kotlin/SimplexNoise3D.kt +++ b/orx-noise/src/main/kotlin/SimplexNoise3D.kt @@ -56,43 +56,43 @@ fun simplex(seed: Int, x: Double, y: Double, z: Double): Double { val n0: Double run { - var t = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - if (t < 0) { + var lt = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 + if (lt < 0) { n0 = 0.0 } else { - t *= t - n0 = t * t * gradCoord3D(seed, i, j, k, x0, y0, z0) + lt *= lt + n0 = lt * lt * gradCoord3D(seed, i, j, k, x0, y0, z0) } } val n1: Double run { - var t = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - if (t < 0) { + var lt = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 + if (lt < 0) { n1 = 0.0 } else { - t *= t - n1 = t * t * gradCoord3D(seed, i + i1, j + j1, k + k1, x1, y1, z1) + lt *= lt + n1 = lt * lt * gradCoord3D(seed, i + i1, j + j1, k + k1, x1, y1, z1) } } val n2: Double run { - var t = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - if (t < 0) { + var lt = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 + if (lt < 0) { n2 = 0.0 } else { - t *= t - n2 = t * t * gradCoord3D(seed, i + i2, j + j2, k + k2, x2, y2, z2) + lt *= lt + n2 = lt * lt * gradCoord3D(seed, i + i2, j + j2, k + k2, x2, y2, z2) } } val n3: Double run { - var t = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - if (t < 0) + var lt = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 + if (lt < 0) n3 = 0.0 else { - t *= t - n3 = t * t * gradCoord3D(seed, i + 1, j + 1, k + 1, x3, y3, z3) + lt *= lt + n3 = lt * lt * gradCoord3D(seed, i + 1, j + 1, k + 1, x3, y3, z3) } } return 32 * (n0 + n1 + n2 + n3) diff --git a/orx-olive/src/main/kotlin/ScriptObjectLoaderKSH.kt b/orx-olive/src/main/kotlin/ScriptObjectLoaderKSH.kt index 796f776c..9f16f063 100644 --- a/orx-olive/src/main/kotlin/ScriptObjectLoaderKSH.kt +++ b/orx-olive/src/main/kotlin/ScriptObjectLoaderKSH.kt @@ -19,6 +19,7 @@ internal fun evalScriptWithConfiguration( return host.eval(script.toScriptSource(), compilationConfiguration, null) } +@Suppress("UNCHECKED_CAST") fun loadFromScriptKSH( script: File, host: BasicScriptingHost = BasicJvmScriptingHost(), diff --git a/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt b/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt index 1609cadd..95d67e20 100644 --- a/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt +++ b/orx-panel/src/main/kotlin/org/openrndr/panel/elements/Slider.kt @@ -167,10 +167,8 @@ class Slider : Element(ElementType("slider")) { if (it.key == KEY_ENTER) { try { val number = NumberFormat.getInstance().parse(keyboardInput).toDouble() - if (number != null) { - interactiveValue = number.coerceIn(range.min, range.max) - } - } catch (e : ParseException) { + interactiveValue = number.coerceIn(range.min, range.max) + } catch (e: ParseException) { // -- silently (but safely) ignore the exception } keyboardInput = "" diff --git a/orx-panel/src/main/kotlin/org/openrndr/panel/elements/TextElements.kt b/orx-panel/src/main/kotlin/org/openrndr/panel/elements/TextElements.kt index 6138ca02..a1d213b0 100644 --- a/orx-panel/src/main/kotlin/org/openrndr/panel/elements/TextElements.kt +++ b/orx-panel/src/main/kotlin/org/openrndr/panel/elements/TextElements.kt @@ -81,9 +81,6 @@ abstract class TextElement(et: ElementType) : Element(et) { } fun TextElement.bind(property: KMutableProperty0) { - var currentValue: Double? = null - - if (root() as? Body == null) { throw RuntimeException("no body") } diff --git a/orx-panel/src/main/kotlin/org/openrndr/panel/style/Matcher.kt b/orx-panel/src/main/kotlin/org/openrndr/panel/style/Matcher.kt index 4ef51d31..3ed49161 100644 --- a/orx-panel/src/main/kotlin/org/openrndr/panel/style/Matcher.kt +++ b/orx-panel/src/main/kotlin/org/openrndr/panel/style/Matcher.kt @@ -48,6 +48,9 @@ class Matcher { Combinator.LATER_SIBLING -> if (result == MatchingResult.RESTART_FROM_CLOSEST_DESCENDANT) { return result } + Combinator.DESCENDANT -> { + // intentionally do nothing + } } } } diff --git a/orx-shader-phrases/src/main/kotlin/ShaderPreprocessor.kt b/orx-shader-phrases/src/main/kotlin/ShaderPreprocessor.kt index f8927694..21da323a 100644 --- a/orx-shader-phrases/src/main/kotlin/ShaderPreprocessor.kt +++ b/orx-shader-phrases/src/main/kotlin/ShaderPreprocessor.kt @@ -34,7 +34,7 @@ fun preprocessShader(source: String): String { "/* imported from $packageClass.$it */\n${it.get(null)}\n" }.joinToString("\n") } else { - var result:String? = null + var result:String? try { val methodName = "get${fieldName.take(1).toUpperCase() + fieldName.drop(1)}" result = c.getMethod(methodName).invoke(null) as String