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(physics3d): a hit is judged by its impulse - every 3D contact carries the mass the two met with and the impulse, speed by mass, and a Breakable breaks on a hit at least as hard as its breakImpulse; RigidBody3D.mass gives a moving body a mass of its own in kilograms, 0 keeping the one its shape gives
yhh24b95d01f73a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 03a53d1c5..56777c823 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,7 +17,8 @@ published separately; it ships inside the editor.### Added- **Things that break.** A model can end with a `fracture` step, `{ op: "fracture", pieces: 12, at, focus }`, which cuts it beforehand into pieces that fit together with no gap, each a closed solid whose cut faces are tagged apart from its skin, smaller round `at` where it will be struck. It is still drawn whole; the editor also writes a mesh for each piece and a prefab of them, each with a dynamic body and a convex hull, and the reply hands over a `Breakable` to put beside the MeshRenderer. Raising `Breakable.broken` hides the whole (its renderer, body and colliders are switched off, not removed), puts the pieces where it stood and throws them out from `origin` at `burst` world units a second; `lifetime` takes them away later, and lowering the flag makes it whole again. Its pieces are loaded while it stands whole, so they appear on the frame it breaks. In the editor a clay pot written by `model_write` and placed on a floor broke into the 12 pieces asked for, then the 5 asked for after an edit, each of which moved, spread apart and came to rest on the floor, and was whole again when the flag was lowered. Nothing breaks it of itself yet: a script, a graph or a collision handler raises the flag. `Physics3D.setLinearVelocity(entity, velocity)` is what throws the pieces and is there for anything else that sends a body off. `Prefabs.prepare(path)` loads a prefab and everything its entities use and holds it, so a later `instantiate` does not wait on files.-- **A thing breaks when it is hit hard enough.** `Breakable.breakSpeed` breaks it on a contact at least that fast, in world units a second at which the two came together, and the pieces leave from where it was hit. It needs a collider of its own, which the editor's reply to a fractured model now hands over as `hull` (a `ConvexCollider3D` of its shape); with a dynamic body as well it can be knocked over and break where it lands. The speed comes from the 3D world: every `Physics3DEvents.contactEnters` entry carries `speed`, how fast the first body was closing on the second along the normal, read before the solver answered, from both the Jolt and PhysX worlds. A sphere dropped 1.5 m onto a pad reported 5.56 m/s from Jolt and 5.40 from PhysX against the 5.42 the fall gives. In the editor a stone dropped six metres onto a pot broke it from its rim and took its collider away, and a pebble set down on another left it whole. Native builds carry the new speed buffer but were only compiled on Windows, not run.+- **A thing breaks when it is hit hard enough.** `Breakable.breakImpulse` breaks it on a contact at least that hard, the speed at which the two came together times the mass they met with, and the pieces leave from where it was hit. It needs a collider of its own, which the editor's reply to a fractured model now hands over as `hull` (a `ConvexCollider3D` of its shape); with a dynamic body as well it can be knocked over and break where it lands. Every `Physics3DEvents.contactEnters` entry now carries `speed` (how fast the first body was closing on the second along the normal, read before the solver answered), `mass` (the kilograms they met with, 1 / (1/a + 1/b), a body that does not move counting as none) and `impulse`, their product, from both the Jolt and PhysX worlds. A sphere of 0.5 m dropped 1.5 m onto a pad reported 5.56 m/s from Jolt and 5.40 from PhysX against the 5.42 the fall gives, and met it with 523.60 kg, its own mass, from both. In the editor a 2 kg stone dropped six metres onto a pot broke it from its rim and took its collider away, and a 50 g pebble dropped from as high onto another left it whole. Native builds carry the new buffers but were only compiled on Windows, not run.+- **A 3D body has a mass of its own.** `RigidBody3D.mass` sets a moving body's mass in kilograms, its inertia scaled with it; 0, the default, keeps the mass its shape gives at the density of water, so scenes made before it weigh what they did. It reaches a body already in play when it changes. Both worlds were given 2 kg and answered 2, and refused a mass that is not a positive number.## [0.104.1] - 2026-11-13diff --git a/desktop b/desktopindex 89dd6d603..cce5604f4 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 89dd6d6038025e4aef514053788e5cf20e15c989+Subproject commit cce5604f45c20c849d7111856dc61cfe696dbe3cdiff --git a/docs/astro/src/content/docs/gameplay/physics-3d.mdx b/docs/astro/src/content/docs/gameplay/physics-3d.mdxindex 3429aa765..8d1cbe906 100644--- a/docs/astro/src/content/docs/gameplay/physics-3d.mdx+++ b/docs/astro/src/content/docs/gameplay/physics-3d.mdx@@ -87,6 +87,7 @@ cmds.spawn()|---|---|| `bodyType` | `Static` never moves, `Kinematic` is moved by hand, `Dynamic` is solved. || `gravityScale` | This body's share of world gravity. `0` is weightlessness, not slow falling. |+| `mass` | Kilograms. `0` (the default) takes it from the shape at the density of water: a ball of 10 cm radius is 4.2 kg. Set it to make a hollow crate light or a small anvil heavy; it reaches a body already in play when it changes. A static or kinematic body has none. || `linearDamping` / `angularDamping` | How quickly motion bleeds off (both default `0.05`; 2D bodies default to `0`). || `fixedRotation` | Freezes the orientation the body was given — what keeps a character from toppling. It does not right a body that starts tilted. || `layer` | Which of the sixteen [collision layers](#collision-layers) the body is in. |@@ -555,7 +556,7 @@ for (const { sensorEntity, visitorEntity } of events.sensorEnters) {| Channel | What it carries ||---|---|-| `contactEnters` | Both entities, the contact normal and the point, in the same units as `Transform`, and `speed`: how fast the first was closing on the second where they met, along the normal, in those units a second, read before the solver answered. A ball dropped a metre lands at about 4.4 m/s. |+| `contactEnters` | Both entities, the contact normal and the point, in the same units as `Transform`, and `speed`: how fast the first was closing on the second where they met, along the normal, in those units a second, read before the solver answered (a ball dropped a metre lands at about 4.4 m/s); `mass`, the kilograms they met with, 1 / (1/a + 1/b) with a body that does not move counting as no inverse mass, so a stone landing on a floor meets it with its own; and `impulse`, `speed` times `mass`, how hard. || `contactExits` | Only the pair — see below. || `sensorEnters` / `sensorExits` | The **sensor first**, then the visitor. |@@ -654,21 +655,23 @@ world.update(pot, Breakable, (b) => { b.origin = hitPointInItsOwnSpace; b.broken| `burst` | number | `300` | How fast the pieces leave, in world units a second, out from `origin`. 0 lets them fall where they are. || `origin` | vec3 | `0,0,0` | Where it is struck, from its own origin. || `lifetime` | number | `0` | Seconds the pieces last before they are taken away. 0 keeps them. |-| `breakSpeed` | number | `0` | A hit at least this fast breaks it, in world units a second. 0 breaks it only when `broken` is raised. |+| `breakImpulse` | number | `0` | A hit at least this hard breaks it: speed times mass, kg by world units a second. 0 breaks it only when `broken` is raised. |The whole is hidden, not removed: its renderer, body and colliders are switchedoff and come back when `broken` is lowered. Without a 3D world the piecesappear in place and stay there.-To have it break when something hits it, give it a `breakSpeed` and a collider-of its own (the editor's reply to a fractured model hands over a-`ConvexCollider3D` of its shape as `hull`). A contact at least that fast, by-the speed at which the two came together, breaks it, and the pieces leave from-where it was hit; the hardest hit wins when there are several in a step. With-the collider alone it stands still; with a dynamic `RigidBody3D` as well it can-be knocked over, and breaks where it lands if it lands hard enough. In a scene-of 100 units to the metre, a fall of one metre arrives at about 440 and a thrown-stone at 1000 or more.+To have it break when something hits it, give it a `breakImpulse` and a+collider of its own (the editor's reply to a fractured model hands over a+`ConvexCollider3D` of its shape as `hull`). A contact at least that hard+breaks it, and the pieces leave from where it was hit; the hardest hit wins+when there are several in a step. How hard is the speed at which the two came+together times the mass they met with, so in a scene of 100 units to the metre a+1 kg stone landing at 10 m/s is 1000 and a 50 g pebble at the same speed is 50.+With the collider alone it stands still and a stone meets it with the stone's+own mass; with a dynamic `RigidBody3D` as well it can be knocked over, and when+it falls it meets the floor with its own. Give the stones and the pot the masses+they should have with `RigidBody3D.mass`.`Physics3D.setLinearVelocity(entity, velocity)` is what throws them, and isthere for anything else that needs to send a body off: a blast, a kick. Itdiff --git a/docs/astro/src/content/docs/zh-cn/gameplay/physics-3d.mdx b/docs/astro/src/content/docs/zh-cn/gameplay/physics-3d.mdxindex d2f396723..fedd18781 100644--- a/docs/astro/src/content/docs/zh-cn/gameplay/physics-3d.mdx+++ b/docs/astro/src/content/docs/zh-cn/gameplay/physics-3d.mdx@@ -71,6 +71,7 @@ cmds.spawn()|---|---|| `bodyType` | `Static` 从不移动,`Kinematic` 由你搬动,`Dynamic` 由求解器解。 || `gravityScale` | 这个刚体分担的重力比例。`0` 是失重,不是「掉得慢」。 |+| `mass` | 千克。`0`(默认)按形状以水的密度计算:半径 10 cm 的球是 4.2 kg。用它让空箱子变轻、小铁砧变重;运行中修改也会生效。静态和运动学刚体没有质量。 || `linearDamping` / `angularDamping` | 运动衰减的快慢(默认都是 `0.05`;2D 刚体默认是 `0`)。 || `fixedRotation` | 冻结刚体被给定的朝向——让角色不会倒下的那个开关。它不会把一个一开始就歪的刚体扶正。 || `layer` | 刚体所在的十六个[碰撞层](#碰撞层)之一。 |@@ -488,7 +489,7 @@ for (const { sensorEntity, visitorEntity } of events.sensorEnters) {| 通道 | 带着什么 ||---|---|-| `contactEnters` | 两个实体、接触法线和接触点,接触点与 `Transform` 同单位;以及 `speed`:接触时第一个物体沿法线靠近第二个物体的速度,同单位每秒,在求解器处理之前读取。从一米高落下的球约以 4.4 m/s 着地。 |+| `contactEnters` | 两个实体、接触法线和接触点,接触点与 `Transform` 同单位;以及 `speed`:接触时第一个物体沿法线靠近第二个物体的速度,同单位每秒,在求解器处理之前读取(从一米高落下的球约以 4.4 m/s 着地);`mass`:两者相撞时的有效质量(千克),1 / (1/a + 1/b),不动的物体视为逆质量为 0,所以石头落在地上时就是石头自己的质量;`impulse`:`speed` 乘 `mass`,即撞击力度。 || `contactExits` | 只有这一对——原因见下。 || `sensorEnters` / `sensorExits` | **传感器在前**,然后是访客。 |@@ -563,16 +564,17 @@ world.update(pot, Breakable, (b) => { b.origin = hitPointInItsOwnSpace; b.broken| `burst` | number | `300` | 碎块从 `origin` 向外飞出的速度,世界单位每秒。0 表示原地落下。 || `origin` | vec3 | `0,0,0` | 受击的位置,相对它自己的原点。 || `lifetime` | number | `0` | 碎块保留的秒数,之后被移除。0 表示一直保留。 |-| `breakSpeed` | number | `0` | 撞击速度达到它就碎,世界单位每秒。0 表示只在 `broken` 置真时碎。 |+| `breakImpulse` | number | `0` | 撞击力度达到它就碎:速度乘质量,千克·世界单位每秒。0 表示只在 `broken` 置真时碎。 |整体只是隐藏,不是删除:它的渲染器、刚体和碰撞体被关掉,`broken` 置假时恢复。没有 3D 物理世界时,碎块会原地出现并留在那里。-要让它被撞碎,给它设 `breakSpeed`,并给它一个自己的碰撞体(编辑器对碎裂模型的回复里会以-`hull` 给出一个同形状的 `ConvexCollider3D`)。两者相撞的接近速度达到这个值就会碎,碎块从-被击中的位置飞出;同一步里有多次撞击时取最重的一次。只有碰撞体时它是静止的;再加一个动态-`RigidBody3D`,它就能被撞倒,落地够重时在落地处碎掉。在 100 单位一米的场景里,一米高落下约-为 440,扔出的石头在 1000 以上。+要让它被撞碎,给它设 `breakImpulse`,并给它一个自己的碰撞体(编辑器对碎裂模型的回复里会以+`hull` 给出一个同形状的 `ConvexCollider3D`)。撞击力度达到这个值就会碎,碎块从被击中的位置+飞出;同一步里有多次撞击时取最重的一次。力度是两者相撞的接近速度乘以相撞时的有效质量,所以在+100 单位一米的场景里,1 kg 的石头以 10 m/s 落下是 1000,同样速度的 50 g 石子是 50。只有碰撞体+时它是静止的,石头撞上来按石头自己的质量算;再加一个动态 `RigidBody3D`,它就能被撞倒,摔下时+按它自己的质量算。石头和罐子的质量用 `RigidBody3D.mass` 设定。把碎块抛出去用的是 `Physics3D.setLinearVelocity(entity, velocity)`,其他需要把刚体送出去的场合(爆炸、踢击)也可以用它。实体还没有刚体时它返回 false,实体刚生成的diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.jsonindex 72c8d99a5..e95204a1d 100644--- a/docs/astro/src/data/apiStability.generated.json+++ b/docs/astro/src/data/apiStability.generated.json@@ -3,10 +3,10 @@"counts": {"public": 115,"beta": 178,- "experimental": 3092,+ "experimental": 3099,"deprecated": 3},- "total": 3385,+ "total": 3392,"subsystems": [{"id": "mobile-controls",diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.jsonindex 4bfc04f28..51b58c62f 100644--- a/docs/astro/src/data/components.generated.json+++ b/docs/astro/src/data/components.generated.json@@ -648,11 +648,11 @@"range": "≥ 0, step 0.5"},{- "key": "breakSpeed",+ "key": "breakImpulse","type": "number","default": "0",- "doc": "A hit at least this fast breaks it, in world units a second; it needs a collider to be hit. 0 breaks it only when Broken is raised.",- "range": "≥ 0, step 10"+ "doc": "A hit at least this hard breaks it: speed times mass, kg by world units a second (1 kg at 10 m/s is 1000 at 100 units to the metre). It needs a collider to be hit. 0 breaks it only when Broken is raised.",+ "range": "≥ 0, step 50"},{"key": "enabled",@@ -666,7 +666,7 @@"origin.y","origin.z","lifetime",- "breakSpeed"+ "breakImpulse"]},{@@ -6632,6 +6632,13 @@"key": "enabled","type": "boolean","default": "true"+ },+ {+ "key": "mass",+ "type": "number",+ "default": "0",+ "doc": "Kilograms. 0 = from its shape at the density of water (a ball of 10 cm radius is 4.2 kg).",+ "range": "≥ 0"}]},diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 31058b842..5c19096cb 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -5,7 +5,7 @@ Symbols: 115 public · 166 beta · 2188 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"cb0184ba3431d6f9"+"08d1bbb8d5e2107c"```## ANCHOR_AXES — const @experimental@@ -1940,7 +1940,7 @@ ComponentDef<BreakableData>## BreakableData — interface @experimental```-breakSpeed: number+breakImpulse: numberbroken: booleanburst: numberenabled: boolean@@ -9326,6 +9326,7 @@ fixedRotation: booleangravityScale: numberlayer: numberlinearDamping: number+mass: number```## Rng — interface @experimentaldiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex c76f1bdc4..067dc818e 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -5,7 +5,7 @@ Symbols: 115 public · 171 beta · 2208 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"cb0184ba3431d6f9"+"08d1bbb8d5e2107c"```## ANCHOR_AXES — const @experimental@@ -1940,7 +1940,7 @@ ComponentDef<BreakableData>## BreakableData — interface @experimental```-breakSpeed: number+breakImpulse: numberbroken: booleanburst: numberenabled: boolean@@ -9555,6 +9555,7 @@ fixedRotation: booleangravityScale: numberlayer: numberlinearDamping: number+mass: number```## Rng — interface @experimentaldiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 21bf965b3..cedf10d44 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -1935,7 +1935,7 @@ ComponentDef<BreakableData>## BreakableData — interface @experimental```-breakSpeed: number+breakImpulse: numberbroken: booleanburst: numberenabled: boolean@@ -9321,6 +9321,7 @@ fixedRotation: booleangravityScale: numberlayer: numberlinearDamping: number+mass: number```## Rng — interface @experimentaldiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex e77e4d91c..a7baa306a 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -1935,7 +1935,7 @@ ComponentDef<BreakableData>## BreakableData — interface @experimental```-breakSpeed: number+breakImpulse: numberbroken: booleanburst: numberenabled: boolean@@ -9618,6 +9618,7 @@ fixedRotation: booleangravityScale: numberlayer: numberlinearDamping: number+mass: number```## Rng — interface @experimentaldiff --git a/sdk/etc/physics3d.api.md b/sdk/etc/physics3d.api.mdindex 305c9abfb..9eafaea7d 100644--- a/sdk/etc/physics3d.api.md+++ b/sdk/etc/physics3d.api.md@@ -134,6 +134,8 @@ rotation: Quat```entityA: numberentityB: number+impulse: number | undefined+mass: number | undefinednormalX: numbernormalY: numbernormalZ: number@@ -360,6 +362,8 @@ _physics3d_addSliderJoint: (entity: number, bodyA: number, bodyB: number, px: nu_physics3d_addSphere: (entity: number, radius: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number, motion: number, gravityScale: number, linearDamping: number, angularDamping: number, fixedRotation: number, layer: number, continuous: number, friction: number, restitution: number, isSensor: number, cx: number, cy: number, cz: number) => number_physics3d_addSwingTwistJoint: (entity: number, bodyA: number, bodyB: number, px: number, py: number, pz: number, ax: number, ay: number, az: number, nx: number, ny: number, nz: number, normalHalf: number, planeHalf: number, twistMin: number, twistMax: number, collideConnected: number) => number_physics3d_addTorque: ((bodyId: number, tx: number, ty: number, tz: number) => void) | undefined+_physics3d_contactEnterMasses: (() => number) | undefined+_physics3d_contactEnterMassesBytes: (() => number) | undefined_physics3d_contactEnterSpeeds: (() => number) | undefined_physics3d_contactEnterSpeedsBytes: (() => number) | undefined_physics3d_contactEnters: () => number@@ -391,6 +395,7 @@ _physics3d_setCharacterPosition: (characterId: number, px: number, py: number, p_physics3d_setJointMotor: (entity: number, enable: number, speed: number) => void_physics3d_setLayerMask: (layer: number, mask: number) => void_physics3d_setLinearVelocity: (bodyId: number, vx: number, vy: number, vz: number) => void+_physics3d_setMass: ((bodyId: number, mass: number) => void) | undefined_physics3d_setSolver: (velocityIterations: number, positionIterations: number, allowSleep: number, bounceThreshold: number) => void_physics3d_setTransform: (bodyId: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number) => void_physics3d_shutdown: () => void@@ -505,6 +510,7 @@ fixedRotation: booleangravityScale: numberlayer: numberlinearDamping: number+mass: number```## Sensor3DEvent — interface @experimentaldiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex ec4772280..ccdaf3bcf 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -1935,7 +1935,7 @@ ComponentDef<BreakableData>## BreakableData — interface @experimental```-breakSpeed: number+breakImpulse: numberbroken: booleanburst: numberenabled: boolean@@ -9328,6 +9328,7 @@ fixedRotation: booleangravityScale: numberlayer: numberlinearDamping: number+mass: number```## Rng — interface @experimentaldiff --git a/sdk/src/breakable/breakable.ts b/sdk/src/breakable/breakable.tsindex 674590de2..9aa7f37e3 100644--- a/sdk/src/breakable/breakable.ts+++ b/sdk/src/breakable/breakable.ts@@ -36,11 +36,12 @@ export interface BreakableData {/** Seconds the pieces last before they are taken away. 0 keeps them. */lifetime: number;/**- * A hit at least this fast breaks it, in world units a second at which the two came together where they met:- * something thrown at it, or it falling on something. 0 breaks it only when `broken` is raised. It needs a- * collider of its own to be hit at all.+ * A hit at least this hard breaks it: the speed at which the two came together times the mass they met with, in+ * kilograms by world units a second. A 1 kg stone landing at 10 m/s, in a scene of 100 units to the metre, is+ * 1000; a pebble of 50 g at the same speed is 50. A thing that falls meets the floor with its own mass. 0 breaks it+ * only when `broken` is raised. It needs a collider of its own to be hit at all.*/- breakSpeed: number;+ breakImpulse: number;enabled: boolean;}@@ -50,7 +51,7 @@ export const Breakable = defineComponent<BreakableData>('Breakable', {burst: 300,origin: { x: 0, y: 0, z: 0 },lifetime: 0,- breakSpeed: 0,+ breakImpulse: 0,enabled: true,}, {assetFields: [{ field: 'pieces', type: 'prefab' }],@@ -60,7 +61,7 @@ export const Breakable = defineComponent<BreakableData>('Breakable', {burst: { min: 0, step: 10, tooltip: 'How fast the pieces leave, in world units a second, out from Origin. 0 lets them fall where they are.' },origin: { tooltip: 'Where it is struck, from its own origin: the pieces fly away from here.' },lifetime: { min: 0, step: 0.5, tooltip: 'Seconds the pieces last before they are taken away. 0 keeps them.' },- breakSpeed: { min: 0, step: 10, tooltip: 'A hit at least this fast breaks it, in world units a second; it needs a collider to be hit. 0 breaks it only when Broken is raised.' },+ breakImpulse: { min: 0, step: 50, tooltip: 'A hit at least this hard breaks it: speed times mass, kg by world units a second (1 kg at 10 m/s is 1000 at 100 units to the metre). It needs a collider to be hit. 0 breaks it only when Broken is raised.' },},});@@ -73,15 +74,15 @@ export function setBodyPusher(push: BodyPusher | null): void {pusher = push;}-type ContactSink = (a: Entity, b: Entity, speed: number, point: Vec3) => void;+type ContactSink = (a: Entity, b: Entity, impulse: number, point: Vec3) => void;const sinks = new Set<ContactSink>();/**- * Two bodies met, closing at `speed` world units a second at `point`: what a 3D world says after each of its steps,- * so that a thing struck hard enough breaks without the world knowing anything breaks.+ * Two bodies met at `point` with `impulse`, kilograms by world units a second: what a 3D world says after each of its+ * steps, so that a thing struck hard enough breaks without the world knowing anything breaks.*/-export function reportContact(a: Entity, b: Entity, speed: number, point: Vec3): void {- for (const sink of sinks) sink(a, b, speed, point);+export function reportContact(a: Entity, b: Entity, impulse: number, point: Vec3): void {+ for (const sink of sinks) sink(a, b, impulse, point);}interface Broken {@@ -155,12 +156,12 @@ export class BreakablePlugin implements Plugin {}, () => { /* breaking says why it cannot, when it is asked to */ });};// Hits are noted as the world steps and acted on in the update after: the step is no place to spawn pieces.- const hits: { entity: Entity; speed: number; point: Vec3 }[] = [];- const sink: ContactSink = (a, b, speed, point) => {+ const hits: { entity: Entity; impulse: number; point: Vec3 }[] = [];+ const sink: ContactSink = (a, b, impulse, point) => {for (const entity of [a, b]) {if (!world.valid(entity) || !world.has(entity, Breakable)) continue;const data = world.get(entity, Breakable) as BreakableData;- if (data.enabled && !data.broken && data.breakSpeed > 0 && speed >= data.breakSpeed) hits.push({ entity, speed, point });+ if (data.enabled && !data.broken && data.breakImpulse > 0 && impulse >= data.breakImpulse) hits.push({ entity, impulse, point });}};sinks.add(sink);@@ -218,8 +219,8 @@ export class BreakablePlugin implements Plugin {const prefabs = app.hasResource(Prefabs) ? app.getResource(Prefabs) : null;// Struck hard enough: it breaks from where it was hit, the hardest hit if there were several.if (hits.length) {- const hardest = new Map<Entity, { speed: number; point: Vec3 }>();- for (const h of hits) if ((hardest.get(h.entity)?.speed ?? -1) < h.speed) hardest.set(h.entity, h);+ const hardest = new Map<Entity, { impulse: number; point: Vec3 }>();+ for (const h of hits) if ((hardest.get(h.entity)?.impulse ?? -1) < h.impulse) hardest.set(h.entity, h);hits.length = 0;for (const [entity, h] of hardest) {if (!world.valid(entity) || !world.has(entity, Breakable)) continue;diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.tsindex e7e7a9eaf..f046a6ce5 100644--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts@@ -1878,6 +1878,7 @@ export interface RigidBody3DPtrData {gravityScale: number;linearDamping: number;angularDamping: number;+ mass: number;fixedRotation: boolean;layer: number;continuousCollision: boolean;@@ -1892,10 +1893,11 @@ export function fillRigidBody3D(out.gravityScale = f32[(ptr + 4) >> 2];out.linearDamping = f32[(ptr + 8) >> 2];out.angularDamping = f32[(ptr + 12) >> 2];- out.fixedRotation = u8[ptr + 16] !== 0;- out.layer = u32[(ptr + 20) >> 2];- out.continuousCollision = u8[ptr + 24] !== 0;- out.enabled = u8[ptr + 25] !== 0;+ out.mass = f32[(ptr + 16) >> 2];+ out.fixedRotation = u8[ptr + 20] !== 0;+ out.layer = u32[(ptr + 24) >> 2];+ out.continuousCollision = u8[ptr + 28] !== 0;+ out.enabled = u8[ptr + 29] !== 0;}export function writeRigidBody3D(@@ -1906,10 +1908,11 @@ export function writeRigidBody3D(f32[(ptr + 4) >> 2] = data.gravityScale;f32[(ptr + 8) >> 2] = data.linearDamping;f32[(ptr + 12) >> 2] = data.angularDamping;- u8[ptr + 16] = data.fixedRotation ? 1 : 0;- u32[(ptr + 20) >> 2] = data.layer;- u8[ptr + 24] = data.continuousCollision ? 1 : 0;- u8[ptr + 25] = data.enabled ? 1 : 0;+ f32[(ptr + 16) >> 2] = data.mass;+ u8[ptr + 20] = data.fixedRotation ? 1 : 0;+ u32[(ptr + 24) >> 2] = data.layer;+ u8[ptr + 28] = data.continuousCollision ? 1 : 0;+ u8[ptr + 29] = data.enabled ? 1 : 0;}export function createRigidBody3DData(): RigidBody3DPtrData {@@ -1918,6 +1921,7 @@ export function createRigidBody3DData(): RigidBody3DPtrData {gravityScale: 0,linearDamping: 0,angularDamping: 0,+ mass: 0,fixedRotation: false,layer: 0,continuousCollision: false,diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.tsindex c1032e036..787b5cf9f 100644--- a/sdk/src/ecs/component.generated.ts+++ b/sdk/src/ecs/component.generated.ts@@ -15,7 +15,7 @@ import type { AlignContent, AlignItems, AlignSelf, BillboardMode, BodyType, Canv* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to* run on mismatch, because mismatched offsets read the wrong heap bytes.*/-export const ABI_LAYOUT_HASH = 'cb0184ba3431d6f9';+export const ABI_LAYOUT_HASH = '08d1bbb8d5e2107c';/*** One asset-valued field of a component: which field, and what kind of@@ -1019,6 +1019,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {gravityScale: 1,linearDamping: 0.05,angularDamping: 0.05,+ mass: 0,fixedRotation: false,layer: 0,continuousCollision: false,@@ -1033,6 +1034,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {gravityScale: { min: 0 },linearDamping: { min: 0 },angularDamping: { min: 0 },+ mass: { min: 0, tooltip: "Kilograms. 0 = from its shape at the density of water (a ball of 10 cm radius is 4.2 kg)." },layer: { min: 0, max: 15, advanced: true },continuousCollision: { advanced: true },},@@ -1993,6 +1995,7 @@ export interface RigidBody3DData {gravityScale: number;linearDamping: number;angularDamping: number;+ mass: number;fixedRotation: boolean;layer: number;continuousCollision: boolean;diff --git a/sdk/src/physics3d/Physics3DComponents.ts b/sdk/src/physics3d/Physics3DComponents.tsindex 3480699e3..528764357 100644--- a/sdk/src/physics3d/Physics3DComponents.ts+++ b/sdk/src/physics3d/Physics3DComponents.ts@@ -27,8 +27,10 @@ export const RigidBody3D = defineBuiltin<RigidBody3DData>('RigidBody3D', {fixedRotation: false,continuousCollision: false,enabled: true,+ mass: 0,}, {fields: {+ mass: { min: 0, tooltip: 'Kilograms. 0 = from its shape at the density of water (a ball of 10 cm radius is 4.2 kg).' },linearDamping: { min: 0, advanced: true },angularDamping: { min: 0, advanced: true },fixedRotation: { advanced: true },diff --git a/sdk/src/physics3d/Physics3DModule.ts b/sdk/src/physics3d/Physics3DModule.tsindex b02c19d40..dbe1b5cde 100644--- a/sdk/src/physics3d/Physics3DModule.ts+++ b/sdk/src/physics3d/Physics3DModule.ts@@ -144,6 +144,11 @@ export interface Physics3DWasmModule {/** Optional for older binaries: one closing speed for each contact begun. */_physics3d_contactEnterSpeeds?(): number;_physics3d_contactEnterSpeedsBytes?(): number;+ /** Optional for older binaries: the mass, in kilograms, each contact begun met with. */+ _physics3d_contactEnterMasses?(): number;+ _physics3d_contactEnterMassesBytes?(): number;+ /** Optional for older binaries: a moving body's mass in kilograms. */+ _physics3d_setMass?(bodyId: number, mass: number): void;_physics3d_contactExits(): number;_physics3d_contactExitsBytes(): number;_physics3d_sensorEnters(): number;@@ -220,6 +225,16 @@ export interface Contact3DEvent {* answered: a ball dropped on a floor from a metre lands at about 4.4 m/s. Undefined from a binary too old to say.*/speed?: number;+ /**+ * The mass they met with, in kilograms: 1 / (1/a + 1/b), where a body that does not move counts as having no+ * inverse mass, so a stone landing on a floor meets it with the stone's own. Infinity where neither moves of itself.+ */+ mass?: number;+ /**+ * How hard: `speed` times `mass`, in kilograms by world units a second, the push it takes to stop the two coming+ * together. A 1 kg stone landing at 10 m/s in a scene of 100 units to the metre is 1000.+ */+ impulse?: number;}/** A sensor was entered or left. The SENSOR is always named first. */@@ -279,6 +294,16 @@ export function drainPhysics3DEvents(module: Physics3DWasmModule,// One for each contact, in its order; a count that does not match is a binary that writes something else.if (speeds.length === events.contactEnters.length) events.contactEnters.forEach((c, i) => { c.speed = speeds[i]! * pixelsPerUnit; });}+ if (module._physics3d_contactEnterMasses && module._physics3d_contactEnterMassesBytes) {+ const masses = read(module._physics3d_contactEnterMasses(), module._physics3d_contactEnterMassesBytes(), 1, (o) => f32[o]!);+ if (masses.length === events.contactEnters.length) {+ events.contactEnters.forEach((c, i) => {+ c.mass = masses[i]!;+ // Nothing pushes at no speed, however heavy: an unmoving pair is no blow.+ if (c.speed !== undefined) c.impulse = c.speed > 0 ? c.speed * c.mass : 0;+ });+ }+ }events.contactExits = read(module._physics3d_contactExits(), module._physics3d_contactExitsBytes(), 2,(o) => ({ entityA: f32[o] as Entity, entityB: f32[o + 1] as Entity }));diff --git a/sdk/src/physics3d/Physics3DPlugin.ts b/sdk/src/physics3d/Physics3DPlugin.tsindex 66810870f..dd56f93b5 100644--- a/sdk/src/physics3d/Physics3DPlugin.ts+++ b/sdk/src/physics3d/Physics3DPlugin.ts@@ -91,7 +91,7 @@ export class Physics3DPlugin implements Plugin {runtime.characters, events, runtime.joints, runtime.pieces,app.hasResource(CollisionGeometryRes) ? app.getResource(CollisionGeometryRes) : null);// What met what, and how hard: told to whatever breaks, which knows nothing of the solver.- for (const c of events.contactEnters) if (c.speed !== undefined) reportContact(c.entityA, c.entityB, c.speed, { x: c.pointX, y: c.pointY, z: c.pointZ });+ for (const c of events.contactEnters) if (c.impulse !== undefined) reportContact(c.entityA, c.entityB, c.impulse, { x: c.pointX, y: c.pointY, z: c.pointZ });}, { name: 'Physics3DStepSystem' }), { profileDomain: 'physics3d' });// Installed with the world, drawn only once a game turns the resource// on — a scene that never asks for it pays a resource and nothing else.diff --git a/sdk/src/physics3d/Physics3DSystem.ts b/sdk/src/physics3d/Physics3DSystem.tsindex 3380def2d..032de77f3 100644--- a/sdk/src/physics3d/Physics3DSystem.ts+++ b/sdk/src/physics3d/Physics3DSystem.ts@@ -383,8 +383,10 @@ const IMPLICIT_STATIC_COLLIDERS = [MeshCollider3D, BoxCollider3D, SphereColliderconst implicitBodies = new WeakMap<BodyMap, Set<Entity>>();const IMPLICIT_STATIC: RigidBody3DData = {bodyType: 0, layer: 0, gravityScale: 0, linearDamping: 0, angularDamping: 0,- fixedRotation: false, continuousCollision: false, enabled: true,+ fixedRotation: false, continuousCollision: false, enabled: true, mass: 0,};+/** Per body map: the mass last given to each body that was given one, so a change in play reaches the world. */+const givenMasses = new WeakMap<BodyMap, Map<Entity, number>>();/** Bring the world's population in line with the ECS, then step and read back. */export function stepPhysics3D(app: App, module: Physics3DWasmModule,@@ -420,6 +422,8 @@ export function stepPhysics3D(app: App, module: Physics3DWasmModule,}const implicit = implicitBodies.get(bodies) ?? new Set<Entity>();implicitBodies.set(bodies, implicit);+ const given = givenMasses.get(bodies) ?? new Map<Entity, number>();+ givenMasses.set(bodies, given);for (const [entity, body] of bodied) {if (!body.enabled || live.has(entity)) continue;live.add(entity);@@ -435,6 +439,14 @@ export function stepPhysics3D(app: App, module: Physics3DWasmModule,if (created) {const id = createBody(app, module, entity, body, ppu);if (id !== 0) bodies.set(entity, id);+ given.delete(entity);+ }+ // Its own mass where it says one; 0 leaves the one its shape gives. Read each step, as gravityScale is not:+ // what a thing weighs is something a game changes while it runs (a crate emptied, a barrel filled).+ const mass = body.mass ?? 0;+ if (bodies.has(entity) && body.bodyType === MOTION.Dynamic && mass > 0 && given.get(entity) !== mass) {+ module._physics3d_setMass?.(bodies.get(entity)!, mass);+ given.set(entity, mass);}if (body.bodyType !== MOTION.Dynamic && bodies.has(entity) && app.world.has(entity, Transform)) {const t = app.world.get(entity, Transform), p = t.worldPosition, r = t.worldRotation;@@ -457,6 +469,7 @@ export function stepPhysics3D(app: App, module: Physics3DWasmModule,module._physics3d_removeBody(bodies.get(entity)!);bodies.delete(entity);poses.delete(entity);+ given.delete(entity);}syncPieces(app, module, geometry, pieces, bodies, ppu);diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.tsindex d219c9fe9..d57729955 100644--- a/sdk/src/wasm/ptrLayouts.generated.ts+++ b/sdk/src/wasm/ptrLayouts.generated.ts@@ -500,10 +500,11 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {{ name: 'gravityScale', type: 'f32', offset: 4 },{ name: 'linearDamping', type: 'f32', offset: 8 },{ name: 'angularDamping', type: 'f32', offset: 12 },- { name: 'fixedRotation', type: 'bool', offset: 16 },- { name: 'layer', type: 'u32', offset: 20 },- { name: 'continuousCollision', type: 'bool', offset: 24 },- { name: 'enabled', type: 'bool', offset: 25 },+ { name: 'mass', type: 'f32', offset: 16 },+ { name: 'fixedRotation', type: 'bool', offset: 20 },+ { name: 'layer', type: 'u32', offset: 24 },+ { name: 'continuousCollision', type: 'bool', offset: 28 },+ { name: 'enabled', type: 'bool', offset: 29 },],},SegmentCollider2D: {diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.tsindex 724c2e020..65844cdb5 100644--- a/sdk/src/wasm/wasm.generated.ts+++ b/sdk/src/wasm/wasm.generated.ts@@ -909,6 +909,7 @@ export interface RigidBody3D {gravityScale: number;linearDamping: number;angularDamping: number;+ mass: number;fixedRotation: boolean;layer: number;continuousCollision: boolean;diff --git a/sdk/tests/breakable.test.ts b/sdk/tests/breakable.test.tsindex 6a355e2ef..2e3d9fb1d 100644--- a/sdk/tests/breakable.test.ts+++ b/sdk/tests/breakable.test.ts@@ -180,9 +180,9 @@ describe('a thing that breaks', () => {expect(app.world.valid(made[1]!.root)).toBe(true);});- it('breaks when struck at least as fast as its breakSpeed, from where it was struck', async () => {+ it('breaks when struck at least as hard as its breakImpulse, from where it was struck', async () => {const { app, whole, prefabs, tick } = setup();- app.world.update(whole, Breakable, (d) => { d.breakSpeed = 400; });+ app.world.update(whole, Breakable, (d) => { d.breakImpulse = 400; });const other = app.world.spawn('Ball');// Too soft: a ball rolled into it.reportContact(other, whole, 120, { x: 110, y: 50, z: 0 });@@ -203,7 +203,7 @@ describe('a thing that breaks', () => {expect(prefabs.instantiate).toHaveBeenCalledTimes(1);});- it('is not broken by a hit when it has no breakSpeed, however hard', async () => {+ it('is not broken by a hit when it has no breakImpulse, however hard', async () => {const { app, whole, prefabs, tick } = setup();reportContact(app.world.spawn('Boulder'), whole, 1e6, { x: 100, y: 50, z: 0 });await tick(2);diff --git a/sdk/tests/physics3d-ecs.test.ts b/sdk/tests/physics3d-ecs.test.tsindex f7c5b2452..d89e5648e 100644--- a/sdk/tests/physics3d-ecs.test.ts+++ b/sdk/tests/physics3d-ecs.test.ts@@ -24,7 +24,7 @@ import {PointJoint3D, HingeJoint3D, SliderJoint3D, FixedJoint3D, SwingTwistJoint3D, SixDOFJoint3D,type Joint3DMap, type HingeJoint3DData, type SliderJoint3DData, type SixDOFJoint3DData, type SwingTwistJoint3DData,} from '../src/physics3d/Physics3DJoints';-import type { Physics3DWasmModule } from '../src/physics3d/Physics3DModule';+import { drainPhysics3DEvents, type Physics3DEventsData, type Physics3DWasmModule } from '../src/physics3d/Physics3DModule';import type { App } from '../src/app/app';import type { Entity } from '../src/types';import { sceneUses3DPhysics, sceneUsesPhysics } from '../src/runtime/runtimeLoader';@@ -98,6 +98,7 @@ function fakeModule(): Physics3DWasmModule & {_physics3d_setAdvancedJointMotor: record('setAdvancedJointMotor'),_physics3d_removeJoint: record('removeJoint'),_physics3d_setJointMotor: record('setJointMotor'),+ _physics3d_setMass: record('setMass'),_physics3d_jointValue: (entity: number) => { calls.push({ name: 'jointValue', args: [entity] }); return 0.25; },// Distinct allocations, as a real heap gives: one address for everything// let the index write land on top of the vertex write.@@ -233,6 +234,44 @@ describe('the 3D world and the ECS', () => {expect(bodies.size).toBe(3);});+ it('gives a moving body the mass it says, and a new one when it changes in play', () => {+ const light = spawn();+ world.insert(light, SphereCollider3D);+ world.insert(light, RigidBody3D, { bodyType: 2, mass: 0.05 });+ const plain = spawn();+ world.insert(plain, SphereCollider3D);+ const wall = spawn();+ world.insert(wall, BoxCollider3D);+ world.insert(wall, RigidBody3D, { bodyType: 0, mass: 900 });++ stepPhysics3D(app, module, bodies, DEFAULT_PHYSICS3D_CONFIG);+ stepPhysics3D(app, module, bodies, DEFAULT_PHYSICS3D_CONFIG);+ // Once, and only to the body that moves and says a mass; the others keep what their shape gives.+ expect(called('setMass').map((c) => c.args)).toEqual([[bodies.get(light)!, 0.05]]);++ world.update(light, RigidBody3D, (b: { mass: number }) => { b.mass = 3; });+ stepPhysics3D(app, module, bodies, DEFAULT_PHYSICS3D_CONFIG);+ expect(called('setMass').map((c) => c.args)).toEqual([[bodies.get(light)!, 0.05], [bodies.get(light)!, 3]]);+ });++ it('reads how hard two bodies met: speed by the mass they met with', () => {+ const a = spawn(), b = spawn();+ module.publishContacts([a, b, 0, 1, 0, 0, 0, 0]);+ const speeds = new Float32Array([4]);+ const masses = new Float32Array([2.5]);+ const speedAt = 3000 * 4, massAt = 3008 * 4;+ module.HEAPF32.set(speeds, speedAt / 4);+ module.HEAPF32.set(masses, massAt / 4);+ Object.assign(module, {+ _physics3d_contactEnterSpeeds: () => speedAt, _physics3d_contactEnterSpeedsBytes: () => 4,+ _physics3d_contactEnterMasses: () => massAt, _physics3d_contactEnterMassesBytes: () => 4,+ });+ const events = { contactEnters: [], contactExits: [], sensorEnters: [], sensorExits: [] } as Physics3DEventsData;+ drainPhysics3DEvents(module, events, 100);+ // In world units a second, at 100 to the metre; the mass is kilograms whatever the units.+ expect(events.contactEnters[0]).toMatchObject({ speed: 400, mass: 2.5, impulse: 1000 });+ });+it('registers nothing for a body with no shape', () => {spawn();stepPhysics3D(app, module, bodies, DEFAULT_PHYSICS3D_CONFIG);diff --git a/sdk/tests/physics3d-smoke.mjs b/sdk/tests/physics3d-smoke.mjsindex 96112ce4e..957f87609 100644--- a/sdk/tests/physics3d-smoke.mjs+++ b/sdk/tests/physics3d-smoke.mjs@@ -309,12 +309,14 @@ const dropId = m._physics3d_addSphere(DROP, 0.5, 20, 2, 0, ...IDENTITY,m._physics3d_optimize();let landing = null;let landingSpeed = null;+let landingMass = null;for (let i = 0; i < 180 && !landing; i++) {step(1);const enters = contactEnters();const at = enters.findIndex((e) => e[1] === DROP || e[0] === DROP);landing = at >= 0 ? enters[at] : null;if (landing) landingSpeed = pairs('_physics3d_contactEnterSpeeds', '_physics3d_contactEnterSpeedsBytes', 1)[at]?.[0] ?? null;+ if (landing) landingMass = pairs('_physics3d_contactEnterMasses', '_physics3d_contactEnterMassesBytes', 1)[at]?.[0] ?? null;}check('a contact names both entities', landing != null&& (landing[0] === PAD || landing[1] === PAD), JSON.stringify(landing));@@ -325,6 +327,21 @@ check('and where they met', landing != null && near(landing[6], 0.0, 0.15),check('a contact says how fast the two came together', landingSpeed != null && near(Math.abs(landingSpeed), Math.sqrt(2 * 9.81 * 1.5), 0.35) && landingSpeed > 0,`speed=${landingSpeed?.toFixed(3)} want +${Math.sqrt(2 * 9.81 * 1.5).toFixed(3)}`);check('one speed for each contact', m._physics3d_contactEnterSpeedsBytes() / 4 === m._physics3d_contactEntersBytes() / 32);+// And with what mass: a 0.5 m sphere at the density of water is 523.6 kg, and the pad does not move, so the two meet+// with the sphere's own.+check('a contact says the mass the two met with', landingMass != null && near(landingMass, 4 / 3 * Math.PI * 0.125 * 1000, 2),+ `mass=${landingMass?.toFixed(2)} want ${(4 / 3 * Math.PI * 0.125 * 1000).toFixed(2)}`);+check('one mass for each contact', m._physics3d_contactEnterMassesBytes() / 4 === m._physics3d_contactEntersBytes() / 32);+// A body given a mass of its own has it.+const LIGHT = 22;+const lightId = m._physics3d_addSphere(LIGHT, 0.5, 30, 2, 0, ...IDENTITY, ...FREE(DYNAMIC), 0.5, 0, 0);+m._physics3d_setMass(lightId, 2);+const lightMass = m._physics3d_getBodyDynamics(lightId) ? m.HEAPF32[m._physics3d_queryResult() >> 2] : null;+check('a body can be given its own mass', lightMass != null && near(lightMass, 2, 1e-3), `mass=${lightMass}`);+m._physics3d_setMass(lightId, -1);+const keptMass = m._physics3d_getBodyDynamics(lightId) ? m.HEAPF32[m._physics3d_queryResult() >> 2] : null;+check('and a mass that is no mass is refused', keptMass != null && near(keptMass, 2, 1e-3), `mass=${keptMass}`);+m._physics3d_removeBody(lightId);// A buffer holds ONE step's events, so they are collected as the steps run —// reading after a run of steps catches only the last one's.const collect = (read, steps) => {diff --git a/src/esengine/aot/EngineDigest.generated.h b/src/esengine/aot/EngineDigest.generated.hindex 338bbeec6..60eb7e08f 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 0x7b92719069728377ULL-#define ES_ENGINE_ABI_DIGEST_64 0x97a52221ac92f3abULL+#define ES_ENGINE_ABI_DIGEST_32 0xc399cbaff9d6f7ceULL+#define ES_ENGINE_ABI_DIGEST_64 0xc34abad701e12e82ULL#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 95ea2cc75..9f704c52e 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 d9d5bdcc4536d5bd+ * @schema_hash 3cc1f95c10724533*/-#define ES_EDITOR_API_SCHEMA_HASH "d9d5bdcc4536d5bd"+#define ES_EDITOR_API_SCHEMA_HASH "3cc1f95c10724533"#include <emscripten/bind.h>#include <string>@@ -642,6 +642,7 @@ std::string editor_getComponentSchema(const std::string& name) {{"key":"gravityScale","type":"float","group":"RigidBody3D"},{"key":"linearDamping","type":"float","group":"RigidBody3D"},{"key":"angularDamping","type":"float","group":"RigidBody3D"},+ {"key":"mass","type":"float","group":"RigidBody3D"},{"key":"fixedRotation","type":"bool","group":"RigidBody3D"},{"key":"layer","type":"int","group":"RigidBody3D"},{"key":"continuousCollision","type":"bool","group":"RigidBody3D"},@@ -1765,6 +1766,7 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::sif (field == "gravityScale") { c.gravityScale = value; }else if (field == "linearDamping") { c.linearDamping = value; }else if (field == "angularDamping") { c.angularDamping = value; }+ else if (field == "mass") { c.mass = value; }else { return false; }return true;} else if (comp == "SegmentCollider2D") {@@ -2363,6 +2365,7 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::stif (field == "gravityScale") { return c.gravityScale; }else if (field == "linearDamping") { return c.linearDamping; }else if (field == "angularDamping") { return c.angularDamping; }+ else if (field == "mass") { return c.mass; }} else if (comp == "SegmentCollider2D") {if (!reg.has<esengine::ecs::SegmentCollider2D>(entity)) return 0.0f;const auto& c = reg.get<esengine::ecs::SegmentCollider2D>(entity);diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex 1fd10dfd9..f8571152c 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -1332,6 +1332,7 @@ struct RigidBody3DJS {f32 gravityScale;f32 linearDamping;f32 angularDamping;+ f32 mass;bool fixedRotation;u32 layer;bool continuousCollision;@@ -1343,6 +1344,7 @@ void rigidbody3dApplyJS(esengine::ecs::RigidBody3D& c, const RigidBody3DJS& js)c.gravityScale = js.gravityScale;c.linearDamping = js.linearDamping;c.angularDamping = js.angularDamping;+ c.mass = js.mass;c.fixedRotation = js.fixedRotation;c.layer = js.layer;c.continuousCollision = js.continuousCollision;@@ -1361,6 +1363,7 @@ RigidBody3DJS rigidbody3dToJS(const esengine::ecs::RigidBody3D& c) {js.gravityScale = c.gravityScale;js.linearDamping = c.linearDamping;js.angularDamping = c.angularDamping;+ js.mass = c.mass;js.fixedRotation = c.fixedRotation;js.layer = c.layer;js.continuousCollision = c.continuousCollision;@@ -2265,6 +2268,7 @@ EMSCRIPTEN_BINDINGS(esengine_components) {.field("gravityScale", &RigidBody3DJS::gravityScale).field("linearDamping", &RigidBody3DJS::linearDamping).field("angularDamping", &RigidBody3DJS::angularDamping)+ .field("mass", &RigidBody3DJS::mass).field("fixedRotation", &RigidBody3DJS::fixedRotation).field("layer", &RigidBody3DJS::layer).field("continuousCollision", &RigidBody3DJS::continuousCollision)@@ -4273,10 +4277,11 @@ static_assert(offsetof(esengine::ecs::RigidBody3D, bodyType) == 0, "ABI offset dstatic_assert(offsetof(esengine::ecs::RigidBody3D, gravityScale) == 4, "ABI offset drift: esengine::ecs::RigidBody3D.gravityScale (EHT expected 4)");static_assert(offsetof(esengine::ecs::RigidBody3D, linearDamping) == 8, "ABI offset drift: esengine::ecs::RigidBody3D.linearDamping (EHT expected 8)");static_assert(offsetof(esengine::ecs::RigidBody3D, angularDamping) == 12, "ABI offset drift: esengine::ecs::RigidBody3D.angularDamping (EHT expected 12)");-static_assert(offsetof(esengine::ecs::RigidBody3D, fixedRotation) == 16, "ABI offset drift: esengine::ecs::RigidBody3D.fixedRotation (EHT expected 16)");-static_assert(offsetof(esengine::ecs::RigidBody3D, layer) == 20, "ABI offset drift: esengine::ecs::RigidBody3D.layer (EHT expected 20)");-static_assert(offsetof(esengine::ecs::RigidBody3D, continuousCollision) == 24, "ABI offset drift: esengine::ecs::RigidBody3D.continuousCollision (EHT expected 24)");-static_assert(offsetof(esengine::ecs::RigidBody3D, enabled) == 25, "ABI offset drift: esengine::ecs::RigidBody3D.enabled (EHT expected 25)");+static_assert(offsetof(esengine::ecs::RigidBody3D, mass) == 16, "ABI offset drift: esengine::ecs::RigidBody3D.mass (EHT expected 16)");+static_assert(offsetof(esengine::ecs::RigidBody3D, fixedRotation) == 20, "ABI offset drift: esengine::ecs::RigidBody3D.fixedRotation (EHT expected 20)");+static_assert(offsetof(esengine::ecs::RigidBody3D, layer) == 24, "ABI offset drift: esengine::ecs::RigidBody3D.layer (EHT expected 24)");+static_assert(offsetof(esengine::ecs::RigidBody3D, continuousCollision) == 28, "ABI offset drift: esengine::ecs::RigidBody3D.continuousCollision (EHT expected 28)");+static_assert(offsetof(esengine::ecs::RigidBody3D, enabled) == 29, "ABI offset drift: esengine::ecs::RigidBody3D.enabled (EHT expected 29)");static_assert(offsetof(esengine::ecs::SegmentCollider2D, point1) == 0, "ABI offset drift: esengine::ecs::SegmentCollider2D.point1 (EHT expected 0)");static_assert(offsetof(esengine::ecs::SegmentCollider2D, point2) == 8, "ABI offset drift: esengine::ecs::SegmentCollider2D.point2 (EHT expected 8)");static_assert(offsetof(esengine::ecs::SegmentCollider2D, density) == 16, "ABI offset drift: esengine::ecs::SegmentCollider2D.density (EHT expected 16)");@@ -4441,7 +4446,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "cb0184ba3431d6f9";+static const char* kEsAbiLayoutHash = "08d1bbb8d5e2107c";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/bindings/modules/physics3d/Physics3DBindings.hpp b/src/esengine/bindings/modules/physics3d/Physics3DBindings.hppindex 9bae9ec0a..8f30fba12 100644--- a/src/esengine/bindings/modules/physics3d/Physics3DBindings.hpp+++ b/src/esengine/bindings/modules/physics3d/Physics3DBindings.hpp@@ -87,6 +87,9 @@ void physics3d_removeBody(uint32_t bodyId);void physics3d_setTransform(uint32_t bodyId, float px, float py, float pz,float qx, float qy, float qz, float qw);void physics3d_setLinearVelocity(uint32_t bodyId, float vx, float vy, float vz);+// A moving body's mass, in kilograms, its inertia scaled with it so it turns as its shape says; nothing for a body+// that does not move, or a mass that is not a positive number.+void physics3d_setMass(uint32_t bodyId, float mass);int physics3d_getBodyState(uint32_t bodyId);// What a force needs to know of a body: its mass and how it is turning.int physics3d_getBodyDynamics(uint32_t bodyId);@@ -164,6 +167,12 @@ size_t physics3d_contactEntersBytes();// @heapreturn physics3d_contactEnterSpeedsBytes()uintptr_t physics3d_contactEnterSpeeds();size_t physics3d_contactEnterSpeedsBytes();+// The mass the two met with at each contact begun this step, in kilograms: 1 / (1/a + 1/b), a body that does not move+// counting as one of no inverse mass, so a stone on a floor meets it with the stone's own mass. Infinite where neither+// moves of itself (a kinematic body into a static one). One float for each entry of physics3d_contactEnters.+// @heapreturn physics3d_contactEnterMassesBytes()+uintptr_t physics3d_contactEnterMasses();+size_t physics3d_contactEnterMassesBytes();// @heapreturn physics3d_contactExitsBytes()uintptr_t physics3d_contactExits();size_t physics3d_contactExitsBytes();diff --git a/src/esengine/bindings/modules/physics3d/Physics3DContext.hpp b/src/esengine/bindings/modules/physics3d/Physics3DContext.hppindex db24c4490..dda71caf6 100644--- a/src/esengine/bindings/modules/physics3d/Physics3DContext.hpp+++ b/src/esengine/bindings/modules/physics3d/Physics3DContext.hpp@@ -130,6 +130,8 @@ struct Context {std::vector<float> contactEnterBuffer;/** One closing speed for each contact in contactEnterBuffer. */std::vector<float> contactEnterSpeedBuffer;+ /** One meeting mass, in kilograms, for each contact in contactEnterBuffer. */+ std::vector<float> contactEnterMassBuffer;std::vector<float> contactExitBuffer;std::vector<float> sensorEnterBuffer;std::vector<float> sensorExitBuffer;diff --git a/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp b/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cppindex 9c432a5ed..67b0c9371 100644--- a/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp+++ b/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp@@ -31,6 +31,7 @@#include <Jolt/Physics/Collision/CollisionCollectorImpl.h>#include <Jolt/Physics/Collision/CollisionDispatch.h>#include <Jolt/Physics/Collision/ContactListener.h>+#include <limits>#include <Jolt/Physics/Collision/ShapeCast.h>#include <Jolt/RegisterTypes.h>@@ -131,6 +132,10 @@ public:// the first into the second, so the first closing on the second is a positive speed.const Vec3 closing = body1.GetPointVelocity(point) - body2.GetPointVelocity(point);g().contactEnterSpeedBuffer.push_back(closing.Dot(normal));+ // A static or kinematic body is pushed by nothing: it gives no inverse mass to the meeting.+ const auto inverse = [](const Body& body) { return body.IsDynamic() ? body.GetMotionProperties()->GetInverseMass() : 0.0f; };+ const float both = inverse(body1) + inverse(body2);+ g().contactEnterMassBuffer.push_back(both > 0.0f ? 1.0f / both : std::numeric_limits<float>::infinity());}void OnContactRemoved(const SubShapeIDPair& pair) override {@@ -246,6 +251,7 @@ void physics3d_shutdown() {g().sensorBodies.clear();g().contactEnterBuffer.clear();g().contactEnterSpeedBuffer.clear();+ g().contactEnterMassBuffer.clear();g().contactExitBuffer.clear();g().sensorEnterBuffer.clear();g().sensorExitBuffer.clear();@@ -295,6 +301,7 @@ void physics3d_step(float dt, int collisionSteps) {// buffer emptied afterwards would publish nothing.g().contactEnterBuffer.clear();g().contactEnterSpeedBuffer.clear();+ g().contactEnterMassBuffer.clear();g().contactExitBuffer.clear();g().sensorEnterBuffer.clear();g().sensorExitBuffer.clear();@@ -516,6 +523,19 @@ void physics3d_setLinearVelocity(uint32_t bodyId, float vx, float vy, float vz)g().system->GetBodyInterface().SetLinearVelocity(BodyID(bodyId), Vec3(vx, vy, vz));}+EMSCRIPTEN_KEEPALIVE+void physics3d_setMass(uint32_t bodyId, float mass) {+ if (!g().isValid() || bodyId == 0 || !(mass > 0.0f) || !std::isfinite(mass)) return;+ const BodyLockWrite lock(g().system->GetBodyLockInterface(), BodyID(bodyId));+ if (!lock.Succeeded() || !lock.GetBody().IsDynamic()) return;+ Body& body = lock.GetBody();+ // The shape's own mass properties, as the density gave them, brought to the mass asked: its inertia comes along.+ MassProperties props = body.GetShape()->GetMassProperties();+ props.ScaleToMass(mass);+ MotionProperties* motion = body.GetMotionProperties();+ motion->SetMassProperties(motion->GetAllowedDOFs(), props);+}+/// Writes (px,py,pz, qx,qy,qz,qw, vx,vy,vz) into the query buffer; 0 when the body/// is gone. One body's state, for a caller that wants it outside the step readback.EMSCRIPTEN_KEEPALIVE@@ -908,6 +928,16 @@ size_t physics3d_transformsBytes() {return g().transformBuffer.size() * sizeof(float);}+EMSCRIPTEN_KEEPALIVE+uintptr_t physics3d_contactEnterMasses() {+ return reinterpret_cast<uintptr_t>(g().contactEnterMassBuffer.data());+}++EMSCRIPTEN_KEEPALIVE+size_t physics3d_contactEnterMassesBytes() {+ return g().contactEnterMassBuffer.size() * sizeof(float);+}+EMSCRIPTEN_KEEPALIVEuintptr_t physics3d_contactEnterSpeeds() {return reinterpret_cast<uintptr_t>(g().contactEnterSpeedBuffer.data());diff --git a/src/esengine/bindings/modules/physics3d_physx/PhysXModuleEntry.cpp b/src/esengine/bindings/modules/physics3d_physx/PhysXModuleEntry.cppindex 41fce39ae..99f83a039 100644--- a/src/esengine/bindings/modules/physics3d_physx/PhysXModuleEntry.cpp+++ b/src/esengine/bindings/modules/physics3d_physx/PhysXModuleEntry.cpp@@ -22,6 +22,7 @@#include <algorithm>#include <cmath>#include <cstring>+#include <limits>using namespace physx;using esengine::physics3d_physx::Body;@@ -115,6 +116,16 @@ PxVec3 pointVelocity(const PxContactPairHeader& header, int side, const PxContacreturn velocity;}+/** What one side gives the meeting: 0 for a static or kinematic actor, or one that has been removed. */+float inverseMass(const PxContactPairHeader& header, int side) {+ const PxContactPairHeaderFlag::Enum removed = side == 0 ? PxContactPairHeaderFlag::eREMOVED_ACTOR_0 : PxContactPairHeaderFlag::eREMOVED_ACTOR_1;+ const PxActor* actor = header.actors[side];+ if ((header.flags & removed) || !actor) return 0.0f;+ const PxRigidDynamic* body = actor->is<PxRigidDynamic>();+ if (!body || (body->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC)) return 0.0f;+ return body->getInvMass();+}+/** Records what touched what, in the layouts the Jolt module writes. */class ContactRecorder final : public PxSimulationEventCallback {public:@@ -154,6 +165,8 @@ public:closing = (at[0] - at[1]).dot(normal);}g().contactEnterSpeedBuffer.push_back(closing);+ const float both = inverseMass(header, 0) + inverseMass(header, 1);+ g().contactEnterMassBuffer.push_back(both > 0.0f ? 1.0f / both : std::numeric_limits<float>::infinity());}if (pair.events & PxPairFlag::eNOTIFY_TOUCH_LOST) {g().contactExitBuffer.push_back(static_cast<float>(a));@@ -377,6 +390,7 @@ void physics3d_shutdown() {g().queryBuffer.clear();g().contactEnterBuffer.clear();g().contactEnterSpeedBuffer.clear();+ g().contactEnterMassBuffer.clear();g().contactExitBuffer.clear();g().sensorEnterBuffer.clear();g().sensorExitBuffer.clear();@@ -404,6 +418,7 @@ void physics3d_step(float dt, int collisionSteps) {if (!g().isValid() || dt <= 0.0f) return;g().contactEnterBuffer.clear();g().contactEnterSpeedBuffer.clear();+ g().contactEnterMassBuffer.clear();g().contactExitBuffer.clear();g().sensorEnterBuffer.clear();g().sensorExitBuffer.clear();@@ -623,6 +638,15 @@ void physics3d_setTransform(uint32_t bodyId, float px, float py, float pz,}}+EMSCRIPTEN_KEEPALIVE+void physics3d_setMass(uint32_t bodyId, float mass) {+ Body* body = g().body(bodyId);+ if (!g().isValid() || body == nullptr || !(mass > 0.0f) || !std::isfinite(mass)) return;+ PxRigidDynamic* dynamic = body->actor->is<PxRigidDynamic>();+ if (dynamic == nullptr || isKinematic(dynamic)) return;+ PxRigidBodyExt::setMassAndUpdateInertia(*dynamic, mass);+}+EMSCRIPTEN_KEEPALIVEvoid physics3d_setLinearVelocity(uint32_t bodyId, float vx, float vy, float vz) {Body* body = g().body(bodyId);@@ -684,6 +708,10 @@ uintptr_t physics3d_transforms() { return reinterpret_cast<uintptr_t>(g().transfEMSCRIPTEN_KEEPALIVEsize_t physics3d_transformsBytes() { return g().transformBuffer.size() * sizeof(float); }EMSCRIPTEN_KEEPALIVE+uintptr_t physics3d_contactEnterMasses() { return reinterpret_cast<uintptr_t>(g().contactEnterMassBuffer.data()); }+EMSCRIPTEN_KEEPALIVE+size_t physics3d_contactEnterMassesBytes() { return g().contactEnterMassBuffer.size() * sizeof(float); }+EMSCRIPTEN_KEEPALIVEuintptr_t physics3d_contactEnterSpeeds() { return reinterpret_cast<uintptr_t>(g().contactEnterSpeedBuffer.data()); }EMSCRIPTEN_KEEPALIVEsize_t physics3d_contactEnterSpeedsBytes() { return g().contactEnterSpeedBuffer.size() * sizeof(float); }diff --git a/src/esengine/bindings/modules/physics3d_physx/PhysXWorld.hpp b/src/esengine/bindings/modules/physics3d_physx/PhysXWorld.hppindex 7d5bd90db..4a1a44002 100644--- a/src/esengine/bindings/modules/physics3d_physx/PhysXWorld.hpp+++ b/src/esengine/bindings/modules/physics3d_physx/PhysXWorld.hpp@@ -110,6 +110,8 @@ struct World {std::vector<float> contactEnterBuffer;/** One closing speed for each contact in contactEnterBuffer. */std::vector<float> contactEnterSpeedBuffer;+ /** One meeting mass, in kilograms, for each contact in contactEnterBuffer. */+ std::vector<float> contactEnterMassBuffer;std::vector<float> contactExitBuffer;std::vector<float> sensorEnterBuffer;std::vector<float> sensorExitBuffer;diff --git a/src/esengine/ecs/components/RigidBody3D.hpp b/src/esengine/ecs/components/RigidBody3D.hppindex ac1841f1a..b66082ff8 100644--- a/src/esengine/ecs/components/RigidBody3D.hpp+++ b/src/esengine/ecs/components/RigidBody3D.hpp@@ -48,6 +48,12 @@ struct RigidBody3D {ES_PROPERTY(min=0)f32 angularDamping{0.05f};+ /** @brief Its mass in kilograms. 0 = as heavy as its shape at the density of water,+ * a ball of 10 cm radius 4.2 kg; set it to make a hollow thing light or a small thing+ * heavy. A static or kinematic body has none: nothing moves it. */+ ES_PROPERTY(min=0, tooltip="Kilograms. 0 = from its shape at the density of water (a ball of 10 cm radius is 4.2 kg).")+ f32 mass{0.0f};+/** @brief Keeps the body upright: the solver may move it, never turn it. What a* character on legs wants, and what a crate does not. */ES_PROPERTY()diff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.hindex eb9714607..d992b536e 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 0x97a52221ac92f3abULL+#define ES_CONF_EXPECTED_CONTRACT_HASH 0xc34abad701e12e82ULL/* 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 0cdd55397..618d3f67c 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 0x97a52221ac92f3abULL+#define ES_ABI_ENGINE_DIGEST 0xc34abad701e12e82ULLES_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 89134226c..1ddf12dce 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 0x97a52221ac92f3abULL+#define ES_ABI_ENGINE_DIGEST 0xc34abad701e12e82ULLES_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 6c16c29d0..0bc8fad6c 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 0x97a52221ac92f3abULL+#define ES_EXPECTED_CONTRACT_HASH 0xc34abad701e12e82ULL/* 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/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex d8bf4db0c..90de2bd3d 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -4736,4 +4736,8 @@ export const NOTED = {{"note": "A thing breaks when it is hit hard enough."},"feat(editor): a fractured model's reply hands over a hull of its shape, and the breakable check drops a stone on one pot and a pebble on another":{"note": "A thing breaks when it is hit hard enough."},+ "feat(physics3d): a hit is judged by its impulse - every 3D contact carries the mass the two met with and the impulse, speed by mass, and a Breakable breaks on a hit at least as hard as its breakImpulse; RigidBody3D.mass gives a moving body a mass of its own in kilograms, 0 keeping the one its shape gives":+ {"note": "A thing breaks when it is hit hard enough."},+ "feat(editor): the breakable check drops a 2 kg stone and a 50 g pebble from the same height, and the tool text says how hard a hit is":+ {"note": "A thing breaks when it is hit hard enough."},};