ChunkDev 🦋
@chunkdev
Building ChunkCity - an Infinite City Builder for PC & mobile 💻📱. No engine, built with #Kotlin
When you slep a cheap light overlay on your scene and it just looks better. At this point I have various system whose sole purpose is to render a bunch of particle like effects with as few draw calls as possible.
It's been a while. Here I added an effect radius preview. Technically I am using the same mechanism I use to mark objects without mesh rebuilding in general: Special marker meshes that get drawn only at certain pixels using stencil masks.
First post of the year after a few stressful weeks at work. Added support for Kotlin objects (singletons): no lazy init yet, but the implementation was refreshingly straightforward. #kotlin
I just learnt that Valve used it in Half-Life and called it "Half Lambert"
I tried similar things before but this one works exceptionally well while being extremely simple yet elegant. Also thanks for sprinkling in hermite splines, just to conclude that even math says it's a great solution.
I considered doing it this way, but adding a separate function and calling it reliably behind the scene sounds like a major headache. So instead I added special instructions to the VM to communicate a bit mask of used default values to the function. They are only present before inlining.
Taught my Kotlin scripting runtime to handle default parameters and named arguments. For simplicity, default evaluation lives in the function body and gets removed when inlined at the call site. #kotlin
Good question. I don't support default or named parameters nor `by` keyword yet so that may be a limitation. In terms of raw performance see the attached screenshot where I let it calculate prime numbers up to 1,000,000. My project is under 10k LOC.
Added vararg support to my runtime. Fewer things broke than expected. #kotlin
Implemented a Vector3 inspired by libGDX in my Kotlin scripting runtime. Overriding equality just works - and later sharing the native host class should work seamlessly as well. #kotlin
I added thread support to my runtime. It’s mostly a wrapper around Kotlin’s threads - and of course I had to demonstrate it with the obligatory race-condition example. #kotlin
Sorry I had to use the most useless CS-class example ever to show off interfaces working. #kotlin
I discovered that adding new opcodes is sometimes easier if I introduce them through handwritten MiniKt assembly functions, so I can reuse the normal function resolution. The compiler inlines them anyway. #kotlin
Added generics for classes. It was painful. I wasn’t aware how much the compiler does for you. #kotlin
Me: I won’t add many features to this tiny Kotlin scripting runtime. Also me: adds function-level generics. #kotlin
Something I like to use it for it resources where you call some sort of start() method and then must not forget to call a corresponding end() method. You can write that logic once in a function and never again forget to call end():
I would assume so, given that without the inline modifier you cannot use statements like return to return the outer function from within the lambda
One of Kotlin’s wildest features: you can define control flow altering functions using lambda expressions with a special syntax. Thanks to aggressive inlining it’s basically free. #kotlin
Higher-order functions take other functions as arguments. The fun part: you must not inline the call unless the target is constant - otherwise you break semantics (and your VM). #kotlin
I did the absolutely sane thing of letting the script run another script; Kotlin-ception achieved #kotlin