Remove most warnings in ORX

Closes #61
This commit is contained in:
Edwin Jakobs
2020-04-09 16:00:27 +02:00
parent 8fc74555b3
commit d0d096d773
10 changed files with 55 additions and 57 deletions

View File

@@ -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
}

View File

@@ -91,7 +91,7 @@ fun <T, R> (() -> T).watch(transducer: (T) -> R):()->R {
var result = transducer(this())
watchers[this as () -> Any?]!!.watchers.add {
watchers[this]!!.watchers.add {
result = transducer(this())
}

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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)

View File

@@ -19,6 +19,7 @@ internal fun evalScriptWithConfiguration(
return host.eval(script.toScriptSource(), compilationConfiguration, null)
}
@Suppress("UNCHECKED_CAST")
fun <T> loadFromScriptKSH(
script: File,
host: BasicScriptingHost = BasicJvmScriptingHost(),

View File

@@ -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 = ""

View File

@@ -81,9 +81,6 @@ abstract class TextElement(et: ElementType) : Element(et) {
}
fun TextElement.bind(property: KMutableProperty0<String>) {
var currentValue: Double? = null
if (root() as? Body == null) {
throw RuntimeException("no body")
}

View File

@@ -48,6 +48,9 @@ class Matcher {
Combinator.LATER_SIBLING -> if (result == MatchingResult.RESTART_FROM_CLOSEST_DESCENDANT) {
return result
}
Combinator.DESCENDANT -> {
// intentionally do nothing
}
}
}
}

View File

@@ -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