reze-engine 0.50.3 → 0.50.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/engine.d.ts +247 -2
  2. package/dist/engine.d.ts.map +1 -1
  3. package/dist/engine.js +822 -64
  4. package/dist/model.d.ts +49 -1
  5. package/dist/model.d.ts.map +1 -1
  6. package/dist/model.js +160 -4
  7. package/dist/physics/autofit.d.ts +147 -0
  8. package/dist/physics/autofit.d.ts.map +1 -0
  9. package/dist/physics/autofit.js +501 -0
  10. package/dist/physics/physics.d.ts +35 -0
  11. package/dist/physics/physics.d.ts.map +1 -1
  12. package/dist/physics/physics.js +64 -0
  13. package/dist/physics/world.d.ts +4 -0
  14. package/dist/physics/world.d.ts.map +1 -1
  15. package/dist/physics/world.js +6 -0
  16. package/dist/shaders/cast-api.d.ts +1 -1
  17. package/dist/shaders/cast-api.d.ts.map +1 -1
  18. package/dist/shaders/cast-layout.d.ts +44 -1
  19. package/dist/shaders/cast-layout.d.ts.map +1 -1
  20. package/dist/shaders/cast-layout.js +44 -1
  21. package/dist/shaders/materials/common.d.ts.map +1 -1
  22. package/dist/shaders/materials/common.js +7 -1
  23. package/dist/shaders/materials/nodes.d.ts +1 -1
  24. package/dist/shaders/materials/nodes.d.ts.map +1 -1
  25. package/dist/shaders/materials/nodes.js +17 -9
  26. package/dist/shaders/passes/composite.d.ts +1 -1
  27. package/dist/shaders/passes/composite.d.ts.map +1 -1
  28. package/dist/shaders/passes/depth-prepass.d.ts +1 -1
  29. package/dist/shaders/passes/depth-prepass.d.ts.map +1 -1
  30. package/dist/shaders/passes/depth-prepass.js +52 -12
  31. package/dist/shaders/passes/field-blit.d.ts +26 -0
  32. package/dist/shaders/passes/field-blit.d.ts.map +1 -0
  33. package/dist/shaders/passes/field-blit.js +65 -0
  34. package/dist/shaders/passes/ground-noise.d.ts +7 -0
  35. package/dist/shaders/passes/ground-noise.d.ts.map +1 -0
  36. package/dist/shaders/passes/ground-noise.js +88 -0
  37. package/dist/shaders/passes/ground.d.ts +16 -0
  38. package/dist/shaders/passes/ground.d.ts.map +1 -1
  39. package/dist/shaders/passes/ground.js +131 -27
  40. package/dist/shaders/passes/outline.d.ts +1 -1
  41. package/dist/shaders/passes/outline.d.ts.map +1 -1
  42. package/dist/shaders/passes/outline.js +12 -3
  43. package/dist/shaders/passes/particles.d.ts.map +1 -1
  44. package/dist/shaders/passes/particles.js +6 -2
  45. package/dist/shaders/passes/scene-contract.d.ts +38 -6
  46. package/dist/shaders/passes/scene-contract.d.ts.map +1 -1
  47. package/dist/shaders/passes/scene-contract.js +53 -16
  48. package/dist/shaders/passes/sim.d.ts +34 -0
  49. package/dist/shaders/passes/sim.d.ts.map +1 -0
  50. package/dist/shaders/passes/sim.js +169 -0
  51. package/dist/shaders/passes/trails.d.ts.map +1 -1
  52. package/dist/shaders/passes/trails.js +36 -8
  53. package/dist/shaders/score-api.d.ts +10 -0
  54. package/dist/shaders/score-api.d.ts.map +1 -0
  55. package/dist/shaders/score-api.js +114 -0
  56. package/package.json +1 -1
  57. package/src/engine.ts +867 -56
  58. package/src/model.ts +163 -4
  59. package/src/physics/physics.ts +63 -0
  60. package/src/physics/world.ts +7 -0
  61. package/src/shaders/cast-layout.ts +44 -1
  62. package/src/shaders/materials/common.ts +7 -1
  63. package/src/shaders/materials/nodes.ts +17 -9
  64. package/src/shaders/passes/depth-prepass.ts +53 -12
  65. package/src/shaders/passes/ground.ts +133 -27
  66. package/src/shaders/passes/outline.ts +14 -3
  67. package/src/shaders/passes/particles.ts +6 -2
  68. package/src/shaders/passes/scene-contract.ts +55 -16
  69. package/src/shaders/passes/trails.ts +36 -8
  70. package/dist/physics-debug.d.ts +0 -30
  71. package/dist/physics-debug.d.ts.map +0 -1
  72. package/dist/physics-debug.js +0 -526
  73. package/dist/shaders/materials/body.d.ts +0 -2
  74. package/dist/shaders/materials/body.d.ts.map +0 -1
  75. package/dist/shaders/materials/body.js +0 -95
  76. package/dist/shaders/materials/cloth_rough.d.ts +0 -2
  77. package/dist/shaders/materials/cloth_rough.d.ts.map +0 -1
  78. package/dist/shaders/materials/cloth_rough.js +0 -69
  79. package/dist/shaders/materials/cloth_smooth.d.ts +0 -2
  80. package/dist/shaders/materials/cloth_smooth.d.ts.map +0 -1
  81. package/dist/shaders/materials/cloth_smooth.js +0 -61
  82. package/dist/shaders/materials/default.d.ts +0 -2
  83. package/dist/shaders/materials/default.d.ts.map +0 -1
  84. package/dist/shaders/materials/default.js +0 -43
  85. package/dist/shaders/materials/eye.d.ts +0 -2
  86. package/dist/shaders/materials/eye.d.ts.map +0 -1
  87. package/dist/shaders/materials/eye.js +0 -60
  88. package/dist/shaders/materials/face.d.ts +0 -2
  89. package/dist/shaders/materials/face.d.ts.map +0 -1
  90. package/dist/shaders/materials/face.js +0 -95
  91. package/dist/shaders/materials/hair.d.ts +0 -2
  92. package/dist/shaders/materials/hair.d.ts.map +0 -1
  93. package/dist/shaders/materials/hair.js +0 -90
  94. package/dist/shaders/materials/metal.d.ts +0 -2
  95. package/dist/shaders/materials/metal.d.ts.map +0 -1
  96. package/dist/shaders/materials/metal.js +0 -77
  97. package/dist/shaders/materials/mmd_classic.d.ts +0 -2
  98. package/dist/shaders/materials/mmd_classic.d.ts.map +0 -1
  99. package/dist/shaders/materials/mmd_classic.js +0 -66
  100. package/dist/shaders/materials/stockings.d.ts +0 -2
  101. package/dist/shaders/materials/stockings.d.ts.map +0 -1
  102. package/dist/shaders/materials/stockings.js +0 -122
  103. package/dist/shaders/passes/physics-debug.d.ts +0 -2
  104. package/dist/shaders/passes/physics-debug.d.ts.map +0 -1
  105. package/dist/shaders/passes/physics-debug.js +0 -69
package/dist/model.d.ts CHANGED
@@ -198,6 +198,15 @@ export declare class Model {
198
198
  private rootIsIdentity;
199
199
  private skinMatricesArray?;
200
200
  private deformOrder;
201
+ /** 1 where the simulation overwrites the bone's world matrix. See setPhysicsDrivenBones. */
202
+ private physicsDriven;
203
+ /** Bones to recompute after a step, in deform order — null when no rig needs it. */
204
+ private physicsAppendOrder;
205
+ /** Simulated bones something inherits from; their local rotation is recovered. */
206
+ private physicsAppendSources;
207
+ /** Recovered post-step local rotations, kept OUT of localRotations on purpose. */
208
+ private appendRotOverride;
209
+ private appendRotOverrideSet;
201
210
  private bindWorldPos;
202
211
  private tweenState;
203
212
  private tweenTimeMs;
@@ -511,7 +520,46 @@ export declare class Model {
511
520
  private solveIKChains;
512
521
  private ikComputedSet;
513
522
  private computeSingleBoneWorldMatrix;
514
- computeWorldMatrices(): void;
523
+ /**
524
+ * Which bones the physics simulation overwrites, and what that costs the
525
+ * append (付与) pass — the 胸 problem.
526
+ *
527
+ * PMX lets a bone inherit a fraction of another bone's rotation (付与親 /
528
+ * append parent). The pipeline computes that inheritance inside
529
+ * computeWorldMatrices, which runs BEFORE physics — and it reads the
530
+ * parent's LOCAL rotation, which physics never writes: the simulation
531
+ * publishes world matrices only. So when a rig hangs a bone off a simulated
532
+ * one, the inheritance saw the animated pose and nothing else, and the
533
+ * dependent bone sat still no matter how much the parent swung. Rigs that
534
+ * drive a chest this way — a simulated bone with the visible bones
535
+ * appending from it — produced no motion at all.
536
+ *
537
+ * The engine calls this once, after building the simulation, and it
538
+ * precomputes the whole answer: WHICH bones need revisiting after a step,
539
+ * in deform order. Everything downstream is a walk over that list.
540
+ */
541
+ setPhysicsDrivenBones(boneIndices: number[]): void;
542
+ /** The simulated bones that visible bones INHERIT from — the chest rig, in
543
+ * one list. Empty unless setPhysicsDrivenBones found such a relationship. */
544
+ getAppendSourceBones(): number[];
545
+ /**
546
+ * Re-run the append pass against the simulation's result. Call after a step.
547
+ *
548
+ * Two halves. First the simulated bones an append parent list names get their
549
+ * post-step LOCAL rotation recovered — physics published only world matrices,
550
+ * and the append math speaks local. The recovery is the ordinary change of
551
+ * basis: local = parentWorld⁻¹ · world, read back as a quaternion off the
552
+ * relative basis, which is exact for the rigid transforms these are.
553
+ *
554
+ * Then the dependent bones recompute, in deform order, reading that recovered
555
+ * rotation instead of the animated one. The recovered value lives in its OWN
556
+ * array rather than in localRotations, deliberately: localRotations is what
557
+ * next frame's pose blends against and what the simulation reads to build
558
+ * kinematic targets, and writing a simulation result back into it would make
559
+ * the animation chase its own tail.
560
+ */
561
+ applyPhysicsAppend(): void;
562
+ computeWorldMatrices(subset?: Int32Array): void;
515
563
  }
516
564
  export {};
517
565
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAA6C,MAAM,QAAQ,CAAA;AAEpF,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAI5C,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EAEjB,UAAU,EASX,MAAM,aAAa,CAAA;AAkBpB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;2EAE2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,CAAC,EAAE,MAAM,EAAE,CAAA;IACX,CAAC,EAAE,MAAM,EAAE,CAAA;CACZ;AAOD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,O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ACrD,OAAO,CAAC,eAAe;IAQvB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,OAAO;IAgGpD,OAAO,CAAC,aAAa;IAyCrB,OAAO,CAAC,aAAa,CAAyB;IAI9C,OAAO,CAAC,4BAA4B;IAsHpC;;;;;;;;;;;;;;;;;OAiBG;IACH,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI;IAkDlD;kFAC8E;IAC9E,oBAAoB,IAAI,MAAM,EAAE;IAIhC;;;;;;;;;;;;;;;OAeG;IACH,kBAAkB,IAAI,IAAI;IA4C1B,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI;CAiGhD"}
package/dist/model.js CHANGED
@@ -13,6 +13,10 @@ const _animSlerp = new Quat(0, 0, 0, 1);
13
13
  const _animInterpT = new Vec3(0, 0, 0);
14
14
  const _convOut = new Vec3(0, 0, 0);
15
15
  const _convMat = new Float32Array(16);
16
+ // Scratch for the post-physics append recovery — see applyPhysicsAppend.
17
+ const _appendBasisX = new Vec3(0, 0, 0);
18
+ const _appendBasisY = new Vec3(0, 0, 0);
19
+ const _appendBasisZ = new Vec3(0, 0, 0);
16
20
  // Blend-path scratch: per-entry sample target and the crossfade's two fixed entries.
17
21
  const _blendQ = new Quat(0, 0, 0, 1);
18
22
  const _blendT = new Vec3(0, 0, 0);
@@ -118,6 +122,15 @@ export class Model {
118
122
  this.rootMatrixValues = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
119
123
  this.rootMatrixDirty = false;
120
124
  this.rootIsIdentity = true;
125
+ /** 1 where the simulation overwrites the bone's world matrix. See setPhysicsDrivenBones. */
126
+ this.physicsDriven = null;
127
+ /** Bones to recompute after a step, in deform order — null when no rig needs it. */
128
+ this.physicsAppendOrder = null;
129
+ /** Simulated bones something inherits from; their local rotation is recovered. */
130
+ this.physicsAppendSources = null;
131
+ /** Recovered post-step local rotations, kept OUT of localRotations on purpose. */
132
+ this.appendRotOverride = null;
133
+ this.appendRotOverrideSet = null;
121
134
  this.tweenTimeMs = 0; // Time tracking for tweens (milliseconds)
122
135
  // Animation: state and multiple slots (idle, walk, attack, etc.); commit/rollback for action-game style
123
136
  this.animationState = new AnimationState();
@@ -2175,7 +2188,139 @@ export class Model {
2175
2188
  worldMat.values.set(localMVals);
2176
2189
  }
2177
2190
  }
2178
- computeWorldMatrices() {
2191
+ /**
2192
+ * Which bones the physics simulation overwrites, and what that costs the
2193
+ * append (付与) pass — the 胸 problem.
2194
+ *
2195
+ * PMX lets a bone inherit a fraction of another bone's rotation (付与親 /
2196
+ * append parent). The pipeline computes that inheritance inside
2197
+ * computeWorldMatrices, which runs BEFORE physics — and it reads the
2198
+ * parent's LOCAL rotation, which physics never writes: the simulation
2199
+ * publishes world matrices only. So when a rig hangs a bone off a simulated
2200
+ * one, the inheritance saw the animated pose and nothing else, and the
2201
+ * dependent bone sat still no matter how much the parent swung. Rigs that
2202
+ * drive a chest this way — a simulated bone with the visible bones
2203
+ * appending from it — produced no motion at all.
2204
+ *
2205
+ * The engine calls this once, after building the simulation, and it
2206
+ * precomputes the whole answer: WHICH bones need revisiting after a step,
2207
+ * in deform order. Everything downstream is a walk over that list.
2208
+ */
2209
+ setPhysicsDrivenBones(boneIndices) {
2210
+ const bones = this.skeleton.bones;
2211
+ const n = bones.length;
2212
+ this.physicsDriven = new Uint8Array(n);
2213
+ for (const b of boneIndices)
2214
+ if (b >= 0 && b < n)
2215
+ this.physicsDriven[b] = 1;
2216
+ // Bones to recompute after a step: anything that INHERITS from a simulated
2217
+ // bone, everything under it, and anything inheriting from those in turn.
2218
+ // Simulated bones themselves are deliberately excluded — their world matrix
2219
+ // IS the simulation's output, and recomputing it from a local pose the
2220
+ // simulation never wrote would throw the step away.
2221
+ const affected = new Uint8Array(n);
2222
+ let changed = true;
2223
+ while (changed) {
2224
+ changed = false;
2225
+ for (let k = 0; k < n; k++) {
2226
+ const i = this.deformOrder[k];
2227
+ if (affected[i] || this.physicsDriven[i])
2228
+ continue;
2229
+ const b = bones[i];
2230
+ const ap = b.appendParentIndex;
2231
+ const inheritsAffected = (b.appendRotate || b.appendMove) && ap !== undefined && ap >= 0 && ap < n && (this.physicsDriven[ap] || affected[ap]);
2232
+ const parentAffected = b.parentIndex >= 0 && affected[b.parentIndex];
2233
+ if (inheritsAffected || parentAffected) {
2234
+ affected[i] = 1;
2235
+ changed = true;
2236
+ }
2237
+ }
2238
+ }
2239
+ const order = [];
2240
+ for (let k = 0; k < n; k++) {
2241
+ const i = this.deformOrder[k];
2242
+ if (affected[i])
2243
+ order.push(i);
2244
+ }
2245
+ this.physicsAppendOrder = order.length > 0 ? Int32Array.from(order) : null;
2246
+ // The simulated bones something actually inherits from — the only ones
2247
+ // whose post-step local rotation has to be recovered below.
2248
+ const sources = new Set();
2249
+ for (const i of order) {
2250
+ const ap = bones[i].appendParentIndex;
2251
+ if (ap !== undefined && ap >= 0 && ap < n && this.physicsDriven[ap])
2252
+ sources.add(ap);
2253
+ }
2254
+ this.physicsAppendSources = sources.size > 0 ? Int32Array.from(sources) : null;
2255
+ if (this.appendRotOverride === null && this.physicsAppendOrder) {
2256
+ this.appendRotOverride = Array.from({ length: n }, () => Quat.identity());
2257
+ this.appendRotOverrideSet = new Uint8Array(n);
2258
+ }
2259
+ }
2260
+ /** The simulated bones that visible bones INHERIT from — the chest rig, in
2261
+ * one list. Empty unless setPhysicsDrivenBones found such a relationship. */
2262
+ getAppendSourceBones() {
2263
+ return this.physicsAppendSources ? Array.from(this.physicsAppendSources) : [];
2264
+ }
2265
+ /**
2266
+ * Re-run the append pass against the simulation's result. Call after a step.
2267
+ *
2268
+ * Two halves. First the simulated bones an append parent list names get their
2269
+ * post-step LOCAL rotation recovered — physics published only world matrices,
2270
+ * and the append math speaks local. The recovery is the ordinary change of
2271
+ * basis: local = parentWorld⁻¹ · world, read back as a quaternion off the
2272
+ * relative basis, which is exact for the rigid transforms these are.
2273
+ *
2274
+ * Then the dependent bones recompute, in deform order, reading that recovered
2275
+ * rotation instead of the animated one. The recovered value lives in its OWN
2276
+ * array rather than in localRotations, deliberately: localRotations is what
2277
+ * next frame's pose blends against and what the simulation reads to build
2278
+ * kinematic targets, and writing a simulation result back into it would make
2279
+ * the animation chase its own tail.
2280
+ */
2281
+ applyPhysicsAppend() {
2282
+ const order = this.physicsAppendOrder;
2283
+ const sources = this.physicsAppendSources;
2284
+ if (!order || !sources || !this.appendRotOverride || !this.appendRotOverrideSet)
2285
+ return;
2286
+ const bones = this.skeleton.bones;
2287
+ const worldMats = this.runtimeSkeleton.worldMatrices;
2288
+ this.appendRotOverrideSet.fill(0);
2289
+ for (let s = 0; s < sources.length; s++) {
2290
+ const i = sources[s];
2291
+ const w = worldMats[i].values;
2292
+ const p = bones[i].parentIndex;
2293
+ // Columns of the bone's own basis, expressed in its parent's frame. With
2294
+ // no parent the world basis already IS the local one.
2295
+ let bx0 = w[0], bx1 = w[1], bx2 = w[2];
2296
+ let by0 = w[4], by1 = w[5], by2 = w[6];
2297
+ let bz0 = w[8], bz1 = w[9], bz2 = w[10];
2298
+ if (p >= 0) {
2299
+ const pm = worldMats[p].values;
2300
+ // parentᵀ · child, the rotation half of parentWorld⁻¹ · world: the
2301
+ // parent basis is orthonormal, so its inverse is its transpose.
2302
+ const r0 = bx0, r1 = bx1, r2 = bx2;
2303
+ bx0 = pm[0] * r0 + pm[1] * r1 + pm[2] * r2;
2304
+ bx1 = pm[4] * r0 + pm[5] * r1 + pm[6] * r2;
2305
+ bx2 = pm[8] * r0 + pm[9] * r1 + pm[10] * r2;
2306
+ const g0 = by0, g1 = by1, g2 = by2;
2307
+ by0 = pm[0] * g0 + pm[1] * g1 + pm[2] * g2;
2308
+ by1 = pm[4] * g0 + pm[5] * g1 + pm[6] * g2;
2309
+ by2 = pm[8] * g0 + pm[9] * g1 + pm[10] * g2;
2310
+ const b0 = bz0, b1 = bz1, b2 = bz2;
2311
+ bz0 = pm[0] * b0 + pm[1] * b1 + pm[2] * b2;
2312
+ bz1 = pm[4] * b0 + pm[5] * b1 + pm[6] * b2;
2313
+ bz2 = pm[8] * b0 + pm[9] * b1 + pm[10] * b2;
2314
+ }
2315
+ _appendBasisX.setXYZ(bx0, bx1, bx2);
2316
+ _appendBasisY.setXYZ(by0, by1, by2);
2317
+ _appendBasisZ.setXYZ(bz0, bz1, bz2);
2318
+ Quat.fromBasisInto(_appendBasisX, _appendBasisY, _appendBasisZ, this.appendRotOverride[i]);
2319
+ this.appendRotOverrideSet[i] = 1;
2320
+ }
2321
+ this.computeWorldMatrices(order);
2322
+ }
2323
+ computeWorldMatrices(subset) {
2179
2324
  const bones = this.skeleton.bones;
2180
2325
  const localRot = this.runtimeSkeleton.localRotations;
2181
2326
  const localTrans = this.runtimeSkeleton.localTranslations;
@@ -2186,8 +2331,15 @@ export class Model {
2186
2331
  // Flat traversal in precomputed order: every bone's parent is already done, so no
2187
2332
  // per-bone visited check, no recursion, and no per-call allocation. Same per-bone
2188
2333
  // math as before. Scratch slots are safe to reuse since there's no reentrancy now.
2189
- const order = this.deformOrder;
2190
- for (let k = 0; k < boneCount; k++) {
2334
+ //
2335
+ // A SUBSET is the post-physics pass (applyPhysicsAppend): the same walk over
2336
+ // the bones that inherit from a simulated one, in the same relative order,
2337
+ // leaving every other bone — the simulated ones above all — untouched.
2338
+ const order = subset ?? this.deformOrder;
2339
+ const count = subset ? subset.length : boneCount;
2340
+ const override = this.appendRotOverride;
2341
+ const overrideSet = this.appendRotOverrideSet;
2342
+ for (let k = 0; k < count; k++) {
2191
2343
  const i = order[k];
2192
2344
  const b = bones[i];
2193
2345
  const boneRot = localRot[i];
@@ -2200,7 +2352,11 @@ export class Model {
2200
2352
  const hasRatio = Math.abs(ratio) > 1e-6;
2201
2353
  if (hasRatio) {
2202
2354
  if (b.appendRotate) {
2203
- const appendRot = localRot[appendParentIdx];
2355
+ // The simulated parent's RECOVERED rotation when there is one — the
2356
+ // whole point of the post-physics pass. localRotations still holds
2357
+ // the animated pose for that bone, which is exactly what must not
2358
+ // be inherited here.
2359
+ const appendRot = override && overrideSet && overrideSet[appendParentIdx] ? override[appendParentIdx] : localRot[appendParentIdx];
2204
2360
  let ax = appendRot.x, ay = appendRot.y, az = appendRot.z;
2205
2361
  const aw = appendRot.w;
2206
2362
  const absRatio = ratio < 0 ? -ratio : ratio;
@@ -0,0 +1,147 @@
1
+ import { type Rigidbody } from "./types";
2
+ import type { Skinning } from "../model";
3
+ /**
4
+ * Supplementary colliders fitted to the mesh a PMX rigid body fails to cover.
5
+ *
6
+ * PMX body proxies are bodies of revolution — 下半身 is a capsule lying
7
+ * transversely across the hips, so its cross-section is a circle. A pelvis seen
8
+ * from the side is not a circle, and across every rig measured the butt sits
9
+ * 0.18–0.71 units OUTSIDE that capsule while the front is flush or inside. That
10
+ * gap is where a skirt goes through a character: the cloth is resting correctly
11
+ * on the collider it was given, and the collider stops half a unit short of the
12
+ * skin.
13
+ *
14
+ * A rest offset cannot close it (see RigidBodyStore.restOffset) — it is one
15
+ * scalar on a radially symmetric shape, and the error is asymmetric. Measured
16
+ * on 托特's run cycle, the offset that clears the butt is 0.5, which is simply
17
+ * the size of the missing geometry, and at that value the skirt stands off the
18
+ * front and hips by the same 0.5.
19
+ *
20
+ * So fit the missing piece instead: take each bone-following body's own skinned
21
+ * vertices, find the ones that escape its shape in a concentrated lobe, and fit
22
+ * a capsule to that lobe. That is the fix riggers apply by hand, derived from
23
+ * the mesh rather than guessed.
24
+ *
25
+ * Measured on 托特's run cycle, counting butt vertices swallowed by a cloth
26
+ * body: 32.4 per frame with nothing, 30.9 with a 0.02 rest offset, 12.4 with
27
+ * this pass, 10.4 with both.
28
+ */
29
+ export interface AutoFitOptions {
30
+ /** A vertex counts as protruding past this much (model units). Below it the
31
+ * mesh is within authoring tolerance of the proxy and needs no help. */
32
+ minProtrusion?: number;
33
+ /**
34
+ * Ignore vertices further out than this multiple of the source shape's
35
+ * RADIUS (its smallest characteristic dimension).
36
+ *
37
+ * A coarse first cut at keeping hair and loose clothing out — anything
38
+ * standing further off the proxy than the proxy is wide is not skin. The
39
+ * discriminator that actually does the work is minConcentration.
40
+ */
41
+ maxProtrusionRatio?: number;
42
+ /** Fewer protruding vertices than this and it is a spike, not a region. */
43
+ minVertices?: number;
44
+ /**
45
+ * Per-axis quantile the fitted lobe's extent is clipped to, each end. A
46
+ * handful of stray vertices (a weight-painting slip, a seam) would otherwise
47
+ * stretch the capsule far past the surface everyone can see.
48
+ */
49
+ quantile?: number;
50
+ /** Skip the fit unless the capsule actually reaches this far past what is
51
+ * already covered — otherwise it adds solver rows for nothing. */
52
+ minGain?: number;
53
+ /** How tightly the kept lobe's outward directions must agree, 0–1. A loose
54
+ * sanity check; the real discriminator is minConcentration. */
55
+ minDirectionality?: number;
56
+ /** Vertices outside the dominant lobe, by this cosine, are not part of the
57
+ * feature being fitted. */
58
+ lobeCos?: number;
59
+ /**
60
+ * How much deeper the fitted lobe must be than protrusion typically is on
61
+ * this body, averaged over the vertices that protrude at all.
62
+ *
63
+ * This is the guard that separates "the proxy is missing a lobe" from "the
64
+ * proxy is not a proxy for this mesh at all". A pelvis escapes its capsule by
65
+ * 0.53 at the back and 0.14 at the front, so the back lobe stands well clear
66
+ * of the average. Hair escapes the skull by a similar depth in every
67
+ * direction, so its deepest lobe is no deeper than typical and the ratio sits
68
+ * near 1. See the note at the meanProtrusion computation for what this
69
+ * deliberately refuses to fit.
70
+ *
71
+ * Without it the pass fits the hairstyle — measured on 托特, 頭 reports
72
+ * 3653 of 4669 vertices outside its capsule, and the fitted shape was a crate
73
+ * around the whole head. No threshold on depth or vertex count tells those
74
+ * two cases apart; concentration does.
75
+ */
76
+ minConcentration?: number;
77
+ /**
78
+ * How many capsules may be fitted to one body, each against what the previous
79
+ * ones already cover.
80
+ *
81
+ * One capsule inscribed in a lobe does not fill it — on 托特's butt a single
82
+ * fit removed 58% of the clipping and left the rest at the edges the capsule
83
+ * could not reach. Each further pass re-measures protrusion against the
84
+ * original shape UNION everything fitted so far, so it lands on whatever is
85
+ * still exposed instead of re-fitting the same bulge.
86
+ */
87
+ maxShapesPerBody?: number;
88
+ /**
89
+ * Quantile of the lobe's perpendicular spread used as the capsule radius.
90
+ *
91
+ * The clip-versus-float dial, and the one to reach for if a result looks
92
+ * wrong. Lower hugs the body: less standoff in idle, more clipping left. 1.0
93
+ * encloses the lobe entirely, which is what produced a visibly hovering
94
+ * skirt on 托特.
95
+ */
96
+ radiusQuantile?: number;
97
+ /**
98
+ * Fit only the deepest part of each lobe: points at least this fraction of
99
+ * the lobe's own maximum protrusion.
100
+ *
101
+ * A lobe tapers to nothing at its edges, and a capsule sized to span the
102
+ * whole thing has to be fat enough to reach the edges too. Fitting the deep
103
+ * core keeps each capsule small and lets a later pass handle the shallows
104
+ * with its own, which is both tighter and closer to what the surface is
105
+ * actually doing.
106
+ */
107
+ lobeDepthFraction?: number;
108
+ }
109
+ /** What the pass decided for one source body — surfaced so a rig can be
110
+ * inspected rather than silently rebuilt underneath its author. */
111
+ export interface AutoFitResult {
112
+ /** Index of the body in the input array that this supplements. */
113
+ sourceIndex: number;
114
+ sourceName: string;
115
+ /** Vertices dominated by that body's bone, and how many were outside it. */
116
+ vertexCount: number;
117
+ protrudingCount: number;
118
+ /** Furthest any kept vertex sat outside the source shape. */
119
+ maxProtrusion: number;
120
+ /** How far the fitted capsule reaches past what was already covered. */
121
+ gain: number;
122
+ /** Length of the kept lobe's mean outward direction, 0–1. */
123
+ directionality: number;
124
+ /** Lobe depth over the body's average protrusion. See minConcentration. */
125
+ concentration: number;
126
+ /**
127
+ * Furthest the capsule's newly exposed surface sits from the skin it was
128
+ * fitted to — the amount cloth resting on it will stand off the body at the
129
+ * worst point, and the number to watch if a result looks puffy. Only the part
130
+ * reaching outside the source shape is measured; the rest is buried.
131
+ */
132
+ overshoot: number;
133
+ body: Rigidbody;
134
+ }
135
+ /**
136
+ * Fit supplementary colliders for every bone-following body whose own mesh
137
+ * escapes it.
138
+ *
139
+ * `vertices` is the model's interleaved vertex buffer (stride 8, position
140
+ * first) and `skinning` its joints/weights — both in PMX bind pose, the same
141
+ * space as `shapePosition` / `shapeRotation`, so nothing has to be skinned.
142
+ *
143
+ * Returns one entry per body it chose to supplement; the caller appends
144
+ * `.body` to the rigid body list before constructing RezePhysics.
145
+ */
146
+ export declare function fitSupplementaryColliders(rigidbodies: Rigidbody[], vertices: Float32Array, skinning: Skinning, options?: AutoFitOptions): AutoFitResult[];
147
+ //# sourceMappingURL=autofit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autofit.d.ts","sourceRoot":"","sources":["../../src/physics/autofit.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,SAAS,CAAA;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,cAAc;IAC7B;6EACyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;uEACmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;oEACgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;gCAC4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;;;;;;;;;;;OAgBG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AA2BD;oEACoE;AACpE,MAAM,WAAW,aAAa;I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