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(particle): an emitter can carry an added velocity per particle and limit particle speed with a dampening, and the Cocos velocity, force and limit modules map onto them
yhh5d1d06a1306b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 51cd6fe16..051aadc03 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,7 @@ published separately; it ships inside the editor.- **Scroll areas can be pulled past an end and spring back.** A scroll area whose movement is Elastic now does what the setting always said: a drag past an end is stiffer the further out it goes, letting go returns the content, and a flick that reaches an end bounces off it. It is opt-in per area (`ScrollMovement.Elastic`; Clamped, the default, behaves as before), and the gesture model (`ScrollMotion`, with `ScrollContainer.dragTo` and `getOverscroll`) is exported for scrolling anything else the same way.- **More easing curves.** Sine, quart, quint, expo and circ (each in, out and in-out), bounce in and in-out, and smoothstep and smootherstep join the quad, cubic, back, elastic and out-bounce curves. They are new `EasingType` members after the existing ones, so a saved tween keeps its curve, and they ease the same in a C++ tween and a script value tween.- **World content has a rectangle: `ContentRect`.** A size and the pivot the entity's transform sits on, which the `Sprite` and `Text` on the entity follow and which a `UIMask` on it clips to — no `UINode` needed, so a clipping region or a scroll viewport can stand in the world. `contentRectContains` tests a world point against it.+- **Particles can carry an added velocity and be held to a speed limit.** `ParticleEmitter.addedVelocityMin` and `addedVelocityMax` give each particle a velocity on top of its own, chosen between the two when it is born and untouched by gravity, damping and noise. `speedLimit` pulls a faster particle back toward the limit, by `limitDampen` of the excess every 1/60 s so the braking does not depend on the frame rate. Both are run by the CPU simulation.- **An emitter can start late.** `ParticleEmitter.startDelay` holds back emission for that many seconds after the emitter starts playing; the duration of a non-looping emitter is counted from the end of the delay. Zero, the default, is the behaviour before.- **Particles can be stretched along their velocity.** `ParticleEmitter.renderMode` is `Billboard` (as before) or `Stretched`, which turns each particle's quad so its Y axis runs along the particle's velocity and makes it `size * lengthScale + speed * velocityScale` long: sparks, rain and streaks. A particle at rest keeps its own rotation. It is drawn by the CPU simulation; an emitter simulated on the GPU still draws as a billboard.- **Fade a whole group of world content with one value: `GroupOpacity`.** On an entity it fades that entity and everything under it; the opacities multiply down the hierarchy into each descendant's own alpha, as `UINode.opacity` does for a UI subtree. Sprites, text, shapes, trails and tilemap layers follow it. It is not a composited layer, so children that overlap show through one another while the group is partly faded.diff --git a/docs/astro/src/content/docs/world/particles.mdx b/docs/astro/src/content/docs/world/particles.mdxindex 32ee783e5..16c1820aa 100644--- a/docs/astro/src/content/docs/world/particles.mdx+++ b/docs/astro/src/content/docs/world/particles.mdx@@ -125,6 +125,9 @@ Where particles spawn and their initial direction. See [Emitter shapes](#emitter| `angleSpreadMax` | number | `360` | End of the emission-direction arc (°). || `gravity` | Vec2 | `{0, 0}` | Constant acceleration applied to every particle. || `damping` | number | `0` | Velocity drag per second (`0` = none). |+| `addedVelocityMin` / `addedVelocityMax` | Vec3 | `{0,0,0}` | A velocity each particle carries on top of its own, chosen between the two ends when it is born. Gravity, damping, noise and the speed limit do not act on it. CPU simulation. |+| `speedLimit` | number | `0` | The fastest a particle may move under its own velocity (`0` = no limit). A faster one is pulled back toward the limit. CPU simulation. |+| `limitDampen` | number | `1` | How much of the excess over the limit is removed per 1/60 s: `1` clamps at once, a small value brakes gently. |### Noise & turbulencediff --git a/docs/astro/src/content/docs/zh-cn/world/particles.mdx b/docs/astro/src/content/docs/zh-cn/world/particles.mdxindex 1a5c4e21b..02c3c4720 100644--- a/docs/astro/src/content/docs/zh-cn/world/particles.mdx+++ b/docs/astro/src/content/docs/zh-cn/world/particles.mdx@@ -116,6 +116,9 @@ const spawnEmbers = defineSystem([Commands()], (cmds) => {| `angleSpreadMax` | number | `360` | 发射方向弧的结束(°)。 || `gravity` | Vec2 | `{0, 0}` | 施加到每个粒子的恒定加速度。 || `damping` | number | `0` | 每秒速度阻尼(`0` = 无)。 |+| `addedVelocityMin` / `addedVelocityMax` | Vec3 | `{0,0,0}` | 每个粒子在自身速度之上额外带的速度,出生时在两端之间随机取值。重力、阻尼、噪声和速度上限都不作用于它。仅 CPU 模拟。 |+| `speedLimit` | number | `0` | 粒子凭自身速度能达到的最快速度(`0` = 不限)。更快的会被拉回到上限附近。仅 CPU 模拟。 |+| `limitDampen` | number | `1` | 每 1/60 秒去掉超出上限部分的多少:`1` 立即夹到上限,小值则缓慢刹车。 |### 噪声与湍流 (Noise & turbulence)diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.jsonindex 270cda0d6..8c0c1cad8 100644--- a/docs/astro/src/data/components.generated.json+++ b/docs/astro/src/data/components.generated.json@@ -3627,6 +3627,31 @@"default": "0","range": "≥ 0"},+ {+ "key": "addedVelocityMin",+ "type": "Vec3",+ "default": "(0, 0, 0)",+ "doc": "A velocity each particle carries on top of its own, chosen between the two ends when it is born. Gravity, damping, noise and the speed limit do not act on it. Run by the CPU simulation."+ },+ {+ "key": "addedVelocityMax",+ "type": "Vec3",+ "default": "(0, 0, 0)"+ },+ {+ "key": "speedLimit",+ "type": "number",+ "default": "0",+ "doc": "The fastest a particle may move under its own velocity; 0 is no limit. A faster particle is pulled back toward the limit. Run by the CPU simulation.",+ "range": "≥ 0"+ },+ {+ "key": "limitDampen",+ "type": "number",+ "default": "1",+ "doc": "How much of the excess over the limit is removed per 1/60 s: 1 clamps at once, a small value brakes gently.",+ "range": "0–1"+ },{"key": "noiseStrength","type": "number",diff --git a/pipeline/src/import/cocos/particle.ts b/pipeline/src/import/cocos/particle.tsindex ce5a2d5fb..dad86a522 100644--- a/pipeline/src/import/cocos/particle.ts+++ b/pipeline/src/import/cocos/particle.ts@@ -158,6 +158,10 @@ function sizeKeys(v: unknown): Array<{ time: number; value: number; inTangent: n/** Cocos's emitter shapes in the engine's numbering. */const SHAPE: Record<number, number> = { 0: 2 /* Box */, 1: 1 /* Circle */, 2: 3 /* Cone */, 3: 4 /* Sphere */, 4: 5 /* Hemisphere */ };+function enabledModule(v: unknown): Raw | null {+ return isObj(v) && v._enable === true ? v : null;+}+export function particleSystem(c: { enabled: boolean; data: Raw }, ctx: ParticleContext, where: string): { type: string; data: Raw } {const d = c.data;const note = (code: string): void => ctx.report.note(code, where);@@ -261,9 +265,38 @@ export function particleSystem(c: { enabled: boolean; data: Raw }, ctx: Particlelose('particle-no-material');}+ // a velocity carried on top of the particle's own, chosen per axis when it is born+ const velocity = enabledModule(d._velocityOvertimeModule);+ if (velocity) {+ const axes = (['x', 'y', 'z'] as const).map((a) => curveRange(velocity[a], 0, 0));+ out.addedVelocityMin = { x: axes[0]!.min, y: axes[1]!.min, z: axes[2]!.min };+ out.addedVelocityMax = { x: axes[0]!.max, y: axes[1]!.max, z: axes[2]!.max };+ if (['x', 'y', 'z'].some((a) => [1, 2].includes(num((velocity[a] as Raw | undefined)?.mode, 0)))) lose('particle-velocity-curve');+ if (mid(curveRange(velocity.speedModifier, 0, 1)) !== 1) lose('particle-velocity-speed-modifier');+ }++ // a force is an acceleration: it joins gravity+ const force = enabledModule(d._forceOvertimeModule);+ if (force) {+ const accel = (['x', 'y', 'z'] as const).map((a) => mid(curveRange(force[a], 0, 0)));+ const g = out.gravity as { x: number; y: number; z: number };+ out.gravity = { x: g.x + accel[0]!, y: g.y + accel[1]!, z: g.z + accel[2]! };+ if (['x', 'y', 'z'].some((a) => [1, 2].includes(num((force[a] as Raw | undefined)?.mode, 0)))) lose('particle-force-curve');+ }++ // the fastest a particle may go, pulled back by the dampen fraction+ const limit = enabledModule(d._limitVelocityOvertimeModule);+ if (limit) {+ if (limit.separateAxes === true || limit._separateAxes === true) {+ lose('particle-limit-per-axis');+ } else {+ out.speedLimit = Math.max(mid(curveRange(limit.limit, 0, 0)), 1e-4); // 0 means "stop" there, and "off" here+ out.limitDampen = Math.min(1, Math.max(0, num(limit.dampen, 1)));+ }+ }+for (const [module, code] of [- ['_velocityOvertimeModule', 'particle-velocity-over-time'], ['_forceOvertimeModule', 'particle-force-over-time'],- ['_limitVelocityOvertimeModule', 'particle-limit-velocity'], ['_noiseModule', 'particle-noise'], ['_trailModule', 'particle-trail'],+ ['_noiseModule', 'particle-noise'], ['_trailModule', 'particle-trail'],] as const) {const m = d[module];if (isObj(m) && m._enable === true) lose(code);diff --git a/pipeline/tests/cocos-particle.test.ts b/pipeline/tests/cocos-particle.test.tsindex 9f8f6d949..6cddc0fe9 100644--- a/pipeline/tests/cocos-particle.test.ts+++ b/pipeline/tests/cocos-particle.test.ts@@ -123,6 +123,27 @@ describe('a particle system', () => {expect((mesh.out.data as Record<string, any>).renderMode).toBeUndefined();});+ it('maps added velocity, a speed limit and a force, and counts the curves it cannot hold', () => {+ const { out, report } = convert({+ _velocityOvertimeModule: { _enable: true, x: between(-0.2, 0.2), y: constant(1), z: constant(0), speedModifier: constant(1) },+ _limitVelocityOvertimeModule: { _enable: true, limit: constant(3), dampen: 0.2, separateAxes: false },+ _forceOvertimeModule: { _enable: true, x: constant(0), y: constant(-30), z: constant(0) },+ });+ const d = out.data as Record<string, any>;+ expect(d.addedVelocityMin).toEqual({ x: -0.2, y: 1, z: 0 });+ expect(d.addedVelocityMax).toEqual({ x: 0.2, y: 1, z: 0 });+ expect([d.speedLimit, d.limitDampen]).toEqual([3, 0.2]);+ expect(d.gravity.y).toBeCloseTo(-4.9 - 30, 5); // the system's own gravity plus the force+ expect(report.components['cc.ParticleSystem']).toEqual({ mapped: 1, partial: 0, unmapped: 0 });+ const def = registry.ParticleEmitter!;+ expect(validate('ParticleEmitter', def._default, d, def.assetFields)).toEqual([]);++ const bent = convert({ _velocityOvertimeModule: { _enable: true, x: curve([[0, 0], [1, 5]]), y: constant(0), z: constant(0), speedModifier: constant(1) } });+ expect(bent.report.notes['particle-velocity-curve']?.count).toBe(1);+ const axes = convert({ _limitVelocityOvertimeModule: { _enable: true, separateAxes: true } });+ expect(axes.report.notes['particle-limit-per-axis']?.count).toBe(1);+ });+it('counts the modules the emitter has no field for', () => {const { report } = convert({ _noiseModule: { _enable: true }, _trailModule: { _enable: true } });expect(report.notes['particle-noise']?.count).toBe(1);diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex e2dc15170..af092d4de 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -5,7 +5,7 @@ Symbols: 115 public · 161 beta · 1966 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"e41570f14820a1a8"+"097d3c7989a498a1"```## ANCHOR_AXES — const @experimental@@ -6463,6 +6463,8 @@ BuiltinComponentDef<ParticleEmitterData>## ParticleEmitterData — interface @beta```+addedVelocityMax: Vec3+addedVelocityMin: Vec3angleSpreadMax: numberangleSpreadMin: numberangularVelocityMax: number@@ -6496,6 +6498,7 @@ layer: numberlengthScale: numberlifetimeMax: numberlifetimeMin: number+limitDampen: numberlooping: booleanmaterial: numbermaxParticles: number@@ -6515,6 +6518,7 @@ shapeSize: Vec3simulationSpace: SimulationSpacesizeCurve: { keys: { t: number; v: number; }[]; }sizeEasing: ParticleEasing+speedLimit: numberspeedMax: numberspeedMin: numberspriteColumns: numberdiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex 7c05bba7c..e91e9fb1e 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -5,7 +5,7 @@ Symbols: 115 public · 166 beta · 1985 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"e41570f14820a1a8"+"097d3c7989a498a1"```## ANCHOR_AXES — const @experimental@@ -6666,6 +6666,8 @@ BuiltinComponentDef<ParticleEmitterData>## ParticleEmitterData — interface @beta```+addedVelocityMax: Vec3+addedVelocityMin: Vec3angleSpreadMax: numberangleSpreadMin: numberangularVelocityMax: number@@ -6699,6 +6701,7 @@ layer: numberlengthScale: numberlifetimeMax: numberlifetimeMin: number+limitDampen: numberlooping: booleanmaterial: numbermaxParticles: number@@ -6718,6 +6721,7 @@ shapeSize: Vec3simulationSpace: SimulationSpacesizeCurve: { keys: { t: number; v: number; }[]; }sizeEasing: ParticleEasing+speedLimit: numberspeedMax: numberspeedMin: numberspriteColumns: numberdiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex b431f7222..ea22c5204 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -6458,6 +6458,8 @@ BuiltinComponentDef<ParticleEmitterData>## ParticleEmitterData — interface @beta```+addedVelocityMax: Vec3+addedVelocityMin: Vec3angleSpreadMax: numberangleSpreadMin: numberangularVelocityMax: number@@ -6491,6 +6493,7 @@ layer: numberlengthScale: numberlifetimeMax: numberlifetimeMin: number+limitDampen: numberlooping: booleanmaterial: numbermaxParticles: number@@ -6510,6 +6513,7 @@ shapeSize: Vec3simulationSpace: SimulationSpacesizeCurve: { keys: { t: number; v: number; }[]; }sizeEasing: ParticleEasing+speedLimit: numberspeedMax: numberspeedMin: numberspriteColumns: numberdiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 3761c0530..e8dc8d612 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -6753,6 +6753,8 @@ BuiltinComponentDef<ParticleEmitterData>## ParticleEmitterData — interface @beta```+addedVelocityMax: Vec3+addedVelocityMin: Vec3angleSpreadMax: numberangleSpreadMin: numberangularVelocityMax: number@@ -6786,6 +6788,7 @@ layer: numberlengthScale: numberlifetimeMax: numberlifetimeMin: number+limitDampen: numberlooping: booleanmaterial: numbermaxParticles: number@@ -6805,6 +6808,7 @@ shapeSize: Vec3simulationSpace: SimulationSpacesizeCurve: { keys: { t: number; v: number; }[]; }sizeEasing: ParticleEasing+speedLimit: numberspeedMax: numberspeedMin: numberspriteColumns: numberdiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 1bc2809b6..2515d25c6 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -6465,6 +6465,8 @@ BuiltinComponentDef<ParticleEmitterData>## ParticleEmitterData — interface @beta```+addedVelocityMax: Vec3+addedVelocityMin: Vec3angleSpreadMax: numberangleSpreadMin: numberangularVelocityMax: number@@ -6498,6 +6500,7 @@ layer: numberlengthScale: numberlifetimeMax: numberlifetimeMin: number+limitDampen: numberlooping: booleanmaterial: numbermaxParticles: number@@ -6517,6 +6520,7 @@ shapeSize: Vec3simulationSpace: SimulationSpacesizeCurve: { keys: { t: number; v: number; }[]; }sizeEasing: ParticleEasing+speedLimit: numberspeedMax: numberspeedMin: numberspriteColumns: numberdiff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.tsindex f45d6302b..54fbb6920 100644--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts@@ -1255,6 +1255,10 @@ export interface ParticleEmitterPtrData {angularVelocityMax: number;gravity: Vec3;damping: number;+ addedVelocityMin: Vec3;+ addedVelocityMax: Vec3;+ speedLimit: number;+ limitDampen: number;noiseStrength: number;noiseFrequency: number;noiseScrollSpeed: number;@@ -1331,43 +1335,47 @@ export function fillParticleEmitter(out.angularVelocityMax = f32[(ptr + 148) >> 2];const gravity_ = out.gravity; gravity_.x = f32[(ptr + 152) >> 2]; gravity_.y = f32[((ptr + 152) >> 2) + 1]; gravity_.z = f32[((ptr + 152) >> 2) + 2];out.damping = f32[(ptr + 164) >> 2];- out.noiseStrength = f32[(ptr + 168) >> 2];- out.noiseFrequency = f32[(ptr + 172) >> 2];- out.noiseScrollSpeed = f32[(ptr + 176) >> 2];- out.noiseOctaves = u32[(ptr + 180) >> 2] | 0;- out.texture = u32[(ptr + 184) >> 2];- out.spriteColumns = u32[(ptr + 188) >> 2] | 0;- out.spriteRows = u32[(ptr + 192) >> 2] | 0;- out.spriteFPS = f32[(ptr + 196) >> 2];- out.spriteLoop = u8[ptr + 200] !== 0;- out.blendMode = u32[(ptr + 204) >> 2] | 0;- out.layer = u32[(ptr + 208) >> 2] | 0;- out.material = u32[(ptr + 212) >> 2];- out.simulationSpace = u32[(ptr + 216) >> 2] | 0;- out.renderMode = u32[(ptr + 220) >> 2] | 0;- out.velocityScale = f32[(ptr + 224) >> 2];- out.lengthScale = f32[(ptr + 228) >> 2];- out.enabled = u8[ptr + 232] !== 0;- out.subEmitterTrigger = u32[(ptr + 236) >> 2] | 0;- out.subEmitterChance = f32[(ptr + 240) >> 2];- out.subEmitterInheritVelocity = f32[(ptr + 244) >> 2];- out.subEmitter = u32[(ptr + 248) >> 2];- out.trailEnabled = u8[ptr + 252] !== 0;- out.trailWidth = f32[(ptr + 256) >> 2];- out.trailPoints = u32[(ptr + 260) >> 2] | 0;- out.trailMinDistance = f32[(ptr + 264) >> 2];- out.collisionEnabled = u8[ptr + 268] !== 0;- out.collisionFloor = f32[(ptr + 272) >> 2];- out.collisionMode = u32[(ptr + 276) >> 2] | 0;- out.collisionMask = u32[(ptr + 280) >> 2];- out.collisionQueryBudget = u32[(ptr + 284) >> 2] | 0;- out.collisionMaxDistance = f32[(ptr + 288) >> 2];- out.collisionFallback = u32[(ptr + 292) >> 2] | 0;- out.collisionEvents = u8[ptr + 296] !== 0;- out.collisionEventBudget = u32[(ptr + 300) >> 2] | 0;- out.collisionBounce = f32[(ptr + 304) >> 2];- out.collisionFriction = f32[(ptr + 308) >> 2];- out.collisionLifetimeLoss = f32[(ptr + 312) >> 2];+ const addedVelocityMin_ = out.addedVelocityMin; addedVelocityMin_.x = f32[(ptr + 168) >> 2]; addedVelocityMin_.y = f32[((ptr + 168) >> 2) + 1]; addedVelocityMin_.z = f32[((ptr + 168) >> 2) + 2];+ const addedVelocityMax_ = out.addedVelocityMax; addedVelocityMax_.x = f32[(ptr + 180) >> 2]; addedVelocityMax_.y = f32[((ptr + 180) >> 2) + 1]; addedVelocityMax_.z = f32[((ptr + 180) >> 2) + 2];+ out.speedLimit = f32[(ptr + 192) >> 2];+ out.limitDampen = f32[(ptr + 196) >> 2];+ out.noiseStrength = f32[(ptr + 200) >> 2];+ out.noiseFrequency = f32[(ptr + 204) >> 2];+ out.noiseScrollSpeed = f32[(ptr + 208) >> 2];+ out.noiseOctaves = u32[(ptr + 212) >> 2] | 0;+ out.texture = u32[(ptr + 216) >> 2];+ out.spriteColumns = u32[(ptr + 220) >> 2] | 0;+ out.spriteRows = u32[(ptr + 224) >> 2] | 0;+ out.spriteFPS = f32[(ptr + 228) >> 2];+ out.spriteLoop = u8[ptr + 232] !== 0;+ out.blendMode = u32[(ptr + 236) >> 2] | 0;+ out.layer = u32[(ptr + 240) >> 2] | 0;+ out.material = u32[(ptr + 244) >> 2];+ out.simulationSpace = u32[(ptr + 248) >> 2] | 0;+ out.renderMode = u32[(ptr + 252) >> 2] | 0;+ out.velocityScale = f32[(ptr + 256) >> 2];+ out.lengthScale = f32[(ptr + 260) >> 2];+ out.enabled = u8[ptr + 264] !== 0;+ out.subEmitterTrigger = u32[(ptr + 268) >> 2] | 0;+ out.subEmitterChance = f32[(ptr + 272) >> 2];+ out.subEmitterInheritVelocity = f32[(ptr + 276) >> 2];+ out.subEmitter = u32[(ptr + 280) >> 2];+ out.trailEnabled = u8[ptr + 284] !== 0;+ out.trailWidth = f32[(ptr + 288) >> 2];+ out.trailPoints = u32[(ptr + 292) >> 2] | 0;+ out.trailMinDistance = f32[(ptr + 296) >> 2];+ out.collisionEnabled = u8[ptr + 300] !== 0;+ out.collisionFloor = f32[(ptr + 304) >> 2];+ out.collisionMode = u32[(ptr + 308) >> 2] | 0;+ out.collisionMask = u32[(ptr + 312) >> 2];+ out.collisionQueryBudget = u32[(ptr + 316) >> 2] | 0;+ out.collisionMaxDistance = f32[(ptr + 320) >> 2];+ out.collisionFallback = u32[(ptr + 324) >> 2] | 0;+ out.collisionEvents = u8[ptr + 328] !== 0;+ out.collisionEventBudget = u32[(ptr + 332) >> 2] | 0;+ out.collisionBounce = f32[(ptr + 336) >> 2];+ out.collisionFriction = f32[(ptr + 340) >> 2];+ out.collisionLifetimeLoss = f32[(ptr + 344) >> 2];}export function writeParticleEmitter(@@ -1407,43 +1415,47 @@ export function writeParticleEmitter(f32[(ptr + 148) >> 2] = data.angularVelocityMax;f32[(ptr + 152) >> 2] = data.gravity.x; f32[((ptr + 152) >> 2) + 1] = data.gravity.y; f32[((ptr + 152) >> 2) + 2] = data.gravity.z;f32[(ptr + 164) >> 2] = data.damping;- f32[(ptr + 168) >> 2] = data.noiseStrength;- f32[(ptr + 172) >> 2] = data.noiseFrequency;- f32[(ptr + 176) >> 2] = data.noiseScrollSpeed;- u32[(ptr + 180) >> 2] = data.noiseOctaves | 0;- u32[(ptr + 184) >> 2] = data.texture;- u32[(ptr + 188) >> 2] = data.spriteColumns | 0;- u32[(ptr + 192) >> 2] = data.spriteRows | 0;- f32[(ptr + 196) >> 2] = data.spriteFPS;- u8[ptr + 200] = data.spriteLoop ? 1 : 0;- u32[(ptr + 204) >> 2] = data.blendMode | 0;- u32[(ptr + 208) >> 2] = data.layer | 0;- u32[(ptr + 212) >> 2] = data.material;- u32[(ptr + 216) >> 2] = data.simulationSpace | 0;- u32[(ptr + 220) >> 2] = data.renderMode | 0;- f32[(ptr + 224) >> 2] = data.velocityScale;- f32[(ptr + 228) >> 2] = data.lengthScale;- u8[ptr + 232] = data.enabled ? 1 : 0;- u32[(ptr + 236) >> 2] = data.subEmitterTrigger | 0;- f32[(ptr + 240) >> 2] = data.subEmitterChance;- f32[(ptr + 244) >> 2] = data.subEmitterInheritVelocity;- u32[(ptr + 248) >> 2] = data.subEmitter;- u8[ptr + 252] = data.trailEnabled ? 1 : 0;- f32[(ptr + 256) >> 2] = data.trailWidth;- u32[(ptr + 260) >> 2] = data.trailPoints | 0;- f32[(ptr + 264) >> 2] = data.trailMinDistance;- u8[ptr + 268] = data.collisionEnabled ? 1 : 0;- f32[(ptr + 272) >> 2] = data.collisionFloor;- u32[(ptr + 276) >> 2] = data.collisionMode | 0;- u32[(ptr + 280) >> 2] = data.collisionMask;- u32[(ptr + 284) >> 2] = data.collisionQueryBudget | 0;- f32[(ptr + 288) >> 2] = data.collisionMaxDistance;- u32[(ptr + 292) >> 2] = data.collisionFallback | 0;- u8[ptr + 296] = data.collisionEvents ? 1 : 0;- u32[(ptr + 300) >> 2] = data.collisionEventBudget | 0;- f32[(ptr + 304) >> 2] = data.collisionBounce;- f32[(ptr + 308) >> 2] = data.collisionFriction;- f32[(ptr + 312) >> 2] = data.collisionLifetimeLoss;+ f32[(ptr + 168) >> 2] = data.addedVelocityMin.x; f32[((ptr + 168) >> 2) + 1] = data.addedVelocityMin.y; f32[((ptr + 168) >> 2) + 2] = data.addedVelocityMin.z;+ f32[(ptr + 180) >> 2] = data.addedVelocityMax.x; f32[((ptr + 180) >> 2) + 1] = data.addedVelocityMax.y; f32[((ptr + 180) >> 2) + 2] = data.addedVelocityMax.z;+ f32[(ptr + 192) >> 2] = data.speedLimit;+ f32[(ptr + 196) >> 2] = data.limitDampen;+ f32[(ptr + 200) >> 2] = data.noiseStrength;+ f32[(ptr + 204) >> 2] = data.noiseFrequency;+ f32[(ptr + 208) >> 2] = data.noiseScrollSpeed;+ u32[(ptr + 212) >> 2] = data.noiseOctaves | 0;+ u32[(ptr + 216) >> 2] = data.texture;+ u32[(ptr + 220) >> 2] = data.spriteColumns | 0;+ u32[(ptr + 224) >> 2] = data.spriteRows | 0;+ f32[(ptr + 228) >> 2] = data.spriteFPS;+ u8[ptr + 232] = data.spriteLoop ? 1 : 0;+ u32[(ptr + 236) >> 2] = data.blendMode | 0;+ u32[(ptr + 240) >> 2] = data.layer | 0;+ u32[(ptr + 244) >> 2] = data.material;+ u32[(ptr + 248) >> 2] = data.simulationSpace | 0;+ u32[(ptr + 252) >> 2] = data.renderMode | 0;+ f32[(ptr + 256) >> 2] = data.velocityScale;+ f32[(ptr + 260) >> 2] = data.lengthScale;+ u8[ptr + 264] = data.enabled ? 1 : 0;+ u32[(ptr + 268) >> 2] = data.subEmitterTrigger | 0;+ f32[(ptr + 272) >> 2] = data.subEmitterChance;+ f32[(ptr + 276) >> 2] = data.subEmitterInheritVelocity;+ u32[(ptr + 280) >> 2] = data.subEmitter;+ u8[ptr + 284] = data.trailEnabled ? 1 : 0;+ f32[(ptr + 288) >> 2] = data.trailWidth;+ u32[(ptr + 292) >> 2] = data.trailPoints | 0;+ f32[(ptr + 296) >> 2] = data.trailMinDistance;+ u8[ptr + 300] = data.collisionEnabled ? 1 : 0;+ f32[(ptr + 304) >> 2] = data.collisionFloor;+ u32[(ptr + 308) >> 2] = data.collisionMode | 0;+ u32[(ptr + 312) >> 2] = data.collisionMask;+ u32[(ptr + 316) >> 2] = data.collisionQueryBudget | 0;+ f32[(ptr + 320) >> 2] = data.collisionMaxDistance;+ u32[(ptr + 324) >> 2] = data.collisionFallback | 0;+ u8[ptr + 328] = data.collisionEvents ? 1 : 0;+ u32[(ptr + 332) >> 2] = data.collisionEventBudget | 0;+ f32[(ptr + 336) >> 2] = data.collisionBounce;+ f32[(ptr + 340) >> 2] = data.collisionFriction;+ f32[(ptr + 344) >> 2] = data.collisionLifetimeLoss;}export function createParticleEmitterData(): ParticleEmitterPtrData {@@ -1481,6 +1493,10 @@ export function createParticleEmitterData(): ParticleEmitterPtrData {angularVelocityMax: 0,gravity: { x: 0, y: 0, z: 0 },damping: 0,+ addedVelocityMin: { x: 0, y: 0, z: 0 },+ addedVelocityMax: { x: 0, y: 0, z: 0 },+ speedLimit: 0,+ limitDampen: 0,noiseStrength: 0,noiseFrequency: 0,noiseScrollSpeed: 0,diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.tsindex f65b1b197..e1ab67f35 100644--- a/sdk/src/ecs/component.generated.ts+++ b/sdk/src/ecs/component.generated.ts@@ -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 = 'e41570f14820a1a8';+export const ABI_LAYOUT_HASH = '097d3c7989a498a1';/*** One asset-valued field of a component: which field, and what kind of@@ -733,6 +733,10 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {angularVelocityMax: 0,gravity: { x: 0, y: 0, z: 0 },damping: 0,+ addedVelocityMin: { x: 0, y: 0, z: 0 },+ addedVelocityMax: { x: 0, y: 0, z: 0 },+ speedLimit: 0,+ limitDampen: 1,noiseStrength: 0,noiseFrequency: 0.01,noiseScrollSpeed: 0,@@ -810,6 +814,10 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {angularVelocityMax: { category: "Rotation" },gravity: { category: "Velocity" },damping: { min: 0, category: "Velocity" },+ addedVelocityMin: { tooltip: "A velocity each particle carries on top of its own, chosen between the two ends when it is born. Gravity, damping, noise and the speed limit do not act on it. Run by the CPU simulation.", category: "Velocity" },+ addedVelocityMax: { category: "Velocity" },+ speedLimit: { min: 0, tooltip: "The fastest a particle may move under its own velocity; 0 is no limit. A faster particle is pulled back toward the limit. Run by the CPU simulation.", category: "Velocity" },+ limitDampen: { min: 0, max: 1, tooltip: "How much of the excess over the limit is removed per 1/60 s: 1 clamps at once, a small value brakes gently.", category: "Velocity" },noiseStrength: { min: 0, category: "Noise" },noiseFrequency: { min: 0, category: "Noise" },noiseScrollSpeed: { category: "Noise" },@@ -1762,6 +1770,10 @@ export interface ParticleEmitterData {angularVelocityMax: number;gravity: Vec3;damping: number;+ addedVelocityMin: Vec3;+ addedVelocityMax: Vec3;+ speedLimit: number;+ limitDampen: number;noiseStrength: number;noiseFrequency: number;noiseScrollSpeed: number;diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.tsindex 4436a861c..009213ee4 100644--- a/sdk/src/wasm/ptrLayouts.generated.ts+++ b/sdk/src/wasm/ptrLayouts.generated.ts@@ -366,43 +366,47 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {{ name: 'angularVelocityMax', type: 'f32', offset: 148 },{ name: 'gravity', type: 'vec3', offset: 152 },{ name: 'damping', type: 'f32', offset: 164 },- { name: 'noiseStrength', type: 'f32', offset: 168 },- { name: 'noiseFrequency', type: 'f32', offset: 172 },- { name: 'noiseScrollSpeed', type: 'f32', offset: 176 },- { name: 'noiseOctaves', type: 'i32', offset: 180 },- { name: 'texture', type: 'u32', offset: 184 },- { name: 'spriteColumns', type: 'i32', offset: 188 },- { name: 'spriteRows', type: 'i32', offset: 192 },- { name: 'spriteFPS', type: 'f32', offset: 196 },- { name: 'spriteLoop', type: 'bool', offset: 200 },- { name: 'blendMode', type: 'i32', offset: 204 },- { name: 'layer', type: 'i32', offset: 208 },- { name: 'material', type: 'u32', offset: 212 },- { name: 'simulationSpace', type: 'i32', offset: 216 },- { name: 'renderMode', type: 'i32', offset: 220 },- { name: 'velocityScale', type: 'f32', offset: 224 },- { name: 'lengthScale', type: 'f32', offset: 228 },- { name: 'enabled', type: 'bool', offset: 232 },- { name: 'subEmitterTrigger', type: 'i32', offset: 236 },- { name: 'subEmitterChance', type: 'f32', offset: 240 },- { name: 'subEmitterInheritVelocity', type: 'f32', offset: 244 },- { name: 'subEmitter', type: 'u32', offset: 248 },- { name: 'trailEnabled', type: 'bool', offset: 252 },- { name: 'trailWidth', type: 'f32', offset: 256 },- { name: 'trailPoints', type: 'i32', offset: 260 },- { name: 'trailMinDistance', type: 'f32', offset: 264 },- { name: 'collisionEnabled', type: 'bool', offset: 268 },- { name: 'collisionFloor', type: 'f32', offset: 272 },- { name: 'collisionMode', type: 'i32', offset: 276 },- { name: 'collisionMask', type: 'u32', offset: 280 },- { name: 'collisionQueryBudget', type: 'i32', offset: 284 },- { name: 'collisionMaxDistance', type: 'f32', offset: 288 },- { name: 'collisionFallback', type: 'i32', offset: 292 },- { name: 'collisionEvents', type: 'bool', offset: 296 },- { name: 'collisionEventBudget', type: 'i32', offset: 300 },- { name: 'collisionBounce', type: 'f32', offset: 304 },- { name: 'collisionFriction', type: 'f32', offset: 308 },- { name: 'collisionLifetimeLoss', type: 'f32', offset: 312 },+ { name: 'addedVelocityMin', type: 'vec3', offset: 168 },+ { name: 'addedVelocityMax', type: 'vec3', offset: 180 },+ { name: 'speedLimit', type: 'f32', offset: 192 },+ { name: 'limitDampen', type: 'f32', offset: 196 },+ { name: 'noiseStrength', type: 'f32', offset: 200 },+ { name: 'noiseFrequency', type: 'f32', offset: 204 },+ { name: 'noiseScrollSpeed', type: 'f32', offset: 208 },+ { name: 'noiseOctaves', type: 'i32', offset: 212 },+ { name: 'texture', type: 'u32', offset: 216 },+ { name: 'spriteColumns', type: 'i32', offset: 220 },+ { name: 'spriteRows', type: 'i32', offset: 224 },+ { name: 'spriteFPS', type: 'f32', offset: 228 },+ { name: 'spriteLoop', type: 'bool', offset: 232 },+ { name: 'blendMode', type: 'i32', offset: 236 },+ { name: 'layer', type: 'i32', offset: 240 },+ { name: 'material', type: 'u32', offset: 244 },+ { name: 'simulationSpace', type: 'i32', offset: 248 },+ { name: 'renderMode', type: 'i32', offset: 252 },+ { name: 'velocityScale', type: 'f32', offset: 256 },+ { name: 'lengthScale', type: 'f32', offset: 260 },+ { name: 'enabled', type: 'bool', offset: 264 },+ { name: 'subEmitterTrigger', type: 'i32', offset: 268 },+ { name: 'subEmitterChance', type: 'f32', offset: 272 },+ { name: 'subEmitterInheritVelocity', type: 'f32', offset: 276 },+ { name: 'subEmitter', type: 'u32', offset: 280 },+ { name: 'trailEnabled', type: 'bool', offset: 284 },+ { name: 'trailWidth', type: 'f32', offset: 288 },+ { name: 'trailPoints', type: 'i32', offset: 292 },+ { name: 'trailMinDistance', type: 'f32', offset: 296 },+ { name: 'collisionEnabled', type: 'bool', offset: 300 },+ { name: 'collisionFloor', type: 'f32', offset: 304 },+ { name: 'collisionMode', type: 'i32', offset: 308 },+ { name: 'collisionMask', type: 'u32', offset: 312 },+ { name: 'collisionQueryBudget', type: 'i32', offset: 316 },+ { name: 'collisionMaxDistance', type: 'f32', offset: 320 },+ { name: 'collisionFallback', type: 'i32', offset: 324 },+ { name: 'collisionEvents', type: 'bool', offset: 328 },+ { name: 'collisionEventBudget', type: 'i32', offset: 332 },+ { name: 'collisionBounce', type: 'f32', offset: 336 },+ { name: 'collisionFriction', type: 'f32', offset: 340 },+ { name: 'collisionLifetimeLoss', type: 'f32', offset: 344 },],},ParticleForceField: {diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.tsindex 4c35a9f54..4bf56f6ff 100644--- a/sdk/src/wasm/wasm.generated.ts+++ b/sdk/src/wasm/wasm.generated.ts@@ -767,6 +767,10 @@ export interface ParticleEmitter {angularVelocityMax: number;gravity: Vec3;damping: number;+ addedVelocityMin: Vec3;+ addedVelocityMax: Vec3;+ speedLimit: number;+ limitDampen: number;noiseStrength: number;noiseFrequency: number;noiseScrollSpeed: number;diff --git a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snapindex c5f3e146f..30dfcc141 100644--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap@@ -570,6 +570,13 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho},},"ParticleEmitter": {+ "addedVelocityMax": {+ "category": "Velocity",+ },+ "addedVelocityMin": {+ "category": "Velocity",+ "tooltip": "A velocity each particle carries on top of its own, chosen between the two ends when it is born. Gravity, damping, noise and the speed limit do not act on it. Run by the CPU simulation.",+ },"angleSpreadMax": {"category": "Velocity","shownWhen": {@@ -872,6 +879,12 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho"category": "Lifetime","min": 0,},+ "limitDampen": {+ "category": "Velocity",+ "max": 1,+ "min": 0,+ "tooltip": "How much of the excess over the limit is removed per 1/60 s: 1 clamps at once, a small value brakes gently.",+ },"looping": {"category": "Emission",},@@ -1028,6 +1041,11 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho},],},+ "speedLimit": {+ "category": "Velocity",+ "min": 0,+ "tooltip": "The fastest a particle may move under its own velocity; 0 is no limit. A faster particle is pulled back toward the limit. Run by the CPU simulation.",+ },"speedMax": {"category": "Velocity",},diff --git a/src/esengine/aot/EngineDigest.generated.h b/src/esengine/aot/EngineDigest.generated.hindex 2efd3dc99..3c4aac95b 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 0x426310d99a92b4adULL-#define ES_ENGINE_ABI_DIGEST_64 0xda66422d358dcce9ULL+#define ES_ENGINE_ABI_DIGEST_32 0xf8803b93f89c650eULL+#define ES_ENGINE_ABI_DIGEST_64 0x2125285699976f62ULL#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 a09ce4068..ad5079f34 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 68323eb41201a201+ * @schema_hash 3f55d2569faef078*/-#define ES_EDITOR_API_SCHEMA_HASH "68323eb41201a201"+#define ES_EDITOR_API_SCHEMA_HASH "3f55d2569faef078"#include <emscripten/bind.h>#include <string>@@ -501,6 +501,14 @@ std::string editor_getComponentSchema(const std::string& name) {{"key":"gravity.y","type":"float","group":"ParticleEmitter"},{"key":"gravity.z","type":"float","group":"ParticleEmitter"},{"key":"damping","type":"float","group":"ParticleEmitter"},+ {"key":"addedVelocityMin.x","type":"float","group":"ParticleEmitter"},+ {"key":"addedVelocityMin.y","type":"float","group":"ParticleEmitter"},+ {"key":"addedVelocityMin.z","type":"float","group":"ParticleEmitter"},+ {"key":"addedVelocityMax.x","type":"float","group":"ParticleEmitter"},+ {"key":"addedVelocityMax.y","type":"float","group":"ParticleEmitter"},+ {"key":"addedVelocityMax.z","type":"float","group":"ParticleEmitter"},+ {"key":"speedLimit","type":"float","group":"ParticleEmitter"},+ {"key":"limitDampen","type":"float","group":"ParticleEmitter"},{"key":"noiseStrength","type":"float","group":"ParticleEmitter"},{"key":"noiseFrequency","type":"float","group":"ParticleEmitter"},{"key":"noiseScrollSpeed","type":"float","group":"ParticleEmitter"},@@ -1592,6 +1600,14 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::selse if (field == "gravity.y") { c.gravity.y = value; }else if (field == "gravity.z") { c.gravity.z = value; }else if (field == "damping") { c.damping = value; }+ else if (field == "addedVelocityMin.x") { c.addedVelocityMin.x = value; }+ else if (field == "addedVelocityMin.y") { c.addedVelocityMin.y = value; }+ else if (field == "addedVelocityMin.z") { c.addedVelocityMin.z = value; }+ else if (field == "addedVelocityMax.x") { c.addedVelocityMax.x = value; }+ else if (field == "addedVelocityMax.y") { c.addedVelocityMax.y = value; }+ else if (field == "addedVelocityMax.z") { c.addedVelocityMax.z = value; }+ else if (field == "speedLimit") { c.speedLimit = value; }+ else if (field == "limitDampen") { c.limitDampen = value; }else if (field == "noiseStrength") { c.noiseStrength = value; }else if (field == "noiseFrequency") { c.noiseFrequency = value; }else if (field == "noiseScrollSpeed") { c.noiseScrollSpeed = value; }@@ -2164,6 +2180,14 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::stelse if (field == "gravity.y") { return c.gravity.y; }else if (field == "gravity.z") { return c.gravity.z; }else if (field == "damping") { return c.damping; }+ else if (field == "addedVelocityMin.x") { return c.addedVelocityMin.x; }+ else if (field == "addedVelocityMin.y") { return c.addedVelocityMin.y; }+ else if (field == "addedVelocityMin.z") { return c.addedVelocityMin.z; }+ else if (field == "addedVelocityMax.x") { return c.addedVelocityMax.x; }+ else if (field == "addedVelocityMax.y") { return c.addedVelocityMax.y; }+ else if (field == "addedVelocityMax.z") { return c.addedVelocityMax.z; }+ else if (field == "speedLimit") { return c.speedLimit; }+ else if (field == "limitDampen") { return c.limitDampen; }else if (field == "noiseStrength") { return c.noiseStrength; }else if (field == "noiseFrequency") { return c.noiseFrequency; }else if (field == "noiseScrollSpeed") { return c.noiseScrollSpeed; }diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex 67cd5161f..5366fbbff 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -971,6 +971,10 @@ struct ParticleEmitterJS {f32 angularVelocityMax;glm::vec3 gravity;f32 damping;+ glm::vec3 addedVelocityMin;+ glm::vec3 addedVelocityMax;+ f32 speedLimit;+ f32 limitDampen;f32 noiseStrength;f32 noiseFrequency;f32 noiseScrollSpeed;@@ -1044,6 +1048,10 @@ void particleemitterApplyJS(esengine::ecs::ParticleEmitter& c, const ParticleEmic.angularVelocityMax = js.angularVelocityMax;c.gravity = js.gravity;c.damping = js.damping;+ c.addedVelocityMin = js.addedVelocityMin;+ c.addedVelocityMax = js.addedVelocityMax;+ c.speedLimit = js.speedLimit;+ c.limitDampen = js.limitDampen;c.noiseStrength = js.noiseStrength;c.noiseFrequency = js.noiseFrequency;c.noiseScrollSpeed = js.noiseScrollSpeed;@@ -1124,6 +1132,10 @@ ParticleEmitterJS particleemitterToJS(const esengine::ecs::ParticleEmitter& c) {js.angularVelocityMax = c.angularVelocityMax;js.gravity = c.gravity;js.damping = c.damping;+ js.addedVelocityMin = c.addedVelocityMin;+ js.addedVelocityMax = c.addedVelocityMax;+ js.speedLimit = c.speedLimit;+ js.limitDampen = c.limitDampen;js.noiseStrength = c.noiseStrength;js.noiseFrequency = c.noiseFrequency;js.noiseScrollSpeed = c.noiseScrollSpeed;@@ -2102,6 +2114,10 @@ EMSCRIPTEN_BINDINGS(esengine_components) {.field("angularVelocityMax", &ParticleEmitterJS::angularVelocityMax).field("gravity", &ParticleEmitterJS::gravity).field("damping", &ParticleEmitterJS::damping)+ .field("addedVelocityMin", &ParticleEmitterJS::addedVelocityMin)+ .field("addedVelocityMax", &ParticleEmitterJS::addedVelocityMax)+ .field("speedLimit", &ParticleEmitterJS::speedLimit)+ .field("limitDampen", &ParticleEmitterJS::limitDampen).field("noiseStrength", &ParticleEmitterJS::noiseStrength).field("noiseFrequency", &ParticleEmitterJS::noiseFrequency).field("noiseScrollSpeed", &ParticleEmitterJS::noiseScrollSpeed)@@ -4036,43 +4052,47 @@ static_assert(offsetof(esengine::ecs::ParticleEmitter, angularVelocityMin) == 14static_assert(offsetof(esengine::ecs::ParticleEmitter, angularVelocityMax) == 148, "ABI offset drift: esengine::ecs::ParticleEmitter.angularVelocityMax (EHT expected 148)");static_assert(offsetof(esengine::ecs::ParticleEmitter, gravity) == 152, "ABI offset drift: esengine::ecs::ParticleEmitter.gravity (EHT expected 152)");static_assert(offsetof(esengine::ecs::ParticleEmitter, damping) == 164, "ABI offset drift: esengine::ecs::ParticleEmitter.damping (EHT expected 164)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, noiseStrength) == 168, "ABI offset drift: esengine::ecs::ParticleEmitter.noiseStrength (EHT expected 168)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, noiseFrequency) == 172, "ABI offset drift: esengine::ecs::ParticleEmitter.noiseFrequency (EHT expected 172)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, noiseScrollSpeed) == 176, "ABI offset drift: esengine::ecs::ParticleEmitter.noiseScrollSpeed (EHT expected 176)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, noiseOctaves) == 180, "ABI offset drift: esengine::ecs::ParticleEmitter.noiseOctaves (EHT expected 180)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, texture) == 184, "ABI offset drift: esengine::ecs::ParticleEmitter.texture (EHT expected 184)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, spriteColumns) == 188, "ABI offset drift: esengine::ecs::ParticleEmitter.spriteColumns (EHT expected 188)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, spriteRows) == 192, "ABI offset drift: esengine::ecs::ParticleEmitter.spriteRows (EHT expected 192)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, spriteFPS) == 196, "ABI offset drift: esengine::ecs::ParticleEmitter.spriteFPS (EHT expected 196)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, spriteLoop) == 200, "ABI offset drift: esengine::ecs::ParticleEmitter.spriteLoop (EHT expected 200)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, blendMode) == 204, "ABI offset drift: esengine::ecs::ParticleEmitter.blendMode (EHT expected 204)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, layer) == 208, "ABI offset drift: esengine::ecs::ParticleEmitter.layer (EHT expected 208)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, material) == 212, "ABI offset drift: esengine::ecs::ParticleEmitter.material (EHT expected 212)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, simulationSpace) == 216, "ABI offset drift: esengine::ecs::ParticleEmitter.simulationSpace (EHT expected 216)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, renderMode) == 220, "ABI offset drift: esengine::ecs::ParticleEmitter.renderMode (EHT expected 220)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, velocityScale) == 224, "ABI offset drift: esengine::ecs::ParticleEmitter.velocityScale (EHT expected 224)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, lengthScale) == 228, "ABI offset drift: esengine::ecs::ParticleEmitter.lengthScale (EHT expected 228)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, enabled) == 232, "ABI offset drift: esengine::ecs::ParticleEmitter.enabled (EHT expected 232)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, subEmitterTrigger) == 236, "ABI offset drift: esengine::ecs::ParticleEmitter.subEmitterTrigger (EHT expected 236)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, subEmitterChance) == 240, "ABI offset drift: esengine::ecs::ParticleEmitter.subEmitterChance (EHT expected 240)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, subEmitterInheritVelocity) == 244, "ABI offset drift: esengine::ecs::ParticleEmitter.subEmitterInheritVelocity (EHT expected 244)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, subEmitter) == 248, "ABI offset drift: esengine::ecs::ParticleEmitter.subEmitter (EHT expected 248)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, trailEnabled) == 252, "ABI offset drift: esengine::ecs::ParticleEmitter.trailEnabled (EHT expected 252)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, trailWidth) == 256, "ABI offset drift: esengine::ecs::ParticleEmitter.trailWidth (EHT expected 256)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, trailPoints) == 260, "ABI offset drift: esengine::ecs::ParticleEmitter.trailPoints (EHT expected 260)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, trailMinDistance) == 264, "ABI offset drift: esengine::ecs::ParticleEmitter.trailMinDistance (EHT expected 264)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionEnabled) == 268, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionEnabled (EHT expected 268)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionFloor) == 272, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionFloor (EHT expected 272)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionMode) == 276, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionMode (EHT expected 276)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionMask) == 280, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionMask (EHT expected 280)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionQueryBudget) == 284, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionQueryBudget (EHT expected 284)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionMaxDistance) == 288, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionMaxDistance (EHT expected 288)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionFallback) == 292, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionFallback (EHT expected 292)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionEvents) == 296, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionEvents (EHT expected 296)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionEventBudget) == 300, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionEventBudget (EHT expected 300)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionBounce) == 304, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionBounce (EHT expected 304)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionFriction) == 308, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionFriction (EHT expected 308)");-static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionLifetimeLoss) == 312, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionLifetimeLoss (EHT expected 312)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, addedVelocityMin) == 168, "ABI offset drift: esengine::ecs::ParticleEmitter.addedVelocityMin (EHT expected 168)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, addedVelocityMax) == 180, "ABI offset drift: esengine::ecs::ParticleEmitter.addedVelocityMax (EHT expected 180)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, speedLimit) == 192, "ABI offset drift: esengine::ecs::ParticleEmitter.speedLimit (EHT expected 192)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, limitDampen) == 196, "ABI offset drift: esengine::ecs::ParticleEmitter.limitDampen (EHT expected 196)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, noiseStrength) == 200, "ABI offset drift: esengine::ecs::ParticleEmitter.noiseStrength (EHT expected 200)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, noiseFrequency) == 204, "ABI offset drift: esengine::ecs::ParticleEmitter.noiseFrequency (EHT expected 204)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, noiseScrollSpeed) == 208, "ABI offset drift: esengine::ecs::ParticleEmitter.noiseScrollSpeed (EHT expected 208)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, noiseOctaves) == 212, "ABI offset drift: esengine::ecs::ParticleEmitter.noiseOctaves (EHT expected 212)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, texture) == 216, "ABI offset drift: esengine::ecs::ParticleEmitter.texture (EHT expected 216)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, spriteColumns) == 220, "ABI offset drift: esengine::ecs::ParticleEmitter.spriteColumns (EHT expected 220)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, spriteRows) == 224, "ABI offset drift: esengine::ecs::ParticleEmitter.spriteRows (EHT expected 224)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, spriteFPS) == 228, "ABI offset drift: esengine::ecs::ParticleEmitter.spriteFPS (EHT expected 228)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, spriteLoop) == 232, "ABI offset drift: esengine::ecs::ParticleEmitter.spriteLoop (EHT expected 232)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, blendMode) == 236, "ABI offset drift: esengine::ecs::ParticleEmitter.blendMode (EHT expected 236)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, layer) == 240, "ABI offset drift: esengine::ecs::ParticleEmitter.layer (EHT expected 240)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, material) == 244, "ABI offset drift: esengine::ecs::ParticleEmitter.material (EHT expected 244)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, simulationSpace) == 248, "ABI offset drift: esengine::ecs::ParticleEmitter.simulationSpace (EHT expected 248)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, renderMode) == 252, "ABI offset drift: esengine::ecs::ParticleEmitter.renderMode (EHT expected 252)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, velocityScale) == 256, "ABI offset drift: esengine::ecs::ParticleEmitter.velocityScale (EHT expected 256)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, lengthScale) == 260, "ABI offset drift: esengine::ecs::ParticleEmitter.lengthScale (EHT expected 260)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, enabled) == 264, "ABI offset drift: esengine::ecs::ParticleEmitter.enabled (EHT expected 264)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, subEmitterTrigger) == 268, "ABI offset drift: esengine::ecs::ParticleEmitter.subEmitterTrigger (EHT expected 268)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, subEmitterChance) == 272, "ABI offset drift: esengine::ecs::ParticleEmitter.subEmitterChance (EHT expected 272)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, subEmitterInheritVelocity) == 276, "ABI offset drift: esengine::ecs::ParticleEmitter.subEmitterInheritVelocity (EHT expected 276)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, subEmitter) == 280, "ABI offset drift: esengine::ecs::ParticleEmitter.subEmitter (EHT expected 280)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, trailEnabled) == 284, "ABI offset drift: esengine::ecs::ParticleEmitter.trailEnabled (EHT expected 284)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, trailWidth) == 288, "ABI offset drift: esengine::ecs::ParticleEmitter.trailWidth (EHT expected 288)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, trailPoints) == 292, "ABI offset drift: esengine::ecs::ParticleEmitter.trailPoints (EHT expected 292)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, trailMinDistance) == 296, "ABI offset drift: esengine::ecs::ParticleEmitter.trailMinDistance (EHT expected 296)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionEnabled) == 300, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionEnabled (EHT expected 300)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionFloor) == 304, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionFloor (EHT expected 304)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionMode) == 308, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionMode (EHT expected 308)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionMask) == 312, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionMask (EHT expected 312)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionQueryBudget) == 316, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionQueryBudget (EHT expected 316)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionMaxDistance) == 320, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionMaxDistance (EHT expected 320)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionFallback) == 324, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionFallback (EHT expected 324)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionEvents) == 328, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionEvents (EHT expected 328)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionEventBudget) == 332, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionEventBudget (EHT expected 332)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionBounce) == 336, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionBounce (EHT expected 336)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionFriction) == 340, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionFriction (EHT expected 340)");+static_assert(offsetof(esengine::ecs::ParticleEmitter, collisionLifetimeLoss) == 344, "ABI offset drift: esengine::ecs::ParticleEmitter.collisionLifetimeLoss (EHT expected 344)");static_assert(offsetof(esengine::ecs::ParticleForceField, type) == 0, "ABI offset drift: esengine::ecs::ParticleForceField.type (EHT expected 0)");static_assert(offsetof(esengine::ecs::ParticleForceField, strength) == 4, "ABI offset drift: esengine::ecs::ParticleForceField.strength (EHT expected 4)");static_assert(offsetof(esengine::ecs::ParticleForceField, radius) == 8, "ABI offset drift: esengine::ecs::ParticleForceField.radius (EHT expected 8)");@@ -4270,7 +4290,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "e41570f14820a1a8";+static const char* kEsAbiLayoutHash = "097d3c7989a498a1";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/ecs/components/ParticleEmitter.hpp b/src/esengine/ecs/components/ParticleEmitter.hppindex 43b5799bf..3d7d034d2 100644--- a/src/esengine/ecs/components/ParticleEmitter.hpp+++ b/src/esengine/ecs/components/ParticleEmitter.hpp@@ -186,6 +186,18 @@ struct ParticleEmitter {ES_PROPERTY(min=0, category=Velocity)f32 damping{0.0f};+ ES_PROPERTY(category=Velocity, tooltip="A velocity each particle carries on top of its own, chosen between the two ends when it is born. Gravity, damping, noise and the speed limit do not act on it. Run by the CPU simulation.")+ glm::vec3 addedVelocityMin{0.0f, 0.0f, 0.0f};++ ES_PROPERTY(category=Velocity)+ glm::vec3 addedVelocityMax{0.0f, 0.0f, 0.0f};++ ES_PROPERTY(min=0, category=Velocity, tooltip="The fastest a particle may move under its own velocity; 0 is no limit. A faster particle is pulled back toward the limit. Run by the CPU simulation.")+ f32 speedLimit{0.0f};++ ES_PROPERTY(min=0, max=1, category=Velocity, tooltip="How much of the excess over the limit is removed per 1/60 s: 1 clamps at once, a small value brakes gently.")+ f32 limitDampen{1.0f};+// Noise / Turbulence — a divergence-free curl-noise flow field advects each// particle, layered on top of velocity/gravity. Strength 0 disables it (no// field is sampled), so the module is free when unused.diff --git a/src/esengine/particle/Particle.hpp b/src/esengine/particle/Particle.hppindex e394c4c0b..3f6deff59 100644--- a/src/esengine/particle/Particle.hpp+++ b/src/esengine/particle/Particle.hpp@@ -13,6 +13,7 @@ namespace esengine::particle {struct Particle {glm::vec3 position{0.0f};glm::vec3 velocity{0.0f};+ glm::vec3 added_velocity{0.0f}; ///< Carried on top of `velocity`, outside gravity, damping and the speed limit.f32 rotation = 0.0f;f32 angular_velocity = 0.0f;f32 lifetime = 1.0f;diff --git a/src/esengine/particle/ParticleSpeedLimit.hpp b/src/esengine/particle/ParticleSpeedLimit.hppnew file mode 100644index 000000000..04105a377--- /dev/null+++ b/src/esengine/particle/ParticleSpeedLimit.hpp@@ -0,0 +1,28 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+#pragma once++#include "../core/Types.hpp"++#include <glm/glm.hpp>++#include <cmath>++namespace esengine::particle {++/**+ * @brief A particle's velocity after its speed limit has pulled it back.+ *+ * @details The excess over the limit shrinks by `dampen` for every 1/60 s that passes, so the braking does not change with the frame rate:+ * 1 removes the whole excess at once, a small value eases a fast particle down over several frames. A particle within the limit is+ * left as it is.+ */+inline glm::vec3 limitedVelocity(glm::vec3 velocity, f32 limit, f32 dampen, f32 dt) {+ const f32 speed = glm::length(velocity);+ if (limit <= 0.0f || speed <= limit) return velocity;+ const f32 keep = std::pow(1.0f - glm::clamp(dampen, 0.0f, 1.0f), dt * 60.0f); // the part of the excess left after dt+ const f32 target = limit + (speed - limit) * keep;+ return velocity * (target / speed);+}++} // namespace esengine::particlediff --git a/src/esengine/particle/ParticleSystem.cpp b/src/esengine/particle/ParticleSystem.cppindex 6ff7ae95e..e87078a6b 100644--- a/src/esengine/particle/ParticleSystem.cpp+++ b/src/esengine/particle/ParticleSystem.cpp@@ -9,6 +9,7 @@#include "../core/RandomSource.hpp"#include "../ecs/components/Camera.hpp"+#include "ParticleSpeedLimit.hpp"namespace esengine::particle {@@ -425,6 +426,9 @@ void ParticleSystem::emitInto(const ecs::ParticleEmitter& emitter, EmitterState&const glm::vec3 dir = isWorldSpace ? worldDirOf(sample.direction, frame): sample.direction;p->velocity = dir * speed + velocityBias;+ p->added_velocity = glm::vec3(randomRange(emitter.addedVelocityMin.x, emitter.addedVelocityMax.x),+ randomRange(emitter.addedVelocityMin.y, emitter.addedVelocityMax.y),+ randomRange(emitter.addedVelocityMin.z, emitter.addedVelocityMax.z));p->sprite_frame = 0;p->subEmitterDepth = depth;@@ -603,11 +607,14 @@ void ParticleSystem::updateParticles(const ecs::ParticleEmitter& emitter,if (emitter.damping > 0.0f) {p.velocity *= (1.0f - emitter.damping * dt);}+ if (emitter.speedLimit > 0.0f) {+ p.velocity = limitedVelocity(p.velocity, emitter.speedLimit, emitter.limitDampen, dt);+ }// Applied to the STEP, not to velocity, so speed-over-life cannot become// a second force system: gravity, damping and noise still accumulate into// velocity exactly as before.const glm::vec3 collisionFrom = p.position;- p.position += p.velocity * (speedLut ? sampleSizeLut(*speedLut, t) : 1.0f) * dt;+ p.position += (p.velocity * (speedLut ? sampleSizeLut(*speedLut, t) : 1.0f) + p.added_velocity) * dt;if (noiseOn) {// The curl field is a 2D flow, sampled on the plane the particle isdiff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txtindex c4069fce2..03805259b 100644--- a/tests/CMakeLists.txt+++ b/tests/CMakeLists.txt@@ -358,6 +358,14 @@ target_include_directories(test_particle_stretch PRIVATE)add_test(NAME test_particle_stretch COMMAND test_particle_stretch)+# Particle speed limit: the braking arithmetic, and that it does not depend on the frame rate. Header-only.+add_executable(test_particle_speed_limit particle/test_particle_speed_limit.cpp)+target_include_directories(test_particle_speed_limit PRIVATE+ ${CMAKE_SOURCE_DIR}/src+ ${CMAKE_SOURCE_DIR}/third_party/glm+)+add_test(NAME test_particle_speed_limit COMMAND test_particle_speed_limit)+# LOD selection: the projection arithmetic, the hysteresis band and the per-view# memory. Header-only, so it runs without a device — the pixel gates say which# level was drawn, this says which of the claims behind it broke.diff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.hindex 919d1e6fb..2e3e845f1 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 0xda66422d358dcce9ULL+#define ES_CONF_EXPECTED_CONTRACT_HASH 0x2125285699976f62ULL/* 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 35fef1c8d..d8784a64f 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 0xda66422d358dcce9ULL+#define ES_ABI_ENGINE_DIGEST 0x2125285699976f62ULLES_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 f1ef6fd11..ea8691dd5 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 0xda66422d358dcce9ULL+#define ES_ABI_ENGINE_DIGEST 0x2125285699976f62ULLES_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 ae35ea9cc..fef966e24 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 0xda66422d358dcce9ULL+#define ES_EXPECTED_CONTRACT_HASH 0x2125285699976f62ULL/* 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/particle/test_particle.cpp b/tests/particle/test_particle.cppindex 2e67fe7ec..06b8937bf 100644--- a/tests/particle/test_particle.cpp+++ b/tests/particle/test_particle.cpp@@ -317,6 +317,68 @@ TEST_CASE("system_no_start_delay_emits_on_the_first_update_as_before") {CHECK_EQ(system.totalAliveParticles(), 7u);}+TEST_CASE("system_added_velocity_moves_a_particle_that_gravity_and_damping_do_not_touch") {+ ecs::Registry registry;+ ParticleSystem system;++ Entity e = registry.create();+ registry.emplace<ecs::Transform>(e);+ auto& emitter = registry.emplace<ecs::ParticleEmitter>(e);+ emitter.rate = 0.0f;+ emitter.burstCount = 1;+ emitter.shape = static_cast<i32>(ecs::EmitterShape::Point);+ emitter.speedMin = 0.0f;+ emitter.speedMax = 0.0f;+ emitter.lifetimeMin = 10.0f;+ emitter.lifetimeMax = 10.0f;+ emitter.maxParticles = 4;+ emitter.addedVelocityMin = {10.0f, 0.0f, 0.0f};+ emitter.addedVelocityMax = {10.0f, 0.0f, 0.0f};+ emitter.damping = 1.0f;+ emitter.enabled = true;+ emitter.playOnStart = true;++ system.update(registry, 0.016f); // born+ system.update(registry, 0.5f);+ system.update(registry, 0.5f);+ auto* state = system.getState(e);+ REQUIRE(state != nullptr);+ f32 x = 0.0f;+ state->pool.forEachAlive([&](const Particle& p) { x = p.position.x; });+ CHECK(x == doctest::Approx(10.0f).epsilon(0.1)); // 10 per second for about a second, damping or not+}++TEST_CASE("system_speed_limit_holds_a_fast_particle_to_the_limit") {+ ecs::Registry registry;+ ParticleSystem system;++ Entity e = registry.create();+ registry.emplace<ecs::Transform>(e);+ auto& emitter = registry.emplace<ecs::ParticleEmitter>(e);+ emitter.rate = 0.0f;+ emitter.burstCount = 1;+ emitter.shape = static_cast<i32>(ecs::EmitterShape::Point);+ emitter.angleSpreadMin = 0.0f;+ emitter.angleSpreadMax = 0.0f;+ emitter.speedMin = 100.0f;+ emitter.speedMax = 100.0f;+ emitter.lifetimeMin = 10.0f;+ emitter.lifetimeMax = 10.0f;+ emitter.maxParticles = 4;+ emitter.speedLimit = 10.0f;+ emitter.limitDampen = 1.0f;+ emitter.enabled = true;+ emitter.playOnStart = true;++ system.update(registry, 0.016f);+ system.update(registry, 0.016f);+ auto* state = system.getState(e);+ REQUIRE(state != nullptr);+ f32 speed = 0.0f;+ state->pool.forEachAlive([&](const Particle& p) { speed = glm::length(p.velocity); });+ CHECK(speed == doctest::Approx(10.0f).epsilon(0.01));+}+TEST_CASE("system_disabled_emitter_no_spawn") {ecs::Registry registry;ParticleSystem system;diff --git a/tests/particle/test_particle_speed_limit.cpp b/tests/particle/test_particle_speed_limit.cppnew file mode 100644index 000000000..2e46ce5bf--- /dev/null+++ b/tests/particle/test_particle_speed_limit.cpp@@ -0,0 +1,46 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file test_particle_speed_limit.cpp — a speed limit pulls a fast particle back, at a rate that does not depend on the frame rate.+ */+#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN+#include <doctest.h>++#include <esengine/particle/ParticleSpeedLimit.hpp>++using namespace esengine;+using namespace esengine::particle;++TEST_CASE("a particle within the limit is left alone") {+ const glm::vec3 v{3, 4, 0}; // speed 5+ CHECK(limitedVelocity(v, 5.0f, 1.0f, 0.016f) == v);+ CHECK(limitedVelocity(v, 9.0f, 0.5f, 0.016f) == v);+}++TEST_CASE("a limit of zero is no limit") {+ const glm::vec3 v{30, 40, 0};+ CHECK(limitedVelocity(v, 0.0f, 1.0f, 0.016f) == v);+}++TEST_CASE("full dampening clamps to the limit at once and keeps the direction") {+ const glm::vec3 out = limitedVelocity({30, 40, 0}, 10.0f, 1.0f, 0.016f);+ CHECK(glm::length(out) == doctest::Approx(10.0f));+ CHECK(out.x / out.y == doctest::Approx(0.75f));+}++TEST_CASE("partial dampening removes part of the excess, and never goes under the limit") {+ // speed 20, limit 10, one 1/60 s frame at dampen 0.25: a quarter of the excess goes+ const glm::vec3 out = limitedVelocity({20, 0, 0}, 10.0f, 0.25f, 1.0f / 60.0f);+ CHECK(out.x == doctest::Approx(10.0f + 10.0f * 0.75f));+ glm::vec3 v{20, 0, 0};+ for (int i = 0; i < 600; ++i) v = limitedVelocity(v, 10.0f, 0.25f, 1.0f / 60.0f);+ CHECK(glm::length(v) >= 10.0f - 1e-4f);+ CHECK(glm::length(v) == doctest::Approx(10.0f).epsilon(1e-3));+}++TEST_CASE("the braking per second is the same at 30 and at 120 frames per second") {+ glm::vec3 slow{20, 0, 0}, fast{20, 0, 0};+ for (int i = 0; i < 30; ++i) slow = limitedVelocity(slow, 10.0f, 0.1f, 1.0f / 30.0f);+ for (int i = 0; i < 120; ++i) fast = limitedVelocity(fast, 10.0f, 0.1f, 1.0f / 120.0f);+ CHECK(slow.x == doctest::Approx(fast.x).epsilon(1e-3));+}diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 0f48900b0..ae33342e5 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -28,6 +28,8 @@ export const NOTES_FLOOR = 'v0.65.0';* the reader recognises anyway.*/export const NOTED = {+ 'feat(particle): an emitter can carry an added velocity per particle and limit particle speed with a dampening, and the Cocos velocity, force and limit modules map onto them':+ {"note":"Particles can carry an added velocity and be held to a speed limit."},'feat(particle): an emitter can wait startDelay seconds before it emits, with the duration counted from the end of the delay, and the Cocos start delay maps onto it':{"note":"An emitter can start late."},'feat(particle): a stretched render mode lays a particle along its velocity and lengthens it with speed, and the Cocos stretched billboard maps onto it':