Move classes to own files.
This commit is contained in:
parent
35ddb2166c
commit
18aefdf41d
11 changed files with 130 additions and 137 deletions
21
src/main/kotlin/Scene.kt
Normal file
21
src/main/kotlin/Scene.kt
Normal file
|
@ -0,0 +1,21 @@
|
|||
data class Scene(val things: List<Thing>, val light: PointLight): Thing {
|
||||
override fun intersects(ray: Ray): Hit? {
|
||||
var closest: Hit? = null
|
||||
for (thing in things) {
|
||||
val hit = thing.intersects(ray)
|
||||
if (hit != null && (closest == null || hit.distance < closest.distance)) {
|
||||
closest = hit
|
||||
}
|
||||
}
|
||||
|
||||
return closest
|
||||
}
|
||||
|
||||
fun colorForRay(ray: Ray): MaterialColor? {
|
||||
val hit = intersects(ray)
|
||||
if (hit != null) {
|
||||
return hit.material.shade(ray, hit, this)
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue