Give the figure real girdles, fix orbit pinning, add roller pads

Shoulder and pelvis widths grow to human-like proportions per profile
(shoulders wider than hips for neutral/male, reversed for female) and
are now drawn — bars across the attach points that read near-full-width
face-on and as a shoulder/hip nub in profile, so limbs visibly hang
from a torso instead of a point. Orbiting no longer re-solves IK pins
in the rotated view (pins are canvas targets in the authored camera):
the pose resolves first and the posed body rotates, which fixes hands
sticking to stale screen points mid-orbit (Cat-Cow, Bird Dog, Plank).
Leg Extension and Leg Curl swap their ankle bars for a machine roller
disc — a new `roller` prop riding the shin's press side. Fixtures
regenerated; both renderers updated in lockstep.

Claude-Session: https://claude.ai/code/session_01LEoff8bXGBS83tK1c55Mf7
This commit is contained in:
2026-07-06 21:00:03 -04:00
parent fd3bcb513f
commit 5e4980f0d7
106 changed files with 543 additions and 156 deletions
@@ -146,10 +146,13 @@ struct ExerciseFigureView: View {
}
private func drawSpine(_ ctx: inout GraphicsContext, _ geo: FigureGeometry) {
let color = ink("spine", shade: .near)
stroke(&ctx, geo.girdle, color: color, width: 5)
stroke(&ctx, geo.pelvisBar, color: color, width: 5)
var path = Path()
path.move(to: geo.spineStart)
path.addQuadCurve(to: geo.spineEnd, control: geo.spineControl)
ctx.stroke(path, with: .color(ink("spine", shade: .near)),
ctx.stroke(path, with: .color(color),
style: StrokeStyle(lineWidth: 6, lineCap: .round, lineJoin: .round))
}
@@ -210,6 +213,10 @@ struct ExerciseFigureView: View {
/// renderer's `resolve_props` change them in lockstep.
private func drawAttachedProps(_ ctx: inout GraphicsContext, _ geo: FigureGeometry) {
for prop in figure.props {
if prop.type == "roller" {
drawRoller(&ctx, geo, prop)
continue
}
let defaults: (halfLen: Double, width: Double, plateR: Double)
switch prop.type {
case "bar": defaults = (24, 4, 0)
@@ -239,6 +246,21 @@ struct ExerciseFigureView: View {
}
}
/// A machine roller pad seen end-on: a disc riding the limb's lower bone near the
/// joint, on the `side` (+1/1) of the bone it presses. Kept 1:1 with the reference
/// renderer's `resolve_props`.
private func drawRoller(_ ctx: inout GraphicsContext, _ geo: FigureGeometry, _ prop: MotionProp) {
guard let at = prop.at, let anchor = jointAnchor(geo, at) else { return }
let r = prop.r ?? 5
let back = prop.back ?? 0
let side = prop.side ?? 1
let px = anchor.direction.dy * side, py = -anchor.direction.dx * side
let center = CGPoint(x: anchor.point.x - anchor.direction.dx * back + px * (r + 3),
y: anchor.point.y - anchor.direction.dy * back + py * (r + 3))
let rect = CGRect(x: center.x - r, y: center.y - r, width: 2 * r, height: 2 * r)
ctx.fill(Path(ellipseIn: rect), with: .color(.figureProp))
}
private func drawSceneShape(_ ctx: inout GraphicsContext, _ shape: PropSceneShape) {
let color: Color = shape.color == "prop" ? .figureProp : .figureEquipment
switch shape.kind {
+6 -1
View File
@@ -159,7 +159,7 @@ struct PropSceneShape: Codable {
/// One equipment prop. `type` selects the flavor; the other fields apply per type
/// (mirroring the reference renderer's `resolve_props`).
struct MotionProp: Codable {
let type: String // "scene" | "cable" | "bar" | "dumbbell" | "pad"
let type: String // "scene" | "cable" | "bar" | "dumbbell" | "pad" | "roller"
/// scene: the static shapes.
let shapes: [PropSceneShape]?
/// cable: fixed anchor `[x, y]` moving joint `to`.
@@ -174,6 +174,11 @@ struct MotionProp: Codable {
let w: Double?
/// End-disc radius (dumbbell plates default 4.5; bars none).
let plateR: Double?
/// roller: which side of the lower bone the disc presses (+1/1), its radius,
/// and how far back along the bone from the joint it sits.
let side: Double?
let r: Double?
let back: Double?
}
/// A key frame of anatomical joint angles. A joint absent from the frame poses at
+20 -2
View File
@@ -159,6 +159,10 @@ struct FigureGeometry {
var noseStart, noseEnd: CGPoint?
/// Quadratic Bézier through pelvis mid neck (control = 2·mid (pelvis+neck)/2).
var spineStart, spineControl, spineEnd: CGPoint
/// Shoulder girdle and pelvis bars, drawn with the spine: left attach center
/// right attach, far offsets included so the bars meet the drawn limbs exactly.
var girdle: [CGPoint]
var pelvisBar: [CGPoint]
/// Attach elbow/knee hand (arms: 3 points); hip knee ankle toe (legs: 4).
var limbs: [FigureLimb: [CGPoint]]
/// Parts far-to-near, `"head"` always last (`"spine"`, `"arm_r"`, then `"head"`).
@@ -452,9 +456,14 @@ enum MotionSolver {
return (fixedRank[lhs] ?? 0) < (fixedRank[rhs] ?? 0)
} + ["head"]
func attachPoint(_ v: Vec3, _ limb: FigureLimb) -> CGPoint {
scr(v, shade[limb] == .far ? off : .zero)
}
let geo = FigureGeometry(
headCenter: head, headRadius: prof.headR, noseStart: noseStart, noseEnd: noseEnd,
spineStart: pelvis, spineControl: control, spineEnd: neckB,
girdle: [attachPoint(p.shoulderL, .armL), neckB, attachPoint(p.shoulderR, .armR)],
pelvisBar: [attachPoint(p.hipL, .legL), pelvis, attachPoint(p.hipR, .legR)],
limbs: limbs, order: order, shade: shade)
return (resolved, geo)
}
@@ -500,8 +509,17 @@ struct MotionTimeline {
}
/// The drawable geometry at wall-clock `time`. `yawOffset` turns the camera past
/// the exercise's authored yaw the slow-orbit presentation.
/// the exercise's authored yaw the slow-orbit presentation. Pins are canvas
/// targets in the *authored* view, so the pose resolves there first and the posed
/// body is then rotated; re-pinning in a rotated view would glue hands to screen
/// points that no longer correspond to anything (arms visibly "stuck" mid-orbit).
func geometry(at time: Double, yawOffset: Double = 0) -> FigureGeometry {
MotionSolver.frameGeometry(frame(at: time), prof: profile, cam: cam + yawOffset).1
let frame = frame(at: time)
guard yawOffset != 0 else {
return MotionSolver.frameGeometry(frame, prof: profile, cam: cam).1
}
var posed = MotionSolver.frameGeometry(frame, prof: profile, cam: cam).0
posed.pins = [:]
return MotionSolver.frameGeometry(posed, prof: profile, cam: cam + yawOffset).1
}
}