@rig-c/parts 1.73.0 → 1.73.1

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.
package/README.md CHANGED
@@ -595,7 +595,10 @@ and [`CONFIG_TURN_SURFACE_REQUIRED`](docs/AUTHORING.md#CONFIG_TURN_SURFACE_REQUI
595
595
  fields in proportion to its skin weights. Inside the existing setup alpha
596
596
  overlap with a single-group neighbour, a blended attachment's vertex takes
597
597
  that neighbour's existing emitted triangle field at its setup position (#804), without changing skin weights,
598
- setup or idle. Conflicting neighbour groups are refused by name. Each sibling island takes only its
598
+ setup or idle. A `motion.blink.still` unit neighbour supplies both emitted
599
+ pieces, each on its own bone and resolved depth; transparent padding does not
600
+ let either piece lend its field to the other's art (#807). Missing emitted
601
+ split support is refused by name. Conflicting neighbour groups are refused by name. Each sibling island takes only its
599
602
  own group; parts without a blended attachment keep their existing role behavior
600
603
  and output bytes. Unlisted meshes do not consume turn depth sheets. See the
601
604
  [blended surface contract](docs/AUTHORING.md#per-layer-depth-sheets-773).
package/docs/AUTHORING.md CHANGED
@@ -5644,7 +5644,16 @@ Two same-group fields with incompatible emitted offsets raise
5644
5644
  [`RIG_TURN_SURFACE_OVERLAP_DEPTH`](#RIG_TURN_SURFACE_OVERLAP_DEPTH).
5645
5645
 
5646
5646
  Unit/rear neighbours contribute their actual emitted rigid carrier motion,
5647
- including its resolved unit depth or rear counter field. Their own sheet is
5647
+ including its resolved unit depth or rear counter field. A unit region split by
5648
+ `motion.blink.still` supplies both emitted drawings: the lower slot and
5649
+ `<part>_still`, each with its own bone and resolved unit depth (#807). Support
5650
+ uses the shown region's image size, offsets and rotation, with transparent
5651
+ padding excluded from each piece's crop rectangle. The original source-alpha
5652
+ condition still applies; the lower piece cannot lend its depth to upper art
5653
+ through its transparent padding. A missing split slot, shown attachment,
5654
+ image or setup frame raises
5655
+ [`RIG_TURN_SURFACE_OVERLAP_SUPPORT`](#RIG_TURN_SURFACE_OVERLAP_SUPPORT);
5656
+ a slot explicitly showing nothing supplies no attachment. Their own sheet is
5648
5657
  not resampled to invent a spatial bend or a new refusal. Generated surface
5649
5658
  grids keep their Core generator: Core's grid builder and transform evaluator
5650
5659
  provide inspection metadata for the same existing topology and vertex field.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/parts",
3
- "version": "1.73.0",
3
+ "version": "1.73.1",
4
4
  "description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/rig.ts CHANGED
@@ -138,6 +138,7 @@ import { explicitAttachment, type ExplicitMeshReport } from './explicitmesh.ts';
138
138
  * order the objects are built in, and every number is rounded by `pyRound`).
139
139
  */
140
140
  import { type AutoSpec, type BoneEntry, type InfluenceMeshSpec, type WeightRule, type CharacterConfig, type ConfigConstraint, type ConfigStop, CONSTRAINT_FOLLOWS, constraintForRig, contourRegionsOf, type ContourSpec, DEFAULT_BUST_BONE_L, DEFAULT_BUST_BONE_R, type Point, type RibsSpec, ROOT_BONE, stopForRig, turnRidersByBone, weightsABone } from './config.ts';
141
+ import { RUNTIME_PI } from 'rig-c/src/core/world.ts';
141
142
  import { type BoneTransform, computeExactFrameTransforms, computeWorldTransforms, cropToSpineY, normaliseDegrees, paintingToSetupPoint, setupToPaintingPoint, toBoneLocal, toWorld } from './coords.ts';
142
143
  import { type Problem, refuseIfAny, PartsError } from './errors.ts';
143
144
  import { recordedFocusProblems } from './setfocus.ts';
@@ -3662,7 +3663,7 @@ export function buildWaistPairSource(
3662
3663
  boneLandmarks,
3663
3664
  hasAlternateFaceSet,
3664
3665
  surfaceMeshes: turnSurfaceMeshes(cfg, rig, parts.rig_size),
3665
- neighbourMeshes: turnNeighbourMeshes(cfg, rig, parts),
3666
+ neighbourMeshes: turnNeighbourMeshes(cfg, rig, parts, new Map(outImages)),
3666
3667
  });
3667
3668
  }
3668
3669
  bindFaceSurfaceDeform(motion, (merged) => {
@@ -3679,7 +3680,7 @@ export function buildWaistPairSource(
3679
3680
  boneLandmarks,
3680
3681
  hasAlternateFaceSet,
3681
3682
  surfaceMeshes: turnSurfaceMeshes(cfg, rig, parts.rig_size),
3682
- neighbourMeshes: turnNeighbourMeshes(cfg, rig, parts),
3683
+ neighbourMeshes: turnNeighbourMeshes(cfg, rig, parts, new Map(outImages)),
3683
3684
  });
3684
3685
  }
3685
3686
  if (cfg.turn?.roles === undefined && (cfg.turn === undefined || cfg.turn.body === undefined || cfg.turn.depths !== undefined)) {
@@ -4200,7 +4201,7 @@ function turnSurfaceMeshes(cfg: CharacterConfig, rig: RigSpec, canvas: readonly
4200
4201
  }
4201
4202
 
4202
4203
  /** Actual shown support; Core's own grid topology is inspection metadata only. */
4203
- function turnNeighbourMeshes(cfg: CharacterConfig, rig: RigSpec, parts: PartsFile) {
4204
+ export function turnNeighbourMeshes(cfg: CharacterConfig, rig: RigSpec, parts: PartsFile, emittedImages: ReadonlyMap<string, Raster>) {
4204
4205
  const meshes: NonNullable<Parameters<typeof buildDepth25DTurn>[2]['neighbourMeshes']>[number][] = [];
4205
4206
  const canvas = parts.rig_size;
4206
4207
  const aliases = new Map<string, string>((rig.stops ?? []).flatMap(s => s.links.map(link => [`${link}_d`, link])));
@@ -4209,8 +4210,17 @@ function turnNeighbourMeshes(cfg: CharacterConfig, rig: RigSpec, parts: PartsFil
4209
4210
  if (cfg.meshes[part] !== undefined && [cfg.turn?.roles?.[part], cfg.turn?.body?.roles?.[part]].includes('surface')) continue;
4210
4211
  const record = parts.parts.find(p => p.name === part);
4211
4212
  if (record === undefined) continue;
4213
+ const split = cfg.regions[part] !== undefined && cfg.motion.blink?.still?.[part] !== undefined
4214
+ && [cfg.turn?.roles?.[part], cfg.turn?.body?.roles?.[part]].includes('unit');
4215
+ const splitSlots = [part, `${part}${STILL_SUFFIX}`];
4216
+ const failSupport = (name: string, detail: string): never => { throw new PartsError([{ code: 'RIG_TURN_SURFACE_OVERLAP_SUPPORT', object: `turn neighbour "${name}"`, detail }]); };
4217
+ if (split) for (const name of splitSlots) {
4218
+ const shown = rig.slots.find(slot => slot.name === name);
4219
+ if (shown === undefined) failSupport(name, 'has no emitted split slot; supply both lower and still slots from the region build');
4220
+ else if (shown.attachment !== null && rig.skins.default[name]?.[shown.attachment] === undefined) failSupport(`${name}/${shown.attachment}`, 'has no shown attachment in the default skin; supply the emitted split drawing');
4221
+ }
4212
4222
  for (const slot of rig.slots) {
4213
- if (slot.name !== part && !slot.name.startsWith(`${part}__island`)) continue;
4223
+ if (slot.name !== part && !slot.name.startsWith(`${part}__island`) && !(split && slot.name === splitSlots[1])) continue;
4214
4224
  for (const [attachment, att] of Object.entries(rig.skins.default[slot.name] ?? {})) {
4215
4225
  if (attachment !== slot.attachment) continue;
4216
4226
  if ('type' in att && att.weights !== undefined && att.weights.length > 0) { meshes.push({ part, slot: slot.name, attachment, weights: att.weights, triangles: att.triangles, canvas }); continue; }
@@ -4227,6 +4237,22 @@ function turnNeighbourMeshes(cfg: CharacterConfig, rig: RigSpec, parts: PartsFil
4227
4237
  weights: bound.bindings.map(row => row.map(w => ({ bone: w.bone, x: f32(w.x), y: f32(w.y), weight: f32(w.weight) }))),
4228
4238
  gridSamples: geometry.points.map(([x, y]) => setupToPaintingPoint(place(x, y), canvas, canvas)),
4229
4239
  });
4240
+ } else if (!('type' in att) && split) {
4241
+ const image = emittedImages.get(att.image) ?? failSupport(`${slot.name}/${attachment}`, `has no emitted image "${att.image}"; supply the split region PNG to measure its support`);
4242
+ if (!Number.isFinite(att.x) || !Number.isFinite(att.y) || (att.rotation !== undefined && !Number.isFinite(att.rotation))
4243
+ || !Number.isSafeInteger(image.width) || !Number.isSafeInteger(image.height) || image.width <= 2 * PAD || image.height <= 2 * PAD) failSupport(`${slot.name}/${attachment}`, `has offsets (${att.x}, ${att.y}), rotation ${att.rotation ?? 0} and image ${image.width}x${image.height}; require finite offsets/rotation and positive integer source dimensions after padding ${PAD} on each side`);
4244
+ // Core stores the region offsets/angle as float32. Its region
4245
+ // rotation uses RUNTIME_PI, not the bone matrix's y-column angle.
4246
+ const angle = f32(att.rotation ?? 0) * RUNTIME_PI / 180, cos = Math.cos(angle), sin = Math.sin(angle);
4247
+ const x = f32(att.x), y = f32(att.y), halfWidth = image.width / 2 - PAD, halfHeight = image.height / 2 - PAD;
4248
+ // Transparent PAD belongs to neither piece's alpha support. Keeping
4249
+ // both padded rectangles would let the lower lend its field to the
4250
+ // upper rows (and vice versa) beside the cut. Source alpha still
4251
+ // decides ownership inside each piece's own emitted crop rectangle.
4252
+ const corners = [[-halfWidth, -halfHeight], [-halfWidth, halfHeight], [halfWidth, halfHeight], [halfWidth, -halfHeight]];
4253
+ meshes.push({ part, slot: slot.name, attachment, canvas, triangles: [0, 1, 2, 0, 2, 3],
4254
+ weights: corners.map(([px, py]) => [{ bone: slot.bone, x: px * cos + x - py * sin, y: py * cos + y + px * sin, weight: 1 }]),
4255
+ });
4230
4256
  } else if (!('type' in att)) {
4231
4257
  const points = [[record.x - PAD, record.y - PAD], [record.x - PAD, record.y + record.h + PAD], [record.x + record.w + PAD, record.y + record.h + PAD], [record.x + record.w + PAD, record.y - PAD]];
4232
4258
  meshes.push({ part, slot: slot.name, attachment, canvas, triangles: [0, 1, 2, 0, 2, 3], weights: points.map(p => { const q = paintingToSetupPoint(p, canvas, canvas), local = toBoneLocal(frame, q[0], q[1]); return [{ bone: slot.bone, x: f32(local[0]), y: f32(local[1]), weight: 1 }]; }) });