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(physics): a fast 3D body stops at a thin wall
esengineac45dddbcaf2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 75abd56ee..1c23ea43a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,12 @@ published separately; it ships inside the editor.### Added+- **A fast 3D body stops at a thin wall.** `RigidBody3D.continuousCollision`+ checks the whole path a step covers rather than only where the body ended up.+ At any speed that crosses more than its own thickness in a step — a bullet, a+ thrown object — discrete collision reports nothing, because the far side of the+ wall is a perfectly valid place to be.+- **A 3D character can shove what it walks into.** `CharacterController3D` gained`pushForce` — the force it may spend moving a dynamic body out of its way. Acharacter is swept rather than solved, so nothing moved for it before: `mass`diff --git a/docs/astro/src/content/docs/gameplay/physics-3d.mdx b/docs/astro/src/content/docs/gameplay/physics-3d.mdxindex 88b4ebfec..d19e486a5 100644--- a/docs/astro/src/content/docs/gameplay/physics-3d.mdx+++ b/docs/astro/src/content/docs/gameplay/physics-3d.mdx@@ -32,6 +32,7 @@ cmds.spawn()| `gravityScale` | This body's share of world gravity. `0` is weightlessness, not slow falling. || `linearDamping` / `angularDamping` | How quickly motion bleeds off. || `fixedRotation` | Freezes the orientation the body was given — what keeps a character from toppling. It does not right a body that starts tilted. |+| `continuousCollision` | Checks the whole path a step covers rather than where the body ended up. What a bullet needs; off by default, since it costs more. |## Shapesdiff --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 69e904f9c..3acc75bf5 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@@ -29,6 +29,7 @@ cmds.spawn()| `gravityScale` | 这个刚体分担的重力比例。`0` 是失重,不是「掉得慢」。 || `linearDamping` / `angularDamping` | 运动衰减的快慢。 || `fixedRotation` | 冻结刚体被给定的朝向——让角色不会倒下的那个开关。它不会把一个一开始就歪的刚体扶正。 |+| `continuousCollision` | 检查这一步走过的整条路径,而不只是它最后停在哪。子弹需要它;默认关闭,因为它更贵。 |## 形状diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.jsonindex 0e547cef7..252878e6b 100644--- a/docs/astro/src/data/components.generated.json+++ b/docs/astro/src/data/components.generated.json@@ -2868,6 +2868,13 @@"default": "false","advanced": true},+ {+ "key": "continuousCollision",+ "type": "boolean",+ "default": "false",+ "doc": "Check the whole path a step covers — what a bullet needs",+ "advanced": true+ },{"key": "enabled","type": "boolean",diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 67a53d78c..d1c18f17d 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -5,7 +5,7 @@ Symbols: 113 public · 65 beta · 1443 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"3ca8b8f014ab2cd1"+"0daf40a6f7ff1a3e"```## ANCHOR_AXES — const @experimental@@ -6216,6 +6216,7 @@ BuiltinComponentDef<RigidBody3DData>```angularDamping: numberbodyType: number+continuousCollision: booleanenabled: booleanfixedRotation: booleangravityScale: numberdiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex 496e398a1..7d1942e4d 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -5,7 +5,7 @@ Symbols: 113 public · 70 beta · 1462 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"3ca8b8f014ab2cd1"+"0daf40a6f7ff1a3e"```## ANCHOR_AXES — const @experimental@@ -6409,6 +6409,7 @@ BuiltinComponentDef<RigidBody3DData>```angularDamping: numberbodyType: number+continuousCollision: booleanenabled: booleanfixedRotation: booleangravityScale: numberdiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 8edf014ee..5d27eb53d 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -6211,6 +6211,7 @@ BuiltinComponentDef<RigidBody3DData>```angularDamping: numberbodyType: number+continuousCollision: booleanenabled: booleanfixedRotation: booleangravityScale: numberdiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 8590b032c..6d5c2b106 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -6456,6 +6456,7 @@ BuiltinComponentDef<RigidBody3DData>```angularDamping: numberbodyType: number+continuousCollision: booleanenabled: booleanfixedRotation: booleangravityScale: numberdiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex f53ec8424..55d14d45c 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -6218,6 +6218,7 @@ BuiltinComponentDef<RigidBody3DData>```angularDamping: numberbodyType: number+continuousCollision: booleanenabled: booleanfixedRotation: booleangravityScale: numberdiff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.tsindex 8de5ebc6f..96a5ce594 100644--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts@@ -1172,6 +1172,7 @@ export interface RigidBody3DPtrData {angularDamping: number;fixedRotation: boolean;layer: number;+ continuousCollision: boolean;enabled: boolean;}@@ -1185,7 +1186,8 @@ export function fillRigidBody3D(out.angularDamping = f32[(ptr + 12) >> 2];out.fixedRotation = u8[ptr + 16] !== 0;out.layer = u32[(ptr + 20) >> 2];- out.enabled = u8[ptr + 24] !== 0;+ out.continuousCollision = u8[ptr + 24] !== 0;+ out.enabled = u8[ptr + 25] !== 0;}export function writeRigidBody3D(@@ -1198,7 +1200,8 @@ export function writeRigidBody3D(f32[(ptr + 12) >> 2] = data.angularDamping;u8[ptr + 16] = data.fixedRotation ? 1 : 0;u32[(ptr + 20) >> 2] = data.layer;- u8[ptr + 24] = data.enabled ? 1 : 0;+ u8[ptr + 24] = data.continuousCollision ? 1 : 0;+ u8[ptr + 25] = data.enabled ? 1 : 0;}export function createRigidBody3DData(): RigidBody3DPtrData {@@ -1209,6 +1212,7 @@ export function createRigidBody3DData(): RigidBody3DPtrData {angularDamping: 0,fixedRotation: false,layer: 0,+ continuousCollision: false,enabled: false,};}diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.tsindex b859a77d5..d082213a5 100644--- a/sdk/src/ecs/component.generated.ts+++ b/sdk/src/ecs/component.generated.ts@@ -15,7 +15,7 @@ import type { Dimension, Padding } from '../wasm/wasm.generated';* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to* run on mismatch, because mismatched offsets read the wrong heap bytes.*/-export const ABI_LAYOUT_HASH = '3ca8b8f014ab2cd1';+export const ABI_LAYOUT_HASH = '0daf40a6f7ff1a3e';/*** One asset-valued field of a component: which field, and what kind of@@ -646,6 +646,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {angularDamping: 0.05,fixedRotation: false,layer: 0,+ continuousCollision: false,enabled: true,},assetFields: [],@@ -658,6 +659,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {linearDamping: { min: 0 },angularDamping: { min: 0 },layer: { min: 0, max: 15, advanced: true },+ continuousCollision: { advanced: true },},},SegmentCollider: {@@ -1308,6 +1310,7 @@ export interface RigidBody3DData {angularDamping: number;fixedRotation: boolean;layer: number;+ continuousCollision: boolean;enabled: boolean;}diff --git a/sdk/src/physics3d/Physics3DComponents.ts b/sdk/src/physics3d/Physics3DComponents.tsindex 1843d0b0b..7b015a2e4 100644--- a/sdk/src/physics3d/Physics3DComponents.ts+++ b/sdk/src/physics3d/Physics3DComponents.ts@@ -25,12 +25,15 @@ export const RigidBody3D = defineBuiltin<RigidBody3DData>('RigidBody3D', {linearDamping: 0.05,angularDamping: 0.05,fixedRotation: false,+ continuousCollision: false,enabled: true,}, {fields: {linearDamping: { min: 0, advanced: true },angularDamping: { min: 0, advanced: true },fixedRotation: { advanced: true },+ continuousCollision: { advanced: true,+ tooltip: 'Check the whole path a step covers — what a bullet needs' },},});diff --git a/sdk/src/physics3d/Physics3DModule.ts b/sdk/src/physics3d/Physics3DModule.tsindex a09fac305..b4cc2e7c8 100644--- a/sdk/src/physics3d/Physics3DModule.ts+++ b/sdk/src/physics3d/Physics3DModule.ts@@ -25,19 +25,22 @@ export interface Physics3DWasmModule {qx: number, qy: number, qz: number, qw: number,motion: number, gravityScale: number, linearDamping: number,angularDamping: number, fixedRotation: number, layer: number,- friction: number, restitution: number, isSensor: number): number;+ continuous: number, friction: number, restitution: number,+ isSensor: number): number;_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,- friction: number, restitution: number, isSensor: number): number;+ continuous: number, friction: number, restitution: number,+ isSensor: number): number;_physics3d_addCapsule(entity: number, radius: number, halfHeight: 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,- friction: number, restitution: number, isSensor: number): number;+ continuous: number, friction: number, restitution: number,+ isSensor: number): number;_physics3d_addMeshBody(entity: number, vertexPtr: number, vertexCount: number,indexPtr: number, indexCount: number,px: number, py: number, pz: number,diff --git a/sdk/src/physics3d/Physics3DSystem.ts b/sdk/src/physics3d/Physics3DSystem.tsindex b46bedc5a..50841ce8e 100644--- a/sdk/src/physics3d/Physics3DSystem.ts+++ b/sdk/src/physics3d/Physics3DSystem.ts@@ -132,7 +132,8 @@ function createBody(app: App, module: Physics3DWasmModule, entity: Entity,const px = p.x / ppu, py = p.y / ppu, pz = p.z / ppu;// How the body answers to the world, in the order the module reads it.const how = [motionOf(body), body.gravityScale, body.linearDamping,- body.angularDamping, body.fixedRotation ? 1 : 0, body.layer] as const;+ body.angularDamping, body.fixedRotation ? 1 : 0, body.layer,+ body.continuousCollision ? 1 : 0] as const;const box = app.world.get(entity, BoxCollider3D) as BoxCollider3DData | undefined;if (box?.enabled) {diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.tsindex 024833e31..ea91c7351 100644--- a/sdk/src/wasm/ptrLayouts.generated.ts+++ b/sdk/src/wasm/ptrLayouts.generated.ts@@ -325,7 +325,8 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {{ name: 'angularDamping', type: 'f32', offset: 12 },{ name: 'fixedRotation', type: 'bool', offset: 16 },{ name: 'layer', type: 'u32', offset: 20 },- { name: 'enabled', type: 'bool', offset: 24 },+ { name: 'continuousCollision', type: 'bool', offset: 24 },+ { name: 'enabled', type: 'bool', offset: 25 },],},SegmentCollider: {diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.tsindex c9c7d2a45..5243ff93d 100644--- a/sdk/src/wasm/wasm.generated.ts+++ b/sdk/src/wasm/wasm.generated.ts@@ -495,6 +495,7 @@ export interface RigidBody3D {angularDamping: number;fixedRotation: boolean;layer: number;+ continuousCollision: boolean;enabled: boolean;}diff --git a/sdk/tests/physics3d-ecs.test.ts b/sdk/tests/physics3d-ecs.test.tsindex e9db94dd6..20ce9ef68 100644--- a/sdk/tests/physics3d-ecs.test.ts+++ b/sdk/tests/physics3d-ecs.test.ts@@ -337,6 +337,19 @@ describe('the 3D world and the ECS', () => {expect(bodies.size).toBe(0);});+ it('sends the continuous-collision choice to the world', () => {+ const e = spawn();+ world.insert(e, SphereCollider3D);+ (world.get(e, RigidBody3D) as { continuousCollision: boolean }).continuousCollision = true;++ stepPhysics3D(app, module, bodies, DEFAULT_PHYSICS3D_CONFIG);++ // entity, radius, position(3), rotation(4), motion, gravity, damping(2),+ // fixedRotation, layer, then the motion quality \u2014 a flag nothing forwards+ // leaves every bullet passing through every wall.+ expect(called('addSphere')[0]!.args[15]).toBe(1);+ });+it('sends a body\u2019s layer to the world', () => {const e = spawn();world.insert(e, SphereCollider3D);diff --git a/sdk/tests/physics3d-smoke.mjs b/sdk/tests/physics3d-smoke.mjsindex f2fa9256d..3425cb43e 100644--- a/sdk/tests/physics3d-smoke.mjs+++ b/sdk/tests/physics3d-smoke.mjs@@ -22,7 +22,9 @@ const STATIC = 0, KINEMATIC = 1, DYNAMIC = 2;const IDENTITY = [0, 0, 0, 1];// motion, gravityScale, linearDamping, angularDamping, fixedRotation, layer —// what a body is beyond its shape.-const FREE = (motion, layer = 0) => [motion, 1, 0, 0, 0, layer];+const FREE = (motion, layer = 0) => [motion, 1, 0, 0, 0, layer, 0];+/** The same, with continuous collision on — the path, not the endpoint. */+const SWEPT = (motion, layer = 0) => [motion, 1, 0, 0, 0, layer, 1];/** The position of `entity` in the step's transform readback, or null. */function bodyPos(entity) {@@ -145,7 +147,7 @@ check('and on its own radius', side && side.entity === CAP && near(side.fraction// drops 4.9m in the same second.const FLOAT = 5;const floatId = m._physics3d_addSphere(FLOAT, 0.5, -3, 5, 0, ...IDENTITY,- DYNAMIC, 0, 0, 0, 0, 0, 0.5, 0, 0);+ DYNAMIC, 0, 0, 0, 0, 0, 0, 0.5, 0, 0);step(60);check('gravityScale 0 leaves a body where it was', near(bodyState(floatId).y, 5, 0.01),`y=${bodyState(floatId).y.toFixed(4)} want 5`);@@ -155,7 +157,7 @@ check('gravityScale 0 leaves a body where it was', near(bodyState(floatId).y, 5,// flat, so the tilt it KEEPS is what says the solver may not turn it.const UPRIGHT = 6;const uprightId = m._physics3d_addCapsule(UPRIGHT, 0.3, 0.5, -6, 3, 0,- 0.3, 0, 0, 0.954, DYNAMIC, 1, 0, 0, 1, 0, 0.5, 0, 0);+ 0.3, 0, 0, 0.954, DYNAMIC, 1, 0, 0, 1, 0, 0, 0.5, 0, 0);step(180);const uprightBase = m._physics3d_getBodyState(uprightId) ? m._physics3d_queryResult() >> 2 : 0;const qx = m.HEAPF32[uprightBase + 3];@@ -453,7 +455,7 @@ check('and stops at the pillars', swept != null && swept.fraction < 0.5// ── 11) Joints: what holds two bodies to each other ─────────────────────────// Each asserts a distance the geometry fixes, not "it moved": a joint that was// never installed leaves a body in free fall, which is motion too.-const HELD = (motion, gravity = 1) => [motion, gravity, 0.4, 0.4, 0, 0];+const HELD = (motion, gravity = 1) => [motion, gravity, 0.4, 0.4, 0, 0, 0];const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z);// A hinge holds an arm at arm's length and lets it swing down to hang.@@ -566,7 +568,29 @@ step(120);const freed = bodyState(ropeBallId);check('a removed joint lets go', freed && freed.y < 15, `y=${freed?.y.toFixed(3)}`);-// ── 12) A removed body is gone from both the sweep and the getter ───────────+// ── 12) A fast body and a thin wall, twice ─────────────────────────────────+// ★ 240 m/s lands the discrete body's endpoints at 598 then 602, never inside+// the wall. At 200 m/s a 3.33m step lands one dead ON it and it stops by luck.+const WALL_A = 90, WALL_B = 91, SLUG_A = 92, SLUG_B = 93;+const SLUG = (continuous) => [DYNAMIC, 0, 0, 0, 0, 0, continuous];+m._physics3d_addBox(WALL_A, 0.05, 2, 2, 600, 20, 0, ...IDENTITY, ...FREE(STATIC), 0.5, 0, 0);+m._physics3d_addBox(WALL_B, 0.05, 2, 2, 600, 30, 0, ...IDENTITY, ...FREE(STATIC), 0.5, 0, 0);+const discrete = m._physics3d_addSphere(SLUG_A, 0.05, 590, 20, 0, ...IDENTITY,+ ...SLUG(0), 0.5, 0, 0);+const sweptSlug = m._physics3d_addSphere(SLUG_B, 0.05, 590, 30, 0, ...IDENTITY,+ ...SLUG(1), 0.5, 0, 0);+m._physics3d_optimize();+m._physics3d_setLinearVelocity(discrete, 240, 0, 0);+m._physics3d_setLinearVelocity(sweptSlug, 240, 0, 0);+step(10);+const throughIt = bodyState(discrete);+const stopped = bodyState(sweptSlug);+check('a fast body passes through a thin wall when only its endpoints are checked',+ throughIt && throughIt.x > 601, `x=${throughIt?.x.toFixed(3)} wall at 600`);+check('and continuous collision stops it at the wall', stopped && stopped.x < 600,+ `x=${stopped?.x.toFixed(3)} wall at 600`);++// ── 13) A removed body is gone from both the sweep and the getter ───────────m._physics3d_removeBody(capId);step(1);check('a removed body leaves the readback', bodyPos(CAP) === null);diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cppindex 3fdf3186b..8797e97c9 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 408785a144c7d207+ * @schema_hash 343f6f433e72bf51*/-#define ES_EDITOR_API_SCHEMA_HASH "408785a144c7d207"+#define ES_EDITOR_API_SCHEMA_HASH "343f6f433e72bf51"#include <emscripten/bind.h>#include <string>@@ -426,6 +426,7 @@ std::string editor_getComponentSchema(const std::string& name) {{"key":"angularDamping","type":"float","group":"RigidBody3D"},{"key":"fixedRotation","type":"bool","group":"RigidBody3D"},{"key":"layer","type":"int","group":"RigidBody3D"},+ {"key":"continuousCollision","type":"bool","group":"RigidBody3D"},{"key":"enabled","type":"bool","group":"RigidBody3D"}])JSON";} else if (name == "SegmentCollider") {@@ -2368,6 +2369,7 @@ bool editor_setBool(Registry& reg, u32 e, const std::string& comp, const std::stif (!reg.has<esengine::ecs::RigidBody3D>(entity)) return false;auto& c = reg.get<esengine::ecs::RigidBody3D>(entity);if (field == "fixedRotation") { c.fixedRotation = value; }+ else if (field == "continuousCollision") { c.continuousCollision = value; }else if (field == "enabled") { c.enabled = value; }else { return false; }return true;@@ -2561,6 +2563,7 @@ bool editor_getBool(Registry& reg, u32 e, const std::string& comp, const std::stif (!reg.has<esengine::ecs::RigidBody3D>(entity)) return false;const auto& c = reg.get<esengine::ecs::RigidBody3D>(entity);if (field == "fixedRotation") { return c.fixedRotation; }+ else if (field == "continuousCollision") { return c.continuousCollision; }else if (field == "enabled") { return c.enabled; }} else if (comp == "SegmentCollider") {if (!reg.has<esengine::ecs::SegmentCollider>(entity)) return false;diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex 0f21a4547..5594804a1 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -845,6 +845,7 @@ struct RigidBody3DJS {f32 angularDamping;bool fixedRotation;u32 layer;+ bool continuousCollision;bool enabled;};@@ -855,6 +856,7 @@ void rigidbody3dApplyJS(esengine::ecs::RigidBody3D& c, const RigidBody3DJS& js)c.angularDamping = js.angularDamping;c.fixedRotation = js.fixedRotation;c.layer = js.layer;+ c.continuousCollision = js.continuousCollision;c.enabled = js.enabled;}@@ -872,6 +874,7 @@ RigidBody3DJS rigidbody3dToJS(const esengine::ecs::RigidBody3D& c) {js.angularDamping = c.angularDamping;js.fixedRotation = c.fixedRotation;js.layer = c.layer;+ js.continuousCollision = c.continuousCollision;js.enabled = c.enabled;return js;}@@ -1512,6 +1515,7 @@ EMSCRIPTEN_BINDINGS(esengine_components) {.field("angularDamping", &RigidBody3DJS::angularDamping).field("fixedRotation", &RigidBody3DJS::fixedRotation).field("layer", &RigidBody3DJS::layer)+ .field("continuousCollision", &RigidBody3DJS::continuousCollision).field("enabled", &RigidBody3DJS::enabled);value_object<esengine::ecs::SegmentCollider>("SegmentCollider")@@ -2807,7 +2811,8 @@ static_assert(offsetof(esengine::ecs::RigidBody3D, linearDamping) == 8, "ABI offstatic_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, enabled) == 24, "ABI offset drift: esengine::ecs::RigidBody3D.enabled (EHT expected 24)");+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::SegmentCollider, point1) == 0, "ABI offset drift: esengine::ecs::SegmentCollider.point1 (EHT expected 0)");static_assert(offsetof(esengine::ecs::SegmentCollider, point2) == 8, "ABI offset drift: esengine::ecs::SegmentCollider.point2 (EHT expected 8)");static_assert(offsetof(esengine::ecs::SegmentCollider, density) == 16, "ABI offset drift: esengine::ecs::SegmentCollider.density (EHT expected 16)");@@ -2945,7 +2950,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "3ca8b8f014ab2cd1";+static const char* kEsAbiLayoutHash = "0daf40a6f7ff1a3e";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp b/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cppindex 486eec75c..9e59789b7 100644--- a/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp+++ b/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp@@ -82,6 +82,7 @@ struct BodyMotion {float angularDamping = 0.0f;int fixedRotation = 0;uint32_t layer = 0;+ int continuous = 0;};/// The entity a body speaks for, or 0 when nothing claims it.@@ -168,6 +169,10 @@ uint32_t addBody(uint32_t entity, const Ref<Shape>& shape, float px, float py, fsettings.mAllowedDOFs = EAllowedDOFs::TranslationX | EAllowedDOFs::TranslationY| EAllowedDOFs::TranslationZ;}+ // Discrete collision only asks where a body IS at the end of a step, so+ // anything that crosses more than its own thickness in one step arrives on the+ // far side of a wall having never touched it.+ if (how.continuous != 0) settings.mMotionQuality = EMotionQuality::LinearCast;BodyInterface& bodies = g().system->GetBodyInterface();const BodyID id = bodies.CreateAndAddBody(settings, motionType == EMotionType::Static ? EActivation::DontActivate@@ -293,9 +298,10 @@ uint32_t physics3d_addBox(uint32_t entity, float hx, float hy, float hz,float qx, float qy, float qz, float qw,int motion, float gravityScale, float linearDamping,float angularDamping, int fixedRotation, uint32_t layer,- float friction, float restitution, int isSensor) {+ int continuous, float friction, float restitution, int isSensor) {return addBody(entity, new BoxShape(Vec3(hx, hy, hz)), px, py, pz, qx, qy, qz, qw,- {motion, gravityScale, linearDamping, angularDamping, fixedRotation, layer},+ {motion, gravityScale, linearDamping, angularDamping, fixedRotation, layer,+ continuous},friction, restitution, isSensor);}@@ -305,9 +311,10 @@ uint32_t physics3d_addSphere(uint32_t entity, float radius,float qx, float qy, float qz, float qw,int motion, float gravityScale, float linearDamping,float angularDamping, int fixedRotation, uint32_t layer,- float friction, float restitution, int isSensor) {+ int continuous, float friction, float restitution, int isSensor) {return addBody(entity, new SphereShape(radius), px, py, pz, qx, qy, qz, qw,- {motion, gravityScale, linearDamping, angularDamping, fixedRotation, layer},+ {motion, gravityScale, linearDamping, angularDamping, fixedRotation, layer,+ continuous},friction, restitution, isSensor);}@@ -319,9 +326,10 @@ uint32_t physics3d_addCapsule(uint32_t entity, float radius, float halfHeight,float qx, float qy, float qz, float qw,int motion, float gravityScale, float linearDamping,float angularDamping, int fixedRotation, uint32_t layer,- float friction, float restitution, int isSensor) {+ int continuous, float friction, float restitution, int isSensor) {return addBody(entity, new CapsuleShape(halfHeight, radius), px, py, pz, qx, qy, qz, qw,- {motion, gravityScale, linearDamping, angularDamping, fixedRotation, layer},+ {motion, gravityScale, linearDamping, angularDamping, fixedRotation, layer,+ continuous},friction, restitution, isSensor);}diff --git a/src/esengine/ecs/components/RigidBody3D.hpp b/src/esengine/ecs/components/RigidBody3D.hppindex a3a2151df..6828e8e50 100644--- a/src/esengine/ecs/components/RigidBody3D.hpp+++ b/src/esengine/ecs/components/RigidBody3D.hpp@@ -58,6 +58,14 @@ struct RigidBody3D {ES_PROPERTY(min=0, max=15, advanced)u32 layer{0};+ /** @brief Checks the whole path a step covers rather than where the body ended+ * up. What a bullet needs: discrete collision only asks where a body IS,+ * so anything crossing more than its own thickness in one step arrives+ * on the far side of a wall having never touched it. Costs more, which+ * is why it is off. */+ ES_PROPERTY(advanced)+ bool continuousCollision{false};+/** @brief Disabled bodies are left out of the world entirely. */ES_PROPERTY()bool enabled{true};