A 3D model pipeline, pushed by Gemini 4 Carbon
agent
+1:12:54reasoning
Testing tools/blender_sculpt_cast.py with the headless Blender instance to ensure complete script execution. The test uses a dedicated cache directory to isolate the environment. Verify the script's behavior with the target arm_f_strong and its expected outputs.
run_command{"CommandLine":"python3 -c '\nimport os, sys, time, subprocess, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, gear as G, outfit as O, poses as P, vroid_portrait as vp\nfrom cast import CAST\nfrom vrm import VRM\nfrom rig import Rig, grip_points\nimport battle_slice as bs\n\nos.makedirs(os.path.expanduser(\"~/.cache/lowmarch_bl_test\"), exist_ok=True)\nv_path = bs.cached_cage_vrm(\"valen\")\nv = VRM(v_path)\nsh = G.shape(\"athletic\", \"bare\", leg_len=1.075, head=0.935, torso=0.90, chest=1.04, shoulder_w=0.012, curl=14, face_normals=0.0, hair_normals=0.0)\nsh[\"arm_out\"] = bs.arm_room(v, sh)\npose_ref = vp.bone_pose(v, sh, vp.BUST_POSE)\nprims = v.primitives(None, pose_ref)\nroles = [vp.role_of(p[\"material\"]) for p in prims]\nlm = vp.landmarks(prims, roles)\nfit = O.Fit(v, pose_ref, prims, roles)\nfit.grip = grip_points(v, sh, P.BUST)\nfist_R, fwd_R, side_R, flat_R, _ = G._hand_frame(fit, \"R\")\n\nrig = Rig(v, sh, ortho=True)\ng_pose = bs.vanguard_pose(v_path, sh)[0][1]\nnames = v.nodes_by_name()\nWg = rig.world(g_pose)\nMg = Wg[names[\"J_Bip_L_LowerArm\"]]\nEg = Mg[:3, 3]; Hg = Wg[names[\"J_Bip_L_Hand\"]][:3, 3]\nF3 = np.diag([-1., 1., -1.])\na = np.radians(-32.0)\nRy_inv = np.array([[np.cos(a),0,np.sin(a)],[0,1,0],[-np.sin(a),0,np.cos(a)]])\ncam_to_vrm = lambda u: F3 @ (Ry_inv @ (np.asarray(u, float)/np.linalg.norm(u)))\nout_g = cam_to_vrm([0.52, 0.06, 0.85])\nup_g = cam_to_vrm([-0.06, 0.99, -0.03]); up_g -= out_g * (up_g @ out_g); up_g /= np.linalg.norm(up_g)\nfw_g = np.cross(out_g, up_g)\ncentre_g = Eg * 0.25 + Hg * 0.75 + out_g * 0.195 + fw_g * 0.025\nT_g2r = fit.world[\"J_Bip_L_LowerArm\"] @ np.linalg.inv(Mg)\nR_g2r = T_g2r[:3, :3] / np.linalg.norm(T_g2r[:3, :3], axis=0)\n\nbody_p = [p for p, r in zip(prims, roles) if r == \"body\"][0]\nface_p = [p for p, r in zip(prims, roles) if r == \"face\"][0]\nin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_in.npz\")\nout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\")\nnp.savez(in_npz, body_pos=body_p[\"pos\"], body_tri=body_p[\"tri\"], face_pos=face_p[\"pos\"], face_tri=face_p[\"tri\"],\n bones=fit.bone, landmarks=lm,\n guard_info=dict(fist_R=fist_R, fwd_R=fwd_R, side_R=side_R, flat_R=flat_R,\n shield_centre=(T_g2r @ np.append(centre_g, 1.0))[:3],\n shield_out=R_g2r @ out_g, shield_up=R_g2r @ up_g))\nt0 = time.time()\nres = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", in_npz, out_npz, \"valen\"],\n capture_output=True, text=True)\ndt = time.time() - t0\nprint(\"RC:\", res.returncode, \"Time:\", round(dt, 2), \"s\")\nif res.returncode != 0:\n print(\"STDOUT:\\n\", res.stdout[-2000:])\n print(\"STDERR:\\n\", res.stderr[-2000:])\nelse:\n d = np.load(out_npz, allow_pickle=True)\n pcs = d[\"pieces\"]\n print(\"Pieces:\", len(pcs), \"Total tris:\", sum(len(x[4]) for x in pcs), \"Total verts:\", sum(len(x[2]) for x in pcs))\n for x in pcs[:8]:\n print(\" \", x[0], x[1], x[2].shape, x[4].shape, x[5], x[6])\n'","WaitMsBeforeAsync":10000,"toolSummary":"Smoke-test Blender 5.2 Valen sculpt & build"}error
input
{ "CommandLine": "python3 -c '\nimport os, sys, time, subprocess, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, gear as G, outfit as O, poses as P, vroid_portrait as vp\nfrom cast import CAST\nfrom vrm import VRM\nfrom rig import Rig, grip_points\nimport battle_slice as bs\n\nos.makedirs(os.path.expanduser(\"~/.cache/lowmarch_bl_test\"), exist_ok=True)\nv_path = bs.cached_cage_vrm(\"valen\")\nv = VRM(v_path)\nsh = G.shape(\"athletic\", \"bare\", leg_len=1.075, head=0.935, torso=0.90, chest=1.04, shoulder_w=0.012, curl=14, face_normals=0.0, hair_normals=0.0)\nsh[\"arm_out\"] = bs.arm_room(v, sh)\npose_ref = vp.bone_pose(v, sh, vp.BUST_POSE)\nprims = v.primitives(None, pose_ref)\nroles = [vp.role_of(p[\"material\"]) for p in prims]\nlm = vp.landmarks(prims, roles)\nfit = O.Fit(v, pose_ref, prims, roles)\nfit.grip = grip_points(v, sh, P.BUST)\nfist_R, fwd_R, side_R, flat_R, _ = G._hand_frame(fit, \"R\")\n\nrig = Rig(v, sh, ortho=True)\ng_pose = bs.vanguard_pose(v_path, sh)[0][1]\nnames = v.nodes_by_name()\nWg = rig.world(g_pose)\nMg = Wg[names[\"J_Bip_L_LowerArm\"]]\nEg = Mg[:3, 3]; Hg = Wg[names[\"J_Bip_L_Hand\"]][:3, 3]\nF3 = np.diag([-1., 1., -1.])\na = np.radians(-32.0)\nRy_inv = np.array([[np.cos(a),0,np.sin(a)],[0,1,0],[-np.sin(a),0,np.cos(a)]])\ncam_to_vrm = lambda u: F3 @ (Ry_inv @ (np.asarray(u, float)/np.linalg.norm(u)))\nout_g = cam_to_vrm([0.52, 0.06, 0.85])\nup_g = cam_to_vrm([-0.06, 0.99, -0.03]); up_g -= out_g * (up_g @ out_g); up_g /= np.linalg.norm(up_g)\nfw_g = np.cross(out_g, up_g)\ncentre_g = Eg * 0.25 + Hg * 0.75 + out_g * 0.195 + fw_g * 0.025\nT_g2r = fit.world[\"J_Bip_L_LowerArm\"] @ np.linalg.inv(Mg)\nR_g2r = T_g2r[:3, :3] / np.linalg.norm(T_g2r[:3, :3], axis=0)\n\nbody_p = [p for p, r in zip(prims, roles) if r == \"body\"][0]\nface_p = [p for p, r in zip(prims, roles) if r == \"face\"][0]\nin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_in.npz\")\nout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\")\nnp.savez(in_npz, body_pos=body_p[\"pos\"], body_tri=body_p[\"tri\"], face_pos=face_p[\"pos\"], face_tri=face_p[\"tri\"],\n bones=fit.bone, landmarks=lm,\n guard_info=dict(fist_R=fist_R, fwd_R=fwd_R, side_R=side_R, flat_R=flat_R,\n shield_centre=(T_g2r @ np.append(centre_g, 1.0))[:3],\n shield_out=R_g2r @ out_g, shield_up=R_g2r @ up_g))\nt0 = time.time()\nres = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", in_npz, out_npz, \"valen\"],\n capture_output=True, text=True)\ndt = time.time() - t0\nprint(\"RC:\", res.returncode, \"Time:\", round(dt, 2), \"s\")\nif res.returncode != 0:\n print(\"STDOUT:\\n\", res.stdout[-2000:])\n print(\"STDERR:\\n\", res.stderr[-2000:])\nelse:\n d = np.load(out_npz, allow_pickle=True)\n pcs = d[\"pieces\"]\n print(\"Pieces:\", len(pcs), \"Total tris:\", sum(len(x[4]) for x in pcs), \"Total verts:\", sum(len(x[2]) for x in pcs))\n for x in pcs[:8]:\n print(\" \", x[0], x[1], x[2].shape, x[4].shape, x[5], x[6])\n'", "WaitMsBeforeAsync": 10000, "toolSummary": "Smoke-test Blender 5.2 Valen sculpt & build" }result, error, 8 lines
Command exited with code 1. Command output: Traceback (most recent call last): File "<string>", line 11, in <module> File "~/work/lowmarch/tools/battle_slice.py", line 49, in cached_cage_vrm p = cage.path_for(name, CAST[name]["cage"]) KeyError: 'valen'read_file{"EndLine":560,"Path":"~/work/lowmarch/tools/battle_slice.py","StartLine":451}
input
{ "EndLine": 560, "Path": "~/work/lowmarch/tools/battle_slice.py", "StartLine": 451 }result, 111 lines
Showing lines 451-560 of 686 451: arm_l = rig.pos(P.BUST, "J_Bip_L_LowerArm") - rig.pos(P.BUST, "J_Bip_L_UpperArm") 452: span_l = float(np.linalg.norm(arm_l) + np.linalg.norm(f["L"] - rig.pos(P.BUST, "J_Bip_L_LowerArm"))) 453: arm_r = rig.pos(P.BUST, "J_Bip_R_LowerArm") - rig.pos(P.BUST, "J_Bip_R_UpperArm") 454: span_r = float(np.linalg.norm(arm_r) + np.linalg.norm(f["R"] - rig.pos(P.BUST, "J_Bip_R_LowerArm"))) 455: 456: base = P.merge(P.BATTLE_IDLE, P.fist("L"), { 457: "J_Bip_C_Hips": P.move(0, -0.070, -0.015, P.rot((1, 0, 0), -5.0)), 458: "J_Bip_C_Spine": P.rot((0, 1, 0), -12.0) @ P.rot((1, 0, 0), -2.0), 459: "J_Bip_C_Chest": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -1.5), 460: "J_Bip_C_Neck": P.rot((0, 1, 0), 7.0) @ P.rot((1, 0, 0), 3.0), 461: "J_Bip_C_Head": P.rot((0, 1, 0), 5.0) @ P.rot((1, 0, 0), 2.5), 462: }) 463: foot = {s: rig.pos(P.BATTLE_IDLE, f"J_Bip_{s}_Foot") for s in "LR"} 464: pose = rig.leg_ik(base, "L", foot["L"] + np.array([-0.08, 0.0, -0.16]), pole=(0, 0, -1)) 465: pose = rig.leg_ik(pose, "R", foot["R"] + np.array([0.08, 0.0, 0.15]), pole=(0, -0.2, -1)) 466: 467: D = np.array([0.14, 0.54, -0.83]) 468: D /= np.linalg.norm(D) 469: fr = rig.pos(pose, "J_Bip_R_UpperArm") + span_r * np.array([0.05, -0.58, -0.22]) 470: q = fr - rig.pos(pose, "J_Bip_L_UpperArm") 471: b, c = float(D @ q), float(q @ q) - (0.82 * span_l) ** 2 472: t = float(np.clip(-b + math.sqrt(max(b * b - c, 0.0)), 0.24, 0.48)) 473: 474: pose = duel.clear_grip(rig, body, pose, "R", ref, fr, D, (0.6, -0.5, 0.7)) 475: pose = duel.clear_grip(rig, body, pose, "L", ref, fr + D * t, D, (-0.8, -0.9, 0.2)) 476: return [(0.0, pose), (1.0, pose)] 477: 478: 479: def apply_forward_face_normals(p, forward=0.10, pull=0.45): 480: """Apply head-proxy normals with forward offset so 3/4 cheeks wrap into clean shadow.""" 481: lm_now = vp.landmarks(p.prims, p.roles) 482: names = p.v.nodes_by_name() 483: Wn = p.v.node_world(p.pose_ref) 484: neck = (Wn[names["J_Bip_C_Neck"]][:3, 3], Wn[names["J_Bip_C_Head"]][:3, 3]) 485: vp.face_normals(p.prims, p.roles, lm_now, amount=1.0, hair=0.0, forward=forward, pull=pull, neck=neck) 486: 487: 488: def wrap_glb_json(path): 489: with open(path, "rb") as f: 490: b64 = base64.b64encode(f.read()).decode() 491: with open(path + ".json", "w") as f: 492: json.dump({"glb": b64}, f) 493: os.remove(path) 494: 495: 496: def build_unit(spec): 497: vrm_path = cached_cage_vrm(spec["cage_body"]) 498: v0 = vp.VRM(vrm_path) 499: shape = dict(spec["shape"], face_normals=0.0) 500: shape["arm_out"] = arm_room(v0, shape) 501: 502: cl = {"idle": spec["pose_fn"](v0, shape)} 503: rig_guard = Rig(v0, shape, ortho=True) 504: guard_pose = cl["idle"][0][1] 505: costume_fn = (lambda fit: spec["costume"](fit, rig_guard=rig_guard, guard_pose=guard_pose)) \ 506: if spec["name"] == "valen" else spec["costume"] 507: 508: p = vp.Portrait( 509: vrm_path, 510: morphs=spec["morphs"], 511: pose=vp.BUST_POSE, 512: ref_pose=vp.BUST_POSE, 513: shape=shape, 514: costume=costume_fn, 515: ) 516: apply_forward_face_normals(p, forward=0.10, pull=0.45) 517: p.paint = dict(spec["paint"], hair_cap=spec["paint"]["hair"]) 518: pal = dict(vp.PALETTE, **spec["colors"]) 519: 520: glb_path = os.path.join(OUT_DIR, f"{spec['name']}.glb") 521: export_glb.export_skinned(p, pal, glb_path, clips=cl, max_tex=1024) 522: wrap_glb_json(glb_path) 523: 524: info = export_glb.scene_info(p, pal) 525: info["roles"]["hair_cap"] = info["roles"]["hair"] 526: info["paint"]["hair_cap"] = dict(kind="hair", base=spec["paint"]["hair"], shade=True) 527: return dict( 528: name=spec["name"], 529: label=spec["label"], 530: place=spec["place"], 531: clip="idle", 532: clip_t=0.0, 533: wind=spec.get("wind", 0.0), 534: info=info, 535: ) 536: 537: 538: def build_scene(): 539: os.makedirs(OUT_DIR, exist_ok=True) 540: with open(SLICE_HTML) as f: 541: html = f.read() 542: with open(os.path.join(OUT_DIR, "index.html"), "w") as f: 543: f.write(html) 544: 545: three_link = os.path.join(OUT_DIR, "three") 546: if not os.path.exists(three_link): 547: os.symlink(LOCAL_THREE, three_link) 548: 549: units = [ 550: dict( 551: name="valen", 552: label="Valen (Vanguard Captain)", 553: cage_body="arm_f_strong", 554: morphs={"Fcl_BRW_Angry": 0.38, "Fcl_EYE_Angry": 0.18}, 555: shape={"blush": 0.25}, 556: costume=vanguard_captain, 557: pose_fn=vanguard_pose, 558: place={"pos": [-0.74, 0.0, 0.04], "yaw": 32.0}, 559: wind=-3.2, 560: colors={run_command{"CommandLine":"python3 -c '\nimport os, sys, time, subprocess, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, gear as G, outfit as O, poses as P, vroid_portrait as vp\nfrom vrm import VRM\nfrom rig import Rig, grip_points\nimport battle_slice as bs\n\nos.makedirs(os.path.expanduser(\"~/.cache/lowmarch_bl_test\"), exist_ok=True)\nv_path = bs.cached_cage_vrm(\"arm_f_strong\")\nv = VRM(v_path)\nsh = G.shape(\"athletic\", \"bare\", leg_len=1.075, head=0.935, torso=0.90, chest=1.04, shoulder_w=0.012, curl=14, face_normals=0.0, hair_normals=0.0)\nsh[\"arm_out\"] = bs.arm_room(v, sh)\npose_ref = vp.bone_pose(v, sh, vp.BUST_POSE)\nprims = v.primitives(None, pose_ref)\nroles = [vp.role_of(p[\"material\"]) for p in prims]\nlm = vp.landmarks(prims, roles)\nfit = O.Fit(v, pose_ref, prims, roles)\nfit.grip = grip_points(v, sh, P.BUST)\nfist_R, fwd_R, side_R, flat_R, _ = G._hand_frame(fit, \"R\")\n\nrig = Rig(v, sh, ortho=True)\ng_pose = bs.vanguard_pose(v, sh)[0][1]\nnames = v.nodes_by_name()\nWg = rig.world(g_pose)\nMg = Wg[names[\"J_Bip_L_LowerArm\"]]\nEg = Mg[:3, 3]; Hg = Wg[names[\"J_Bip_L_Hand\"]][:3, 3]\nF3 = np.diag([-1., 1., -1.])\na = np.radians(-32.0)\nRy_inv = np.array([[np.cos(a),0,np.sin(a)],[0,1,0],[-np.sin(a),0,np.cos(a)]])\ncam_to_vrm = lambda u: F3 @ (Ry_inv @ (np.asarray(u, float)/np.linalg.norm(u)))\nout_g = cam_to_vrm([0.52, 0.06, 0.85])\nup_g = cam_to_vrm([-0.06, 0.99, -0.03]); up_g -= out_g * (up_g @ out_g); up_g /= np.linalg.norm(up_g)\nfw_g = np.cross(out_g, up_g)\ncentre_g = Eg * 0.25 + Hg * 0.75 + out_g * 0.195 + fw_g * 0.025\nT_g2r = fit.world[\"J_Bip_L_LowerArm\"] @ np.linalg.inv(Mg)\nR_g2r = T_g2r[:3, :3] / np.linalg.norm(T_g2r[:3, :3], axis=0)\n\nbody_p = [p for p, r in zip(prims, roles) if r == \"body\"][0]\nface_p = [p for p, r in zip(prims, roles) if r == \"face\"][0]\nin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_in.npz\")\nout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\")\nnp.savez(in_npz, body_pos=body_p[\"pos\"], body_tri=body_p[\"tri\"], face_pos=face_p[\"pos\"], face_tri=face_p[\"tri\"],\n bones=fit.bone, landmarks=lm,\n guard_info=dict(fist_R=fist_R, fwd_R=fwd_R, side_R=side_R, flat_R=flat_R,\n shield_centre=(T_g2r @ np.append(centre_g, 1.0))[:3],\n shield_out=R_g2r @ out_g, shield_up=R_g2r @ up_g))\nt0 = time.time()\nres = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", in_npz, out_npz, \"valen\"],\n capture_output=True, text=True)\ndt = time.time() - t0\nprint(\"Valen RC:\", res.returncode, \"Time:\", round(dt, 2), \"s\")\nif res.returncode != 0:\n print(\"STDOUT:\\n\", res.stdout[-2500:])\n print(\"STDERR:\\n\", res.stderr[-2500:])\nelse:\n d = np.load(out_npz, allow_pickle=True)\n pcs = d[\"pieces\"]\n print(\"Valen Pieces:\", len(pcs), \"Total tris:\", sum(len(x[4]) for x in pcs), \"Total verts:\", sum(len(x[2]) for x in pcs))\n for x in pcs[:8]:\n print(\" \", x[0], x[1], x[2].shape, x[4].shape, x[5], x[6])\n\n# Also test Korin!\nvk_path = bs.cached_cage_vrm(\"arm_m_strong\")\nvk = VRM(vk_path)\nshk = G.shape(\"stocky\", \"veteran\", face_normals=0.0, hair_normals=0.0)\nshk[\"arm_out\"] = bs.arm_room(vk, shk)\npose_k = vp.bone_pose(vk, shk, vp.BUST_POSE)\nprims_k = vk.primitives(None, pose_k)\nroles_k = [vp.role_of(p[\"material\"]) for p in prims_k]\nlm_k = vp.landmarks(prims_k, roles_k)\nfit_k = O.Fit(vk, pose_k, prims_k, roles_k)\nbp_k = [p for p, r in zip(prims_k, roles_k) if r == \"body\"][0]\nfp_k = [p for p, r in zip(prims_k, roles_k) if r == \"face\"][0]\nkin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_in.npz\")\nkout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_out.npz\")\nnp.savez(kin_npz, body_pos=bp_k[\"pos\"], body_tri=bp_k[\"tri\"], face_pos=fp_k[\"pos\"], face_tri=fp_k[\"tri\"],\n bones=fit_k.bone, landmarks=lm_k)\nt1 = time.time()\nres_k = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", kin_npz, kout_npz, \"korin\"],\n capture_output=True, text=True)\nprint(\"Korin RC:\", res_k.returncode, \"Time:\", round(time.time() - t1, 2), \"s\")\nif res_k.returncode != 0:\n print(\"STDERR:\\n\", res_k.stderr[-2000:])\nelse:\n dk = np.load(kout_npz, allow_pickle=True)\n pcsk = dk[\"pieces\"]\n print(\"Korin Pieces:\", len(pcsk), \"Total tris:\", sum(len(x[4]) for x in pcsk))\n'","WaitMsBeforeAsync":10000,"toolSummary":"Run headless Blender 5.2 test for Valen and Korin"}error
input
{ "CommandLine": "python3 -c '\nimport os, sys, time, subprocess, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, gear as G, outfit as O, poses as P, vroid_portrait as vp\nfrom vrm import VRM\nfrom rig import Rig, grip_points\nimport battle_slice as bs\n\nos.makedirs(os.path.expanduser(\"~/.cache/lowmarch_bl_test\"), exist_ok=True)\nv_path = bs.cached_cage_vrm(\"arm_f_strong\")\nv = VRM(v_path)\nsh = G.shape(\"athletic\", \"bare\", leg_len=1.075, head=0.935, torso=0.90, chest=1.04, shoulder_w=0.012, curl=14, face_normals=0.0, hair_normals=0.0)\nsh[\"arm_out\"] = bs.arm_room(v, sh)\npose_ref = vp.bone_pose(v, sh, vp.BUST_POSE)\nprims = v.primitives(None, pose_ref)\nroles = [vp.role_of(p[\"material\"]) for p in prims]\nlm = vp.landmarks(prims, roles)\nfit = O.Fit(v, pose_ref, prims, roles)\nfit.grip = grip_points(v, sh, P.BUST)\nfist_R, fwd_R, side_R, flat_R, _ = G._hand_frame(fit, \"R\")\n\nrig = Rig(v, sh, ortho=True)\ng_pose = bs.vanguard_pose(v, sh)[0][1]\nnames = v.nodes_by_name()\nWg = rig.world(g_pose)\nMg = Wg[names[\"J_Bip_L_LowerArm\"]]\nEg = Mg[:3, 3]; Hg = Wg[names[\"J_Bip_L_Hand\"]][:3, 3]\nF3 = np.diag([-1., 1., -1.])\na = np.radians(-32.0)\nRy_inv = np.array([[np.cos(a),0,np.sin(a)],[0,1,0],[-np.sin(a),0,np.cos(a)]])\ncam_to_vrm = lambda u: F3 @ (Ry_inv @ (np.asarray(u, float)/np.linalg.norm(u)))\nout_g = cam_to_vrm([0.52, 0.06, 0.85])\nup_g = cam_to_vrm([-0.06, 0.99, -0.03]); up_g -= out_g * (up_g @ out_g); up_g /= np.linalg.norm(up_g)\nfw_g = np.cross(out_g, up_g)\ncentre_g = Eg * 0.25 + Hg * 0.75 + out_g * 0.195 + fw_g * 0.025\nT_g2r = fit.world[\"J_Bip_L_LowerArm\"] @ np.linalg.inv(Mg)\nR_g2r = T_g2r[:3, :3] / np.linalg.norm(T_g2r[:3, :3], axis=0)\n\nbody_p = [p for p, r in zip(prims, roles) if r == \"body\"][0]\nface_p = [p for p, r in zip(prims, roles) if r == \"face\"][0]\nin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_in.npz\")\nout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\")\nnp.savez(in_npz, body_pos=body_p[\"pos\"], body_tri=body_p[\"tri\"], face_pos=face_p[\"pos\"], face_tri=face_p[\"tri\"],\n bones=fit.bone, landmarks=lm,\n guard_info=dict(fist_R=fist_R, fwd_R=fwd_R, side_R=side_R, flat_R=flat_R,\n shield_centre=(T_g2r @ np.append(centre_g, 1.0))[:3],\n shield_out=R_g2r @ out_g, shield_up=R_g2r @ up_g))\nt0 = time.time()\nres = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", in_npz, out_npz, \"valen\"],\n capture_output=True, text=True)\ndt = time.time() - t0\nprint(\"Valen RC:\", res.returncode, \"Time:\", round(dt, 2), \"s\")\nif res.returncode != 0:\n print(\"STDOUT:\\n\", res.stdout[-2500:])\n print(\"STDERR:\\n\", res.stderr[-2500:])\nelse:\n d = np.load(out_npz, allow_pickle=True)\n pcs = d[\"pieces\"]\n print(\"Valen Pieces:\", len(pcs), \"Total tris:\", sum(len(x[4]) for x in pcs), \"Total verts:\", sum(len(x[2]) for x in pcs))\n for x in pcs[:8]:\n print(\" \", x[0], x[1], x[2].shape, x[4].shape, x[5], x[6])\n\n# Also test Korin!\nvk_path = bs.cached_cage_vrm(\"arm_m_strong\")\nvk = VRM(vk_path)\nshk = G.shape(\"stocky\", \"veteran\", face_normals=0.0, hair_normals=0.0)\nshk[\"arm_out\"] = bs.arm_room(vk, shk)\npose_k = vp.bone_pose(vk, shk, vp.BUST_POSE)\nprims_k = vk.primitives(None, pose_k)\nroles_k = [vp.role_of(p[\"material\"]) for p in prims_k]\nlm_k = vp.landmarks(prims_k, roles_k)\nfit_k = O.Fit(vk, pose_k, prims_k, roles_k)\nbp_k = [p for p, r in zip(prims_k, roles_k) if r == \"body\"][0]\nfp_k = [p for p, r in zip(prims_k, roles_k) if r == \"face\"][0]\nkin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_in.npz\")\nkout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_out.npz\")\nnp.savez(kin_npz, body_pos=bp_k[\"pos\"], body_tri=bp_k[\"tri\"], face_pos=fp_k[\"pos\"], face_tri=fp_k[\"tri\"],\n bones=fit_k.bone, landmarks=lm_k)\nt1 = time.time()\nres_k = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", kin_npz, kout_npz, \"korin\"],\n capture_output=True, text=True)\nprint(\"Korin RC:\", res_k.returncode, \"Time:\", round(time.time() - t1, 2), \"s\")\nif res_k.returncode != 0:\n print(\"STDERR:\\n\", res_k.stderr[-2000:])\nelse:\n dk = np.load(kout_npz, allow_pickle=True)\n pcsk = dk[\"pieces\"]\n print(\"Korin Pieces:\", len(pcsk), \"Total tris:\", sum(len(x[4]) for x in pcsk))\n'", "WaitMsBeforeAsync": 10000, "toolSummary": "Run headless Blender 5.2 test for Valen and Korin" }result, error, 8 lines
Command exited with code 1. Command output: Traceback (most recent call last): File "<string>", line 14, in <module> File "~/work/lowmarch/tools/vroid_portrait.py", line 186, in bone_pose spec[f"J_Bip_{side}_Shoulder"] = ((sh["shoulders"], 1.0, 1.0), False) KeyError: 'shoulders'run_command{"CommandLine":"python3 -c '\nimport os, sys, time, subprocess, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, gear as G, outfit as O, poses as P, vroid_portrait as vp\nfrom vrm import VRM\nfrom rig import Rig, grip_points\nimport battle_slice as bs\n\nos.makedirs(os.path.expanduser(\"~/.cache/lowmarch_bl_test\"), exist_ok=True)\nv_path = bs.cached_cage_vrm(\"arm_f_strong\")\nv = VRM(v_path)\nsh = {**vp.SHAPE, **G.shape(\"athletic\", \"bare\", leg_len=1.075, head=0.935, torso=0.90, chest=1.04, shoulder_w=0.012, curl=14, face_normals=0.0, hair_normals=0.0)}\nsh[\"arm_out\"] = bs.arm_room(v, sh)\npose_ref = vp.bone_pose(v, sh, vp.BUST_POSE)\nprims = v.primitives(None, pose_ref)\nroles = [vp.role_of(p[\"material\"]) for p in prims]\nlm = vp.landmarks(prims, roles)\nfit = O.Fit(v, pose_ref, prims, roles)\nfit.grip = grip_points(v, sh, P.BUST)\nfist_R, fwd_R, side_R, flat_R, _ = G._hand_frame(fit, \"R\")\n\nrig = Rig(v, sh, ortho=True)\ng_pose = bs.vanguard_pose(v, sh)[0][1]\nnames = v.nodes_by_name()\nWg = rig.world(g_pose)\nMg = Wg[names[\"J_Bip_L_LowerArm\"]]\nEg = Mg[:3, 3]; Hg = Wg[names[\"J_Bip_L_Hand\"]][:3, 3]\nF3 = np.diag([-1., 1., -1.])\na = np.radians(-32.0)\nRy_inv = np.array([[np.cos(a),0,np.sin(a)],[0,1,0],[-np.sin(a),0,np.cos(a)]])\ncam_to_vrm = lambda u: F3 @ (Ry_inv @ (np.asarray(u, float)/np.linalg.norm(u)))\nout_g = cam_to_vrm([0.52, 0.06, 0.85])\nup_g = cam_to_vrm([-0.06, 0.99, -0.03]); up_g -= out_g * (up_g @ out_g); up_g /= np.linalg.norm(up_g)\nfw_g = np.cross(out_g, up_g)\ncentre_g = Eg * 0.25 + Hg * 0.75 + out_g * 0.195 + fw_g * 0.025\nT_g2r = fit.world[\"J_Bip_L_LowerArm\"] @ np.linalg.inv(Mg)\nR_g2r = T_g2r[:3, :3] / np.linalg.norm(T_g2r[:3, :3], axis=0)\n\nbody_p = [p for p, r in zip(prims, roles) if r == \"body\"][0]\nface_p = [p for p, r in zip(prims, roles) if r == \"face\"][0]\nin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_in.npz\")\nout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\")\nnp.savez(in_npz, body_pos=body_p[\"pos\"], body_tri=body_p[\"tri\"], face_pos=face_p[\"pos\"], face_tri=face_p[\"tri\"],\n bones=fit.bone, landmarks=lm,\n guard_info=dict(fist_R=fist_R, fwd_R=fwd_R, side_R=side_R, flat_R=flat_R,\n shield_centre=(T_g2r @ np.append(centre_g, 1.0))[:3],\n shield_out=R_g2r @ out_g, shield_up=R_g2r @ up_g))\nt0 = time.time()\nres = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", in_npz, out_npz, \"valen\"],\n capture_output=True, text=True)\ndt = time.time() - t0\nprint(\"Valen RC:\", res.returncode, \"Time:\", round(dt, 2), \"s\")\nif res.returncode != 0:\n print(\"STDOUT:\\n\", res.stdout[-2500:])\n print(\"STDERR:\\n\", res.stderr[-2500:])\nelse:\n d = np.load(out_npz, allow_pickle=True)\n pcs = d[\"pieces\"]\n print(\"Valen Pieces:\", len(pcs), \"Total tris:\", sum(len(x[4]) for x in pcs), \"Total verts:\", sum(len(x[2]) for x in pcs))\n for x in pcs[:8]:\n print(\" \", x[0], x[1], x[2].shape, x[4].shape, x[5], x[6])\n\nvk_path = bs.cached_cage_vrm(\"arm_m_strong\")\nvk = VRM(vk_path)\nshk = {**vp.SHAPE, **G.shape(\"stocky\", \"veteran\", face_normals=0.0, hair_normals=0.0)}\nshk[\"arm_out\"] = bs.arm_room(vk, shk)\npose_k = vp.bone_pose(vk, shk, vp.BUST_POSE)\nprims_k = vk.primitives(None, pose_k)\nroles_k = [vp.role_of(p[\"material\"]) for p in prims_k]\nlm_k = vp.landmarks(prims_k, roles_k)\nfit_k = O.Fit(vk, pose_k, prims_k, roles_k)\nbp_k = [p for p, r in zip(prims_k, roles_k) if r == \"body\"][0]\nfp_k = [p for p, r in zip(prims_k, roles_k) if r == \"face\"][0]\nkin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_in.npz\")\nkout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_out.npz\")\nnp.savez(kin_npz, body_pos=bp_k[\"pos\"], body_tri=bp_k[\"tri\"], face_pos=fp_k[\"pos\"], face_tri=fp_k[\"tri\"],\n bones=fit_k.bone, landmarks=lm_k)\nt1 = time.time()\nres_k = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", kin_npz, kout_npz, \"korin\"],\n capture_output=True, text=True)\nprint(\"Korin RC:\", res_k.returncode, \"Time:\", round(time.time() - t1, 2), \"s\")\nif res_k.returncode != 0:\n print(\"STDERR:\\n\", res_k.stderr[-2000:])\nelse:\n dk = np.load(kout_npz, allow_pickle=True)\n pcsk = dk[\"pieces\"]\n print(\"Korin Pieces:\", len(pcsk), \"Total tris:\", sum(len(x[4]) for x in pcsk))\n'","WaitMsBeforeAsync":10000,"toolSummary":"Run headless Blender 5.2 test with full_shape"}error
input
{ "CommandLine": "python3 -c '\nimport os, sys, time, subprocess, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, gear as G, outfit as O, poses as P, vroid_portrait as vp\nfrom vrm import VRM\nfrom rig import Rig, grip_points\nimport battle_slice as bs\n\nos.makedirs(os.path.expanduser(\"~/.cache/lowmarch_bl_test\"), exist_ok=True)\nv_path = bs.cached_cage_vrm(\"arm_f_strong\")\nv = VRM(v_path)\nsh = {**vp.SHAPE, **G.shape(\"athletic\", \"bare\", leg_len=1.075, head=0.935, torso=0.90, chest=1.04, shoulder_w=0.012, curl=14, face_normals=0.0, hair_normals=0.0)}\nsh[\"arm_out\"] = bs.arm_room(v, sh)\npose_ref = vp.bone_pose(v, sh, vp.BUST_POSE)\nprims = v.primitives(None, pose_ref)\nroles = [vp.role_of(p[\"material\"]) for p in prims]\nlm = vp.landmarks(prims, roles)\nfit = O.Fit(v, pose_ref, prims, roles)\nfit.grip = grip_points(v, sh, P.BUST)\nfist_R, fwd_R, side_R, flat_R, _ = G._hand_frame(fit, \"R\")\n\nrig = Rig(v, sh, ortho=True)\ng_pose = bs.vanguard_pose(v, sh)[0][1]\nnames = v.nodes_by_name()\nWg = rig.world(g_pose)\nMg = Wg[names[\"J_Bip_L_LowerArm\"]]\nEg = Mg[:3, 3]; Hg = Wg[names[\"J_Bip_L_Hand\"]][:3, 3]\nF3 = np.diag([-1., 1., -1.])\na = np.radians(-32.0)\nRy_inv = np.array([[np.cos(a),0,np.sin(a)],[0,1,0],[-np.sin(a),0,np.cos(a)]])\ncam_to_vrm = lambda u: F3 @ (Ry_inv @ (np.asarray(u, float)/np.linalg.norm(u)))\nout_g = cam_to_vrm([0.52, 0.06, 0.85])\nup_g = cam_to_vrm([-0.06, 0.99, -0.03]); up_g -= out_g * (up_g @ out_g); up_g /= np.linalg.norm(up_g)\nfw_g = np.cross(out_g, up_g)\ncentre_g = Eg * 0.25 + Hg * 0.75 + out_g * 0.195 + fw_g * 0.025\nT_g2r = fit.world[\"J_Bip_L_LowerArm\"] @ np.linalg.inv(Mg)\nR_g2r = T_g2r[:3, :3] / np.linalg.norm(T_g2r[:3, :3], axis=0)\n\nbody_p = [p for p, r in zip(prims, roles) if r == \"body\"][0]\nface_p = [p for p, r in zip(prims, roles) if r == \"face\"][0]\nin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_in.npz\")\nout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\")\nnp.savez(in_npz, body_pos=body_p[\"pos\"], body_tri=body_p[\"tri\"], face_pos=face_p[\"pos\"], face_tri=face_p[\"tri\"],\n bones=fit.bone, landmarks=lm,\n guard_info=dict(fist_R=fist_R, fwd_R=fwd_R, side_R=side_R, flat_R=flat_R,\n shield_centre=(T_g2r @ np.append(centre_g, 1.0))[:3],\n shield_out=R_g2r @ out_g, shield_up=R_g2r @ up_g))\nt0 = time.time()\nres = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", in_npz, out_npz, \"valen\"],\n capture_output=True, text=True)\ndt = time.time() - t0\nprint(\"Valen RC:\", res.returncode, \"Time:\", round(dt, 2), \"s\")\nif res.returncode != 0:\n print(\"STDOUT:\\n\", res.stdout[-2500:])\n print(\"STDERR:\\n\", res.stderr[-2500:])\nelse:\n d = np.load(out_npz, allow_pickle=True)\n pcs = d[\"pieces\"]\n print(\"Valen Pieces:\", len(pcs), \"Total tris:\", sum(len(x[4]) for x in pcs), \"Total verts:\", sum(len(x[2]) for x in pcs))\n for x in pcs[:8]:\n print(\" \", x[0], x[1], x[2].shape, x[4].shape, x[5], x[6])\n\nvk_path = bs.cached_cage_vrm(\"arm_m_strong\")\nvk = VRM(vk_path)\nshk = {**vp.SHAPE, **G.shape(\"stocky\", \"veteran\", face_normals=0.0, hair_normals=0.0)}\nshk[\"arm_out\"] = bs.arm_room(vk, shk)\npose_k = vp.bone_pose(vk, shk, vp.BUST_POSE)\nprims_k = vk.primitives(None, pose_k)\nroles_k = [vp.role_of(p[\"material\"]) for p in prims_k]\nlm_k = vp.landmarks(prims_k, roles_k)\nfit_k = O.Fit(vk, pose_k, prims_k, roles_k)\nbp_k = [p for p, r in zip(prims_k, roles_k) if r == \"body\"][0]\nfp_k = [p for p, r in zip(prims_k, roles_k) if r == \"face\"][0]\nkin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_in.npz\")\nkout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_out.npz\")\nnp.savez(kin_npz, body_pos=bp_k[\"pos\"], body_tri=bp_k[\"tri\"], face_pos=fp_k[\"pos\"], face_tri=fp_k[\"tri\"],\n bones=fit_k.bone, landmarks=lm_k)\nt1 = time.time()\nres_k = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", kin_npz, kout_npz, \"korin\"],\n capture_output=True, text=True)\nprint(\"Korin RC:\", res_k.returncode, \"Time:\", round(time.time() - t1, 2), \"s\")\nif res_k.returncode != 0:\n print(\"STDERR:\\n\", res_k.stderr[-2000:])\nelse:\n dk = np.load(kout_npz, allow_pickle=True)\n pcsk = dk[\"pieces\"]\n print(\"Korin Pieces:\", len(pcsk), \"Total tris:\", sum(len(x[4]) for x in pcsk))\n'", "WaitMsBeforeAsync": 10000, "toolSummary": "Run headless Blender 5.2 test with full_shape" }result, error, 6 lines
Command exited with code 1. Command output: Traceback (most recent call last): File "<string>", line 12, in <module> AttributeError: module 'vroid_portrait' has no attribute 'SHAPE'. Did you mean: 'CAPE'?
read_file{"EndLine":190,"Path":"~/work/lowmarch/tools/vroid_portrait.py","StartLine":150}
input
{ "EndLine": 190, "Path": "~/work/lowmarch/tools/vroid_portrait.py", "StartLine": 150 }result, 42 lines
Showing lines 150-190 of 1407 150: 151: 152: def smooth(t): 153: t = np.clip(t, 0, 1) 154: return t * t * (3 - 2 * t) 155: 156: 157: # Archetype shape controls, in three layers (0 / 1 / {} = unchanged): 158: # 1. proportions through the skeleton: bone scales, the way VRoid varies builds 159: # 2. face sculpting: anatomical points move, anchors (eyes, ears, skull, neck) hold still, and a 160: # smooth RBF field fills in between 161: # 3. resting expression: VRoid's own shapes (hooded eyes, stern brows) held at a low weight 162: NEUTRAL = dict(head=1.0, neck=1.0, chest=1.0, height=1.0, 163: shoulders=1.0, arms=1.0, torso=1.0, legs=1.0, leg_len=1.0, hands=1.0, shoulder_w=0.0, 164: face_len=0.0, jaw=0.0, chin_w=0.0, chin_len=0.0, cheek=0.0, brow_ridge=0.0, 165: nose=0.0, nose_w=0.0, 166: eye=1.0, eye_tilt=0.0, iris=1.0, lash=1.0, mouth=1.0, arm_out=0.0, age_lines=0.0, blush=1.0, curl=0.0, 167: face_normals=1.0, hair_normals=0.0, shadow_cards=1.0, fangs=1.0, rest={}) 168: # hair is reshaped with the face: beards (built on the face before the face is sculpted) and side locks 169: # must follow a wider jaw or a longer chin, or the skin comes through them 170: SCULPT_ROLES = ("face", "body", "mouth", "brow", "line", "white", "iris", "highlight", "hair") 171: 172: 173: def bone_pose(v, sh, base_pose): 174: """Pose dict (bone -> 3x3) = base rotations combined with proportion scales. Each scaled bone 175: resets its children to scale 1 except the head, whose children (hair bones) grow with it.""" 176: # Body proportions (all 1.0 = VRoid's): shoulders lengthens the clavicles (wider shoulders), arms 177: # and legs thicken the limbs, torso broadens the waist-to-chest, leg_len lengthens thigh and shin 178: # (the hips are lifted to keep the feet on the ground), hands scales the hands. 179: a, lg, t = sh["arms"], sh["legs"], sh["torso"] 180: spec = {"J_Bip_C_Head": ((sh["head"],) * 3, True), 181: "J_Bip_C_Neck": ((sh["neck"], 1.0, sh["neck"]), False), 182: "J_Bip_C_UpperChest": ((sh["chest"], 1.0, 1 + (sh["chest"] - 1) * 0.6), False), 183: "J_Bip_C_Spine": ((1 + (t - 1) * 0.7, 1.0, 1 + (t - 1) * 0.5), False), 184: "J_Bip_C_Chest": ((t, 1.0, 1 + (t - 1) * 0.7), False)} 185: for side in "LR": 186: spec[f"J_Bip_{side}_Shoulder"] = ((sh["shoulders"], 1.0, 1.0), False) 187: for b in ("UpperArm", "LowerArm"): 188: spec[f"J_Bip_{side}_{b}"] = ((1.0, a, a), False) # arm bones run along x 189: for b in ("UpperLeg", "LowerLeg"): 190: spec[f"J_Bip_{side}_{b}"] = ((lg, sh["leg_len"], lg), False) # leg bones run along yrun_command{"CommandLine":"python3 -c '\nimport os, sys, time, subprocess, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, gear as G, outfit as O, poses as P, vroid_portrait as vp\nfrom vrm import VRM\nfrom rig import Rig, grip_points\nimport battle_slice as bs\n\nos.makedirs(os.path.expanduser(\"~/.cache/lowmarch_bl_test\"), exist_ok=True)\nv_path = bs.cached_cage_vrm(\"arm_f_strong\")\nv = VRM(v_path)\nsh = {**vp.NEUTRAL, **G.shape(\"athletic\", \"bare\", leg_len=1.075, head=0.935, torso=0.90, chest=1.04, shoulder_w=0.012, curl=14, face_normals=0.0, hair_normals=0.0)}\nsh[\"arm_out\"] = bs.arm_room(v, sh)\npose_ref = vp.bone_pose(v, sh, vp.BUST_POSE)\nprims = v.primitives(None, pose_ref)\nroles = [vp.role_of(p[\"material\"]) for p in prims]\nlm = vp.landmarks(prims, roles)\nfit = O.Fit(v, pose_ref, prims, roles)\nfit.grip = grip_points(v, sh, P.BUST)\nfist_R, fwd_R, side_R, flat_R, _ = G._hand_frame(fit, \"R\")\n\nrig = Rig(v, sh, ortho=True)\ng_pose = bs.vanguard_pose(v, sh)[0][1]\nnames = v.nodes_by_name()\nWg = rig.world(g_pose)\nMg = Wg[names[\"J_Bip_L_LowerArm\"]]\nEg = Mg[:3, 3]; Hg = Wg[names[\"J_Bip_L_Hand\"]][:3, 3]\nF3 = np.diag([-1., 1., -1.])\na = np.radians(-32.0)\nRy_inv = np.array([[np.cos(a),0,np.sin(a)],[0,1,0],[-np.sin(a),0,np.cos(a)]])\ncam_to_vrm = lambda u: F3 @ (Ry_inv @ (np.asarray(u, float)/np.linalg.norm(u)))\nout_g = cam_to_vrm([0.52, 0.06, 0.85])\nup_g = cam_to_vrm([-0.06, 0.99, -0.03]); up_g -= out_g * (up_g @ out_g); up_g /= np.linalg.norm(up_g)\nfw_g = np.cross(out_g, up_g)\ncentre_g = Eg * 0.25 + Hg * 0.75 + out_g * 0.195 + fw_g * 0.025\nT_g2r = fit.world[\"J_Bip_L_LowerArm\"] @ np.linalg.inv(Mg)\nR_g2r = T_g2r[:3, :3] / np.linalg.norm(T_g2r[:3, :3], axis=0)\n\nbody_p = [p for p, r in zip(prims, roles) if r == \"body\"][0]\nface_p = [p for p, r in zip(prims, roles) if r == \"face\"][0]\nin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_in.npz\")\nout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\")\nnp.savez(in_npz, body_pos=body_p[\"pos\"], body_tri=body_p[\"tri\"], face_pos=face_p[\"pos\"], face_tri=face_p[\"tri\"],\n bones=fit.bone, landmarks=lm,\n guard_info=dict(fist_R=fist_R, fwd_R=fwd_R, side_R=side_R, flat_R=flat_R,\n shield_centre=(T_g2r @ np.append(centre_g, 1.0))[:3],\n shield_out=R_g2r @ out_g, shield_up=R_g2r @ up_g))\nt0 = time.time()\nres = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", in_npz, out_npz, \"valen\"],\n capture_output=True, text=True)\ndt = time.time() - t0\nprint(\"Valen RC:\", res.returncode, \"Time:\", round(dt, 2), \"s\")\nif res.returncode != 0:\n print(\"STDOUT:\\n\", res.stdout[-2500:])\n print(\"STDERR:\\n\", res.stderr[-2500:])\nelse:\n d = np.load(out_npz, allow_pickle=True)\n pcs = d[\"pieces\"]\n print(\"Valen Pieces:\", len(pcs), \"Total tris:\", sum(len(x[4]) for x in pcs), \"Total verts:\", sum(len(x[2]) for x in pcs))\n for x in pcs[:8]:\n print(\" \", x[0], x[1], x[2].shape, x[4].shape, x[5], x[6])\n\nvk_path = bs.cached_cage_vrm(\"arm_m_strong\")\nvk = VRM(vk_path)\nshk = {**vp.NEUTRAL, **G.shape(\"stocky\", \"veteran\", face_normals=0.0, hair_normals=0.0)}\nshk[\"arm_out\"] = bs.arm_room(vk, shk)\npose_k = vp.bone_pose(vk, shk, vp.BUST_POSE)\nprims_k = vk.primitives(None, pose_k)\nroles_k = [vp.role_of(p[\"material\"]) for p in prims_k]\nlm_k = vp.landmarks(prims_k, roles_k)\nfit_k = O.Fit(vk, pose_k, prims_k, roles_k)\nbp_k = [p for p, r in zip(prims_k, roles_k) if r == \"body\"][0]\nfp_k = [p for p, r in zip(prims_k, roles_k) if r == \"face\"][0]\nkin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_in.npz\")\nkout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_out.npz\")\nnp.savez(kin_npz, body_pos=bp_k[\"pos\"], body_tri=bp_k[\"tri\"], face_pos=fp_k[\"pos\"], face_tri=fp_k[\"tri\"],\n bones=fit_k.bone, landmarks=lm_k)\nt1 = time.time()\nres_k = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", kin_npz, kout_npz, \"korin\"],\n capture_output=True, text=True)\nprint(\"Korin RC:\", res_k.returncode, \"Time:\", round(time.time() - t1, 2), \"s\")\nif res_k.returncode != 0:\n print(\"STDERR:\\n\", res_k.stderr[-2000:])\nelse:\n dk = np.load(kout_npz, allow_pickle=True)\n pcsk = dk[\"pieces\"]\n print(\"Korin Pieces:\", len(pcsk), \"Total tris:\", sum(len(x[4]) for x in pcsk))\n'","WaitMsBeforeAsync":10000,"toolSummary":"Run headless Blender 5.2 test for Valen and Korin"}
input
{ "CommandLine": "python3 -c '\nimport os, sys, time, subprocess, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, gear as G, outfit as O, poses as P, vroid_portrait as vp\nfrom vrm import VRM\nfrom rig import Rig, grip_points\nimport battle_slice as bs\n\nos.makedirs(os.path.expanduser(\"~/.cache/lowmarch_bl_test\"), exist_ok=True)\nv_path = bs.cached_cage_vrm(\"arm_f_strong\")\nv = VRM(v_path)\nsh = {**vp.NEUTRAL, **G.shape(\"athletic\", \"bare\", leg_len=1.075, head=0.935, torso=0.90, chest=1.04, shoulder_w=0.012, curl=14, face_normals=0.0, hair_normals=0.0)}\nsh[\"arm_out\"] = bs.arm_room(v, sh)\npose_ref = vp.bone_pose(v, sh, vp.BUST_POSE)\nprims = v.primitives(None, pose_ref)\nroles = [vp.role_of(p[\"material\"]) for p in prims]\nlm = vp.landmarks(prims, roles)\nfit = O.Fit(v, pose_ref, prims, roles)\nfit.grip = grip_points(v, sh, P.BUST)\nfist_R, fwd_R, side_R, flat_R, _ = G._hand_frame(fit, \"R\")\n\nrig = Rig(v, sh, ortho=True)\ng_pose = bs.vanguard_pose(v, sh)[0][1]\nnames = v.nodes_by_name()\nWg = rig.world(g_pose)\nMg = Wg[names[\"J_Bip_L_LowerArm\"]]\nEg = Mg[:3, 3]; Hg = Wg[names[\"J_Bip_L_Hand\"]][:3, 3]\nF3 = np.diag([-1., 1., -1.])\na = np.radians(-32.0)\nRy_inv = np.array([[np.cos(a),0,np.sin(a)],[0,1,0],[-np.sin(a),0,np.cos(a)]])\ncam_to_vrm = lambda u: F3 @ (Ry_inv @ (np.asarray(u, float)/np.linalg.norm(u)))\nout_g = cam_to_vrm([0.52, 0.06, 0.85])\nup_g = cam_to_vrm([-0.06, 0.99, -0.03]); up_g -= out_g * (up_g @ out_g); up_g /= np.linalg.norm(up_g)\nfw_g = np.cross(out_g, up_g)\ncentre_g = Eg * 0.25 + Hg * 0.75 + out_g * 0.195 + fw_g * 0.025\nT_g2r = fit.world[\"J_Bip_L_LowerArm\"] @ np.linalg.inv(Mg)\nR_g2r = T_g2r[:3, :3] / np.linalg.norm(T_g2r[:3, :3], axis=0)\n\nbody_p = [p for p, r in zip(prims, roles) if r == \"body\"][0]\nface_p = [p for p, r in zip(prims, roles) if r == \"face\"][0]\nin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_in.npz\")\nout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\")\nnp.savez(in_npz, body_pos=body_p[\"pos\"], body_tri=body_p[\"tri\"], face_pos=face_p[\"pos\"], face_tri=face_p[\"tri\"],\n bones=fit.bone, landmarks=lm,\n guard_info=dict(fist_R=fist_R, fwd_R=fwd_R, side_R=side_R, flat_R=flat_R,\n shield_centre=(T_g2r @ np.append(centre_g, 1.0))[:3],\n shield_out=R_g2r @ out_g, shield_up=R_g2r @ up_g))\nt0 = time.time()\nres = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", in_npz, out_npz, \"valen\"],\n capture_output=True, text=True)\ndt = time.time() - t0\nprint(\"Valen RC:\", res.returncode, \"Time:\", round(dt, 2), \"s\")\nif res.returncode != 0:\n print(\"STDOUT:\\n\", res.stdout[-2500:])\n print(\"STDERR:\\n\", res.stderr[-2500:])\nelse:\n d = np.load(out_npz, allow_pickle=True)\n pcs = d[\"pieces\"]\n print(\"Valen Pieces:\", len(pcs), \"Total tris:\", sum(len(x[4]) for x in pcs), \"Total verts:\", sum(len(x[2]) for x in pcs))\n for x in pcs[:8]:\n print(\" \", x[0], x[1], x[2].shape, x[4].shape, x[5], x[6])\n\nvk_path = bs.cached_cage_vrm(\"arm_m_strong\")\nvk = VRM(vk_path)\nshk = {**vp.NEUTRAL, **G.shape(\"stocky\", \"veteran\", face_normals=0.0, hair_normals=0.0)}\nshk[\"arm_out\"] = bs.arm_room(vk, shk)\npose_k = vp.bone_pose(vk, shk, vp.BUST_POSE)\nprims_k = vk.primitives(None, pose_k)\nroles_k = [vp.role_of(p[\"material\"]) for p in prims_k]\nlm_k = vp.landmarks(prims_k, roles_k)\nfit_k = O.Fit(vk, pose_k, prims_k, roles_k)\nbp_k = [p for p, r in zip(prims_k, roles_k) if r == \"body\"][0]\nfp_k = [p for p, r in zip(prims_k, roles_k) if r == \"face\"][0]\nkin_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_in.npz\")\nkout_npz = os.path.expanduser(\"~/.cache/lowmarch_bl_test/korin_out.npz\")\nnp.savez(kin_npz, body_pos=bp_k[\"pos\"], body_tri=bp_k[\"tri\"], face_pos=fp_k[\"pos\"], face_tri=fp_k[\"tri\"],\n bones=fit_k.bone, landmarks=lm_k)\nt1 = time.time()\nres_k = subprocess.run([\"blender\", \"-b\", \"--factory-startup\", \"--python\", \"tools/blender_sculpt_cast.py\", \"--\", kin_npz, kout_npz, \"korin\"],\n capture_output=True, text=True)\nprint(\"Korin RC:\", res_k.returncode, \"Time:\", round(time.time() - t1, 2), \"s\")\nif res_k.returncode != 0:\n print(\"STDERR:\\n\", res_k.stderr[-2000:])\nelse:\n dk = np.load(kout_npz, allow_pickle=True)\n pcsk = dk[\"pieces\"]\n print(\"Korin Pieces:\", len(pcsk), \"Total tris:\", sum(len(x[4]) for x in pcsk))\n'", "WaitMsBeforeAsync": 10000, "toolSummary": "Run headless Blender 5.2 test for Valen and Korin" }result, 15 lines
Command exited with code 0. Command output: Valen RC: 0 Time: 3.69 s Valen Pieces: 102 Total tris: 278260 Total verts: 141070 hair_crown hair (49559, 3) (97320, 3) head_rigid hair hair_ponytail hair (9184, 3) (17864, 3) ponytail_blend hair hair_cuff gold (240, 3) (480, 3) head_rigid hair hair_ribbon signature (704, 3) (1336, 3) ponytail_blend hair arming_tunic doublet (5456, 3) (10912, 3) torso_skin doublet officer_collar signature (1206, 3) (2408, 3) neck_blend collar officer_collar_gold gold (360, 3) (676, 3) neck_blend collar gorget steel (1760, 3) (3520, 3) uchest_blend plate Korin RC: 0 Time: 1.08 s Korin Pieces: 10 Total tris: 36782
agent
+1:14:51reasoning
The initial run shows successful completion with no errors for both test cases, significantly faster than the prior attempts. Examining the data, the 'hair_crown' component requires further investigation regarding triangle count to ensure it aligns with expectations. This initial success is promising but requires a closer inspection of individual model components to confirm full validity.
The 'hair_crown' component's high triangle count warranted investigation. Analysis of the _add_lock_curve function revealed the source: a combination of NURBS curve subdivisions and potentially high resolution settings, specifically impacting the 'tap_cu' curve. Further context suggests the export target is for a real-time renderer, which benefits from significantly lower triangle counts.
run_command{"CommandLine":"python3 -c '\nimport os, numpy as np\nd = np.load(os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\"), allow_pickle=True)\npcs = sorted(d[\"pieces\"], key=lambda x: -len(x[4]))\nfor x in pcs[:20]:\n print(f\"{x[0]:26s} {x[1]:10s} verts={len(x[2]):6d} tris={len(x[4]):6d}\")\n'","WaitMsBeforeAsync":5000,"toolSummary":"Inspect triangle counts per Blender piece"}
input
{ "CommandLine": "python3 -c '\nimport os, numpy as np\nd = np.load(os.path.expanduser(\"~/.cache/lowmarch_bl_test/valen_out.npz\"), allow_pickle=True)\npcs = sorted(d[\"pieces\"], key=lambda x: -len(x[4]))\nfor x in pcs[:20]:\n print(f\"{x[0]:26s} {x[1]:10s} verts={len(x[2]):6d} tris={len(x[4]):6d}\")\n'", "WaitMsBeforeAsync": 5000, "toolSummary": "Inspect triangle counts per Blender piece" }result, 23 lines
Command exited with code 0. Command output: hair_crown hair verts= 49559 tris= 97320 hair_ponytail hair verts= 9184 tris= 17864 gothic_cuirass steel verts= 5952 tris= 11904 arming_tunic doublet verts= 5456 tris= 10912 ivory_underkirtle heraldry verts= 5152 tris= 10304 aegis_body signature verts= 3430 tris= 6856 breeches_L doublet verts= 3224 tris= 6448 breeches_R doublet verts= 3224 tris= 6448 cavalier_boot_L boot verts= 2392 tris= 4784 cavalier_boot_R boot verts= 2392 tris= 4784 surcoat_panel_0 signature verts= 2322 tris= 4640 surcoat_panel_1 signature verts= 2322 tris= 4640 lantern_sleeve_L signature verts= 2208 tris= 4416 lantern_sleeve_R signature verts= 2208 tris= 4416 boot_foot_L boot verts= 1824 tris= 3648 boot_foot_R boot verts= 1824 tris= 3648 gorget steel verts= 1760 tris= 3520 fluted_greave_L steel verts= 1558 tris= 3112 fluted_greave_R steel verts= 1558 tris= 3112 vambrace_L steel verts= 1320 tris= 2640
agent
+1:15:08reasoning
The high triangle count for hair_crown is unexpected, particularly when compared to hair_ponytail. The issue stems from the dome_ob object's subdivision level and triangulation, which significantly increases the triangle count after subdivision.
edit_file{"Path":"~/work/lowmarch/tools/blender_sculpt_cast.py","Replacement":" tap_cu = bpy.data.curves.new(f\"Taper_{profile_kind}\", type=\"CURVE\")\n tap_cu.dimensions = \"2D\"\n tap_cu.resolution_u = 6\n tsp = tap_cu.splines.new(\"NURBS\")","Target":" tap_cu = bpy.data.curves.new(f\"Taper_{profile_kind}\", type=\"CURVE\")\n tap_cu.dimensions = \"2D\"\n tsp = tap_cu.splines.new(\"NURBS\")"}
input
{ "Path": "~/work/lowmarch/tools/blender_sculpt_cast.py", "Replacement": " tap_cu = bpy.data.curves.new(f\"Taper_{profile_kind}\", type=\"CURVE\")\n tap_cu.dimensions = \"2D\"\n tap_cu.resolution_u = 6\n tsp = tap_cu.splines.new(\"NURBS\")", "Target": " tap_cu = bpy.data.curves.new(f\"Taper_{profile_kind}\", type=\"CURVE\")\n tap_cu.dimensions = \"2D\"\n tsp = tap_cu.splines.new(\"NURBS\")" }result, 1 line
Made 1 replacement in ~/work/lowmarch/tools/blender_sculpt_cast.py starting at line 255 (+1/-0 lines).
edit_file{"Path":"~/work/lowmarch/tools/blender_sculpt_cast.py","Replacement":"def _add_lock_curve(name, pts_bl, width, thick_ratio, head_center_bl, bev_ob, tap_ob, twist=0.0, res_u=7):","Target":"def _add_lock_curve(name, pts_bl, width, thick_ratio, head_center_bl, bev_ob, tap_ob, twist=0.0, res_u=14):"}
input
{ "Path": "~/work/lowmarch/tools/blender_sculpt_cast.py", "Replacement": "def _add_lock_curve(name, pts_bl, width, thick_ratio, head_center_bl, bev_ob, tap_ob, twist=0.0, res_u=7):", "Target": "def _add_lock_curve(name, pts_bl, width, thick_ratio, head_center_bl, bev_ob, tap_ob, twist=0.0, res_u=14):" }result, 1 line
Made 1 replacement in ~/work/lowmarch/tools/blender_sculpt_cast.py starting at line 271 (+1/-1 lines).
edit_file{"Path":"~/work/lowmarch/tools/blender_sculpt_cast.py","Replacement":" hair_objs.append(_add_lock_curve(f\"CrownBraid_{side_nm}\", b_pts, 0.015, 0.85, hc, bev_braid, tap_braid, twist=sx * 3.8, res_u=9))","Target":" hair_objs.append(_add_lock_curve(f\"CrownBraid_{side_nm}\", b_pts, 0.015, 0.85, hc, bev_braid, tap_braid, twist=sx * 3.8, res_u=18))"}
input
{ "Path": "~/work/lowmarch/tools/blender_sculpt_cast.py", "Replacement": " hair_objs.append(_add_lock_curve(f\"CrownBraid_{side_nm}\", b_pts, 0.015, 0.85, hc, bev_braid, tap_braid, twist=sx * 3.8, res_u=9))", "Target": " hair_objs.append(_add_lock_curve(f\"CrownBraid_{side_nm}\", b_pts, 0.015, 0.85, hc, bev_braid, tap_braid, twist=sx * 3.8, res_u=18))" }result, 1 line
Made 1 replacement in ~/work/lowmarch/tools/blender_sculpt_cast.py starting at line 467 (+1/-1 lines).
edit_file{"Path":"~/work/lowmarch/tools/blender_sculpt_cast.py","Replacement":" ponytail_objs.append(_add_lock_curve(f\"Ponytail_{k}\", p_tail, wd, 0.48, tie_bl + np.array([0, 0.05, -0.15]),\n bev_lock, tap_lock, twist=tw, res_u=9))","Target":" ponytail_objs.append(_add_lock_curve(f\"Ponytail_{k}\", p_tail, wd, 0.48, tie_bl + np.array([0, 0.05, -0.15]),\n bev_lock, tap_lock, twist=tw, res_u=16))"}
input
{ "Path": "~/work/lowmarch/tools/blender_sculpt_cast.py", "Replacement": " ponytail_objs.append(_add_lock_curve(f\"Ponytail_{k}\", p_tail, wd, 0.48, tie_bl + np.array([0, 0.05, -0.15]),\n bev_lock, tap_lock, twist=tw, res_u=9))", "Target": " ponytail_objs.append(_add_lock_curve(f\"Ponytail_{k}\", p_tail, wd, 0.48, tie_bl + np.array([0, 0.05, -0.15]),\n bev_lock, tap_lock, twist=tw, res_u=16))" }result, 1 line
Made 1 replacement in ~/work/lowmarch/tools/blender_sculpt_cast.py starting at line 514 (+1/-1 lines).
edit_file{"Path":"~/work/lowmarch/tools/blender_sculpt_cast.py","Replacement":" if subsurf > 0 and (U * V < 420):\n sub = ob.modifiers.new(\"Sub\", \"SUBSURF\")\n sub.levels = sub.render_levels = subsurf","Target":" if subsurf > 0:\n sub = ob.modifiers.new(\"Sub\", \"SUBSURF\")\n sub.levels = sub.render_levels = subsurf"}
input
{ "Path": "~/work/lowmarch/tools/blender_sculpt_cast.py", "Replacement": " if subsurf > 0 and (U * V < 420):\n sub = ob.modifiers.new(\"Sub\", \"SUBSURF\")\n sub.levels = sub.render_levels = subsurf", "Target": " if subsurf > 0:\n sub = ob.modifiers.new(\"Sub\", \"SUBSURF\")\n sub.levels = sub.render_levels = subsurf" }result, 1 line
Made 1 replacement in ~/work/lowmarch/tools/blender_sculpt_cast.py starting at line 629 (+1/-1 lines).