ugly-game 0.15.3 → 0.15.4

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.
@@ -899,6 +899,17 @@ export declare class GpuCrowdRenderer {
899
899
  * character's current rung each frame without branching.
900
900
  */
901
901
  enableFaceRig(slot: number, lod: number, dstSlot: number): void;
902
+ /**
903
+ * Copy `slot` (positions AND normals) into `dstSlot` — the seed the face pass then rewrites
904
+ * face vertices on top of. Called by `enableFaceRig`, and by `morph` whenever the slot is
905
+ * rigged (see the re-seed note there).
906
+ *
907
+ * ⚠️ VIA A STAGING BUFFER, because WebGPU REFUSES copyBufferToBuffer when the source and the
908
+ * destination are the SAME buffer — even for ranges that provably do not overlap. ("Source and
909
+ * destination are the same buffer.") Both slots live in the one rest pool, so the copy has to
910
+ * hop out and back.
911
+ */
912
+ private seedFaceSlot;
902
913
  /** Stop dispatching for this slot — it costs exactly what it cost before the rig existed. */
903
914
  disableFaceRig(slot: number): void;
904
915
  /**
@@ -2082,6 +2082,18 @@ export class GpuCrowdRenderer {
2082
2082
  cp.dispatchWorkgroups(Math.ceil(l.plan.vertCount / 64));
2083
2083
  cp.end();
2084
2084
  dev.queue.submit([enc.finish()]);
2085
+ // ⚠️ A RIGGED FACE IS A SECOND COPY OF THIS SLOT, and it does not follow the morph on its
2086
+ // own. The face pass rewrites only face vertices per frame; every other vertex of the
2087
+ // animated slot keeps whatever the seed copy held, so a re-morph that skips the re-seed
2088
+ // draws the OLD body with the NEW face — stretched between the two morphs across the scalp,
2089
+ // a second head floating above the first. Any slider that moves the skull shows it (age is
2090
+ // simply the biggest); no caller remembered, because nothing in `morph`'s signature says a
2091
+ // copy exists. Owned HERE, not by the caller, so the rule cannot be forgotten a second time.
2092
+ // The rung must match: a LOD change re-rigs through `enableFaceRig`, and a copy sized for
2093
+ // the new rung aimed at the old rung's slot would overrun its stride.
2094
+ const rig = this.rigged.get(slot);
2095
+ if (rig?.lod === lod)
2096
+ this.seedFaceSlot(slot, lod, rig.dst);
2085
2097
  }
2086
2098
  // ── the per-frame face rig ───────────────────────────────────────────────────────────────────
2087
2099
  /** Grow the weight and face-table buffers to hold `rows`, and rebuild the bind groups on them. */
@@ -2169,11 +2181,24 @@ export class GpuCrowdRenderer {
2169
2181
  this.rigged.set(slot, { row, lod, dst: dstSlot });
2170
2182
  if ((row + 1) * FACE_ROW_FLOATS > this.wCpu.length)
2171
2183
  this.allocFaceBuffers(growCapacity(row + 1, this.wCpu.length / FACE_ROW_FLOATS));
2184
+ this.seedFaceSlot(slot, lod, dstSlot);
2185
+ }
2186
+ /**
2187
+ * Copy `slot` (positions AND normals) into `dstSlot` — the seed the face pass then rewrites
2188
+ * face vertices on top of. Called by `enableFaceRig`, and by `morph` whenever the slot is
2189
+ * rigged (see the re-seed note there).
2190
+ *
2191
+ * ⚠️ VIA A STAGING BUFFER, because WebGPU REFUSES copyBufferToBuffer when the source and the
2192
+ * destination are the SAME buffer — even for ranges that provably do not overlap. ("Source and
2193
+ * destination are the same buffer.") Both slots live in the one rest pool, so the copy has to
2194
+ * hop out and back.
2195
+ */
2196
+ seedFaceSlot(slot, lod, dstSlot) {
2197
+ const l = maybe(this.lodGpu, lod);
2198
+ const pools = this.pools;
2199
+ if (!l || !pools)
2200
+ return;
2172
2201
  const bytes = l.plan.slotVerts * 16; // the pools are arrays of vec4
2173
- // ⚠️ VIA A STAGING BUFFER, because WebGPU REFUSES copyBufferToBuffer when the source and the
2174
- // destination are the SAME buffer — even for ranges that provably do not overlap. ("Source and
2175
- // destination are the same buffer.") Both slots live in the one rest pool, so the copy has to
2176
- // hop out and back. One-time, at enable, so it costs nothing per frame.
2177
2202
  const staging = this.device.createBuffer({
2178
2203
  size: bytes,
2179
2204
  usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {