Skip to content

0.9.0

Latest

Choose a tag to compare

@pandulapeter pandulapeter released this 16 Nov 15:00
· 266 commits to main since this release

Engine:

  • Added the Batched trait, a Visible that describes a Look instead of drawing itself. Within a layer, consecutive batched actors are drawn as runs of triangles with one native call per run instead of a save, transform, clip, draw, and restore per actor, so a scene's drawing cost no longer grows with its actor count the way it does for plain Visible actors. Each actor's geometry is rebuilt only when its body or its look changes, and an unchanged run redraws last frame's arrays without refilling them. A plain Visible between batched actors ends the run and draws as before, so the paint order is still exactly what drawingOrder says, and batched actors of the same drawingOrder are grouped by texture into longer runs.
  • The available looks are RectangleLook and EllipseLook (one color, with smoothed edges, and an ellipse tessellated as finely as its size on screen needs), SpriteLook (a texture region with srcOffset, srcSize, tint, and filterQuality, drawn in its region's mean color when it is too small on screen to show any of its texture), and the abstract CustomLook, which emits its own geometry into a TriangleBatch in the body's coordinates and is rebuilt after invalidate(). Every look exposes a revision that grows with each change. Give each actor its own look: a shared one still draws correctly, but rebuilds its geometry for every actor on every frame.
  • On devices where TriangleBatchSupport.isTextureSampledPerVertex() reports that per-vertex texture sampling doesn't work, batched sprites are drawn one by one through drawImageRect instead. The engine now runs that probe in the background on its own, so batching needs no setup.
  • Added TriangleBatch.textureTileMode (TileMode.Repeated by default, also Clamp, Mirror, and Decal, which falls back to Clamp on Android below API 31) and TriangleBatch.textureFilterQuality (FilterQuality.Medium by default, which samples mipmaps; None gives nearest-neighbor sampling for pixel art). The defaults keep the previous behavior of a repeating, mipmapped texture.
  • Added ImageBitmap.markImmutable(), which marks a finished bitmap so that the Skia targets (desktop, iOS, and the web) share its pixels instead of copying and re-uploading it on every draw. Mark every bitmap you draw into (a baked texture, a mip level, an atlas page) as soon as it is complete. It is a no-op on Android.
  • Added imageBitmapFromArgb(pixels, width, height, isDrawOnly), which turns a procedurally generated array of ARGB pixels into an immutable bitmap in one call (written straight into Skia's memory on the web) instead of drawing it pixel by pixel. With isDrawOnly = true Android keeps the pixels on the GPU alone as a hardware bitmap. It fails with a clear exception for sizes whose pixel count overflows and when the platform cannot allocate the bitmap.
  • Added ImageBitmap.meanArgb(), the alpha-weighted mean color of a bitmap or of a region of it, sampled on a bounded grid for large regions.
  • Added RenderWarmUp, which times a game's per-frame drawing (measure, addWork, commitFrame) and turns isWarm true once the cost stops falling, falls below an imperceptible threshold, or a maximum duration passes, so a loading screen can stay up exactly as long as the JIT and the platform's caches need. It stops measuring for good once warm and allocates nothing per frame.
  • Added BackgroundPass, a base class for heavy fields a game recomputes now and then (a lighting grid, a density lattice), computed off the frame thread from a snapshot: the frame thread submits a pass, picks its result up with collect a frame or two later, and can abandon one that no longer applies. A pass that throws is dropped, its exception is reported on the given scope, and the worker keeps running.
  • Added lerp for SceneUnit, and for AngleRadians along the shorter way around the circle.
  • KubrikoViewport now lays out the letterbox of AspectRatioMode.Fixed before the modifier passed to it, so a modifier that sizes the viewport (such as fillMaxSize) sizes it within the letterbox instead of keeping the letterbox from forming and the Managers' UI from drawing.

Sprites plugin:

  • Added sprite atlases: SpriteManager.loadAtlas(drawableResources) and SpriteManager.loadSpriteAtlas(resources) declare sprites as belonging together and pack them onto shared, immutable pages in the background, returning a SpriteAtlas with a loadingProgress flow, isLoaded, pages, and getRegion. Each sprite is padded by copies of its own edge pixels (paddingInPixels, 2 by default) so filtering never picks up a neighbor, pages are at most maximumPageSize (2048 by default) in either direction, a sprite sheet is packed whole, and a sprite too large for a page keeps its own bitmap. SpriteManager.unloadAtlas releases an atlas. A sprite that keeps failing to load no longer holds the atlas back: it is packed without it, and the sprite joins as a region of its own bitmap once a retry loads it.
  • Added SpriteRegion (a page bitmap with an offset and a size), SpriteManager.getRegion(resource), which finds a sprite in the first loaded atlas holding it, and SpriteLook.setRegion(region), which shows a region through a batched sprite look. Both allocate nothing and can be called every frame, so batched sprites on the same page draw in one run.
  • Added AnimatedSprite.fromAtlas(getRegion, ...) for sprite sheets packed onto an atlas page, and AnimatedSprite.applyTo(look), which shows the current frame through a SpriteLook, changing the look only when the frame changes. The existing AnimatedSprite constructor keeps its signature.
  • Added TextureMipChain, a lazily built chain of halved copies of a texture whose forScale(scale) picks the level for drawing it smaller than its size, so it neither shimmers nor samples more pixels than it shows, and TextureMipChainCache, which shares one chain per texture. SpriteManager.getMipChain hands out one shared chain per resource, or per atlas page for a SpriteRegion, dropped when the resource or the atlas is unloaded.
  • Added a SpriteManager.newInstance(imageLoader, ...) overload that loads sprites through a custom suspending loader instead of Compose resources, for resources the default loader can't reach (such as those of classes loaded by another class loader). Failed loads are retried like failed default loads.

Collision plugin:

  • BoxCollisionMask.size can now be set, which resizes the box around its center in place. A size with a positive, finite width and height is applied without allocating, so a box can follow a scaling body every frame.
  • Added EllipseCollisionMask, a 16-sided PolygonCollisionMask with the area of the oval it stands for, for ovals a CircleCollisionMask can't represent. It collides with every other mask, is hit by raycasts, gives a physics body its mass like any polygon, and can be resized in place through its settable size like a box.
  • Added ComplexCollisionMask.shapeRevision, which grows whenever a mask's shape changes (a circle's radius, a box's or an ellipse's size) but not when it moves or rotates, so code depending on the shape can tell when to recompute it.
  • Added PolygonCollisionMask.vertexCount and PolygonCollisionMask.vertexAt(index), which read the vertices without allocating; the plugin's own narrow phase and raycasts now use them.
  • Behavior change: PolygonCollisionMask.vertices is now a snapshot that is replaced by a new list when the shape changes, rather than a list fixed at construction. A reference kept to it does not follow a resize, and code that runs every frame should use vertexCount and vertexAt instead. For masks whose shape never changes, the same list is returned every time, as before.

Physics plugin:

  • A body's mass and inertia are now recomputed whenever its collision mask's shape changes (tracked through ComplexCollisionMask.shapeRevision), at every step and before every impulse, so a body that grows gets heavier and an impulse applied right after a resize already uses the new mass. The velocity is kept as it is, so a body that grows while moving keeps its speed rather than its momentum. A body made static with setStatic() stays static through a resize.

Audio playback plugin:

  • Added SoundManager.play(uri, volume), which plays a sound at its own volume from 0 to 1 on every platform; values outside that range are clamped and NaN plays silently. SoundManager.play(uri) keeps playing at full volume.

Persistence plugin:

  • Added PersistenceManager.enum(key, defaultValue), which persists an enum value by the name of its entry. A stored name that no longer matches any entry reads as defaultValue. Like every other persisted value, it is cached by its key alone, so a key must not be shared with a value of another type.

Keyboard input plugin:

  • KeyboardInputManager.isKeyPressed now checks held keys through a primitive array, so it no longer boxes the Key on every call.

Tools:

  • tool-creator-session: the session protocol is now at version 4, adding the PressKeySteps command, which plays several KeyHold steps in one command and can answer with a screenshot, and the CaptureActors command, which captures the game's window together with the ImageRegion that the Actors of the given types take up in it (answered with ActorsCaptured), reading the Actors' bounds on the game's thread and accounting for a letterboxed viewport's alignment. As before, each side skips what it doesn't know, so older Kubriko Creator versions keep working.
  • tool-creator-session no longer has an Edit mode and no longer depends on tool-scene-editor, so games played from Kubriko Creator no longer get the Scene editor on their classpath. A session started with edit now answers with a failure; SessionMode.EDIT is kept only so that older sessions' messages still decode.
  • tool-creator-session now answers a play command that fails unexpectedly with the failure's reason, and lets a game start normally when Kubriko Creator isn't listening for its session.
  • tool-creator-api: CreatorEntryPoint.createSerializationManager() is now called whenever Kubriko Creator shows a Scene with a new build of the project's classes (which it loads into its own process), rather than once per Scene editor session, so it must keep returning a new instance on every call. The module's binary API is now checked against a committed ABI dump, so that it only ever grows compatibly.
  • tool-logger: Logger.log now builds its list of entries once instead of copying it three times.