A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(animation): spring bones give a chain of bones secondary motion in the engine, with colliders to keep it out of the body
yhhe6bc43523cdf
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 69f5d6245..8c5f4c8b2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -35,6 +35,7 @@ published separately; it ships inside the editor.- **Contact shadows and screen-space bounce light.** Contact Shadows and Screen Space GI effects add small sharp shadows at contacts and one bounce of colour between surfaces, and the weather softens the sun's shadows. `contactShadows` marches a short ray toward the scene's sun in the depth buffer; `ssgi` gathers eight rays a pixel over the G-buffer's normals at half size into a float target and averages the neighbours on the same surface before laying the light, times the receiver's colour, over the picture. The Weather component raises the sun's `sourceAngle` and lowers its `shadowStrength` as the sky clouds over.- **Terrain and Foliage.** A Terrain component makes ground from a heightmap or noise, paints it with grass, dirt, snow and rock layers and draws it in chunks that coarsen with distance; a Foliage component scatters grass or a mesh over it, swaying in the wind and thinning out with distance.- **Separate material maps packed on import.** Importing an FBX with separate metalness, roughness and occlusion images now packs them into the one map the Model shader samples, instead of dropping them. Occlusion goes in red, roughness in green and metal in blue, each from its image's red channel (a glossiness map is inverted); a channel with no image stays at full so the material's own value speaks. Only PNG and DDS can be read.+- **Spring bones.** Spring bones give a skeleton secondary motion: a `SpringBone` on the root of a chain of bones (hair, a tail, a cord) makes everything below it a spring that lags the animation, falls with gravity, is pulled back to its animated pose, never stretches, and is kept out of `SpringBoneCollider` spheres and capsules. It runs in C++ in the engine, so it costs the same on every target: 300 chains of six bones step in 0.28 ms. Only the bones' rotations are written, and switching it off gives the animation's own back.- **Water rows in the quality settings.** Project Settings → Rendering has a Level · Water group for the five water quality fields (waves, ripple cells, displacement, mirror, caustics) of the level chosen under Editing level. Each is saved as a difference to that level only, and the group is hidden while quality is off or the project excludes the water module.- **Built-in shaders ship with their modules.** The Water, Terrain, Foliage, Hair, Skin and Eye built-in shaders now ship with their modules instead of the core: a package that installs none of them no longer carries about 80 KB of shader source (a blank web package is 80 KB smaller, a blank WeChat bundle 7% smaller). A material that names one of them is what brings its module into an export, with no component in a scene needed; the three character shaders are a new `esengine/character-shaders` module.- **Opaque models no longer vanish beside glass.** Opaque draws are told from blended ones by the stage they are sorted in, not by their blend mode, when a frame has both a refracting surface and blended draws; before, a lit material whose blend mode was not None (the Model material) was treated as blended and could vanish from such a frame.diff --git a/CMakeLists.txt b/CMakeLists.txtindex a8bff556c..4847423bf 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -140,6 +140,9 @@ set(ESENGINE_HEADERSsrc/esengine/renderer/plugins/TrailPlugin.hppsrc/esengine/trail/TrailSystem.hppsrc/esengine/ecs/components/TrailRenderer.hpp+ src/esengine/springbone/SpringBoneSolver.hpp+ src/esengine/springbone/SpringBoneSystem.hpp+ src/esengine/ecs/components/SpringBone.hppsrc/esengine/renderer/rhi/RenderTarget.hppsrc/esengine/renderer/frame/RenderFrame.hppsrc/esengine/renderer/draw/ImmediateDraw.hppdiff --git a/cmake/ESEngineSources.cmake b/cmake/ESEngineSources.cmakeindex dac38a970..6509b0a82 100644--- a/cmake/ESEngineSources.cmake+++ b/cmake/ESEngineSources.cmake@@ -45,6 +45,8 @@ set(ESENGINE_SOURCES${ESENGINE_ROOT}/src/esengine/renderer/plugins/MeshPlugin.cpp${ESENGINE_ROOT}/src/esengine/renderer/plugins/TrailPlugin.cpp${ESENGINE_ROOT}/src/esengine/trail/TrailSystem.cpp+ ${ESENGINE_ROOT}/src/esengine/springbone/SpringBoneSolver.cpp+ ${ESENGINE_ROOT}/src/esengine/springbone/SpringBoneSystem.cpp${ESENGINE_ROOT}/src/esengine/platform/PathResolver.cpp${ESENGINE_ROOT}/src/esengine/animation/TweenSystem.cpp${ESENGINE_ROOT}/src/esengine/ui/UILayoutSystem.cppdiff --git a/desktop b/desktopindex 7affc79fe..fac062c25 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 7affc79fed72ae29aa99139f2784e1a8fdb9e8c6+Subproject commit fac062c254a91193bec579eef6d749f38fa9aeb1diff --git a/docs/astro/astro.config.mjs b/docs/astro/astro.config.mjsindex 1f70dfb64..ebd86044e 100644--- a/docs/astro/astro.config.mjs+++ b/docs/astro/astro.config.mjs@@ -239,6 +239,7 @@ export default defineConfig({items: [{ label: 'Overview', translations: { 'zh-CN': '总览' }, slug: 'animation/overview' },{ label: 'Timeline', translations: { 'zh-CN': '时间轴' }, slug: 'animation/timeline' },+ { label: 'Spring bones', translations: { 'zh-CN': '弹簧骨骼' }, slug: 'animation/spring-bones' },{ label: 'Spine Animation', translations: { 'zh-CN': 'Spine 动画' }, slug: 'animation/spine' },{ label: 'DragonBones Animation', translations: { 'zh-CN': 'DragonBones 动画' }, slug: 'animation/dragonbones' },],diff --git a/docs/astro/src/content/docs/animation/spring-bones.mdx b/docs/astro/src/content/docs/animation/spring-bones.mdxnew file mode 100644index 000000000..3357b73b3--- /dev/null+++ b/docs/astro/src/content/docs/animation/spring-bones.mdx@@ -0,0 +1,58 @@+---+title: Spring bones+description: Secondary motion for chains of bones (hair, tails, cords): a SpringBone on the chain's root, SpringBoneCollider shapes to keep it out of, and what it costs.+---++Hair, tails, scarves and cords move after the body does: they lag it, swing, and settle. **Spring bones** add that to a skeleton without an animator+authoring it. A `SpringBone` on the **root** of a chain makes every entity below it a spring: the animation still says where each bone would be, and+the chain trails that pose by inertia, falls with gravity, and is pulled back toward it. The root itself is not simulated; it is what the animation or+the body drives.++It is core, not an optional module, and it runs in C++ in the engine, so it costs the same on every target, including ones with no JIT.++## The component++Put a `SpringBone` on the top bone of a hair strand (its parent bone is the body; its children are the strand). Everything below it, down every branch,+is simulated.++| Field | What it does |+|---|---|+| `enabled` | Off leaves the chain exactly as the animation poses it. |+| `stiffness` | How hard each bone is pulled back toward its animated pose, 0 to 1 a frame at 60 Hz. 0 hangs free. |+| `drag` | How much of its speed a bone loses each frame, 0 to 1. Higher settles sooner; the default is damped enough not to ring. |+| `gravity` | World units a second squared (world y is up). The default is a metre a hundred units. |+| `endLength` | A leaf bone has no child to aim at; this gives it a tip that long. 0 leaves leaf bones unsimulated. |+| `radius` | The thickness of the strand, kept clear of the colliders. |+| `weight` | How much of the simulation is used, 0 to 1. 0 is the animation alone. |+| `colliders` | Entities with a `SpringBoneCollider` the chain is kept out of. |++A `SpringBoneCollider` is a sphere, or a capsule along its entity's own Y axis, placed by the entity's transform (and its `offset`). Put them on the head+and shoulders bones so hair does not pass through the body.++## What it does each frame++The animation runs first and writes the bones' local rotations. Then, for each chain:++1. The pose the animation gave is worked out down the chain from the root, using the animation's own rotations. (A bone this system turned last frame+ and that nothing animated this frame is read as the animation had it, not as it was left, so a chain never springs toward its own last result.)+2. The chain is stepped toward that pose: each bone keeps its velocity less drag, falls with gravity, is pulled toward its pose, is put back at its length+ from its parent (parents first, so a bone cannot stretch), and is pushed out of the colliders. The time is split into steps of at most a 60 Hz frame.+3. Each bone is turned to aim at where its child has got to. **Only rotations are written**; a bone's position is never changed, so it cannot leave its parent,+ and skinning needs nothing else.++A jump of the root by more than a few times the chain's length, or a stall of half a second, puts the chain back at its pose instead of whipping it.+Switching the component off, or removing it, gives the bones back as the animation had them. `SpringBoneRes` (`app.getResource(SpringBoneRes)`) has+`reset(root)` for a teleport you want to mark yourself.++## Cost++The solver is a few arithmetic operations per bone. Measured in the editor's play realm, in the wasm engine: **three hundred chains of six bones (2100 nodes)+cost 0.28 ms an update.** The test is `springbone` in the editor checks; `test_springbone` is the C++ unit test of the solver and the system.++## Limits++- A bone with several children aims at its first child; the others follow by being children, and aim at their own.+- Scale is taken from the bones' composed scale; non-uniform scale down a chain is not modelled.+- Collision is bone against sphere or capsule: no collision between strands, no self-collision, and no collision with the world's physics shapes.+- There is no wind yet, and no authoring in the viewport: chains and colliders are set up in the Details panel. A hair importer that finds the strands and makes the chains+ from the model's bone names does not exist yet either.diff --git a/docs/astro/src/content/docs/zh-cn/animation/spring-bones.mdx b/docs/astro/src/content/docs/zh-cn/animation/spring-bones.mdxnew file mode 100644index 000000000..904e12e78--- /dev/null+++ b/docs/astro/src/content/docs/zh-cn/animation/spring-bones.mdx@@ -0,0 +1,46 @@+---+title: 弹簧骨骼+description: 骨骼链的次级运动(头发、尾巴、绳索):放在链根上的 SpringBone,用来挡住它的 SpringBoneCollider 形状,以及它的开销。+---++头发、尾巴、围巾和绳子会在身体动过之后才动:它们滞后、摆动、再安定下来。**弹簧骨骼**不用动画师手工做这些,就能给骨架加上它。把 `SpringBone` 放在一条链的**根**上,根以下的每个实体就成了弹簧:动画仍然说每根骨头本来该在哪里,链则带着惯性拖在那个姿势后面,受重力下坠,并被拉回到那个姿势。根本身不参与模拟,它由动画或身体驱动。++它是核心功能,不是可选模块,在引擎里用 C++ 运行,所以每个目标上开销一样,包括没有 JIT 的目标。++## 组件++把 `SpringBone` 放在一束头发最上面的骨头上(它的父骨头是身体,它的子孙是发束)。它下面的一切,沿每个分支,都会被模拟。++| 字段 | 作用 |+|---|---|+| `enabled` | 关闭后,链完全保持动画摆出的姿势。 |+| `stiffness` | 每根骨头被拉回动画姿势的力度,按 60 Hz 每帧计,0 到 1。0 是自由悬垂。 |+| `drag` | 每帧骨头损失的速度比例,0 到 1。越高越快安定;默认值阻尼足够,不会来回晃。 |+| `gravity` | 世界单位每二次方秒(世界 y 向上)。默认是一米一百个单位。 |+| `endLength` | 末端骨头没有子骨头可以瞄准;这个值给它一段这么长的尖端。0 表示末端骨头不模拟。 |+| `radius` | 发丝的粗细,与碰撞体保持这个距离。 |+| `weight` | 用多少模拟,0 到 1。0 就是只有动画。 |+| `colliders` | 带 `SpringBoneCollider` 的实体,链被挡在它们之外。 |++`SpringBoneCollider` 是一个球,或者沿它自己实体 Y 轴的胶囊,位置由实体的变换(和它的 `offset`)决定。把它们放在头和肩膀的骨头上,头发就不会穿过身体。++## 每帧做什么++动画先运行,写入骨骼的局部旋转。然后对每条链:++1. 沿着链从根往下,用动画自己的旋转算出动画给的姿势。(上一帧被本系统转过、这一帧没有任何东西动画它的骨头,会按动画原本的样子读取,而不是按被留下的样子,所以链不会朝自己上一次的结果弹。)+2. 链朝这个姿势推进:每根骨头保留速度并减去阻力,受重力下坠,被拉向它的姿势,被放回离父骨头的长度处(父在前,所以骨头不会被拉长),并被推出碰撞体。时间被切成不超过一个 60 Hz 帧的步长。+3. 每根骨头被转向它的子骨头跑到的位置。**只写旋转**;骨头的位置从不改变,所以它不会离开父骨头,蒙皮也不需要别的。++根一次跳过链长的好几倍,或者停顿半秒,会把链放回姿势,而不是甩出去。关闭组件或移除它,骨头会按动画原本的样子还回去。`SpringBoneRes`(`app.getResource(SpringBoneRes)`)有 `reset(root)`,用于你想自己标记的瞬移。++## 开销++求解器每根骨头只有几次算术运算。在编辑器的运行时里、wasm 引擎中实测:**三百条六根骨头的链(2100 个节点)每次更新 0.28 毫秒。**测试是编辑器检查里的 `springbone`;`test_springbone` 是求解器和系统的 C++ 单元测试。++## 限制++- 有多个子骨头的骨头瞄准它的第一个子骨头;其他的因为是子骨头而跟着动,并各自瞄准自己的。+- 缩放取骨头合成后的缩放;链上的非均匀缩放没有建模。+- 碰撞是骨头对球或胶囊:没有发丝之间的碰撞,没有自碰撞,也没有和世界物理形状的碰撞。+- 还没有风,也没有视口里的创作:链和碰撞体在 Details 面板里设置。能从模型的骨骼名字找出发束并生成链的头发导入器也还没有。diff --git a/sdk/etc/character-shaders.api.md b/sdk/etc/character-shaders.api.mdnew file mode 100644index 000000000..9ec97bb72--- /dev/null+++ b/sdk/etc/character-shaders.api.md@@ -0,0 +1,10 @@+# API surface — esengine/character-shaders++<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->+Symbols: 0 public · 0 beta · 1 experimental · 0 deprecated++## CHARACTER_SHADER_TEMPLATES — const @experimental+```+BuiltinShaderTemplate[]+```+diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex f26843ea1..30b1ab9f0 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -1,11 +1,11 @@# API surface — esengine/index<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1740 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1748 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"0161363c22733817"+"0683d80a6ccb5275"```## ANCHOR_AXES — const @experimental@@ -7116,6 +7116,11 @@ shadowCellSize: numbershadowDistance: numberskipEffects: readonly string[]ssao: boolean+waterCaustics: boolean+waterDisplacement: boolean+waterMirror: boolean+waterRippleCells: number+waterWaves: number```## QualityReport — interface @experimental@@ -8878,6 +8883,57 @@ y: numberz: number```+## SpringBone — const @experimental+```+BuiltinComponentDef<SpringBoneData>+```++## SpringBoneAPI — class @experimental+```+reset: (root: Entity) => void+update: (dt: number) => void+static new (module: NonNullable<EngineApi>, registry: CppRegistry): SpringBoneAPI+static prototype: SpringBoneAPI+```++## SpringBoneCollider — const @experimental+```+BuiltinComponentDef<SpringBoneColliderData>+```++## SpringBoneColliderData — interface @experimental+```+height: number+offset: Vec3+radius: number+shape: SpringBoneShape+```++## SpringBoneData — interface @experimental+```+colliders: number[]+drag: number+enabled: boolean+endLength: number+gravity: Vec3+radius: number+stiffness: number+weight: number+```++## SpringBonePlugin — class @experimental+```+build: (app: App) => void+name: string+static new (): SpringBonePlugin+static prototype: SpringBonePlugin+```++## SpringBoneRes — const @experimental+```+ResourceDef<SpringBoneAPI>+```+## Sprite — const @public```BuiltinComponentDef<SpriteData>@@ -11177,9 +11233,14 @@ boundary: Point2[]cellSize: numbercells: numberflowSpeed: number+foamFade: numberform: numbermaterial: numberrings: number+rippleDamping: number+rippleSize: number+rippleSpeed: number+ripples: numbershoreWidth: numbersizeX: numbersizeZ: number@@ -11217,7 +11278,10 @@ surface: [number, number, number]```@internal app_: App | null@internal built_: Map<number, Built>+disturb: (x: number, y: number, z: number, radius: number, strength: number) => booleanheightAt: (x: number, z: number) => number | null+quality: WaterQuality+rippleAt: (x: number, y: number, z: number) => numbersample: (x: number, y: number, z: number) => WaterSample | nullstatic new (): Watersstatic prototype: Waters@@ -11230,6 +11294,7 @@ ResourceDef<Waters>## WaveParams — interface @experimental```+count: number | undefineddirection: numberheight: numberlength: number@@ -14723,6 +14788,11 @@ ServicesPluginPlugin```+## springBonePlugin — const @experimental+```+SpringBonePlugin+```+## spriteMotionDriver — const @experimental```MotionDriver<AnimatorClipMotion>diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex f48a444c7..0bc1a746c 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -1,11 +1,11 @@# API surface — esengine/index.native<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 164 beta · 1759 experimental · 3 deprecated+Symbols: 115 public · 164 beta · 1767 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"0161363c22733817"+"0683d80a6ccb5275"```## ANCHOR_AXES — const @experimental@@ -7319,6 +7319,11 @@ shadowCellSize: numbershadowDistance: numberskipEffects: readonly string[]ssao: boolean+waterCaustics: boolean+waterDisplacement: boolean+waterMirror: boolean+waterRippleCells: number+waterWaves: number```## QualityReport — interface @experimental@@ -9091,6 +9096,57 @@ y: numberz: number```+## SpringBone — const @experimental+```+BuiltinComponentDef<SpringBoneData>+```++## SpringBoneAPI — class @experimental+```+reset: (root: Entity) => void+update: (dt: number) => void+static new (module: NonNullable<EngineApi>, registry: CppRegistry): SpringBoneAPI+static prototype: SpringBoneAPI+```++## SpringBoneCollider — const @experimental+```+BuiltinComponentDef<SpringBoneColliderData>+```++## SpringBoneColliderData — interface @experimental+```+height: number+offset: Vec3+radius: number+shape: SpringBoneShape+```++## SpringBoneData — interface @experimental+```+colliders: number[]+drag: number+enabled: boolean+endLength: number+gravity: Vec3+radius: number+stiffness: number+weight: number+```++## SpringBonePlugin — class @experimental+```+build: (app: App) => void+name: string+static new (): SpringBonePlugin+static prototype: SpringBonePlugin+```++## SpringBoneRes — const @experimental+```+ResourceDef<SpringBoneAPI>+```+## Sprite — const @public```BuiltinComponentDef<SpriteData>@@ -11390,9 +11446,14 @@ boundary: Point2[]cellSize: numbercells: numberflowSpeed: number+foamFade: numberform: numbermaterial: numberrings: number+rippleDamping: number+rippleSize: number+rippleSpeed: number+ripples: numbershoreWidth: numbersizeX: numbersizeZ: number@@ -11430,7 +11491,10 @@ surface: [number, number, number]```@internal app_: App | null@internal built_: Map<number, Built>+disturb: (x: number, y: number, z: number, radius: number, strength: number) => booleanheightAt: (x: number, z: number) => number | null+quality: WaterQuality+rippleAt: (x: number, y: number, z: number) => numbersample: (x: number, y: number, z: number) => WaterSample | nullstatic new (): Watersstatic prototype: Waters@@ -11443,6 +11507,7 @@ ResourceDef<Waters>## WaveParams — interface @experimental```+count: number | undefineddirection: numberheight: numberlength: number@@ -14986,6 +15051,11 @@ ServicesPluginPlugin```+## springBonePlugin — const @experimental+```+SpringBonePlugin+```+## spriteMotionDriver — const @experimental```MotionDriver<AnimatorClipMotion>diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 891c4295b..f8993b4be 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.node<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 161 beta · 1739 experimental · 3 deprecated+Symbols: 115 public · 161 beta · 1747 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -7111,6 +7111,11 @@ shadowCellSize: numbershadowDistance: numberskipEffects: readonly string[]ssao: boolean+waterCaustics: boolean+waterDisplacement: boolean+waterMirror: boolean+waterRippleCells: number+waterWaves: number```## QualityReport — interface @experimental@@ -8873,6 +8878,57 @@ y: numberz: number```+## SpringBone — const @experimental+```+BuiltinComponentDef<SpringBoneData>+```++## SpringBoneAPI — class @experimental+```+reset: (root: Entity) => void+update: (dt: number) => void+static new (module: NonNullable<EngineApi>, registry: CppRegistry): SpringBoneAPI+static prototype: SpringBoneAPI+```++## SpringBoneCollider — const @experimental+```+BuiltinComponentDef<SpringBoneColliderData>+```++## SpringBoneColliderData — interface @experimental+```+height: number+offset: Vec3+radius: number+shape: SpringBoneShape+```++## SpringBoneData — interface @experimental+```+colliders: number[]+drag: number+enabled: boolean+endLength: number+gravity: Vec3+radius: number+stiffness: number+weight: number+```++## SpringBonePlugin — class @experimental+```+build: (app: App) => void+name: string+static new (): SpringBonePlugin+static prototype: SpringBonePlugin+```++## SpringBoneRes — const @experimental+```+ResourceDef<SpringBoneAPI>+```+## Sprite — const @public```BuiltinComponentDef<SpriteData>@@ -11172,9 +11228,14 @@ boundary: Point2[]cellSize: numbercells: numberflowSpeed: number+foamFade: numberform: numbermaterial: numberrings: number+rippleDamping: number+rippleSize: number+rippleSpeed: number+ripples: numbershoreWidth: numbersizeX: numbersizeZ: number@@ -11212,7 +11273,10 @@ surface: [number, number, number]```@internal app_: App | null@internal built_: Map<number, Built>+disturb: (x: number, y: number, z: number, radius: number, strength: number) => booleanheightAt: (x: number, z: number) => number | null+quality: WaterQuality+rippleAt: (x: number, y: number, z: number) => numbersample: (x: number, y: number, z: number) => WaterSample | nullstatic new (): Watersstatic prototype: Waters@@ -11225,6 +11289,7 @@ ResourceDef<Waters>## WaveParams — interface @experimental```+count: number | undefineddirection: numberheight: numberlength: number@@ -14728,6 +14793,11 @@ ServicesPluginPlugin```+## springBonePlugin — const @experimental+```+SpringBonePlugin+```+## spriteMotionDriver — const @experimental```MotionDriver<AnimatorClipMotion>diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 3ec71f5ea..405c696d0 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -1,7 +1,7 @@# API surface — esengine/minigame<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1761 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1769 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -7404,6 +7404,11 @@ shadowCellSize: numbershadowDistance: numberskipEffects: readonly string[]ssao: boolean+waterCaustics: boolean+waterDisplacement: boolean+waterMirror: boolean+waterRippleCells: number+waterWaves: number```## QualityReport — interface @experimental@@ -9166,6 +9171,57 @@ y: numberz: number```+## SpringBone — const @experimental+```+BuiltinComponentDef<SpringBoneData>+```++## SpringBoneAPI — class @experimental+```+reset: (root: Entity) => void+update: (dt: number) => void+static new (module: NonNullable<EngineApi>, registry: CppRegistry): SpringBoneAPI+static prototype: SpringBoneAPI+```++## SpringBoneCollider — const @experimental+```+BuiltinComponentDef<SpringBoneColliderData>+```++## SpringBoneColliderData — interface @experimental+```+height: number+offset: Vec3+radius: number+shape: SpringBoneShape+```++## SpringBoneData — interface @experimental+```+colliders: number[]+drag: number+enabled: boolean+endLength: number+gravity: Vec3+radius: number+stiffness: number+weight: number+```++## SpringBonePlugin — class @experimental+```+build: (app: App) => void+name: string+static new (): SpringBonePlugin+static prototype: SpringBonePlugin+```++## SpringBoneRes — const @experimental+```+ResourceDef<SpringBoneAPI>+```+## Sprite — const @public```BuiltinComponentDef<SpriteData>@@ -11471,9 +11527,14 @@ boundary: Point2[]cellSize: numbercells: numberflowSpeed: number+foamFade: numberform: numbermaterial: numberrings: number+rippleDamping: number+rippleSize: number+rippleSpeed: number+ripples: numbershoreWidth: numbersizeX: numbersizeZ: number@@ -11511,7 +11572,10 @@ surface: [number, number, number]```@internal app_: App | null@internal built_: Map<number, Built>+disturb: (x: number, y: number, z: number, radius: number, strength: number) => booleanheightAt: (x: number, z: number) => number | null+quality: WaterQuality+rippleAt: (x: number, y: number, z: number) => numbersample: (x: number, y: number, z: number) => WaterSample | nullstatic new (): Watersstatic prototype: Waters@@ -11524,6 +11588,7 @@ ResourceDef<Waters>## WaveParams — interface @experimental```+count: number | undefineddirection: numberheight: numberlength: number@@ -15032,6 +15097,11 @@ ServicesPluginPlugin```+## springBonePlugin — const @experimental+```+SpringBonePlugin+```+## spriteMotionDriver — const @experimental```MotionDriver<AnimatorClipMotion>diff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.mdindex 51e5a9c69..7b2d8d92c 100644--- a/sdk/etc/wasm.api.md+++ b/sdk/etc/wasm.api.md@@ -51,6 +51,8 @@ addShapeRenderer: (entity: Entity, component: ShapeRenderer) => voidaddSortingGroup: (entity: Entity, component: SortingGroup) => voidaddSphereCollider3D: (entity: Entity, component: SphereCollider3D) => voidaddSpineAnimation: (entity: Entity, component: SpineAnimation) => void+addSpringBone: (entity: Entity, component: SpringBone) => void+addSpringBoneCollider: (entity: Entity, component: SpringBoneCollider) => voidaddSprite: (entity: Entity, component: Sprite) => voidaddSpriteMask: (entity: Entity, component: SpriteMask) => voidaddTilemapLayer: (entity: Entity, component: TilemapLayer) => void@@ -106,6 +108,8 @@ getShapeRenderer: (entity: Entity) => ShapeRenderergetSortingGroup: (entity: Entity) => SortingGroupgetSphereCollider3D: (entity: Entity) => SphereCollider3DgetSpineAnimation: (entity: Entity) => SpineAnimation+getSpringBone: (entity: Entity) => SpringBone+getSpringBoneCollider: (entity: Entity) => SpringBoneCollidergetSprite: (entity: Entity) => SpritegetSpriteMask: (entity: Entity) => SpriteMaskgetTilemapLayer: (entity: Entity) => TilemapLayer@@ -155,6 +159,8 @@ hasShapeRenderer: (entity: Entity) => booleanhasSortingGroup: (entity: Entity) => booleanhasSphereCollider3D: (entity: Entity) => booleanhasSpineAnimation: (entity: Entity) => boolean+hasSpringBone: (entity: Entity) => boolean+hasSpringBoneCollider: (entity: Entity) => booleanhasSprite: (entity: Entity) => booleanhasSpriteMask: (entity: Entity) => booleanhasTilemapLayer: (entity: Entity) => boolean@@ -207,6 +213,8 @@ removeShapeRenderer: (entity: Entity) => voidremoveSortingGroup: (entity: Entity) => voidremoveSphereCollider3D: (entity: Entity) => voidremoveSpineAnimation: (entity: Entity) => void+removeSpringBone: (entity: Entity) => void+removeSpringBoneCollider: (entity: Entity) => voidremoveSprite: (entity: Entity) => voidremoveSpriteMask: (entity: Entity) => voidremoveTilemapLayer: (entity: Entity) => void@@ -527,6 +535,8 @@ renderer_updateTransforms: (registry: CppRegistry) => voidsdfFromAlpha: ((alphaPtr: number, outPtr: number, width: number, height: number, spread: number) => void) | undefinedsetActiveContext: (ctx: CppEngineContext | null) => voidshutdownRenderer: () => void+springbone_reset: ((registry: CppRegistry, entity: number) => void) | undefined+springbone_update: ((registry: CppRegistry, dt: number) => void) | undefinedtilemap_destroyLayer: ((entity: number) => void) | undefinedtilemap_exportChunks: ((entity: number) => string) | undefinedtilemap_fillRect: ((entity: number, x: number, y: number, w: number, h: number, tileId: number) => void) | undefineddiff --git a/sdk/etc/water.api.md b/sdk/etc/water.api.mdindex 4d8ec1198..ebcabec63 100644--- a/sdk/etc/water.api.md+++ b/sdk/etc/water.api.md@@ -1,7 +1,7 @@# API surface — esengine/water<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 0 public · 0 beta · 35 experimental · 0 deprecated+Symbols: 0 public · 0 beta · 37 experimental · 0 deprecated## Floating — const @experimental```@@ -22,6 +22,7 @@ buoyancy: numberdrag: numberpoints: Vec3Like[]radius: number+wake: number```## FloatingForce — interface @experimental@@ -55,6 +56,25 @@ damp: ((x: number, z: number) => number) | undefinedkeep: ((x: number, z: number, cell: number) => boolean) | undefined```+## RippleField — class @experimental+```+cell: number+disturb: (x: number, z: number, radius: number, strength: number) => void+encode: (range: number, into?: Uint8Array) => Uint8Array+foamAt: (x: number, z: number) => number+heightAt: (x: number, z: number) => number+limit: number+n: number+originX: number+originZ: number+peak: () => number+recenter: (x: number, z: number) => boolean+size: number+step: (dt: number, speed: number, damping: number, foamFade: number) => void+static new (n: number, size: number): RippleField+static prototype: RippleField+```+## ShoreField — class @experimental```damp: (x: number, z: number) => number@@ -104,9 +124,14 @@ boundary: Point2[]cellSize: numbercells: numberflowSpeed: number+foamFade: numberform: numbermaterial: numberrings: number+rippleDamping: number+rippleSize: number+rippleSpeed: number+ripples: numbershoreWidth: numbersizeX: numbersizeZ: number@@ -144,7 +169,10 @@ surface: [number, number, number]```@internal app_: App | null@internal built_: Map<number, Built>+disturb: (x: number, y: number, z: number, radius: number, strength: number) => booleanheightAt: (x: number, z: number) => number | null+quality: WaterQuality+rippleAt: (x: number, y: number, z: number) => numbersample: (x: number, y: number, z: number) => WaterSample | nullstatic new (): Watersstatic prototype: Waters@@ -157,6 +185,7 @@ ResourceDef<Waters>## WaveParams — interface @experimental```+count: number | undefineddirection: numberheight: numberlength: number@@ -218,6 +247,11 @@ speed: number(reach: number, width: number): number```+## wakeStrength — function @experimental+```+(sample: WaterSample | null, velocity: [number, number, number], floating: FloatingData, dt: number): number+```+## waterPlugin — const @experimental```Plugindiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex d660207be..4c3a5c70d 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -1,7 +1,7 @@# API surface — esengine/wechat<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 159 beta · 1752 experimental · 3 deprecated+Symbols: 115 public · 159 beta · 1760 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -7118,6 +7118,11 @@ shadowCellSize: numbershadowDistance: numberskipEffects: readonly string[]ssao: boolean+waterCaustics: boolean+waterDisplacement: boolean+waterMirror: boolean+waterRippleCells: number+waterWaves: number```## QualityReport — interface @experimental@@ -8880,6 +8885,57 @@ y: numberz: number```+## SpringBone — const @experimental+```+BuiltinComponentDef<SpringBoneData>+```++## SpringBoneAPI — class @experimental+```+reset: (root: Entity) => void+update: (dt: number) => void+static new (module: NonNullable<EngineApi>, registry: CppRegistry): SpringBoneAPI+static prototype: SpringBoneAPI+```++## SpringBoneCollider — const @experimental+```+BuiltinComponentDef<SpringBoneColliderData>+```++## SpringBoneColliderData — interface @experimental+```+height: number+offset: Vec3+radius: number+shape: SpringBoneShape+```++## SpringBoneData — interface @experimental+```+colliders: number[]+drag: number+enabled: boolean+endLength: number+gravity: Vec3+radius: number+stiffness: number+weight: number+```++## SpringBonePlugin — class @experimental+```+build: (app: App) => void+name: string+static new (): SpringBonePlugin+static prototype: SpringBonePlugin+```++## SpringBoneRes — const @experimental+```+ResourceDef<SpringBoneAPI>+```+## Sprite — const @public```BuiltinComponentDef<SpriteData>@@ -11179,9 +11235,14 @@ boundary: Point2[]cellSize: numbercells: numberflowSpeed: number+foamFade: numberform: numbermaterial: numberrings: number+rippleDamping: number+rippleSize: number+rippleSpeed: number+ripples: numbershoreWidth: numbersizeX: numbersizeZ: number@@ -11219,7 +11280,10 @@ surface: [number, number, number]```@internal app_: App | null@internal built_: Map<number, Built>+disturb: (x: number, y: number, z: number, radius: number, strength: number) => booleanheightAt: (x: number, z: number) => number | null+quality: WaterQuality+rippleAt: (x: number, y: number, z: number) => numbersample: (x: number, y: number, z: number) => WaterSample | nullstatic new (): Watersstatic prototype: Waters@@ -11232,6 +11296,7 @@ ResourceDef<Waters>## WaveParams — interface @experimental```+count: number | undefineddirection: numberheight: numberlength: number@@ -14759,6 +14824,11 @@ ServicesPluginPlugin```+## springBonePlugin — const @experimental+```+SpringBonePlugin+```+## spriteMotionDriver — const @experimental```MotionDriver<AnimatorClipMotion>diff --git a/sdk/src/app/pluginSets.ts b/sdk/src/app/pluginSets.tsindex 6a51d1e83..c9c59311c 100644--- a/sdk/src/app/pluginSets.ts+++ b/sdk/src/app/pluginSets.ts@@ -26,6 +26,7 @@ import { audioPlugin } from '../audio';import { videoPlugin } from '../video';import { particlePlugin } from '../particle';import { trailPlugin } from '../trail';+import { springBonePlugin } from '../springbone';import { meshRendererPlugin } from '../render/meshRenderer';import { staticBatchPlugin } from '../render/staticBatchPlugin';import { postProcessPlugin } from '../postprocess';@@ -56,7 +57,7 @@ export const simulationBasePlugins = (): Plugin[] => [/** What exists to be seen. Every entry drives the engine through `engineApi`. */export const presentationBasePlugins = (): Plugin[] => [- animationPlugin, videoPlugin, particlePlugin, trailPlugin, meshRendererPlugin, staticBatchPlugin,+ animationPlugin, videoPlugin, particlePlugin, trailPlugin, springBonePlugin, meshRendererPlugin, staticBatchPlugin,postProcessPlugin,];@@ -67,7 +68,7 @@ export const presentationBasePlugins = (): Plugin[] => [*/export const PLUGIN_BUILD_ORDER: readonly string[] = ['Diagnostics', 'timer', 'velocity', 'lifecycle', 'animation', 'audio', 'video',- 'particle', 'trail', 'meshRenderer', 'staticBatch', 'terrain', 'foliage', 'spline', 'water', 'floating', 'underwater', 'tilemap', 'postProcess', 'timeline',+ 'particle', 'trail', 'springBone', 'meshRenderer', 'staticBatch', 'terrain', 'foliage', 'spline', 'water', 'floating', 'underwater', 'tilemap', 'postProcess', 'timeline','gameplay','perception', 'fsm', 'bt', 'scriptGraph', 'nav', 'eventBinding', 'replication','services',@@ -93,7 +94,7 @@ export function inBuildOrder(plugins: readonly Plugin[]): Plugin[] {export const webBasePlugins = (): Plugin[] => [diagnosticsPlugin,timerPlugin, velocityPlugin, lifecyclePlugin, animationPlugin, audioPlugin, videoPlugin,- particlePlugin, trailPlugin, meshRendererPlugin, staticBatchPlugin, postProcessPlugin,+ particlePlugin, trailPlugin, springBonePlugin, meshRendererPlugin, staticBatchPlugin, postProcessPlugin,eventBindingPlugin,servicesPlugin,];diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.tsindex c2993db9a..7c0eac952 100644--- a/sdk/src/core-content.ts+++ b/sdk/src/core-content.ts@@ -765,6 +765,17 @@ export {trailPlugin,} from './trail';+// =============================================================================+// Spring bones+// =============================================================================++export {+ SpringBoneRes,+ SpringBoneAPI,+ SpringBonePlugin,+ springBonePlugin,+} from './springbone';+// =============================================================================// MeshRenderer// =============================================================================diff --git a/sdk/src/core-runtime.ts b/sdk/src/core-runtime.tsindex 5f23569c5..21054ec69 100644--- a/sdk/src/core-runtime.ts+++ b/sdk/src/core-runtime.ts@@ -108,6 +108,8 @@ export {SortingGroup,SpriteMask,TrailRenderer,+ SpringBone,+ SpringBoneCollider,MeshRenderer,type MeshRendererData,type MeshRendererGeometry,@@ -143,6 +145,8 @@ export {type ChildrenData,type BitmapTextData,type TrailRendererData,+ type SpringBoneData,+ type SpringBoneColliderData,type SpineAnimationData,type DragonBonesAnimationData,type RigidBody2DData,diff --git a/sdk/src/ecs/bridge/nativeEngineApi.generated.ts b/sdk/src/ecs/bridge/nativeEngineApi.generated.tsindex e32779213..957739042 100644--- a/sdk/src/ecs/bridge/nativeEngineApi.generated.ts+++ b/sdk/src/ecs/bridge/nativeEngineApi.generated.ts@@ -265,6 +265,8 @@ export interface NativeEngineApi {rm_trimTextureCache?(rm: unknown): number;rm_updateTextureSubregion?(rm: unknown, handleId: number, x: number, y: number, width: number, height: number, pixelsPtr: number, pixelsLen: number): void;rm_wrapDeviceTexture?(rm: unknown, textureId: number, width: number, height: number): number;+ springbone_reset?(registry: unknown, entity: number): void;+ springbone_update?(registry: unknown, dt: number): void;tilemap_advanceAnimations?(entity: number, dtMs: number): void;tilemap_clearTileAnimations?(entity: number): void;tilemap_destroyLayer?(entity: number): void;@@ -581,6 +583,8 @@ export function createNativeEngineApi(bind('rm_trimTextureCache', 'es_rm_trimTextureCache', true);bind('rm_updateTextureSubregion', 'es_rm_updateTextureSubregion', true);bind('rm_wrapDeviceTexture', 'es_rm_wrapDeviceTexture', true);+ bind('springbone_reset', 'es_springbone_reset', true);+ bind('springbone_update', 'es_springbone_update', true);bind('tilemap_advanceAnimations', 'es_tilemap_advanceAnimations', false);bind('tilemap_clearTileAnimations', 'es_tilemap_clearTileAnimations', false);bind('tilemap_destroyLayer', 'es_tilemap_destroyLayer', false);diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.tsindex 79018f45a..b2688a7dc 100644--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts@@ -1901,6 +1901,90 @@ export function createSpineAnimationData(): SpineAnimationPtrData {};}+export interface SpringBonePtrData {+ enabled: boolean;+ stiffness: number;+ drag: number;+ gravity: Vec3;+ endLength: number;+ radius: number;+ weight: number;+}++export function fillSpringBone(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: SpringBonePtrData,+): void {+ out.enabled = u8[ptr] !== 0;+ out.stiffness = f32[(ptr + 4) >> 2];+ out.drag = f32[(ptr + 8) >> 2];+ const gravity_ = out.gravity; gravity_.x = f32[(ptr + 12) >> 2]; gravity_.y = f32[((ptr + 12) >> 2) + 1]; gravity_.z = f32[((ptr + 12) >> 2) + 2];+ out.endLength = f32[(ptr + 24) >> 2];+ out.radius = f32[(ptr + 28) >> 2];+ out.weight = f32[(ptr + 32) >> 2];+}++export function writeSpringBone(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: SpringBonePtrData,+): void {+ u8[ptr] = data.enabled ? 1 : 0;+ f32[(ptr + 4) >> 2] = data.stiffness;+ f32[(ptr + 8) >> 2] = data.drag;+ f32[(ptr + 12) >> 2] = data.gravity.x; f32[((ptr + 12) >> 2) + 1] = data.gravity.y; f32[((ptr + 12) >> 2) + 2] = data.gravity.z;+ f32[(ptr + 24) >> 2] = data.endLength;+ f32[(ptr + 28) >> 2] = data.radius;+ f32[(ptr + 32) >> 2] = data.weight;+}++export function createSpringBoneData(): SpringBonePtrData {+ return {+ enabled: false,+ stiffness: 0,+ drag: 0,+ gravity: { x: 0, y: 0, z: 0 },+ endLength: 0,+ radius: 0,+ weight: 0,+ };+}++export interface SpringBoneColliderPtrData {+ shape: number;+ radius: number;+ height: number;+ offset: Vec3;+}++export function fillSpringBoneCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: SpringBoneColliderPtrData,+): void {+ out.shape = u8[ptr];+ out.radius = f32[(ptr + 4) >> 2];+ out.height = f32[(ptr + 8) >> 2];+ const offset_ = out.offset; offset_.x = f32[(ptr + 12) >> 2]; offset_.y = f32[((ptr + 12) >> 2) + 1]; offset_.z = f32[((ptr + 12) >> 2) + 2];+}++export function writeSpringBoneCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: SpringBoneColliderPtrData,+): void {+ u8[ptr] = data.shape;+ f32[(ptr + 4) >> 2] = data.radius;+ f32[(ptr + 8) >> 2] = data.height;+ f32[(ptr + 12) >> 2] = data.offset.x; f32[((ptr + 12) >> 2) + 1] = data.offset.y; f32[((ptr + 12) >> 2) + 2] = data.offset.z;+}++export function createSpringBoneColliderData(): SpringBoneColliderPtrData {+ return {+ shape: 0,+ radius: 0,+ height: 0,+ offset: { x: 0, y: 0, z: 0 },+ };+}+export interface SpritePtrData {texture: number;color: Color;@@ -2585,6 +2669,8 @@ export const PTR_ACCESSORS: Record<string, PtrAccessor<any>> = {SortingGroup: { fill: fillSortingGroup, write: writeSortingGroup, create: createSortingGroupData },SphereCollider3D: { fill: fillSphereCollider3D, write: writeSphereCollider3D, create: createSphereCollider3DData },SpineAnimation: { fill: fillSpineAnimation, write: writeSpineAnimation, create: createSpineAnimationData },+ SpringBone: { fill: fillSpringBone, write: writeSpringBone, create: createSpringBoneData },+ SpringBoneCollider: { fill: fillSpringBoneCollider, write: writeSpringBoneCollider, create: createSpringBoneColliderData },Sprite: { fill: fillSprite, write: writeSprite, create: createSpriteData },SpriteMask: { fill: fillSpriteMask, write: writeSpriteMask, create: createSpriteMaskData },TilemapLayer: { fill: fillTilemapLayer, write: writeTilemapLayer, create: createTilemapLayerData },diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.tsindex 7584a7d07..b956f105c 100644--- a/sdk/src/ecs/component.generated.ts+++ b/sdk/src/ecs/component.generated.ts@@ -7,7 +7,7 @@import type { AssetFieldType } from '../scene/scene';import type { FieldMeta } from './component';import type { Color, Entity, Quat, Vec2, Vec3, Vec4 } from '../types';-import type { AlignContent, AlignItems, AlignSelf, BodyType, CanvasScaleMode, ClearFlags, Dimension, EmitterShape, FlexDirection, FlexWrap, ForceFieldType, JustifyContent, LightType, MaskMode, Padding, ParticleCollisionFallback, ParticleCollisionMode, ParticleEasing, ProjectionType, ReflectionAxis, ReflectionQuality, ReflectionUpdate, ScrollMovement, ShapeType, SimulationSpace, SpriteDrawMode, SpriteMaskInteraction, SubEmitterTrigger, TextAlign, TilemapOrientation, TilemapStaggerAxis, TilemapStaggerIndex, UIDisplay, UIFillMethod, UIFillOrigin, UIPointerEvents, UIPositionType, UIVisualFit, UIVisualType } from '../wasm/wasm.generated';+import type { AlignContent, AlignItems, AlignSelf, BodyType, CanvasScaleMode, ClearFlags, Dimension, EmitterShape, FlexDirection, FlexWrap, ForceFieldType, JustifyContent, LightType, MaskMode, Padding, ParticleCollisionFallback, ParticleCollisionMode, ParticleEasing, ProjectionType, ReflectionAxis, ReflectionQuality, ReflectionUpdate, ScrollMovement, ShapeType, SimulationSpace, SpringBoneShape, SpriteDrawMode, SpriteMaskInteraction, SubEmitterTrigger, TextAlign, TilemapOrientation, TilemapStaggerAxis, TilemapStaggerIndex, UIDisplay, UIFillMethod, UIFillOrigin, UIPointerEvents, UIPositionType, UIVisualFit, UIVisualType } from '../wasm/wasm.generated';/*** Single-source-of-truth hash of the C++/TS boundary ABI (component@@ -15,7 +15,7 @@ import type { AlignContent, AlignItems, AlignSelf, BodyType, CanvasScaleMode, Cl* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to* run on mismatch, because mismatched offsets read the wrong heap bytes.*/-export const ABI_LAYOUT_HASH = '0161363c22733817';+export const ABI_LAYOUT_HASH = '0683d80a6ccb5275';/*** One asset-valued field of a component: which field, and what kind of@@ -1016,6 +1016,50 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {skeletonScale: { min: 0 },},},+ SpringBone: {+ defaults: {+ enabled: true,+ stiffness: 0.1,+ drag: 0.5,+ gravity: { x: 0, y: -980, z: 0 },+ endLength: 0,+ radius: 0,+ weight: 1,+ colliders: [],+ },+ assetFields: [],+ entityFields: ['colliders'],+ colorFields: [],+ animatableFields: [],+ fields: {+ enabled: { tooltip: "Off leaves the chain exactly as the animation poses it." },+ stiffness: { min: 0, max: 1, step: 0.01, slider: true, tooltip: "How hard each bone is pulled back toward its animated pose. 0 hangs free, 1 follows the animation exactly." },+ drag: { min: 0, max: 1, step: 0.01, slider: true, tooltip: "How much of its speed a bone loses each frame. Higher settles sooner." },+ gravity: { tooltip: "Gravity on the chain, in world units a second squared (world y is up)." },+ endLength: { min: 0, step: 0.1, tooltip: "Length of the tip past each end bone, in world units. 0 leaves the end bones unsimulated." },+ radius: { min: 0, step: 0.1, tooltip: "Thickness of the strand, in world units, kept clear of the colliders." },+ weight: { min: 0, max: 1, step: 0.01, slider: true, tooltip: "How much of the simulation is used. 0 is the animation alone." },+ colliders: { tooltip: "Entities with a SpringBoneCollider that this chain is kept out of (the head, the shoulders)." },+ },+ },+ SpringBoneCollider: {+ defaults: {+ shape: 0,+ radius: 10,+ height: 20,+ offset: { x: 0, y: 0, z: 0 },+ },+ assetFields: [],+ entityFields: [],+ colorFields: [],+ animatableFields: [],+ fields: {+ shape: { enum: [{ label: 'Sphere', value: 0 }, { label: 'Capsule', value: 1 }], tooltip: "Sphere, or a capsule along the entity's own Y axis." },+ radius: { min: 0, step: 0.1, tooltip: "Radius in world units, before the entity's scale." },+ height: { min: 0, step: 0.1, tooltip: "A capsule's length between the centres of its end spheres, in world units before scale.", shownWhen: { field: "shape", values: [1] } },+ offset: { tooltip: "Where the centre of the shape is, in the entity's own space." },+ },+ },Sprite: {defaults: {texture: 0,@@ -1786,6 +1830,24 @@ export interface SpineAnimationData {enabled: boolean;}+export interface SpringBoneData {+ enabled: boolean;+ stiffness: number;+ drag: number;+ gravity: Vec3;+ endLength: number;+ radius: number;+ weight: number;+ colliders: Entity[];+}++export interface SpringBoneColliderData {+ shape: SpringBoneShape;+ radius: number;+ height: number;+ offset: Vec3;+}+/*** The fields of the engine's `Sprite` component, generated from* the C++ struct so the two shapes cannot drift.diff --git a/sdk/src/ecs/component.ts b/sdk/src/ecs/component.tsindex 57cc6e4b0..f667d106d 100644--- a/sdk/src/ecs/component.ts+++ b/sdk/src/ecs/component.ts@@ -19,7 +19,7 @@ import type {SortingGroupData, SpriteMaskData, LightProbeVolumeData, OccluderData,ReflectionProbeData, PlanarReflectionData,CanvasData, VelocityData, ParentData, ChildrenData, SpineAnimationData, DragonBonesAnimationData,- TilemapLayerData, BitmapTextData, TrailRendererData, ParticleForceFieldData,+ TilemapLayerData, BitmapTextData, TrailRendererData, ParticleForceFieldData, SpringBoneData, SpringBoneColliderData,CameraData as CameraDataCpp, ParticleEmitterData as ParticleEmitterDataCpp,MeshRendererData as MeshRendererDataCpp,} from './component.generated';@@ -833,7 +833,7 @@ export type {SortingGroupData, SpriteMaskData, LightProbeVolumeData, OccluderData,ReflectionProbeData, PlanarReflectionData,CanvasData, VelocityData, ParentData, ChildrenData, SpineAnimationData, DragonBonesAnimationData,- TilemapLayerData, BitmapTextData, TrailRendererData, ParticleForceFieldData,+ TilemapLayerData, BitmapTextData, TrailRendererData, ParticleForceFieldData, SpringBoneData, SpringBoneColliderData,};export type LocalTransformData = TransformData;@@ -1120,6 +1120,15 @@ export const TrailRenderer = defineBuiltin<TrailRendererData>('TrailRenderer',metaDefaults<TrailRendererData>('TrailRenderer'));+// Spring bones. Pure config: a chain's simulated state is owned by the C++ SpringBoneSystem, keyed by its root entity, and what it+// writes back is the local rotation of the bones under the root.+export const SpringBone = defineBuiltin<SpringBoneData>('SpringBone',+ metaDefaults<SpringBoneData>('SpringBone')+);+export const SpringBoneCollider = defineBuiltin<SpringBoneColliderData>('SpringBoneCollider',+ metaDefaults<SpringBoneColliderData>('SpringBoneCollider')+);+// Particle force field. A scene-placed zone (wind, attractor, vortex, drag) that the// C++ ParticleSystem folds into every nearby world-space particle's integration.export const ParticleForceField = defineBuiltin<ParticleForceFieldData>('ParticleForceField',diff --git a/sdk/src/springbone/SpringBoneAPI.ts b/sdk/src/springbone/SpringBoneAPI.tsnew file mode 100644index 000000000..a9858576c--- /dev/null+++ b/sdk/src/springbone/SpringBoneAPI.ts@@ -0,0 +1,36 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+import type { CppRegistry } from '../wasm';+import type { EngineApi } from '../ecs/bridge/engineApi';+import type { Entity } from '../types';+import { defineResource } from '../ecs/resource';++/**+ * Per-app secondary-motion API. Wraps the C++ registry-scoped spring-bone system, so two App instances (editor tabs) simulate+ * independent chains.+ *+ * Consumed as a resource: declare `Res(SpringBone)` as a system param, or grab it with `app.getResource(SpringBone)`.+ */+export class SpringBoneAPI {+ private readonly module_: NonNullable<EngineApi>;+ private readonly registry_: CppRegistry;++ /** @param module whichever engine core is present (see ecs/engineApi.ts). */+ constructor(module: NonNullable<EngineApi>, registry: CppRegistry) {+ this.module_ = module;+ this.registry_ = registry;+ }++ /** Advance every chain: step the springs toward the pose the animation gave, then turn the bones to match. */+ update(dt: number): void {+ this.module_.springbone_update?.(this.registry_, dt);+ }++ /** Put a chain back at its animated pose on its next frame: a teleport, a respawn, a pose set by hand. */+ reset(root: Entity): void {+ this.module_.springbone_reset?.(this.registry_, root as number);+ }+}++/** Resource handle for the per-app spring-bone API. */+export const SpringBoneRes = defineResource<SpringBoneAPI>(null!, 'SpringBone');diff --git a/sdk/src/springbone/SpringBonePlugin.ts b/sdk/src/springbone/SpringBonePlugin.tsnew file mode 100644index 000000000..e3c946e3a--- /dev/null+++ b/sdk/src/springbone/SpringBonePlugin.ts@@ -0,0 +1,32 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+import type { App, Plugin } from '../app/app';+import { defineSystem, Schedule } from '../ecs/system';+import { Res, Time, type TimeData } from '../ecs/resource';+import { fxPreviewOrPlayMode } from '../ecs/env';+import type { CppRegistry } from '../wasm';+import { engineApi } from '../ecs/bridge/engineApi';+import { SpringBoneRes, SpringBoneAPI } from './SpringBoneAPI';++/**+ * Runs the spring-bone chains after the frame's animation has posed the skeleton (animators write in Update; this is PostUpdate)+ * and before it is drawn. Frozen in editor edit mode like the rest of gameplay, so a chain never swings while it is being authored;+ * the FX preview flag is the one exception (env.ts).+ */+export class SpringBonePlugin implements Plugin {+ name = 'springBone';++ build(app: App): void {+ // `?? {}`: an app with no engine core (a test, a pure-logic host) still gets the resource, and every call through it no-ops.+ const engine = engineApi(app) ?? {};+ const registry = app.world.getCppRegistry() as CppRegistry;+ app.insertResource(SpringBoneRes, new SpringBoneAPI(engine, registry));+ app.addSystemToSchedule(Schedule.PostUpdate, defineSystem(+ [Res(Time), Res(SpringBoneRes)],+ (time: TimeData, springBone: SpringBoneAPI) => { springBone.update(time.delta); },+ { name: 'SpringBoneSystem' },+ ), { runIf: fxPreviewOrPlayMode });+ }+}++export const springBonePlugin = new SpringBonePlugin();diff --git a/sdk/src/springbone/index.ts b/sdk/src/springbone/index.tsnew file mode 100644index 000000000..485461312--- /dev/null+++ b/sdk/src/springbone/index.ts@@ -0,0 +1,4 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+export { SpringBoneAPI, SpringBoneRes } from './SpringBoneAPI';+export { SpringBonePlugin, springBonePlugin } from './SpringBonePlugin';diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.tsindex ff739d241..84a1b9681 100644--- a/sdk/src/wasm.ts+++ b/sdk/src/wasm.ts@@ -614,6 +614,8 @@ export interface ESEngineModule {particle_set_speed_lut?(entity: number, ptr: number, count: number): void;trail_update?(registry: CppRegistry, dt: number): void;trail_clear?(registry: CppRegistry, entity: number): void;+ springbone_update?(registry: CppRegistry, dt: number): void;+ springbone_reset?(registry: CppRegistry, entity: number): void;// Tilemap APItilemap_initLayer?(entity: number, width: number, height: number,diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.tsindex 29bba6842..6884eac6b 100644--- a/sdk/src/wasm/ptrLayouts.generated.ts+++ b/sdk/src/wasm/ptrLayouts.generated.ts@@ -500,6 +500,27 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {{ name: 'enabled', type: 'bool', offset: 84 },],},+ SpringBone: {+ ptrFn: 'getSpringBonePtr',+ fields: [+ { name: 'enabled', type: 'bool', offset: 0 },+ { name: 'stiffness', type: 'f32', offset: 4 },+ { name: 'drag', type: 'f32', offset: 8 },+ { name: 'gravity', type: 'vec3', offset: 12 },+ { name: 'endLength', type: 'f32', offset: 24 },+ { name: 'radius', type: 'f32', offset: 28 },+ { name: 'weight', type: 'f32', offset: 32 },+ ],+ },+ SpringBoneCollider: {+ ptrFn: 'getSpringBoneColliderPtr',+ fields: [+ { name: 'shape', type: 'u8', offset: 0 },+ { name: 'radius', type: 'f32', offset: 4 },+ { name: 'height', type: 'f32', offset: 8 },+ { name: 'offset', type: 'vec3', offset: 12 },+ ],+ },Sprite: {ptrFn: 'getSpritePtr',fields: [diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.tsindex c4e6e9f5a..667850704 100644--- a/sdk/src/wasm/wasm.generated.ts+++ b/sdk/src/wasm/wasm.generated.ts@@ -251,6 +251,11 @@ export enum SimulationSpace {Local = 1,}+export enum SpringBoneShape {+ Sphere = 0,+ Capsule = 1,+}+/*** The engine's `SpriteDrawMode`, generated from the C++ enum.*@@ -856,6 +861,24 @@ export interface SpineAnimation {enabled: boolean;}+export interface SpringBone {+ enabled: boolean;+ stiffness: number;+ drag: number;+ gravity: Vec3;+ endLength: number;+ radius: number;+ weight: number;+ colliders: VectorEntity;+}++export interface SpringBoneCollider {+ shape: number;+ radius: number;+ height: number;+ offset: Vec3;+}+export interface Sprite {texture: number;color: Vec4;@@ -1154,6 +1177,14 @@ export interface Registry {getSpineAnimation(entity: Entity): SpineAnimation;addSpineAnimation(entity: Entity, component: SpineAnimation): void;removeSpineAnimation(entity: Entity): void;+ hasSpringBone(entity: Entity): boolean;+ getSpringBone(entity: Entity): SpringBone;+ addSpringBone(entity: Entity, component: SpringBone): void;+ removeSpringBone(entity: Entity): void;+ hasSpringBoneCollider(entity: Entity): boolean;+ getSpringBoneCollider(entity: Entity): SpringBoneCollider;+ addSpringBoneCollider(entity: Entity, component: SpringBoneCollider): void;+ removeSpringBoneCollider(entity: Entity): void;hasSprite(entity: Entity): boolean;getSprite(entity: Entity): Sprite;addSprite(entity: Entity, component: Sprite): void;@@ -1254,6 +1285,8 @@ export interface ESEngineModule {SortingGroup: new () => SortingGroup;SphereCollider3D: new () => SphereCollider3D;SpineAnimation: new () => SpineAnimation;+ SpringBone: new () => SpringBone;+ SpringBoneCollider: new () => SpringBoneCollider;Sprite: new () => Sprite;SpriteMask: new () => SpriteMask;TilemapLayer: new () => TilemapLayer;diff --git a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snapindex 68f998deb..43d8eb841 100644--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap@@ -1299,6 +1299,82 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho"min": 0,},},+ "SpringBone": {+ "colliders": {+ "tooltip": "Entities with a SpringBoneCollider that this chain is kept out of (the head, the shoulders).",+ },+ "drag": {+ "max": 1,+ "min": 0,+ "slider": true,+ "step": 0.01,+ "tooltip": "How much of its speed a bone loses each frame. Higher settles sooner.",+ },+ "enabled": {+ "tooltip": "Off leaves the chain exactly as the animation poses it.",+ },+ "endLength": {+ "min": 0,+ "step": 0.1,+ "tooltip": "Length of the tip past each end bone, in world units. 0 leaves the end bones unsimulated.",+ },+ "gravity": {+ "tooltip": "Gravity on the chain, in world units a second squared (world y is up).",+ },+ "radius": {+ "min": 0,+ "step": 0.1,+ "tooltip": "Thickness of the strand, in world units, kept clear of the colliders.",+ },+ "stiffness": {+ "max": 1,+ "min": 0,+ "slider": true,+ "step": 0.01,+ "tooltip": "How hard each bone is pulled back toward its animated pose. 0 hangs free, 1 follows the animation exactly.",+ },+ "weight": {+ "max": 1,+ "min": 0,+ "slider": true,+ "step": 0.01,+ "tooltip": "How much of the simulation is used. 0 is the animation alone.",+ },+ },+ "SpringBoneCollider": {+ "height": {+ "min": 0,+ "shownWhen": {+ "field": "shape",+ "values": [+ 1,+ ],+ },+ "step": 0.1,+ "tooltip": "A capsule's length between the centres of its end spheres, in world units before scale.",+ },+ "offset": {+ "tooltip": "Where the centre of the shape is, in the entity's own space.",+ },+ "radius": {+ "min": 0,+ "step": 0.1,+ "tooltip": "Radius in world units, before the entity's scale.",+ },+ "shape": {+ "enum": [+ {+ "label": "Sphere",+ "value": 0,+ },+ {+ "label": "Capsule",+ "value": 1,+ },+ ],+ "tooltip": "Sphere, or a capsule along the entity's own Y axis.",+ },+ },"Sprite": {"color": {"tooltip": "Tint multiplied into the texture (white = unchanged).",diff --git a/src/esengine/aot/AotComponents.generated.cpp b/src/esengine/aot/AotComponents.generated.cppindex bb7c459ca..753f93602 100644--- a/src/esengine/aot/AotComponents.generated.cpp+++ b/src/esengine/aot/AotComponents.generated.cpp@@ -32,6 +32,7 @@#include "esengine/ecs/components/ShapeRenderer.hpp"#include "esengine/ecs/components/SortingGroup.hpp"#include "esengine/ecs/components/SpineAnimation.hpp"+#include "esengine/ecs/components/SpringBone.hpp"#include "esengine/ecs/components/Sprite.hpp"#include "esengine/ecs/components/SpriteMask.hpp"#include "esengine/ecs/components/TilemapLayer.hpp"@@ -250,6 +251,16 @@ ComponentAt engineComponentAt(ecs::Registry& registry, const char* name) {return registry.tryGet<esengine::ecs::SpineAnimation>(Entity::fromRaw(raw));};}+ if (std::strcmp(name, "SpringBone") == 0) {+ return [®istry](std::uint32_t raw) -> void* {+ return registry.tryGet<esengine::ecs::SpringBone>(Entity::fromRaw(raw));+ };+ }+ if (std::strcmp(name, "SpringBoneCollider") == 0) {+ return [®istry](std::uint32_t raw) -> void* {+ return registry.tryGet<esengine::ecs::SpringBoneCollider>(Entity::fromRaw(raw));+ };+ }if (std::strcmp(name, "Sprite") == 0) {return [®istry](std::uint32_t raw) -> void* {return registry.tryGet<esengine::ecs::Sprite>(Entity::fromRaw(raw));@@ -494,6 +505,16 @@ CandidatesOf engineComponentCandidates(ecs::Registry& registry, const char* namereturn denseAsIds(registry.entitiesWith<esengine::ecs::SpineAnimation>());};}+ if (std::strcmp(name, "SpringBone") == 0) {+ return [®istry]() -> Candidates {+ return denseAsIds(registry.entitiesWith<esengine::ecs::SpringBone>());+ };+ }+ if (std::strcmp(name, "SpringBoneCollider") == 0) {+ return [®istry]() -> Candidates {+ return denseAsIds(registry.entitiesWith<esengine::ecs::SpringBoneCollider>());+ };+ }if (std::strcmp(name, "Sprite") == 0) {return [®istry]() -> Candidates {return denseAsIds(registry.entitiesWith<esengine::ecs::Sprite>());@@ -590,6 +611,8 @@ bool isEngineComponent(const char* name) {if (std::strcmp(name, "SortingGroup") == 0) return true;if (std::strcmp(name, "SphereCollider3D") == 0) return true;if (std::strcmp(name, "SpineAnimation") == 0) return true;+ if (std::strcmp(name, "SpringBone") == 0) return true;+ if (std::strcmp(name, "SpringBoneCollider") == 0) return true;if (std::strcmp(name, "Sprite") == 0) return true;if (std::strcmp(name, "SpriteMask") == 0) return true;if (std::strcmp(name, "TilemapLayer") == 0) return true;diff --git a/src/esengine/aot/EngineDigest.generated.h b/src/esengine/aot/EngineDigest.generated.hindex e7221071f..1ecc6b39d 100644--- a/src/esengine/aot/EngineDigest.generated.h+++ b/src/esengine/aot/EngineDigest.generated.h@@ -6,7 +6,7 @@/* One per address width, because the width is IN the digest: a host thattook the other one would refuse every module built for it. */-#define ES_ENGINE_ABI_DIGEST_32 0x05bd8752447266c5ULL-#define ES_ENGINE_ABI_DIGEST_64 0x8ecf13a182e11801ULL+#define ES_ENGINE_ABI_DIGEST_32 0x3e28c8d2ebc2c1c4ULL+#define ES_ENGINE_ABI_DIGEST_64 0x5f1e2389e92b4ae8ULL#define ES_ENGINE_ABI_DIGEST \(sizeof(es_addr_t) == 8 ? ES_ENGINE_ABI_DIGEST_64 : ES_ENGINE_ABI_DIGEST_32)diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cppindex 0e8e29edd..a0e74bd85 100644--- a/src/esengine/bindings/EditorAPI.generated.cpp+++ b/src/esengine/bindings/EditorAPI.generated.cpp@@ -2,10 +2,10 @@* @file EditorAPI.generated.cpp* @brief Auto-generated editor API with string-dispatched component access* @details Generated by EHT - DO NOT EDIT- * @schema_hash 4f90a13f387495ca+ * @schema_hash 29368da0ccf13fa8*/-#define ES_EDITOR_API_SCHEMA_HASH "4f90a13f387495ca"+#define ES_EDITOR_API_SCHEMA_HASH "29368da0ccf13fa8"#include <emscripten/bind.h>#include <string>@@ -36,6 +36,7 @@#include "../ecs/components/ShapeRenderer.hpp"#include "../ecs/components/SortingGroup.hpp"#include "../ecs/components/SpineAnimation.hpp"+#include "../ecs/components/SpringBone.hpp"#include "../ecs/components/Sprite.hpp"#include "../ecs/components/SpriteMask.hpp"#include "../ecs/components/TilemapLayer.hpp"@@ -104,6 +105,8 @@ std::vector<std::string> editor_getComponentNames() {"SortingGroup","SphereCollider3D","SpineAnimation",+ "SpringBone",+ "SpringBoneCollider","Sprite","SpriteMask","TilemapLayer",@@ -627,6 +630,28 @@ std::string editor_getComponentSchema(const std::string& name) {{"key":"material","type":"asset","group":"SpineAnimation"},{"key":"enabled","type":"bool","group":"SpineAnimation"}])JSON";+ } else if (name == "SpringBone") {+ return R"JSON([+ {"key":"enabled","type":"bool","group":"SpringBone"},+ {"key":"stiffness","type":"float","group":"SpringBone"},+ {"key":"drag","type":"float","group":"SpringBone"},+ {"key":"gravity.x","type":"float","group":"SpringBone"},+ {"key":"gravity.y","type":"float","group":"SpringBone"},+ {"key":"gravity.z","type":"float","group":"SpringBone"},+ {"key":"endLength","type":"float","group":"SpringBone"},+ {"key":"radius","type":"float","group":"SpringBone"},+ {"key":"weight","type":"float","group":"SpringBone"},+ {"key":"colliders","type":"entity","group":"SpringBone"}+ ])JSON";+ } else if (name == "SpringBoneCollider") {+ return R"JSON([+ {"key":"shape","type":"enum","group":"SpringBoneCollider","values":["Sphere","Capsule"]},+ {"key":"radius","type":"float","group":"SpringBoneCollider"},+ {"key":"height","type":"float","group":"SpringBoneCollider"},+ {"key":"offset.x","type":"float","group":"SpringBoneCollider"},+ {"key":"offset.y","type":"float","group":"SpringBoneCollider"},+ {"key":"offset.z","type":"float","group":"SpringBoneCollider"}+ ])JSON";} else if (name == "Sprite") {return R"JSON([{"key":"texture","type":"asset","group":"Sprite"},@@ -937,6 +962,12 @@ bool editor_addComponent(Registry& reg, u32 e, const std::string& name) {} else if (name == "SpineAnimation") {if (!reg.has<esengine::ecs::SpineAnimation>(entity)) reg.emplace<esengine::ecs::SpineAnimation>(entity);return true;+ } else if (name == "SpringBone") {+ if (!reg.has<esengine::ecs::SpringBone>(entity)) reg.emplace<esengine::ecs::SpringBone>(entity);+ return true;+ } else if (name == "SpringBoneCollider") {+ if (!reg.has<esengine::ecs::SpringBoneCollider>(entity)) reg.emplace<esengine::ecs::SpringBoneCollider>(entity);+ return true;} else if (name == "Sprite") {if (!reg.has<esengine::ecs::Sprite>(entity)) reg.emplace<esengine::ecs::Sprite>(entity);return true;@@ -1055,6 +1086,10 @@ bool editor_removeComponent(Registry& reg, u32 e, const std::string& name) {if (reg.has<esengine::ecs::SphereCollider3D>(entity)) { reg.remove<esengine::ecs::SphereCollider3D>(entity); return true; }} else if (name == "SpineAnimation") {if (reg.has<esengine::ecs::SpineAnimation>(entity)) { reg.remove<esengine::ecs::SpineAnimation>(entity); return true; }+ } else if (name == "SpringBone") {+ if (reg.has<esengine::ecs::SpringBone>(entity)) { reg.remove<esengine::ecs::SpringBone>(entity); return true; }+ } else if (name == "SpringBoneCollider") {+ if (reg.has<esengine::ecs::SpringBoneCollider>(entity)) { reg.remove<esengine::ecs::SpringBoneCollider>(entity); return true; }} else if (name == "Sprite") {if (reg.has<esengine::ecs::Sprite>(entity)) { reg.remove<esengine::ecs::Sprite>(entity); return true; }} else if (name == "SpriteMask") {@@ -1121,6 +1156,8 @@ bool editor_hasComponent(Registry& reg, u32 e, const std::string& name) {if (name == "SortingGroup") return reg.has<esengine::ecs::SortingGroup>(entity);if (name == "SphereCollider3D") return reg.has<esengine::ecs::SphereCollider3D>(entity);if (name == "SpineAnimation") return reg.has<esengine::ecs::SpineAnimation>(entity);+ if (name == "SpringBone") return reg.has<esengine::ecs::SpringBone>(entity);+ if (name == "SpringBoneCollider") return reg.has<esengine::ecs::SpringBoneCollider>(entity);if (name == "Sprite") return reg.has<esengine::ecs::Sprite>(entity);if (name == "SpriteMask") return reg.has<esengine::ecs::SpriteMask>(entity);if (name == "TilemapLayer") return reg.has<esengine::ecs::TilemapLayer>(entity);@@ -1178,6 +1215,8 @@ std::vector<std::string> editor_getComponents(Registry& reg, u32 e) {if (reg.has<esengine::ecs::SortingGroup>(entity)) result.push_back("SortingGroup");if (reg.has<esengine::ecs::SphereCollider3D>(entity)) result.push_back("SphereCollider3D");if (reg.has<esengine::ecs::SpineAnimation>(entity)) result.push_back("SpineAnimation");+ if (reg.has<esengine::ecs::SpringBone>(entity)) result.push_back("SpringBone");+ if (reg.has<esengine::ecs::SpringBoneCollider>(entity)) result.push_back("SpringBoneCollider");if (reg.has<esengine::ecs::Sprite>(entity)) result.push_back("Sprite");if (reg.has<esengine::ecs::SpriteMask>(entity)) result.push_back("SpriteMask");if (reg.has<esengine::ecs::TilemapLayer>(entity)) result.push_back("TilemapLayer");@@ -1579,6 +1618,29 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::selse if (field == "skeletonScale") { c.skeletonScale = value; }else { return false; }return true;+ } else if (comp == "SpringBone") {+ if (!reg.has<esengine::ecs::SpringBone>(entity)) return false;+ auto& c = reg.get<esengine::ecs::SpringBone>(entity);+ if (field == "stiffness") { c.stiffness = value; }+ else if (field == "drag") { c.drag = value; }+ else if (field == "gravity.x") { c.gravity.x = value; }+ else if (field == "gravity.y") { c.gravity.y = value; }+ else if (field == "gravity.z") { c.gravity.z = value; }+ else if (field == "endLength") { c.endLength = value; }+ else if (field == "radius") { c.radius = value; }+ else if (field == "weight") { c.weight = value; }+ else { return false; }+ return true;+ } else if (comp == "SpringBoneCollider") {+ if (!reg.has<esengine::ecs::SpringBoneCollider>(entity)) return false;+ auto& c = reg.get<esengine::ecs::SpringBoneCollider>(entity);+ if (field == "radius") { c.radius = value; }+ else if (field == "height") { c.height = value; }+ else if (field == "offset.x") { c.offset.x = value; }+ else if (field == "offset.y") { c.offset.y = value; }+ else if (field == "offset.z") { c.offset.z = value; }+ else { return false; }+ return true;} else if (comp == "Sprite") {if (!reg.has<esengine::ecs::Sprite>(entity)) return false;auto& c = reg.get<esengine::ecs::Sprite>(entity);@@ -2080,6 +2142,25 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::stelse if (field == "color.b") { return c.color.b; }else if (field == "color.a") { return c.color.a; }else if (field == "skeletonScale") { return c.skeletonScale; }+ } else if (comp == "SpringBone") {+ if (!reg.has<esengine::ecs::SpringBone>(entity)) return 0.0f;+ const auto& c = reg.get<esengine::ecs::SpringBone>(entity);+ if (field == "stiffness") { return c.stiffness; }+ else if (field == "drag") { return c.drag; }+ else if (field == "gravity.x") { return c.gravity.x; }+ else if (field == "gravity.y") { return c.gravity.y; }+ else if (field == "gravity.z") { return c.gravity.z; }+ else if (field == "endLength") { return c.endLength; }+ else if (field == "radius") { return c.radius; }+ else if (field == "weight") { return c.weight; }+ } else if (comp == "SpringBoneCollider") {+ if (!reg.has<esengine::ecs::SpringBoneCollider>(entity)) return 0.0f;+ const auto& c = reg.get<esengine::ecs::SpringBoneCollider>(entity);+ if (field == "radius") { return c.radius; }+ else if (field == "height") { return c.height; }+ else if (field == "offset.x") { return c.offset.x; }+ else if (field == "offset.y") { return c.offset.y; }+ else if (field == "offset.z") { return c.offset.z; }} else if (comp == "Sprite") {if (!reg.has<esengine::ecs::Sprite>(entity)) return 0.0f;const auto& c = reg.get<esengine::ecs::Sprite>(entity);@@ -2443,6 +2524,12 @@ bool editor_setInt(Registry& reg, u32 e, const std::string& comp, const std::strelse if (field == "material") { c.material = static_cast<u32>(value); }else { return false; }return true;+ } else if (comp == "SpringBoneCollider") {+ if (!reg.has<esengine::ecs::SpringBoneCollider>(entity)) return false;+ auto& c = reg.get<esengine::ecs::SpringBoneCollider>(entity);+ if (field == "shape") { c.shape = static_cast<SpringBoneShape>(value); }+ else { return false; }+ return true;} else if (comp == "Sprite") {if (!reg.has<esengine::ecs::Sprite>(entity)) return false;auto& c = reg.get<esengine::ecs::Sprite>(entity);@@ -2686,6 +2773,10 @@ i32 editor_getInt(Registry& reg, u32 e, const std::string& comp, const std::striconst auto& c = reg.get<esengine::ecs::SpineAnimation>(entity);if (field == "layer") { return static_cast<i32>(c.layer); }else if (field == "material") { return static_cast<i32>(c.material); }+ } else if (comp == "SpringBoneCollider") {+ if (!reg.has<esengine::ecs::SpringBoneCollider>(entity)) return 0;+ const auto& c = reg.get<esengine::ecs::SpringBoneCollider>(entity);+ if (field == "shape") { return static_cast<i32>(c.shape); }} else if (comp == "Sprite") {if (!reg.has<esengine::ecs::Sprite>(entity)) return 0;const auto& c = reg.get<esengine::ecs::Sprite>(entity);@@ -2973,6 +3064,12 @@ bool editor_setBool(Registry& reg, u32 e, const std::string& comp, const std::stelse if (field == "enabled") { c.enabled = value; }else { return false; }return true;+ } else if (comp == "SpringBone") {+ if (!reg.has<esengine::ecs::SpringBone>(entity)) return false;+ auto& c = reg.get<esengine::ecs::SpringBone>(entity);+ if (field == "enabled") { c.enabled = value; }+ else { return false; }+ return true;} else if (comp == "Sprite") {if (!reg.has<esengine::ecs::Sprite>(entity)) return false;auto& c = reg.get<esengine::ecs::Sprite>(entity);@@ -3204,6 +3301,10 @@ bool editor_getBool(Registry& reg, u32 e, const std::string& comp, const std::stelse if (field == "flipX") { return c.flipX; }else if (field == "flipY") { return c.flipY; }else if (field == "enabled") { return c.enabled; }+ } else if (comp == "SpringBone") {+ if (!reg.has<esengine::ecs::SpringBone>(entity)) return false;+ const auto& c = reg.get<esengine::ecs::SpringBone>(entity);+ if (field == "enabled") { return c.enabled; }} else if (comp == "Sprite") {if (!reg.has<esengine::ecs::Sprite>(entity)) return false;const auto& c = reg.get<esengine::ecs::Sprite>(entity);diff --git a/src/esengine/bindings/RendererBindings.cpp b/src/esengine/bindings/RendererBindings.cppindex faa674a16..cc7a30c41 100644--- a/src/esengine/bindings/RendererBindings.cpp+++ b/src/esengine/bindings/RendererBindings.cpp@@ -39,6 +39,7 @@#include "../particle/ParticleSystem.hpp"#endif#include "../trail/TrailSystem.hpp"+#include "../springbone/SpringBoneSystem.hpp"#include "../ui/UISystem.hpp"#ifdef __EMSCRIPTEN__@@ -65,6 +66,7 @@ static EstellaContext& ctx() { return activeCtx(); }#define g_particleSystem (ctx().tryGet<particle::ParticleSystem>())#endif#define g_trailSystem (ctx().tryGet<trail::TrailSystem>())+#define g_springBoneSystem (ctx().tryGet<springbone::SpringBoneSystem>())namespace {// The channels the engine's own mesh uploads use, named by semantic so a change@@ -779,6 +781,17 @@ void trail_clear(ecs::Registry& registry, u32 entity) {g_trailSystem->clear(Entity::fromRaw(entity));}+void springbone_update(ecs::Registry& registry, f32 dt) {+ if (!g_springBoneSystem) return;+ g_springBoneSystem->update(registry, g_transformSystem, dt);+}++void springbone_reset(ecs::Registry& registry, u32 entity) {+ if (!g_springBoneSystem) return;+ (void)registry;+ g_springBoneSystem->reset(Entity::fromRaw(entity));+}+void renderer_setStage(i32 stage) {if (!g_renderFrame) return;g_renderFrame->setStage(static_cast<RenderStage>(stage));diff --git a/src/esengine/bindings/RendererBindings.hpp b/src/esengine/bindings/RendererBindings.hppindex a99f7ad6c..def45693d 100644--- a/src/esengine/bindings/RendererBindings.hpp+++ b/src/esengine/bindings/RendererBindings.hpp@@ -167,6 +167,10 @@ void particle_set_speed_lut(u32 entity, uintptr_t ptr, i32 count);#endifvoid trail_update(ecs::Registry& registry, f32 dt);void trail_clear(ecs::Registry& registry, u32 entity);+/** Advances every SpringBone chain: call after the animation has posed the skeleton, before the frame is drawn. */+void springbone_update(ecs::Registry& registry, f32 dt);+/** Puts a chain back at its animated pose on its next frame (a teleport, a respawn). */+void springbone_reset(ecs::Registry& registry, u32 entity);void renderer_setStage(i32 stage);u32 renderer_createTarget(u32 width, u32 height, i32 flags);u32 renderer_getTargetDepthTexture(u32 handle);diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex 98d3c9674..7bfcc0d89 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -36,6 +36,7 @@#include "../ecs/components/ShapeRenderer.hpp"#include "../ecs/components/SortingGroup.hpp"#include "../ecs/components/SpineAnimation.hpp"+#include "../ecs/components/SpringBone.hpp"#include "../ecs/components/Sprite.hpp"#include "../ecs/components/SpriteMask.hpp"#include "../ecs/components/TilemapLayer.hpp"@@ -248,6 +249,10 @@ EMSCRIPTEN_BINDINGS(esengine_enums) {.value("World", esengine::ecs::SimulationSpace::World).value("Local", esengine::ecs::SimulationSpace::Local);+ enum_<esengine::ecs::SpringBoneShape>("SpringBoneShape")+ .value("Sphere", esengine::ecs::SpringBoneShape::Sphere)+ .value("Capsule", esengine::ecs::SpringBoneShape::Capsule);+enum_<esengine::ecs::SpriteDrawMode>("SpriteDrawMode").value("Auto", esengine::ecs::SpriteDrawMode::Auto).value("Simple", esengine::ecs::SpriteDrawMode::Simple)@@ -1265,6 +1270,78 @@ ShadowCaster2DJS shadowcaster2dToJS(const esengine::ecs::ShadowCaster2D& c) {return js;}+struct SpringBoneJS {+ bool enabled;+ f32 stiffness;+ f32 drag;+ glm::vec3 gravity;+ f32 endLength;+ f32 radius;+ f32 weight;+ std::vector<u32> colliders;+};++void springboneApplyJS(esengine::ecs::SpringBone& c, const SpringBoneJS& js) {+ c.enabled = js.enabled;+ c.stiffness = js.stiffness;+ c.drag = js.drag;+ c.gravity = js.gravity;+ c.endLength = js.endLength;+ c.radius = js.radius;+ c.weight = js.weight;+ c.colliders.reserve(js.colliders.size());+ for (auto v : js.colliders) c.colliders.push_back(Entity(v));+}++esengine::ecs::SpringBone springboneFromJS(const SpringBoneJS& js) {+ esengine::ecs::SpringBone c;+ springboneApplyJS(c, js);+ return c;+}++SpringBoneJS springboneToJS(const esengine::ecs::SpringBone& c) {+ SpringBoneJS js;+ js.enabled = c.enabled;+ js.stiffness = c.stiffness;+ js.drag = c.drag;+ js.gravity = c.gravity;+ js.endLength = c.endLength;+ js.radius = c.radius;+ js.weight = c.weight;+ js.colliders.reserve(c.colliders.size());+ for (auto e : c.colliders) js.colliders.push_back(static_cast<u32>(e));+ return js;+}++struct SpringBoneColliderJS {+ i32 shape;+ f32 radius;+ f32 height;+ glm::vec3 offset;+};++void springbonecolliderApplyJS(esengine::ecs::SpringBoneCollider& c, const SpringBoneColliderJS& js) {+ c.shape = static_cast<SpringBoneShape>(js.shape);+ c.radius = js.radius;+ c.height = js.height;+ c.offset = js.offset;+}++esengine::ecs::SpringBoneCollider springbonecolliderFromJS(const SpringBoneColliderJS& js) {+ esengine::ecs::SpringBoneCollider c;+ springbonecolliderApplyJS(c, js);+ return c;+}++SpringBoneColliderJS springbonecolliderToJS(const esengine::ecs::SpringBoneCollider& c) {+ SpringBoneColliderJS js;+ js.shape = static_cast<i32>(c.shape);+ js.radius = c.radius;+ js.height = c.height;+ js.offset = c.offset;+ return js;+}+struct SpriteJS {u32 texture;glm::vec4 color;@@ -2052,6 +2129,22 @@ EMSCRIPTEN_BINDINGS(esengine_components) {.field("material", &esengine::ecs::SpineAnimation::material).field("enabled", &esengine::ecs::SpineAnimation::enabled);+ value_object<SpringBoneJS>("SpringBone")+ .field("enabled", &SpringBoneJS::enabled)+ .field("stiffness", &SpringBoneJS::stiffness)+ .field("drag", &SpringBoneJS::drag)+ .field("gravity", &SpringBoneJS::gravity)+ .field("endLength", &SpringBoneJS::endLength)+ .field("radius", &SpringBoneJS::radius)+ .field("weight", &SpringBoneJS::weight)+ .field("colliders", &SpringBoneJS::colliders);++ value_object<SpringBoneColliderJS>("SpringBoneCollider")+ .field("shape", &SpringBoneColliderJS::shape)+ .field("radius", &SpringBoneColliderJS::radius)+ .field("height", &SpringBoneColliderJS::height)+ .field("offset", &SpringBoneColliderJS::offset);+value_object<SpriteJS>("Sprite").field("texture", &SpriteJS::texture).field("color", &SpriteJS::color)@@ -2249,6 +2342,8 @@ EMSCRIPTEN_BINDINGS(esengine_registry) {if (r.has<esengine::ecs::SortingGroup>(entity)) { if (!names.empty()) names += "|"; names += "SortingGroup"; }if (r.has<esengine::ecs::SphereCollider3D>(entity)) { if (!names.empty()) names += "|"; names += "SphereCollider3D"; }if (r.has<esengine::ecs::SpineAnimation>(entity)) { if (!names.empty()) names += "|"; names += "SpineAnimation"; }+ if (r.has<esengine::ecs::SpringBone>(entity)) { if (!names.empty()) names += "|"; names += "SpringBone"; }+ if (r.has<esengine::ecs::SpringBoneCollider>(entity)) { if (!names.empty()) names += "|"; names += "SpringBoneCollider"; }if (r.has<esengine::ecs::Sprite>(entity)) { if (!names.empty()) names += "|"; names += "Sprite"; }if (r.has<esengine::ecs::SpriteMask>(entity)) { if (!names.empty()) names += "|"; names += "SpriteMask"; }if (r.has<esengine::ecs::TilemapLayer>(entity)) { if (!names.empty()) names += "|"; names += "TilemapLayer"; }@@ -2301,6 +2396,8 @@ EMSCRIPTEN_BINDINGS(esengine_registry) {if (name == "SortingGroup") return static_cast<int>(componentTypeId<esengine::ecs::SortingGroup>());if (name == "SphereCollider3D") return static_cast<int>(componentTypeId<esengine::ecs::SphereCollider3D>());if (name == "SpineAnimation") return static_cast<int>(componentTypeId<esengine::ecs::SpineAnimation>());+ if (name == "SpringBone") return static_cast<int>(componentTypeId<esengine::ecs::SpringBone>());+ if (name == "SpringBoneCollider") return static_cast<int>(componentTypeId<esengine::ecs::SpringBoneCollider>());if (name == "Sprite") return static_cast<int>(componentTypeId<esengine::ecs::Sprite>());if (name == "SpriteMask") return static_cast<int>(componentTypeId<esengine::ecs::SpriteMask>());if (name == "TilemapLayer") return static_cast<int>(componentTypeId<esengine::ecs::TilemapLayer>());@@ -3149,6 +3246,54 @@ EMSCRIPTEN_BINDINGS(esengine_registry) {r.remove<esengine::ecs::SpineAnimation>(entity);}))+ // SpringBone+ .function("hasSpringBone", optional_override([](Registry& r, u32 e) {+ return r.has<esengine::ecs::SpringBone>(static_cast<Entity>(e));+ }))+ .function("getSpringBone", optional_override([](Registry& r, u32 e) {+ auto entity = static_cast<Entity>(e);+ if (!r.valid(entity) || !r.has<esengine::ecs::SpringBone>(entity)) return SpringBoneJS{};+ return springboneToJS(r.get<esengine::ecs::SpringBone>(entity));+ }))+ .function("addSpringBone", optional_override([](Registry& r, u32 e, const SpringBoneJS& js) {+ auto entity = static_cast<Entity>(e);+ if (!r.valid(entity)) return;+ if (auto* existing = r.tryGet<esengine::ecs::SpringBone>(entity)) {+ springboneApplyJS(*existing, js);+ return;+ }+ r.emplaceOrReplace<esengine::ecs::SpringBone>(entity, springboneFromJS(js));+ }))+ .function("removeSpringBone", optional_override([](Registry& r, u32 e) {+ auto entity = static_cast<Entity>(e);+ if (!r.valid(entity) || !r.has<esengine::ecs::SpringBone>(entity)) return;+ r.remove<esengine::ecs::SpringBone>(entity);+ }))++ // SpringBoneCollider+ .function("hasSpringBoneCollider", optional_override([](Registry& r, u32 e) {+ return r.has<esengine::ecs::SpringBoneCollider>(static_cast<Entity>(e));+ }))+ .function("getSpringBoneCollider", optional_override([](Registry& r, u32 e) {+ auto entity = static_cast<Entity>(e);+ if (!r.valid(entity) || !r.has<esengine::ecs::SpringBoneCollider>(entity)) return SpringBoneColliderJS{};+ return springbonecolliderToJS(r.get<esengine::ecs::SpringBoneCollider>(entity));+ }))+ .function("addSpringBoneCollider", optional_override([](Registry& r, u32 e, const SpringBoneColliderJS& js) {+ auto entity = static_cast<Entity>(e);+ if (!r.valid(entity)) return;+ if (auto* existing = r.tryGet<esengine::ecs::SpringBoneCollider>(entity)) {+ springbonecolliderApplyJS(*existing, js);+ return;+ }+ r.emplaceOrReplace<esengine::ecs::SpringBoneCollider>(entity, springbonecolliderFromJS(js));+ }))+ .function("removeSpringBoneCollider", optional_override([](Registry& r, u32 e) {+ auto entity = static_cast<Entity>(e);+ if (!r.valid(entity) || !r.has<esengine::ecs::SpringBoneCollider>(entity)) return;+ r.remove<esengine::ecs::SpringBoneCollider>(entity);+ }))+// Sprite.function("hasSprite", optional_override([](Registry& r, u32 e) {return r.has<esengine::ecs::Sprite>(static_cast<Entity>(e));@@ -3461,6 +3606,8 @@ emscripten::val esengineGetBuiltinComponentNames() {arr.set(i++, val(std::string("SortingGroup")));arr.set(i++, val(std::string("SphereCollider3D")));arr.set(i++, val(std::string("SpineAnimation")));+ arr.set(i++, val(std::string("SpringBone")));+ arr.set(i++, val(std::string("SpringBoneCollider")));arr.set(i++, val(std::string("Sprite")));arr.set(i++, val(std::string("SpriteMask")));arr.set(i++, val(std::string("TilemapLayer")));@@ -3794,6 +3941,17 @@ static_assert(offsetof(esengine::ecs::SpineAnimation, layer) == 72, "ABI offsetstatic_assert(offsetof(esengine::ecs::SpineAnimation, skeletonScale) == 76, "ABI offset drift: esengine::ecs::SpineAnimation.skeletonScale (EHT expected 76)");static_assert(offsetof(esengine::ecs::SpineAnimation, material) == 80, "ABI offset drift: esengine::ecs::SpineAnimation.material (EHT expected 80)");static_assert(offsetof(esengine::ecs::SpineAnimation, enabled) == 84, "ABI offset drift: esengine::ecs::SpineAnimation.enabled (EHT expected 84)");+static_assert(offsetof(esengine::ecs::SpringBone, enabled) == 0, "ABI offset drift: esengine::ecs::SpringBone.enabled (EHT expected 0)");+static_assert(offsetof(esengine::ecs::SpringBone, stiffness) == 4, "ABI offset drift: esengine::ecs::SpringBone.stiffness (EHT expected 4)");+static_assert(offsetof(esengine::ecs::SpringBone, drag) == 8, "ABI offset drift: esengine::ecs::SpringBone.drag (EHT expected 8)");+static_assert(offsetof(esengine::ecs::SpringBone, gravity) == 12, "ABI offset drift: esengine::ecs::SpringBone.gravity (EHT expected 12)");+static_assert(offsetof(esengine::ecs::SpringBone, endLength) == 24, "ABI offset drift: esengine::ecs::SpringBone.endLength (EHT expected 24)");+static_assert(offsetof(esengine::ecs::SpringBone, radius) == 28, "ABI offset drift: esengine::ecs::SpringBone.radius (EHT expected 28)");+static_assert(offsetof(esengine::ecs::SpringBone, weight) == 32, "ABI offset drift: esengine::ecs::SpringBone.weight (EHT expected 32)");+static_assert(offsetof(esengine::ecs::SpringBoneCollider, shape) == 0, "ABI offset drift: esengine::ecs::SpringBoneCollider.shape (EHT expected 0)");+static_assert(offsetof(esengine::ecs::SpringBoneCollider, radius) == 4, "ABI offset drift: esengine::ecs::SpringBoneCollider.radius (EHT expected 4)");+static_assert(offsetof(esengine::ecs::SpringBoneCollider, height) == 8, "ABI offset drift: esengine::ecs::SpringBoneCollider.height (EHT expected 8)");+static_assert(offsetof(esengine::ecs::SpringBoneCollider, offset) == 12, "ABI offset drift: esengine::ecs::SpringBoneCollider.offset (EHT expected 12)");static_assert(offsetof(esengine::ecs::Sprite, texture) == 0, "ABI offset drift: esengine::ecs::Sprite.texture (EHT expected 0)");static_assert(offsetof(esengine::ecs::Sprite, color) == 4, "ABI offset drift: esengine::ecs::Sprite.color (EHT expected 4)");static_assert(offsetof(esengine::ecs::Sprite, size) == 20, "ABI offset drift: esengine::ecs::Sprite.size (EHT expected 20)");@@ -3906,7 +4064,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "0161363c22733817";+static const char* kEsAbiLayoutHash = "0683d80a6ccb5275";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cppindex 55b0a696a..adae181e3 100644--- a/src/esengine/bindings/WebSDKEntry.cpp+++ b/src/esengine/bindings/WebSDKEntry.cpp@@ -745,6 +745,8 @@ EMSCRIPTEN_BINDINGS(esengine_renderer) {#endifemscripten::function("trail_update", &esengine::trail_update);emscripten::function("trail_clear", &esengine::trail_clear);+ emscripten::function("springbone_update", &esengine::springbone_update);+ emscripten::function("springbone_reset", &esengine::springbone_reset);emscripten::function("renderer_setStage", &esengine::renderer_setStage);emscripten::function("renderer_createTarget", &esengine::renderer_createTarget);emscripten::function("renderer_releaseTarget", &esengine::renderer_releaseTarget);diff --git a/src/esengine/core/EstellaContext.cpp b/src/esengine/core/EstellaContext.cppindex 47a26f95e..cde3c7836 100644--- a/src/esengine/core/EstellaContext.cpp+++ b/src/esengine/core/EstellaContext.cpp@@ -35,6 +35,7 @@#endif#include "../renderer/plugins/TrailPlugin.hpp"#include "../trail/TrailSystem.hpp"+#include "../springbone/SpringBoneSystem.hpp"#ifdef ES_ENABLE_TILEMAP#include "../renderer/plugins/TilemapRenderPlugin.hpp"#include "../tilemap/TilemapSystem.hpp"@@ -75,6 +76,7 @@ void EstellaContext::registerLogicSystems() {services_.getService<particle::ParticleSystem>()->reseedFrom(*services_.getService<RandomSource>());#endifservices_.registerOwned<trail::TrailSystem>(makeUnique<trail::TrailSystem>());+ services_.registerOwned<springbone::SpringBoneSystem>(makeUnique<springbone::SpringBoneSystem>());services_.registerOwned<ecs::TransformSystem>(makeUnique<ecs::TransformSystem>());diff --git a/src/esengine/ecs/components/SpringBone.hpp b/src/esengine/ecs/components/SpringBone.hppnew file mode 100644index 000000000..d2e72ff9b--- /dev/null+++ b/src/esengine/ecs/components/SpringBone.hpp@@ -0,0 +1,96 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file SpringBone.hpp+ * @brief Secondary motion for a chain of bones: hair, tails, cords, cloth edges.+ * @details A SpringBone on the ROOT of a chain makes every entity below it a spring: the+ * animation still says where each bone would be, and the chain lags behind that pose+ * by inertia, falls with gravity, and is pulled back toward it. The root itself is+ * not simulated (it is what the animation or the body drives). The simulation lives+ * in SpringBoneSystem, keyed by the root entity, so this component stays pure+ * configuration and scene serialization never sees the transient state.+ *+ * @author ESEngine Team+ * @date 2026+ *+ * @copyright Copyright (c) 2026 ESEngine Team+ * Licensed under the Apache License, Version 2.0.+ */+#pragma once++#include "../../core/Types.hpp"+#include "../../core/Reflection.hpp"+#include "../../math/Math.hpp"++#include <vector>++namespace esengine::ecs {++/** @brief What a @ref SpringBoneCollider is shaped like. */+ES_ENUM()+enum class SpringBoneShape : i32 {+ Sphere = 0,+ Capsule = 1,+};++ES_COMPONENT()+struct SpringBone {+ /** @brief Simulated this frame. Off leaves the chain exactly as the animation poses it. */+ ES_PROPERTY(tooltip="Off leaves the chain exactly as the animation poses it.")+ bool enabled{true};++ /** @brief How hard each bone is pulled back toward the pose the animation gives it, 0 to 1. */+ ES_PROPERTY(min=0, max=1, step=0.01, slider, tooltip="How hard each bone is pulled back toward its animated pose. 0 hangs free, 1 follows the animation exactly.")+ f32 stiffness{0.1f};++ /** @brief How much of its velocity a bone loses each frame, 0 to 1. */+ ES_PROPERTY(min=0, max=1, step=0.01, slider, tooltip="How much of its speed a bone loses each frame. Higher settles sooner.")+ f32 drag{0.5f};++ /** @brief Gravity on the chain, in world units a second squared. */+ ES_PROPERTY(tooltip="Gravity on the chain, in world units a second squared (world y is up).")+ glm::vec3 gravity{0.0f, -980.0f, 0.0f};++ /** @brief How far the last bones of a chain reach past themselves, in world units: a leaf has no child to aim at, so this gives it a tip. 0 leaves leaves unsimulated. */+ ES_PROPERTY(min=0, step=0.1, tooltip="Length of the tip past each end bone, in world units. 0 leaves the end bones unsimulated.")+ f32 endLength{0.0f};++ /** @brief The thickness of the strand, in world units, kept clear of every collider. */+ ES_PROPERTY(min=0, step=0.1, tooltip="Thickness of the strand, in world units, kept clear of the colliders.")+ f32 radius{0.0f};++ /** @brief How much of the simulated pose is used, 0 to 1: 0 is the animation alone. */+ ES_PROPERTY(min=0, max=1, step=0.01, slider, tooltip="How much of the simulation is used. 0 is the animation alone.")+ f32 weight{1.0f};++ /** @brief Entities with a SpringBoneCollider this chain keeps out of. */+ ES_PROPERTY(entity_ref, tooltip="Entities with a SpringBoneCollider that this chain is kept out of (the head, the shoulders).")+ std::vector<Entity> colliders;++ SpringBone() = default;+};++/**+ * @brief A sphere or capsule a spring chain is kept out of, placed by its entity's transform.+ */+ES_COMPONENT()+struct SpringBoneCollider {+ ES_PROPERTY(enum=SpringBoneShape, tooltip="Sphere, or a capsule along the entity's own Y axis.")+ SpringBoneShape shape{SpringBoneShape::Sphere};++ /** @brief Radius, in world units before the entity's scale. */+ ES_PROPERTY(min=0, step=0.1, tooltip="Radius in world units, before the entity's scale.")+ f32 radius{10.0f};++ /** @brief A capsule's length between its two end spheres' centres, in world units before scale. */+ ES_PROPERTY(min=0, step=0.1, shown_when=shape:Capsule, tooltip="A capsule's length between the centres of its end spheres, in world units before scale.")+ f32 height{20.0f};++ /** @brief Where the shape's centre is, in the entity's own space. */+ ES_PROPERTY(tooltip="Where the centre of the shape is, in the entity's own space.")+ glm::vec3 offset{0.0f, 0.0f, 0.0f};++ SpringBoneCollider() = default;+};++} // namespace esengine::ecsdiff --git a/src/esengine/springbone/SpringBoneSolver.cpp b/src/esengine/springbone/SpringBoneSolver.cppnew file mode 100644index 000000000..23d28a45e--- /dev/null+++ b/src/esengine/springbone/SpringBoneSolver.cpp@@ -0,0 +1,114 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+#include "SpringBoneSolver.hpp"++#include <algorithm>+#include <cmath>++namespace esengine::springbone {++void reset(std::vector<Particle>& chain) {+ for (auto& p : chain) {+ p.position = p.target;+ p.previous = p.target;+ }+}++glm::quat shortestArc(const glm::vec3& from, const glm::vec3& to) {+ const f32 lf = glm::length(from), lt = glm::length(to);+ if (lf < 1e-8f || lt < 1e-8f) return glm::quat(1.0f, 0.0f, 0.0f, 0.0f);+ const glm::vec3 f = from / lf, t = to / lt;+ const f32 d = glm::dot(f, t);+ if (d > 0.999999f) return glm::quat(1.0f, 0.0f, 0.0f, 0.0f);+ if (d < -0.999999f) {+ // Opposite: any axis across `from` turns it round.+ glm::vec3 axis = glm::cross(glm::vec3(1.0f, 0.0f, 0.0f), f);+ if (glm::dot(axis, axis) < 1e-6f) axis = glm::cross(glm::vec3(0.0f, 1.0f, 0.0f), f);+ return glm::angleAxis(3.14159265f, glm::normalize(axis));+ }+ const glm::vec3 axis = glm::cross(f, t);+ // (1 + dot, cross) normalised is the half-angle quaternion of the arc.+ return glm::normalize(glm::quat(1.0f + d, axis.x, axis.y, axis.z));+}++bool pushOut(glm::vec3& p, const Collider& c, f32 extra) {+ const f32 r = c.radius + extra;+ // The nearest point of the capsule's segment (a sphere's is its centre).+ glm::vec3 nearest = c.a;+ const glm::vec3 ab = c.b - c.a;+ const f32 len2 = glm::dot(ab, ab);+ if (len2 > 1e-12f) {+ const f32 t = std::clamp(glm::dot(p - c.a, ab) / len2, 0.0f, 1.0f);+ nearest = c.a + ab * t;+ }+ const glm::vec3 d = p - nearest;+ const f32 d2 = glm::dot(d, d);+ if (d2 >= r * r) return false;+ if (d2 < 1e-12f) {+ // On the axis: leave along any direction rather than not at all.+ p = nearest + glm::vec3(0.0f, r, 0.0f);+ return true;+ }+ const f32 dist = std::sqrt(d2);+ p = nearest + d * (r / dist);+ return true;+}++namespace {++void substep(std::vector<Particle>& chain, const StepParams& params, const std::vector<Collider>& colliders, f32 h) {+ // Stiffness and drag are quoted per 60 Hz frame; at another step they are the same decay over that time.+ const f32 frames = h / kReferenceStep;+ const f32 keep = std::pow(std::clamp(1.0f - params.drag, 0.0f, 1.0f), frames);+ const f32 pull = 1.0f - std::pow(std::clamp(1.0f - params.stiffness, 0.0f, 1.0f), frames);+ const glm::vec3 fall = params.gravity * (h * h);++ const size_t n = chain.size();+ for (size_t i = 0; i < n; ++i) {+ Particle& p = chain[i];+ if (p.parent < 0) {+ p.position = p.target;+ p.previous = p.target;+ continue;+ }+ const glm::vec3 velocity = (p.position - p.previous) * keep;+ p.previous = p.position;+ p.position += velocity + fall;+ p.position += (p.target - p.position) * pull;+ }+ // Parents first: a node's parent is already where it will be, so each node is put at its distance from it and the chain cannot stretch.+ for (size_t i = 0; i < n; ++i) {+ Particle& p = chain[i];+ if (p.parent < 0) continue;+ const Particle& parent = chain[static_cast<size_t>(p.parent)];+ glm::vec3 d = p.position - parent.position;+ const f32 len = glm::length(d);+ if (len < 1e-8f) d = p.target - parent.target;+ else d /= len;+ const f32 dl = glm::length(d);+ if (dl < 1e-8f) continue;+ p.position = parent.position + d / dl * p.restLength;+ // Out of the colliders and back onto the bone's length, a few times over: each undoes a little of the other, and they meet where the+ // bone slides round the collider instead of through it.+ for (int pass = 0; pass < 3 && !colliders.empty(); ++pass) {+ bool moved = false;+ for (const Collider& c : colliders) moved = pushOut(p.position, c, params.radius) || moved;+ if (!moved) break;+ glm::vec3 e = p.position - parent.position;+ const f32 el = glm::length(e);+ if (el > 1e-8f) p.position = parent.position + e / el * p.restLength;+ }+ }+}++} // namespace++void step(std::vector<Particle>& chain, const StepParams& params, const std::vector<Collider>& colliders, f32 dt) {+ if (chain.empty() || dt <= 0.0f) return;+ dt = std::min(dt, kMaxStep);+ const i32 steps = std::max(1, static_cast<i32>(std::ceil(dt / kReferenceStep - 1e-4f)));+ const f32 h = dt / static_cast<f32>(steps);+ for (i32 s = 0; s < steps; ++s) substep(chain, params, colliders, h);+}++} // namespace esengine::springbonediff --git a/src/esengine/springbone/SpringBoneSolver.hpp b/src/esengine/springbone/SpringBoneSolver.hppnew file mode 100644index 000000000..32afa1156--- /dev/null+++ b/src/esengine/springbone/SpringBoneSolver.hpp@@ -0,0 +1,72 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file SpringBoneSolver.hpp+ * @brief The arithmetic of a spring chain, with no registry in it: Verlet integration, length+ * constraints, collision against spheres and capsules, and the rotation that aims a+ * bone at where its child has got to.+ * @details Everything is over plain arrays and plain structs so the same code is exercised by a+ * unit test, by the editor's world, and by a build with no JIT. A chain is a tree stored+ * parents-first: a node's parent always has a smaller index.+ */+#pragma once++#include "../core/Types.hpp"+#include "../math/Math.hpp"++#include <vector>++namespace esengine::springbone {++/** @brief One simulated point of a chain. */+struct Particle {+ /** @brief Index of the parent particle, -1 for the root, which the animation drives. */+ i32 parent = -1;+ /** @brief Simulated world position, and where it was a step ago (Verlet's velocity). */+ glm::vec3 position{0.0f};+ glm::vec3 previous{0.0f};+ /** @brief Where the animation puts it this frame. */+ glm::vec3 target{0.0f};+ /** @brief Its distance from its parent, which the chain keeps. */+ f32 restLength = 0.0f;+};++/** @brief What shapes one step. */+struct StepParams {+ f32 stiffness = 0.1f; ///< Pull toward the animated pose per 60 Hz frame, 0 to 1.+ f32 drag = 0.5f; ///< Share of speed lost per 60 Hz frame, 0 to 1.+ glm::vec3 gravity{0.0f, -980.0f, 0.0f};+ f32 radius = 0.0f; ///< The strand's own thickness, kept clear of colliders.+};++/** @brief A collider in world space: a sphere when `a == b`, else a capsule from `a` to `b`. */+struct Collider {+ glm::vec3 a{0.0f};+ glm::vec3 b{0.0f};+ f32 radius = 0.0f;+};++/** @brief The rate the integration is stepped at: the stiffness and drag are per frame of this. */+constexpr f32 kReferenceStep = 1.0f / 60.0f;++/** @brief Longest stretch of time one call integrates; a stall must not become a lurch. */+constexpr f32 kMaxStep = 1.0f / 20.0f;++/** @brief Sets every particle to rest at its target: the state a chain starts in and the one it is put back in after a teleport. */+void reset(std::vector<Particle>& chain);++/**+ * @brief Advances the chain by `dt` seconds.+ * @details The root is held at its target. Every other particle keeps its velocity less drag, falls with gravity, and is pulled toward its+ * target; then each is put back at its rest length from its parent (parents first, so a bone cannot stretch) and pushed out of+ * every collider. The time is split into steps of at most one 60 Hz frame, so the result does not depend on the frame rate much.+ */+void step(std::vector<Particle>& chain, const StepParams& params, const std::vector<Collider>& colliders, f32 dt);++/** @brief The shortest rotation that turns direction `from` onto direction `to`; identity when either has no length. */+glm::quat shortestArc(const glm::vec3& from, const glm::vec3& to);++/** @brief Moves `p` out of `c` if it is inside (radius widened by `extra`), returning whether it moved. */+bool pushOut(glm::vec3& p, const Collider& c, f32 extra);++} // namespace esengine::springbonediff --git a/src/esengine/springbone/SpringBoneSystem.cpp b/src/esengine/springbone/SpringBoneSystem.cppnew file mode 100644index 000000000..3d1bebab7--- /dev/null+++ b/src/esengine/springbone/SpringBoneSystem.cpp@@ -0,0 +1,270 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+#include "SpringBoneSystem.hpp"++#include "../ecs/components/Hierarchy.hpp"+#include "../ecs/components/SpringBone.hpp"+#include "../ecs/components/Transform.hpp"++#include <algorithm>+#include <cmath>++namespace esengine::springbone {++void SpringBoneSystem::collectBones(ecs::Registry& registry, Entity root, std::vector<Entity>& out) {+ out.clear();+ stack_.clear();+ stack_.push_back(root);+ // Preorder: a bone comes before everything below it, which is the order the solver wants.+ while (!stack_.empty()) {+ const Entity e = stack_.back();+ stack_.pop_back();+ out.push_back(e);+ if (const auto* children = registry.tryGet<ecs::Children>(e)) {+ for (auto it = children->entities.rbegin(); it != children->entities.rend(); ++it) {+ if (registry.valid(*it) && registry.has<ecs::Transform>(*it)) stack_.push_back(*it);+ }+ }+ }+}++bool SpringBoneSystem::gatherColliders(ecs::Registry& registry, const std::vector<Entity>& entities, std::vector<Collider>& out) {+ out.clear();+ for (const Entity e : entities) {+ if (!registry.valid(e)) continue;+ const auto* shape = registry.tryGet<ecs::SpringBoneCollider>(e);+ auto* t = registry.tryGet<ecs::Transform>(e);+ if (!shape || !t) continue;+ t->ensureDecomposed();+ const glm::vec3 centre = t->worldPosition + t->worldRotation * (shape->offset * t->worldScale);+ const f32 scale = std::max({std::abs(t->worldScale.x), std::abs(t->worldScale.y), std::abs(t->worldScale.z)});+ Collider c;+ c.radius = shape->radius * scale;+ if (shape->shape == ecs::SpringBoneShape::Capsule) {+ const glm::vec3 axis = t->worldRotation * glm::vec3(0.0f, 1.0f, 0.0f);+ const f32 half = shape->height * std::abs(t->worldScale.y) * 0.5f;+ c.a = centre - axis * half;+ c.b = centre + axis * half;+ } else {+ c.a = c.b = centre;+ }+ out.push_back(c);+ }+ return !out.empty();+}++void SpringBoneSystem::reset(Entity root) {+ auto it = states_.find(root);+ if (it != states_.end()) it->second.primed = false;+}++const std::vector<Particle>* SpringBoneSystem::chain(Entity root) const {+ const auto it = states_.find(root);+ return it == states_.end() ? nullptr : &it->second.particles;+}++void SpringBoneSystem::update(ecs::Registry& registry, ecs::TransformSystem* transforms, f32 dt) {+ if (!destroyConn_.isConnected()) {+ destroyConn_ = registry.onDestroy([this](Entity entity) {+ states_.erase(entity);+ });+ }+ simulated_ = 0;++ // A chain whose component is gone, or switched off, gives its bones back to the animation as the animation had them.+ for (auto it = states_.begin(); it != states_.end();) {+ const Entity root = it->first;+ const auto* sb = registry.valid(root) ? registry.tryGet<ecs::SpringBone>(root) : nullptr;+ if (sb && sb->enabled && sb->weight > 0.0f) { ++it; continue; }+ const auto& entities = it->second.entities;+ State& gone = it->second;+ for (size_t i = 1; i < entities.size() && i < gone.animated.size(); ++i) {+ if (!registry.valid(entities[i])) continue;+ auto* t = registry.tryGet<ecs::Transform>(entities[i]);+ if (t && gone.hasWritten[i] && t->rotation == gone.written[i]) {+ t->rotation = gone.animated[i];+ ecs::invalidateTransformComposition();+ }+ }+ it = states_.erase(it);+ }++ auto view = registry.activeView<ecs::Transform, ecs::SpringBone>();+ bool any = false;+ for (auto entity : view) { (void)entity; any = true; break; }+ if (!any) return;++ // The animation has written local rotations; the world transforms this reads are composed from them.+ if (transforms) transforms->ensureComposed(registry);++ for (auto entity : view) {+ const auto& sb = view.get<ecs::SpringBone>(entity);+ if (!sb.enabled || sb.weight <= 0.0f) continue;++ collectBones(registry, entity, found_);+ const size_t bones = found_.size();+ if (bones < 2 && !(bones == 1 && sb.endLength > 0.0f)) continue;++ State& st = states_[entity];++ // The bones this chain has, and which are leaves (those get a virtual tip when the chain has an end length).+ size_t leaves = 0;+ childCount_.assign(bones, 0);+ parentOf_.assign(bones, -1);+ auto& childCount = childCount_;+ auto& parentOf = parentOf_;+ for (size_t i = 1; i < bones; ++i) {+ const auto* p = registry.tryGet<ecs::Parent>(found_[i]);+ i32 parent = 0;+ if (p) {+ for (size_t j = i; j-- > 0;) if (found_[j] == p->entity) { parent = static_cast<i32>(j); break; }+ }+ parentOf[i] = parent;+ childCount[static_cast<size_t>(parent)]++;+ }+ for (size_t i = 0; i < bones; ++i) if (childCount[i] == 0) ++leaves;+ const size_t tips = sb.endLength > 0.0f ? leaves : 0;++ if (st.entities != found_ || st.particles.size() != bones + tips) {+ st.entities = found_;+ st.particles.assign(bones + tips, Particle{});+ st.nodes.assign(bones + tips, Node{});+ for (size_t i = 0; i < bones; ++i) {+ st.nodes[i].entity = found_[i];+ st.particles[i].parent = parentOf[i];+ }+ for (size_t i = 1; i < bones; ++i) {+ Node& parent = st.nodes[static_cast<size_t>(parentOf[i])];+ if (parent.firstChild < 0) parent.firstChild = static_cast<i32>(i);+ }+ size_t next = bones;+ if (tips > 0) {+ for (size_t i = 0; i < bones; ++i) {+ if (childCount[i] != 0) continue;+ st.nodes[i].firstChild = static_cast<i32>(next);+ st.particles[next].parent = static_cast<i32>(i);+ ++next;+ }+ }+ st.primed = false;+ st.animated.assign(bones, glm::quat(1.0f, 0.0f, 0.0f, 0.0f));+ st.written.assign(bones, glm::quat(1.0f, 0.0f, 0.0f, 0.0f));+ st.hasWritten.assign(bones, false);+ }++ // Read the pose the animation gave: a bone whose rotation is still the one this system wrote was not animated this frame,+ // so the animation's own value is the one kept from before (otherwise the chain would spring toward its own last result).+ poses_.resize(bones);+ tipOffsets_.assign(bones + tips, glm::vec3(0.0f));+ for (size_t i = 0; i < bones; ++i) {+ auto& t = registry.get<ecs::Transform>(found_[i]);+ t.ensureDecomposed();+ Pose& pose = poses_[i];+ pose.animScale = t.worldScale;+ pose.localPosition = t.position;+ if (i > 0) {+ if (st.hasWritten[i] && t.rotation == st.written[i]) {+ pose.localRotation = st.animated[i];+ } else {+ pose.localRotation = t.rotation;+ st.animated[i] = t.rotation;+ st.hasWritten[i] = false;+ }+ // The pose the animation gave, worked out down the chain from the root with the animation's own rotations: the composed world+ // transforms of the bones below the root include what this system wrote last frame, and a target taken from them would be the chain's own result.+ const Pose& parent = poses_[static_cast<size_t>(parentOf[i])];+ pose.animRot = parent.animRot * pose.localRotation;+ pose.animPos = parent.animPos + parent.animRot * (pose.localPosition * parent.animScale);+ } else {+ pose.localRotation = t.rotation;+ pose.animPos = t.worldPosition;+ pose.animRot = t.worldRotation;+ }+ }++ // Targets: where the animation puts each bone, and the distance each keeps from its parent.+ f32 totalRest = 0.0f;+ for (size_t i = 0; i < bones; ++i) {+ Particle& p = st.particles[i];+ p.target = poses_[i].animPos;+ if (p.parent >= 0) {+ p.restLength = glm::length(p.target - poses_[static_cast<size_t>(p.parent)].animPos);+ totalRest += p.restLength;+ }+ }+ for (size_t i = 0; i < bones; ++i) {+ const i32 tip = st.nodes[i].firstChild;+ if (tip < static_cast<i32>(bones) || tip < 0) continue;+ glm::vec3 direction = poses_[i].animRot * glm::vec3(0.0f, 1.0f, 0.0f);+ if (parentOf[i] >= 0) {+ const glm::vec3 along = poses_[i].animPos - poses_[static_cast<size_t>(parentOf[i])].animPos;+ if (glm::dot(along, along) > 1e-12f) direction = glm::normalize(along);+ }+ Particle& p = st.particles[static_cast<size_t>(tip)];+ p.target = poses_[i].animPos + direction * sb.endLength;+ p.restLength = sb.endLength;+ totalRest += sb.endLength;+ // The tip as the bone sees it in its own animated frame, so forward kinematics with the animated rotation lands on the target.+ tipOffsets_[static_cast<size_t>(tip)] = glm::inverse(poses_[i].animRot) * (p.target - poses_[i].animPos);+ }++ // A jump of the root, or a long stall, is not motion the hair should trail through: put it back at its pose.+ const glm::vec3 rootPosition = poses_[0].animPos;+ const bool teleported = st.primed && glm::length(rootPosition - st.rootPosition) > std::max(totalRest, 1e-3f) * 4.0f;+ if (!st.primed || teleported || dt > 0.5f) {+ springbone::reset(st.particles);+ st.primed = true;+ }+ st.rootPosition = rootPosition;++ gatherColliders(registry, sb.colliders, colliders_);+ StepParams params;+ params.stiffness = sb.stiffness;+ params.drag = sb.drag;+ params.gravity = sb.gravity;+ params.radius = sb.radius;+ step(st.particles, params, colliders_, dt);+ ++simulated_;++ // Write back: each bone is turned to aim at where its child's simulated point is, going down the chain so a bone's own position+ // already follows its turned parent.+ fkPosition_.resize(bones);+ fkRotation_.resize(bones);+ const f32 weight = std::clamp(sb.weight, 0.0f, 1.0f);+ bool wrote = false;+ for (size_t i = 0; i < bones; ++i) {+ glm::quat unaimed;+ if (i == 0) {+ fkPosition_[0] = poses_[0].animPos;+ fkRotation_[0] = poses_[0].animRot;+ unaimed = fkRotation_[0];+ } else {+ const size_t b = static_cast<size_t>(parentOf[i]);+ fkPosition_[i] = fkPosition_[b] + fkRotation_[b] * (poses_[i].localPosition * poses_[b].animScale);+ unaimed = fkRotation_[b] * poses_[i].localRotation;+ fkRotation_[i] = unaimed;+ }+ const i32 c = st.nodes[i].firstChild;+ if (i == 0 || c < 0) continue;+ const glm::vec3 offset = static_cast<size_t>(c) < bones+ ? poses_[static_cast<size_t>(c)].localPosition * poses_[i].animScale+ : tipOffsets_[static_cast<size_t>(c)];+ const glm::vec3 current = fkRotation_[i] * offset;+ const glm::vec3 wanted = st.particles[static_cast<size_t>(c)].position - fkPosition_[i];+ glm::quat aimed = shortestArc(current, wanted) * fkRotation_[i];+ if (weight < 1.0f) aimed = glm::slerp(unaimed, aimed, weight);+ fkRotation_[i] = aimed;++ const size_t b = static_cast<size_t>(parentOf[i]);+ const glm::quat local = glm::normalize(glm::inverse(fkRotation_[b]) * aimed);+ auto& t = registry.get<ecs::Transform>(found_[i]);+ t.rotation = local;+ st.written[i] = local;+ st.hasWritten[i] = true;+ wrote = true;+ }+ if (wrote) ecs::invalidateTransformComposition();+ }+}++} // namespace esengine::springbonediff --git a/src/esengine/springbone/SpringBoneSystem.hpp b/src/esengine/springbone/SpringBoneSystem.hppnew file mode 100644index 000000000..3b45ae94f--- /dev/null+++ b/src/esengine/springbone/SpringBoneSystem.hpp@@ -0,0 +1,94 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file SpringBoneSystem.hpp+ * @brief Per-App secondary motion: runs every SpringBone chain after the animation has posed the+ * skeleton and before the frame is drawn.+ * @details The runtime state (each chain's simulated points) lives HERE, keyed by the chain's root+ * entity, not on the component — the split TrailSystem and ParticleSystem make, so the+ * component stays configuration and serialization never sees the transient state.+ *+ * Per chain, per frame: read the pose the animation gave the bones (world transforms+ * composed from their local ones), step the simulation toward it, then write back, for each+ * bone, the local rotation that aims it at where its child has got to. Positions of bones are+ * never written, so a bone cannot leave its parent; only rotations change, which is what+ * skinning needs.+ */+#pragma once++#include "../core/Types.hpp"+#include "../math/Math.hpp"+#include "../ecs/Registry.hpp"+#include "../ecs/TransformSystem.hpp"+#include "SpringBoneSolver.hpp"++#include <unordered_map>+#include <vector>++namespace esengine::springbone {++class SpringBoneSystem {+public:+ SpringBoneSystem() = default;++ /** @brief Advance every enabled chain by `dt` seconds. Composes world transforms first if the animation moved any. */+ void update(ecs::Registry& registry, ecs::TransformSystem* transforms, f32 dt);++ /** @brief Forget a chain's state: it starts again from the animated pose on its next frame (a teleport, a respawn). */+ void reset(Entity root);++ /** @brief How many chains the last update simulated. */+ u32 simulated() const { return simulated_; }++ /** @brief The simulated world positions of a chain, root first, in the order its bones were found (tips last); null if it has no state. */+ const std::vector<Particle>* chain(Entity root) const;++private:+ /** @brief One bone (or a virtual tip) of a chain, beside its particle. */+ struct Node {+ Entity entity = INVALID_ENTITY; ///< INVALID_ENTITY for a virtual tip.+ i32 firstChild = -1; ///< The child this bone aims at; -1 for a tip.+ };++ /** @brief What a bone's pose was this frame, as the animation left it. */+ struct Pose {+ glm::vec3 animPos{0.0f}; ///< World position, rotation and scale the animation gives the bone.+ glm::quat animRot{1.0f, 0.0f, 0.0f, 0.0f};+ glm::vec3 animScale{1.0f};+ glm::vec3 localPosition{0.0f};+ glm::quat localRotation{1.0f, 0.0f, 0.0f, 0.0f};+ };++ struct State {+ std::vector<Entity> entities; ///< The bones in the order they were found, to notice a hierarchy that changed.+ std::vector<Particle> particles;+ std::vector<Node> nodes;+ glm::vec3 rootPosition{0.0f};+ bool primed = false;+ /// The animation's local rotation of each bone, the one this system last wrote there, and whether it has written one. A bone+ /// still holding what was written was not animated this frame, so the animation's own value is the one kept from before.+ std::vector<glm::quat> animated;+ std::vector<glm::quat> written;+ std::vector<bool> hasWritten;+ };++ std::unordered_map<Entity, State> states_;+ // Scratch for one chain's frame, kept so a frame allocates nothing once the chains exist.+ std::vector<Collider> colliders_;+ std::vector<Entity> found_;+ std::vector<Entity> stack_;+ std::vector<Pose> poses_;+ std::vector<glm::vec3> tipOffsets_;+ std::vector<glm::vec3> fkPosition_;+ std::vector<glm::quat> fkRotation_;+ std::vector<i32> childCount_;+ std::vector<i32> parentOf_;+ u32 simulated_ = 0;+ // RAII: unregisters from the registry's onDestroy when this system is torn down.+ Connection destroyConn_;++ void collectBones(ecs::Registry& registry, Entity root, std::vector<Entity>& out);+ bool gatherColliders(ecs::Registry& registry, const std::vector<Entity>& entities, std::vector<Collider>& out);+};++} // namespace esengine::springbonediff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txtindex 1e360dbb1..78a8ad7c0 100644--- a/tests/CMakeLists.txt+++ b/tests/CMakeLists.txt@@ -45,6 +45,18 @@ target_include_directories(test_tween_activity PRIVATE)add_test(NAME test_tween_activity COMMAND test_tween_activity)+add_executable(test_springbone+ springbone/test_springbone.cpp+ ${CMAKE_SOURCE_DIR}/src/esengine/springbone/SpringBoneSolver.cpp+ ${CMAKE_SOURCE_DIR}/src/esengine/springbone/SpringBoneSystem.cpp+ ${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cpp+)+target_include_directories(test_springbone PRIVATE+ ${CMAKE_SOURCE_DIR}/src+ ${CMAKE_SOURCE_DIR}/third_party/glm+)+add_test(NAME test_springbone COMMAND test_springbone)+add_executable(test_entity_activityecs/test_entity_activity.cpp${CMAKE_SOURCE_DIR}/src/esengine/core/Log.cppdiff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.hindex 95c887e63..fd0bf27e8 100644--- a/tests/aot/generated/conformance/handshake.h+++ b/tests/aot/generated/conformance/handshake.h@@ -1,5 +1,5 @@/* GENERATED by sdk/tests/aot-conformance.test.ts — do not edit. *//* The contract half of the handshake. The width half is the harness. */-#define ES_CONF_EXPECTED_CONTRACT_HASH 0x8ecf13a182e11801ULL+#define ES_CONF_EXPECTED_CONTRACT_HASH 0x5f1e2389e92b4ae8ULL/* And which BUILD the artifact beside this one is. */#define ES_CONF_EXPECTED_MODULE_CONTRACT 0xc3d0e057d5701a2eULLdiff --git a/tests/aot/generated/conformance/systems_decl.c b/tests/aot/generated/conformance/systems_decl.cindex d927080a3..076a3e3c8 100644--- a/tests/aot/generated/conformance/systems_decl.c+++ b/tests/aot/generated/conformance/systems_decl.c@@ -10,7 +10,7 @@answer, it is a read of a different field. The address width belongsto the MACHINE, so it mixes in here rather than in the compiler and a32-bit artifact cannot load into a 64-bit host. */-#define ES_ABI_ENGINE_DIGEST 0x8ecf13a182e11801ULL+#define ES_ABI_ENGINE_DIGEST 0x5f1e2389e92b4ae8ULLES_EXPORT const uint64_t es_abi_hash =ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));diff --git a/tests/aot/generated/move_system_decl.c b/tests/aot/generated/move_system_decl.cindex 2a2fffae5..3e7e78c3c 100644--- a/tests/aot/generated/move_system_decl.c+++ b/tests/aot/generated/move_system_decl.c@@ -10,7 +10,7 @@answer, it is a read of a different field. The address width belongsto the MACHINE, so it mixes in here rather than in the compiler and a32-bit artifact cannot load into a 64-bit host. */-#define ES_ABI_ENGINE_DIGEST 0x8ecf13a182e11801ULL+#define ES_ABI_ENGINE_DIGEST 0x5f1e2389e92b4ae8ULLES_EXPORT const uint64_t es_abi_hash =ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));diff --git a/tests/aot/generated/move_system_hash.h b/tests/aot/generated/move_system_hash.hindex e90f6c68c..2522c3c44 100644--- a/tests/aot/generated/move_system_hash.h+++ b/tests/aot/generated/move_system_hash.h@@ -1,6 +1,6 @@/* GENERATED by @estella/compiler — do not edit. *//* The contract half of the handshake. The width half is the harness. */-#define ES_EXPECTED_CONTRACT_HASH 0x8ecf13a182e11801ULL+#define ES_EXPECTED_CONTRACT_HASH 0x5f1e2389e92b4ae8ULL/* And which BUILD the artifact beside this one is, which the sidecarwritten with it has to carry too. */#define ES_EXPECTED_MODULE_CONTRACT 0x10bf77bb714ea1e3ULLdiff --git a/tests/springbone/test_springbone.cpp b/tests/springbone/test_springbone.cppnew file mode 100644index 000000000..4025284c8--- /dev/null+++ b/tests/springbone/test_springbone.cpp@@ -0,0 +1,315 @@+#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN+#include <doctest.h>++#include "esengine/ecs/TransformSystem.hpp"+#include "esengine/ecs/components/SpringBone.hpp"+#include "esengine/springbone/SpringBoneSolver.hpp"+#include "esengine/springbone/SpringBoneSystem.hpp"++#include <cmath>++using namespace esengine;+using namespace esengine::springbone;++namespace {++/** A chain hanging along -y from the origin: n particles `len` apart, the first the root. */+std::vector<Particle> hanging(int n, f32 len) {+ std::vector<Particle> chain(static_cast<size_t>(n));+ for (int i = 0; i < n; ++i) {+ chain[static_cast<size_t>(i)].parent = i - 1;+ chain[static_cast<size_t>(i)].target = glm::vec3(0.0f, -len * static_cast<f32>(i), 0.0f);+ chain[static_cast<size_t>(i)].restLength = i == 0 ? 0.0f : len;+ }+ reset(chain);+ return chain;+}++void follow(std::vector<Particle>& chain, const glm::vec3& root, f32 len) {+ for (size_t i = 0; i < chain.size(); ++i) chain[i].target = root + glm::vec3(0.0f, -len * static_cast<f32>(i), 0.0f);+}++f32 stretch(const std::vector<Particle>& chain) {+ f32 worst = 0.0f;+ for (size_t i = 1; i < chain.size(); ++i) {+ worst = std::max(worst, std::abs(glm::length(chain[i].position - chain[static_cast<size_t>(chain[i].parent)].position) - chain[i].restLength));+ }+ return worst;+}++} // namespace++TEST_CASE("shortestArc turns one direction onto another") {+ const glm::vec3 pairs[][2] = {{{1, 0, 0}, {0, 1, 0}}, {{0, -1, 0}, {1, 1, 0}}, {{0, 0, 1}, {0, 0, -1}}, {{3, 0, 0}, {3, 0, 0}}};+ for (const auto& p : pairs) {+ const glm::quat q = shortestArc(p[0], p[1]);+ const glm::vec3 turned = q * glm::normalize(p[0]);+ const glm::vec3 want = glm::normalize(p[1]);+ CHECK(turned.x == doctest::Approx(want.x).epsilon(1e-4));+ CHECK(turned.y == doctest::Approx(want.y).epsilon(1e-4));+ CHECK(turned.z == doctest::Approx(want.z).epsilon(1e-4));+ CHECK(glm::length(q) == doctest::Approx(1.0f));+ }+ const glm::quat none = shortestArc(glm::vec3(0.0f), glm::vec3(1, 0, 0));+ CHECK(none.w == doctest::Approx(1.0f));+}++TEST_CASE("a chain at rest in its pose stays there with no gravity") {+ auto chain = hanging(5, 10.0f);+ StepParams params;+ params.gravity = glm::vec3(0.0f);+ for (int i = 0; i < 120; ++i) step(chain, params, {}, 1.0f / 60.0f);+ for (const auto& p : chain) CHECK(glm::length(p.position - p.target) < 1e-4f);+}++TEST_CASE("full stiffness is the animation, exactly") {+ auto chain = hanging(4, 10.0f);+ StepParams params;+ params.stiffness = 1.0f;+ for (int i = 0; i < 30; ++i) {+ follow(chain, glm::vec3(static_cast<f32>(i) * 3.0f, 0.0f, 0.0f), 10.0f);+ step(chain, params, {}, 1.0f / 60.0f);+ }+ for (const auto& p : chain) CHECK(glm::length(p.position - p.target) < 1e-3f);+}++TEST_CASE("a bone never stretches, whatever the chain is doing") {+ auto chain = hanging(6, 10.0f);+ StepParams params;+ params.stiffness = 0.05f;+ for (int i = 0; i < 240; ++i) {+ follow(chain, glm::vec3(std::sin(static_cast<f32>(i) * 0.2f) * 80.0f, 0.0f, 0.0f), 10.0f);+ step(chain, params, {}, 1.0f / 60.0f);+ CHECK(stretch(chain) < 1e-2f);+ }+}++TEST_CASE("the tip lags a moving root and catches up when it stops") {+ auto chain = hanging(5, 10.0f);+ StepParams params;+ params.gravity = glm::vec3(0.0f);+ follow(chain, glm::vec3(100.0f, 0.0f, 0.0f), 10.0f);+ step(chain, params, {}, 1.0f / 60.0f);+ const auto& tip = chain.back();+ CHECK(glm::length(tip.position - tip.target) > 20.0f); // it did not jump with the root+ for (int i = 0; i < 400; ++i) step(chain, params, {}, 1.0f / 60.0f);+ CHECK(glm::length(tip.position - tip.target) < 0.5f);+}++TEST_CASE("the defaults do not ring: a body that walks a few bone lengths is overshot only a little") {+ auto chain = hanging(5, 10.0f);+ StepParams params; // the defaults a SpringBone starts with+ params.gravity = glm::vec3(0.0f);+ f32 over = 0.0f;+ for (int i = 0; i < 400; ++i) {+ follow(chain, glm::vec3(std::min(static_cast<f32>(i), 20.0f) * 2.0f, 0.0f, 0.0f), 10.0f); // 40 units over a third of a second+ step(chain, params, {}, 1.0f / 60.0f);+ over = std::max(over, chain.back().position.x - chain.back().target.x);+ }+ CHECK(over < 4.0f); // a tenth of the move+ CHECK(glm::length(chain.back().position - chain.back().target) < 0.5f);+}++TEST_CASE("gravity hangs a free chain and the weight of stiffness holds it up") {+ // A chain posed out sideways.+ auto sideways = [](f32 stiffness) {+ std::vector<Particle> chain(5);+ for (int i = 0; i < 5; ++i) {+ chain[static_cast<size_t>(i)].parent = i - 1;+ chain[static_cast<size_t>(i)].target = glm::vec3(10.0f * static_cast<f32>(i), 0.0f, 0.0f);+ chain[static_cast<size_t>(i)].restLength = i == 0 ? 0.0f : 10.0f;+ }+ reset(chain);+ StepParams params;+ params.stiffness = stiffness;+ for (int i = 0; i < 600; ++i) step(chain, params, {}, 1.0f / 60.0f);+ return chain.back().position.y;+ };+ const f32 free = sideways(0.0f), held = sideways(0.5f);+ CHECK(free < -30.0f); // hangs down+ CHECK(held > free + 10.0f); // the pose holds it higher+ CHECK(held < 0.0f); // but gravity still has its say+}++TEST_CASE("a collider keeps the chain out") {+ auto chain = hanging(6, 10.0f);+ StepParams params;+ params.gravity = glm::vec3(0.0f);+ // Off to one side, so the chain grazes it: a chain threaded dead through the middle has no side to go round.+ const Collider sphere{glm::vec3(8.0f, -30.0f, 0.0f), glm::vec3(8.0f, -30.0f, 0.0f), 12.0f};+ for (int i = 0; i < 120; ++i) step(chain, params, {sphere}, 1.0f / 60.0f);+ for (size_t i = 1; i < chain.size(); ++i) CHECK(glm::length(chain[i].position - sphere.a) >= 12.0f - 0.05f);+ CHECK(stretch(chain) < 0.5f);+}++TEST_CASE("a capsule pushes out along its length") {+ glm::vec3 p(2.0f, 0.0f, 0.0f);+ const Collider capsule{glm::vec3(0.0f, -10.0f, 0.0f), glm::vec3(0.0f, 10.0f, 0.0f), 5.0f};+ CHECK(pushOut(p, capsule, 0.0f));+ CHECK(p.x == doctest::Approx(5.0f));+ CHECK(p.y == doctest::Approx(0.0f));+ glm::vec3 distant(20.0f, 0.0f, 0.0f);+ CHECK_FALSE(pushOut(distant, capsule, 0.0f));+ glm::vec3 end(0.0f, 12.0f, 0.0f); // inside the end cap+ CHECK(pushOut(end, capsule, 0.0f));+ CHECK(glm::length(end - capsule.b) == doctest::Approx(5.0f));+}++TEST_CASE("the same steps give the same chain, and the frame rate hardly matters") {+ auto run = [](int hz) {+ auto chain = hanging(5, 10.0f);+ StepParams params;+ params.gravity = glm::vec3(0.0f);+ for (int i = 0; i < hz; ++i) {+ const f32 t = static_cast<f32>(i) / static_cast<f32>(hz);+ follow(chain, glm::vec3(std::min(t, 0.3f) * 200.0f, 0.0f, 0.0f), 10.0f);+ step(chain, params, {}, 1.0f / static_cast<f32>(hz));+ }+ return chain.back().position;+ };+ const glm::vec3 a = run(60), b = run(60), c = run(120);+ CHECK(a == b);+ CHECK(glm::length(a - c) < 4.0f);+}++namespace {++struct Rig {+ ecs::Registry registry;+ ecs::TransformSystem transforms;+ SpringBoneSystem system;+ Entity root{}, b1{}, b2{};++ explicit Rig(f32 endLength = 0.0f, f32 stiffness = 0.2f) {+ root = registry.create();+ b1 = registry.create();+ b2 = registry.create();+ registry.emplace<ecs::Transform>(root);+ auto& t1 = registry.emplace<ecs::Transform>(b1);+ t1.position = {0.0f, -10.0f, 0.0f};+ auto& t2 = registry.emplace<ecs::Transform>(b2);+ t2.position = {0.0f, -10.0f, 0.0f};+ ecs::setParent(registry, b1, root);+ ecs::setParent(registry, b2, b1);+ auto& sb = registry.emplace<ecs::SpringBone>(root);+ sb.gravity = glm::vec3(0.0f);+ sb.endLength = endLength;+ sb.stiffness = stiffness;+ transforms.ensureComposed(registry);+ }++ void moveRoot(const glm::vec3& p) {+ registry.get<ecs::Transform>(root).position = p;+ ecs::invalidateTransformComposition();+ }+ void frame(f32 dt = 1.0f / 60.0f) { system.update(registry, &transforms, dt); }+ f32 turned(Entity e) { return 2.0f * std::acos(std::min(std::abs(registry.get<ecs::Transform>(e).rotation.w), 1.0f)); }+};++} // namespace++TEST_CASE("a chain in its pose is left alone") {+ Rig rig;+ for (int i = 0; i < 30; ++i) rig.frame();+ CHECK(rig.turned(rig.b1) < 1e-3f);+ CHECK(rig.system.simulated() == 1);+ // Positions are never written.+ CHECK(rig.registry.get<ecs::Transform>(rig.b1).position.y == doctest::Approx(-10.0f));+}++TEST_CASE("moving the root swings the bones, and they settle back to the animated pose without drifting") {+ Rig rig;+ rig.frame();+ rig.moveRoot({60.0f, 0.0f, 0.0f});+ rig.frame();+ CHECK(rig.turned(rig.b1) > 0.05f);+ for (int i = 0; i < 600; ++i) rig.frame();+ // Nothing animated these bones in between, yet they returned to the pose, not to the last thing this system wrote.+ CHECK(rig.turned(rig.b1) < 0.01f);+ CHECK(rig.turned(rig.b2) < 0.01f);+}++TEST_CASE("an animated rotation is the new pose the chain springs toward") {+ Rig rig;+ rig.frame();+ const glm::quat pose = glm::angleAxis(0.5f, glm::vec3(0.0f, 0.0f, 1.0f));+ for (int i = 0; i < 300; ++i) {+ rig.registry.get<ecs::Transform>(rig.b1).rotation = pose; // the animation, every frame+ ecs::invalidateTransformComposition();+ rig.frame();+ }+ const glm::quat now = rig.registry.get<ecs::Transform>(rig.b1).rotation;+ CHECK(std::abs(glm::dot(now, pose)) > 0.999f);+}++TEST_CASE("an end length gives the last bone a tip to follow") {+ Rig without(0.0f), with(10.0f);+ for (Rig* r : {&without, &with}) {+ r->frame();+ r->moveRoot({80.0f, 0.0f, 0.0f});+ r->frame();+ }+ CHECK(without.turned(without.b2) < 1e-4f); // a leaf with no tip is not simulated+ CHECK(with.turned(with.b2) > 0.02f);+}++TEST_CASE("a jump of the root is a teleport, not a whip") {+ Rig rig;+ rig.frame();+ rig.moveRoot({50000.0f, 0.0f, 0.0f});+ rig.frame();+ CHECK(rig.turned(rig.b1) < 1e-3f);+ CHECK(rig.turned(rig.b2) < 1e-3f);+}++TEST_CASE("switching the chain off gives the bones back as the animation had them") {+ Rig rig;+ rig.frame();+ rig.moveRoot({60.0f, 0.0f, 0.0f});+ rig.frame();+ CHECK(rig.turned(rig.b1) > 0.05f);+ rig.registry.get<ecs::SpringBone>(rig.root).enabled = false;+ rig.frame();+ CHECK(rig.turned(rig.b1) < 1e-4f);+ CHECK(rig.system.chain(rig.root) == nullptr);+}++TEST_CASE("weight blends between the animation and the simulation") {+ Rig full, half;+ half.registry.get<ecs::SpringBone>(half.root).weight = 0.5f;+ f32 amounts[2];+ int k = 0;+ for (Rig* r : {&full, &half}) {+ r->frame();+ r->moveRoot({60.0f, 0.0f, 0.0f});+ r->frame();+ amounts[k++] = r->turned(r->b1);+ }+ CHECK(amounts[1] > 0.0f);+ CHECK(amounts[1] < amounts[0] * 0.7f);+}++TEST_CASE("destroying the root drops its chain") {+ Rig rig;+ rig.frame();+ CHECK(rig.system.chain(rig.root) != nullptr);+ rig.registry.destroy(rig.root);+ CHECK(rig.system.chain(rig.root) == nullptr);+}++TEST_CASE("a collider entity keeps the simulated bones out") {+ Rig rig;+ auto& sb = rig.registry.get<ecs::SpringBone>(rig.root);+ const Entity ball = rig.registry.create();+ rig.registry.emplace<ecs::Transform>(ball).position = {15.0f, -10.0f, 0.0f};+ auto& shape = rig.registry.emplace<ecs::SpringBoneCollider>(ball);+ shape.radius = 8.0f;+ sb.colliders.push_back(ball);+ rig.transforms.ensureComposed(rig.registry);+ rig.frame();+ rig.moveRoot({40.0f, 0.0f, 0.0f});+ for (int i = 0; i < 20; ++i) rig.frame();+ const auto* chain = rig.system.chain(rig.root);+ REQUIRE(chain != nullptr);+ for (size_t i = 1; i < chain->size(); ++i) CHECK(glm::length((*chain)[i].position - glm::vec3(15.0f, -10.0f, 0.0f)) >= 7.9f);+}diff --git a/tools/census-transform-writers.mjs b/tools/census-transform-writers.mjsindex 8efe49330..13d41e201 100644--- a/tools/census-transform-writers.mjs+++ b/tools/census-transform-writers.mjs@@ -59,6 +59,10 @@ const SEAMS = [file: 'src/esengine/bindings/RendererBindings.cpp', fn: 'renderer_renderMeshPreview', role: 'private world',why: 'builds its own Registry and composes it in place, so nothing outside the call can read a stale value',},+ {+ file: 'src/esengine/springbone/SpringBoneSystem.cpp', fn: 'update', role: 'announces',+ why: 'writes the local rotation of every bone it aimed and announces once after the pass; positions are never written',+ },{file: 'src/esengine/bindings/EditorAPI.generated.cpp', fn: 'editor_setFloat', role: 'announces',why: 'emitted from WRITE_HOOKS; check-transform-seam holds which arms get it',diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 3ac79597a..5a8846645 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -2567,6 +2567,8 @@ export const NOTED = {{"note":"Water holds things up. A Floating component on an entity with a RigidBody3D floats it: a buoyant force against gravity (`buoyancy` is the water's density against the body's, so 2 floats it half under) and a drag against its velocity relative to the water, which brings it to rest in a lake and carries it with a river's current, applied at a few points of the body so waves tip it. It works from the CPU's own water surface, so it needs no renderer, and it needs the 3D physics module, which gains force and mass queries."},"feat(water): a camera under the surface sees through the water, fogged and tinted by what it has crossed":{"note":"A camera under water sees through it. Whenever the active camera is below a water body's surface an Underwater effect is added to the post-process volumes: the light of each pixel is taken out colour by colour (red first) by the distance it crossed, with the same absorption and density the surface's material draws with, and the water gives back its own colour, dimmer the deeper the camera is. The surface seen from below turns over and, past the critical angle, reflects whole (Snell's window)."},+ "feat(animation): spring bones give a chain of bones secondary motion in the engine, with colliders to keep it out of the body":+ {"note":"Spring bones give a skeleton secondary motion: a `SpringBone` on the root of a chain of bones (hair, a tail, a cord) makes everything below it a spring that lags the animation, falls with gravity, is pulled back to its animated pose, never stretches, and is kept out of `SpringBoneCollider` spheres and capsules. It runs in C++ in the engine, so it costs the same on every target: 300 chains of six bones step in 0.28 ms. Only the bones' rotations are written, and switching it off gives the animation's own back."},"feat(editor): the quality settings page has a Level · Water group for waves, ripple cells, displacement, mirror and caustics":{"note":"Project Settings → Rendering has a Level · Water group for the five water quality fields (waves, ripple cells, displacement, mirror, caustics) of the level chosen under Editing level. Each is saved as a difference to that level only, and the group is hidden while quality is off or the project excludes the water module."},"feat(sdk): the Water, Terrain, Foliage, Hair, Skin and Eye shaders ship with their modules, and a material that names one brings its module into an export":