Repository navigation
Engine:
- Added the
Batchedtrait, aVisiblethat describes aLookinstead 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 plainVisibleactors. 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 plainVisiblebetween batched actors ends the run and draws as before, so the paint order is still exactly whatdrawingOrdersays, and batched actors of the samedrawingOrderare grouped by texture into longer runs. - The available looks are
RectangleLookandEllipseLook(one color, with smoothed edges, and an ellipse tessellated as finely as its size on screen needs),SpriteLook(a texture region withsrcOffset,srcSize,tint, andfilterQuality, drawn in its region's mean color when it is too small on screen to show any of its texture), and the abstractCustomLook, which emits its own geometry into aTriangleBatchin the body's coordinates and is rebuilt afterinvalidate(). Every look exposes arevisionthat 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 throughdrawImageRectinstead. The engine now runs that probe in the background on its own, so batching needs no setup. - Added
TriangleBatch.textureTileMode(TileMode.Repeatedby default, alsoClamp,Mirror, andDecal, which falls back toClampon Android below API 31) andTriangleBatch.textureFilterQuality(FilterQuality.Mediumby default, which samples mipmaps;Nonegives 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. WithisDrawOnly = trueAndroid 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 turnsisWarmtrue 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 threadsubmits a pass, picks its result up withcollecta frame or two later, and canabandonone that no longer applies. A pass that throws is dropped, its exception is reported on the given scope, and the worker keeps running. - Added
lerpforSceneUnit, and forAngleRadiansalong the shorter way around the circle. KubrikoViewportnow lays out the letterbox ofAspectRatioMode.Fixedbefore the modifier passed to it, so a modifier that sizes the viewport (such asfillMaxSize) 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)andSpriteManager.loadSpriteAtlas(resources)declare sprites as belonging together and pack them onto shared, immutable pages in the background, returning aSpriteAtlaswith aloadingProgressflow,isLoaded,pages, andgetRegion. 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 mostmaximumPageSize(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.unloadAtlasreleases 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, andSpriteLook.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, andAnimatedSprite.applyTo(look), which shows the current frame through aSpriteLook, changing the look only when the frame changes. The existingAnimatedSpriteconstructor keeps its signature. - Added
TextureMipChain, a lazily built chain of halved copies of a texture whoseforScale(scale)picks the level for drawing it smaller than its size, so it neither shimmers nor samples more pixels than it shows, andTextureMipChainCache, which shares one chain per texture.SpriteManager.getMipChainhands out one shared chain per resource, or per atlas page for aSpriteRegion, 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.sizecan 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-sidedPolygonCollisionMaskwith the area of the oval it stands for, for ovals aCircleCollisionMaskcan'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 settablesizelike 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.vertexCountandPolygonCollisionMask.vertexAt(index), which read the vertices without allocating; the plugin's own narrow phase and raycasts now use them. - Behavior change:
PolygonCollisionMask.verticesis 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 usevertexCountandvertexAtinstead. 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 withsetStatic()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 asdefaultValue. 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.isKeyPressednow checks held keys through a primitive array, so it no longer boxes theKeyon every call.
Tools:
tool-creator-session: the session protocol is now at version 4, adding thePressKeyStepscommand, which plays severalKeyHoldsteps in one command and can answer with a screenshot, and theCaptureActorscommand, which captures the game's window together with theImageRegionthat the Actors of the given types take up in it (answered withActorsCaptured), 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-sessionno longer has an Edit mode and no longer depends ontool-scene-editor, so games played from Kubriko Creator no longer get the Scene editor on their classpath. A session started witheditnow answers with a failure;SessionMode.EDITis kept only so that older sessions' messages still decode.tool-creator-sessionnow 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.lognow builds its list of entries once instead of copying it three times.