Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion src/meshops/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@
"blockout-face-compare photo vs RECIPE vs optional scene "
"(0124; FACE_COMPARE_HONESTY — N6); "
"blockout-torso-compare photo vs RECIPE vs optional scene "
"(0125; TORSO_COMPARE_HONESTY — N6). "
"(0125; TORSO_COMPARE_HONESTY — N6); "
"blockout-hip-glute-compare photo vs RECIPE vs optional scene "
"(0126; HIP_GLUTE_COMPARE_HONESTY — N6). "
"Optional: meshops[proportion] (Pillow)."
),
add_completion=False,
Expand Down Expand Up @@ -3418,5 +3420,71 @@ def proportion_blockout_torso_compare_cmd(
raise typer.Exit(0)


@proportion_app.command("blockout-hip-glute-compare")
def proportion_blockout_hip_glute_compare_cmd(
report: Path = typer.Option(
...,
"--report",
help="Path to proportion_report.json (required)",
),
recipe: Path = typer.Option(
...,
"--recipe",
help="Path to blockout_recipe.json (required)",
),
out: Path = typer.Option(
...,
"--out",
help="Output directory for hip_glute_compare.json (required)",
),
scene_dump: Path | None = typer.Option(
None,
"--scene-dump",
help="Optional live Blender/scene dump JSON overlay",
),
force: bool = typer.Option(
False,
"--force",
help="Overwrite existing hip_glute_compare.json",
),
json_out: bool = typer.Option(False, "--json", help="Emit machine result JSON"),
) -> None:
"""Compare Package A hip/glute landmarks vs RECIPE vs optional live scene.

Authoring QA only — not mesh or print success (HIP_GLUTE_COMPARE_HONESTY).
"""
from meshops.proportion.errors import ProportionError
from meshops.proportion.hip_glute_compare import run_blockout_hip_glute_compare
from meshops.proportion.honesty import HIP_GLUTE_COMPARE_HONESTY

try:
payload = run_blockout_hip_glute_compare(
report,
recipe,
out,
scene_dump=scene_dump,
force=force,
)
except ProportionError as exc:
_emit_error(exc, json_mode=json_out, code=1)
except Exception as exc:
_emit_error(exc, json_mode=json_out)

if json_out:
_emit_json(payload)
else:
typer.echo(
f"blockout-hip-glute-compare ok={payload.get('ok')} region={payload.get('region')}"
)
for msg in payload.get("messages") or []:
typer.echo(f" note: {msg}")
pkg_path = payload.get("package_path")
if pkg_path:
typer.echo(f" {pkg_path}")
typer.echo(f"honesty: {HIP_GLUTE_COMPARE_HONESTY}")
typer.echo("blockout-hip-glute-compare authoring QA only — not mesh or print success")
raise typer.Exit(0)


if __name__ == "__main__":
app()
23 changes: 23 additions & 0 deletions src/meshops/mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"mesh_proportion_blockout_feedback",
"mesh_proportion_blockout_face_compare",
"mesh_proportion_blockout_torso_compare",
"mesh_proportion_blockout_hip_glute_compare",
}
)

Expand Down Expand Up @@ -998,4 +999,26 @@ def mesh_proportion_blockout_torso_compare(
force=force,
)

@mcp.tool()
def mesh_proportion_blockout_hip_glute_compare(
report: str,
recipe: str,
out: str,
scene_dump: str | None = None,
force: bool = False,
) -> dict[str, Any]:
"""Compare Package A hip/glute landmarks vs RECIPE vs optional live scene dump.

Authoring QA only — proportion_hip_glute_compare_not_mesh_or_print_success.
Not mesh or print success. Raises ProportionError on hard failures.
"""
return T.mesh_proportion_blockout_hip_glute_compare(
wr,
report=report,
recipe=recipe,
out=out,
scene_dump=scene_dump,
force=force,
)

return mcp
27 changes: 27 additions & 0 deletions src/meshops/mcp/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,3 +1403,30 @@ def mesh_proportion_blockout_torso_compare(
scene_dump=_resolve_tool_path(scene_dump, work_root) if scene_dump else None,
force=force,
)


def mesh_proportion_blockout_hip_glute_compare(
work_root: Path,
*,
report: str,
recipe: str,
out: str,
scene_dump: str | None = None,
force: bool = False,
) -> dict[str, Any]:
"""Photo vs RECIPE vs optional scene. Authoring only — HIP_GLUTE_COMPARE_HONESTY."""
from meshops.proportion.hip_glute_compare import run_blockout_hip_glute_compare

ends_sep = out.endswith(("/", "\\"))
out_base = out.rstrip("/\\") if ends_sep else out
out_resolved = _resolve_tool_path(out_base, work_root)
out_arg: str | Path = (
str(out_resolved) + ("\\" if ends_sep else "") if ends_sep else out_resolved
)
return run_blockout_hip_glute_compare(
_resolve_tool_path(report, work_root),
_resolve_tool_path(recipe, work_root),
out_arg,
scene_dump=_resolve_tool_path(scene_dump, work_root) if scene_dump else None,
force=force,
)
38 changes: 38 additions & 0 deletions src/meshops/proportion/assist.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@
"scap_medial_r",
"mid_back_l",
"mid_back_r",
# 0126 hip/glute/groin form-read (not Pose 23-24 / genital geometry)
"asis_l",
"asis_r",
"psis_l",
"psis_r",
"glute_outer_l",
"glute_outer_r",
"glute_bottom_l",
"glute_bottom_r",
"glute_top_seam",
"groin_fold_l",
"groin_fold_r",
"thigh_medial_l",
"thigh_medial_r",
}
)

Expand Down Expand Up @@ -178,6 +192,30 @@
"mid_back_r",
)

# Frozen v1 hip/glute/groin form-read ids (0126). Existing hip/glute DEPTH stay.
HIP_GLUTE_FRONT_LANDMARK_IDS: tuple[str, ...] = (
"asis_l",
"asis_r",
"groin_fold_l",
"groin_fold_r",
"thigh_medial_l",
"thigh_medial_r",
)
HIP_GLUTE_LEFT_LANDMARK_IDS: tuple[str, ...] = (
"glute_bottom_l",
"glute_top_seam",
"psis_l",
)
HIP_GLUTE_BACK_LANDMARK_IDS: tuple[str, ...] = (
"psis_l",
"psis_r",
"glute_outer_l",
"glute_outer_r",
"glute_bottom_l",
"glute_bottom_r",
"glute_top_seam",
)


def _clamp01(v: float) -> float:
return max(0.0, min(1.0, float(v)))
Expand Down
37 changes: 36 additions & 1 deletion src/meshops/proportion/blockout_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ def _apply_shoulder_girdle_softs(


def _measured_lm_m(report: ProportionReport, lid: str, *, y: bool) -> float | None:
"""Finite landmark y_m or z_m, else None (0125 — never invent)."""
"""Finite landmark y_m or z_m, else None (0125/0126 — never invent)."""
lm = report.landmarks_xyz.get(lid)
if lm is None:
return None
Expand Down Expand Up @@ -5953,6 +5953,41 @@ def _apply_glute_seat_mass(
p.center = [float(sc[0]), lock_y, lock_z]
messages.append(f"glute_seat: dual lock ry={lock_ry:.4f} y={lock_y:.4f} z={lock_z:.4f}")

# 0126: measured Y/Z after dual lock (B33 — dual lock must not clobber; B32 — do not abs).
overlay_idxs = seated_idxs if seated_idxs else idxs
seam_y = _measured_lm_m(report, "glute_top_seam", y=True)
seam_z = _measured_lm_m(report, "glute_top_seam", y=False)
for i in overlay_idxs:
p = parts[i]
if p.center is None or len(p.center) < 3:
continue
name = p.name or ""
if name.endswith("_l"):
side = "l"
elif name.endswith("_r"):
side = "r"
else:
continue
bottom_id = f"glute_bottom_{side}"
my = _measured_lm_m(report, bottom_id, y=True)
mz = _measured_lm_m(report, bottom_id, y=False)
src_y = bottom_id if my is not None else "glute_top_seam"
src_z = bottom_id if mz is not None else "glute_top_seam"
if my is None:
my = seam_y
if mz is None:
mz = seam_z
if my is None and mz is None:
continue
c = list(p.center)
if my is not None:
c[1] = my
messages.append(f"hip_glute: measured glute y={my:.4f} ({src_y})")
if mz is not None:
c[2] = mz
messages.append(f"hip_glute: measured glute z={mz:.4f} ({src_z})")
p.center = c

# 10. composition observability: glute top/bottom vs pelvis mid/top (B12/B15).
if any_seated:
pelvis_z: float | None = None
Expand Down
14 changes: 10 additions & 4 deletions src/meshops/proportion/fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from meshops.proportion.assist import (
FACE_LEFT_LANDMARK_IDS,
HIP_GLUTE_BACK_LANDMARK_IDS,
HIP_GLUTE_LEFT_LANDMARK_IDS,
TORSO_BACK_LANDMARK_IDS,
TORSO_LEFT_LANDMARK_IDS,
)
Expand Down Expand Up @@ -204,7 +206,7 @@ def fuse_xyz(
xyz.z_m = z * height_m
out[lid] = xyz

# 0125: back-view X/Z for torso form-read ids (not DEPTH_PAIRS; Y from left).
# 0125/0126: back-view X/Z for torso + hip/glute form-read ids (not DEPTH_PAIRS; Y from left).
back = views.get("back")
if back is not None and back.landmarks:
back_span = back.figure_span_px or figure_span_from_landmarks(back)
Expand All @@ -215,7 +217,7 @@ def fuse_xyz(
back.figure_span_px = back_span
back_mid = _midline_x(back)
invert_x = str(back.facing_direction or "camera_back") == "camera_back"
for lid in TORSO_BACK_LANDMARK_IDS:
for lid in (*TORSO_BACK_LANDMARK_IDS, *HIP_GLUTE_BACK_LANDMARK_IDS):
src_lm = back.landmarks.get(lid)
if src_lm is None:
continue
Expand Down Expand Up @@ -339,8 +341,12 @@ def fuse_xyz(
mid.x_m = x_ref * height_m
out[mid_id] = mid

# 0124/0125: same-id left overlay for face + torso form-read Y (not DEPTH_PAIRS).
for lid in (*FACE_LEFT_LANDMARK_IDS, *TORSO_LEFT_LANDMARK_IDS):
# 0124/0125/0126: same-id left overlay for face + torso + hip/glute Y.
for lid in (
*FACE_LEFT_LANDMARK_IDS,
*TORSO_LEFT_LANDMARK_IDS,
*HIP_GLUTE_LEFT_LANDMARK_IDS,
):
src_lm = left.landmarks.get(lid)
if src_lm is None:
continue
Expand Down
Loading