diff --git a/design/figure-preview/preview_motion.zi b/design/figure-preview/preview_motion.zi index df7c95ae6..94170b280 100644 --- a/design/figure-preview/preview_motion.zi +++ b/design/figure-preview/preview_motion.zi @@ -7,6 +7,8 @@ // snap), or moving faster than one would // knee a knee bending backwards // through a hand passing through the trunk +// screen a planted foot moving on screen (the camera moving under it) +// pinned her head held at one place on screen while her body travels // `figure_preview --audit` prints them and exits non-zero when any is found. #import "figure_math" #import "figure_joints" @@ -17,10 +19,13 @@ #import "std/math" PREVIEW_AUDIT_RATE :: 30.0 -// A planted foot may creep this far (metres) before it counts as sliding. -PREVIEW_AUDIT_SLIDE :: 0.02 +// A planted heel or ball may stray this far (metres) from where it was set +// down before it counts as sliding. +PREVIEW_AUDIT_SLIDE :: 0.005 // Below the floor by more than this is through it. PREVIEW_AUDIT_FLOOR :: 0.01 +// A planted foot may move this far on screen (metres at her distance). +PREVIEW_AUDIT_SCREEN :: 0.005 // No joint of a calm practice speeds up or slows down faster than this // (m/s²), nor moves faster than the second bound (m/s); the Workout's // brisk moves have the higher bounds. @@ -37,6 +42,8 @@ PreviewAuditTotals :: struct { jump: s32 knee: s32 through: s32 + screen: s32 + pinned: s32 } // Audits every practice and item; returns how many awkward moments it found. @@ -50,9 +57,9 @@ PreviewAudit :: (library: *PreviewLibrary) -> s32 { PreviewAuditItem(library, practice, item, names[practice], *totals) } } - found := totals.slide + totals.floor + totals.jump + totals.knee + totals.through - print("figure audit: % awkward moments: % slides, % through the floor, % jumps, % knees backwards, % hands through the body\n", - found, totals.slide, totals.floor, totals.jump, totals.knee, totals.through) + found := totals.slide + totals.floor + totals.jump + totals.knee + totals.through + totals.screen + totals.pinned + print("figure audit: % awkward moments: % slides, % through the floor, % jumps, % knees backwards, % hands through the body, % feet moving on screen, % heads pinned\n", + found, totals.slide, totals.floor, totals.jump, totals.knee, totals.through, totals.screen, totals.pinned) return found } @@ -130,15 +137,37 @@ PreviewAuditItem :: (library: *PreviewLibrary, practice: s32, item: s32, practic previous_solved: TaiChiSolved // Per heel and ball of each foot: how far it has crept on the floor. crept: [4]float64 + world_planted: [4]Vector3 last_slide: [4]float64 = .[-10.0, -10.0, -10.0, -10.0] last_floor: float64 = -10.0 last_jump: float64 = -10.0 last_knee: float64 = -10.0 last_through: float64 = -10.0 + // On screen: each planted contact's place in the view when set down, + // and how far her head and pelvis range in the view and the world. + screen_planted: [4]Vector3 + screen_crept: [4]float64 + last_screen: float64 = -10.0 + head_low: Vector3 = .{1000.0, 1000.0, 0.0} + head_high: Vector3 = .{-1000.0, -1000.0, 0.0} + pelvis_low: Vector3 = .{1000.0, 1000.0, 1000.0} + pelvis_high: Vector3 = .{-1000.0, -1000.0, -1000.0} seconds: float64 while seconds < duration { moment := PreviewSample(library, practice, item, seconds) joints := moment.body + view := PreviewViewOf(*moment, 0.0, 0.0, 1.0) + toward := FigureV3(Sin(view.yaw) * Cos(view.pitch), Sin(view.pitch), Cos(view.yaw) * Cos(view.pitch)) + across := FigureNormalize(FigureCross(FigureScale(toward, -1.0), FigureV3(0.0, 1.0, 0.0))) + upward := FigureCross(across, FigureScale(toward, -1.0)) + head := FigureSub(FigureAddScaled(joints.neck, FigureV3(0.0, 1.0, 0.0), 0.15), view.center) + head_on_screen := FigureV3(FigureDot(head, across), FigureDot(head, upward), 0.0) + head_low = .{FigureMin(head_low.x, head_on_screen.x), FigureMin(head_low.y, head_on_screen.y), 0.0} + head_high = .{FigureMax(head_high.x, head_on_screen.x), FigureMax(head_high.y, head_on_screen.y), 0.0} + pelvis_low = .{FigureMin(pelvis_low.x, joints.pelvis.x), FigureMin(pelvis_low.y, joints.pelvis.y), + FigureMin(pelvis_low.z, joints.pelvis.z)} + pelvis_high = .{FigureMax(pelvis_high.x, joints.pelvis.x), FigureMax(pelvis_high.y, joints.pelvis.y), + FigureMax(pelvis_high.z, joints.pelvis.z)} // Through the floor: any part of a foot below it. lowest: float64 = 1000.0 part: s32 @@ -170,16 +199,31 @@ PreviewAuditItem :: (library: *PreviewLibrary, practice: s32, item: s32, practic slot := side * 2 + point here := contacts[point] down := here.y < 0.02 && upright - if down && have_previous && before_contacts[point].y < 0.02 { - crept[slot] += FigureLength(FigureV3(here.x - before_contacts[point].x, 0.0, - here.z - before_contacts[point].z)) + if down && have_previous && before_contacts[point].y < 0.02 && crept[slot] >= 0.0 { + crept[slot] = FigureLength(FigureV3(here.x - world_planted[slot].x, 0.0, here.z - world_planted[slot].z)) } else { crept[slot] = 0.0 + world_planted[slot] = here } if crept[slot] > PREVIEW_AUDIT_SLIDE && PreviewAuditReport(practice_name, name, seconds, "slide", PreviewAuditContact(cast(s32)side, cast(s32)point), crept[slot], *last_slide[slot]) { totals.slide += 1 - crept[slot] = 0.0 + crept[slot] = -1.0 + } + // The same contact on screen must not move across it either + // (rising a little as the heel or ball peels is not sliding). + offset := FigureSub(here, view.center) + on_screen := FigureV3(FigureDot(offset, across), 0.0, 0.0) + if down && have_previous && before_contacts[point].y < 0.02 && screen_crept[slot] >= 0.0 { + screen_crept[slot] = FigureDistance(on_screen, screen_planted[slot]) + if screen_crept[slot] > PREVIEW_AUDIT_SCREEN && PreviewAuditReport(practice_name, name, seconds, "screen", + "a planted foot moved on screen by", screen_crept[slot], *last_screen) { + totals.screen += 1 + screen_crept[slot] = -1.0 + } + } else { + screen_crept[slot] = 0.0 + screen_planted[slot] = on_screen } } // A knee bending backwards: it bends over the toes, so its @@ -254,4 +298,13 @@ PreviewAuditItem :: (library: *PreviewLibrary, practice: s32, item: s32, practic have_previous = true seconds += step } + // Her body travels (her pelvis moves over 30 cm) yet her head stays + // within 2 cm on screen: the camera is following her head. + travel := FigureMax(FigureMax(pelvis_high.x - pelvis_low.x, pelvis_high.y - pelvis_low.y), pelvis_high.z - pelvis_low.z) + held := FigureMax(head_high.x - head_low.x, head_high.y - head_low.y) + last_pinned: float64 = -10.0 + if travel > 0.3 && held < 0.02 && PreviewAuditReport(practice_name, name, 0.0, "pinned", + "her head stays put on screen while her pelvis travels m", travel, *last_pinned) { + totals.pinned += 1 + } } diff --git a/design/figure-preview/preview_practices.zi b/design/figure-preview/preview_practices.zi index bd08156fb..c76e6b9a7 100644 --- a/design/figure-preview/preview_practices.zi +++ b/design/figure-preview/preview_practices.zi @@ -64,6 +64,14 @@ PreviewLibrary :: struct { astral: [6]AstralCourse astral_ready: [6]bool astral_even: bool + // The camera framing of the item last framed: where it looks, how tall + // a view and from which way, fixed for the whole item. + framed_practice: s32 + framed_item: s32 + framed_target: Vector3 + framed_height: float64 + framed_yaw: float64 + framed_tilt: float64 } preview_astral_ids: [6]string = .["bruce_foundation_touch", "bruce_full_body_current", @@ -185,7 +193,23 @@ PreviewDuration :: (library: *PreviewLibrary, practice: s32, item: s32) -> float return 60.0 } +// The moment SECONDS into PRACTICE's ITEM, seen by a camera framed once for +// the whole item: it never follows her head or recentres on her, so her +// planted feet stay put on the stage. Astral techniques keep their own +// designed cameras. PreviewSample :: (library: *PreviewLibrary, practice: s32, item: s32, seconds: float64) -> PreviewMoment { + moment := PreviewSampleRaw(library, practice, item, seconds) + if practice == PREVIEW_ASTRAL || !PreviewFrame(library, practice, item) { + return moment + } + moment.target = library.framed_target + moment.height = library.framed_height + moment.camera.yaw = library.framed_yaw + moment.camera.tilt = library.framed_tilt + return moment +} + +PreviewSampleRaw :: (library: *PreviewLibrary, practice: s32, item: s32, seconds: float64) -> PreviewMoment { moment: PreviewMoment if practice == PREVIEW_TAI_CHI { moment.rig = TaiChiRigFor(0) @@ -330,6 +354,57 @@ PreviewJoin :: (buffer: []u8, a: string, b: string) -> string { } #scope_file +// Frames PRACTICE's ITEM once from the bounds of its whole motion, seen from +// its own camera's direction, for a portrait view: the view's centre and +// height fit every joint at every moment, so the camera never moves while +// she does (a long form is framed whole; scroll to zoom in). +PreviewFrame :: (library: *PreviewLibrary, practice: s32, item: s32) -> bool { + if library.framed_practice == practice && library.framed_item == item && library.framed_height > 0.0 { + return true + } + library.framed_practice = practice + library.framed_item = item + library.framed_height = 0.0 + first := PreviewSampleRaw(library, practice, item, 0.0) + yaw := first.camera.yaw + tilt := first.camera.tilt + toward := FigureV3(Sin(yaw) * Cos(tilt), Sin(tilt), Cos(yaw) * Cos(tilt)) + right := FigureNormalize(FigureCross(FigureScale(toward, -1.0), FigureV3(0.0, 1.0, 0.0))) + up := FigureCross(right, FigureScale(toward, -1.0)) + low: [2]float64 = .[1000.0, 1000.0] + high: [2]float64 = .[-1000.0, -1000.0] + duration := PreviewDuration(library, practice, item) + seconds: float64 + while seconds <= duration { + moment := PreviewSampleRaw(library, practice, item, seconds) + body := *moment.body + points: [11]Vector3 = .[body.pelvis, body.neck, FigureAddScaled(body.neck, FigureV3(0.0, 1.0, 0.0), 0.25), + body.wrists[0], body.wrists[1], body.toes[0], body.toes[1], body.ankles[0], body.ankles[1], body.knees[0], + body.knees[1]] + for point: points { + across := FigureDot(point, right) + along := FigureDot(point, up) + low[0] = FigureMin(low[0], across) + low[1] = FigureMin(low[1], along) + high[0] = FigureMax(high[0], across) + high[1] = FigureMax(high[1], along) + } + seconds += 0.25 + } + if high[0] < low[0] { + return false + } + // Room round her, and her shadow under her feet. + width := high[0] - low[0] + 0.5 + tall := high[1] - low[1] + 0.45 + middle := (low[0] + high[0]) * 0.5 + library.framed_height = FigureMax(tall, width / 0.75) + library.framed_target = FigureAdd(FigureScale(right, middle), FigureScale(up, (low[1] + high[1]) * 0.5 - 0.05)) + library.framed_yaw = yaw + library.framed_tilt = tilt + return true +} + PreviewVector :: (value: TaiChiVector3) -> Vector3 { return .{value.x, value.y, value.z} } diff --git a/plans/2026-11-17-astral-projection.md b/plans/2026-11-17-astral-projection.md index d385ec026..349df0834 100644 --- a/plans/2026-11-17-astral-projection.md +++ b/plans/2026-11-17-astral-projection.md @@ -13,6 +13,45 @@ MB-Lab, CharMorph). The owner picked pixiv's CC0 VRoid sample models (practices `shared/figure/woman.vrm` and `man.vrm`); the preview (`design/figure-preview/`) plays every practice with her or him. +## Handoff — natural movement (2026-11-18, moving to Codex) + +- Model 4 (pixiv CC0 VRoid woman and man) is committed in practices + `shared/figure/` and is what the preview shows (Woman/Man switch). + practices d8b54df1: VRM hair and clothes on spring bones, eye blinks + (`FigureModelPose(..., seconds)`, `FigureBlink`). +- Kryon `src/ui/scene_vrm.zi` is pushed (Kryon ac6c8f47): VRM 0.x + humanoid map, expressions, lookAt, spring bones with sphere colliders, + fixed 60 Hz, world frame. `scene_bvh.zi` is not started: every practice + is hand-keyed and timed to its narration, and the audit's faults were in + stepping, IK and interpolation, not in the keys, so mocap has not been + needed yet. +- Motion audit: `figure_preview --audit` (every item at 30 fps; slides on + the floor and on screen, floor, jerks, knees, hands, a pinned head). + Fixed in Breeze 924553d6: feet step and pivot instead of sliding + (TaiChiStepFoot, the timeline's step and pivot), toes clamp above the + floor, soft two-bone reach, hand frames slerped between keys, side + plank roll. 589 findings fell to 9 at the old 2 cm bound. +- The preview no longer follows her pelvis every frame (which pinned her + in the middle and made her feet slide over the painted floor): each item + is framed once from its whole motion with a fixed camera + (`PreviewFrame`); long forms are framed whole, so pan the backdrop with + a slow follow if they should be closer. The audit now measures a slide + as distance from where the heel or ball was set down (5 mm), also on + screen, and flags a head held in place: 66 findings remain, 34 Tai Chi + step and side-plank-roll slides (Wild Horse, Snake, the full forms), the + same 28 on screen, 4 jerks, no pinned head. +- Tests: `build-queue -- make workout-test sun-salutation-pose-test` + (planted feet within 5 mm, floor, speed, knees); practices + `figure_parts_test` (README); Kryon `build-queue -- make + scene-gltf-test`; the preview audit. +- Remains: zero-slide foot locking where the audit still finds drift + (lock a planted foot's floor point through the timeline's blends, with + two-bone leg IK; the side plank roll); root + weight shift and breathing for Tai Chi; head and gaze follow with VRM + lookAt; relaxed fingers check; the before/after clips + (`make-videos.sh` in the task scratchpad renders them from + `build/before` and `build/app` with `--video`); Tai Chi parity below. + - Tai Chi parity: `make test`'s `tests/tai_chi_zi_test.sh` compares the app's solver with the studio's reference, regenerated for the natural stepping, pivots, hand turning, soft reach and toe clamp