diff --git a/scripts/generate_asset.py b/scripts/generate_asset.py index 0e5ca36..a8c6287 100755 --- a/scripts/generate_asset.py +++ b/scripts/generate_asset.py @@ -274,7 +274,11 @@ def _run_pbr_attempts( attempt = { "baker": baker, "target_faces": target, - "technical_safety_target": target == SAFETY_FACE_TARGET and raw_faces > SAFETY_FACE_TARGET, + "technical_safety_target": ( + requested_target is None + and target == SAFETY_FACE_TARGET + and raw_faces > SAFETY_FACE_TARGET + ), } attempt_started = time.perf_counter() try: @@ -533,9 +537,13 @@ def main() -> int: metadata["candidate_pbr"] = _candidate_stats(candidate_path, exported) metadata["candidate_pbr"].update(chosen) - metadata["candidate_pbr"]["technical_decimation"] = bool( + metadata["candidate_pbr"]["decimated"] = bool( chosen["target_faces"] is not None and chosen["target_faces"] < raw_faces ) + metadata["candidate_pbr"]["technical_decimation"] = bool( + metadata["candidate_pbr"]["decimated"] + and chosen["technical_safety_target"] + ) metadata["timings_seconds"]["pbr_export"] = round(time.perf_counter() - pbr_started, 3) from trellis2.gltf_validation import validate_output_pair diff --git a/tests/test_generate_asset.py b/tests/test_generate_asset.py index 1968dad..c7b1328 100644 --- a/tests/test_generate_asset.py +++ b/tests/test_generate_asset.py @@ -98,6 +98,24 @@ def test_explicit_kdtree_never_loads_metal(): assert list(generate_asset._attempt_schedule("kdtree", None, 1000)) == [("kdtree", None)] +def test_explicit_200k_target_is_not_mislabeled_as_safety_fallback(tmp_path: Path): + def fake_export(mesh, path, *, baker, target, texture_size): + path.write_bytes(b"candidate") + return object(), True + + _, chosen, _ = generate_asset._run_pbr_attempts( + _mesh(800_000), + tmp_path / "candidate_pbr.glb", + preferred_baker="kdtree", + requested_target=200_000, + texture_size=512, + export_fn=fake_export, + ) + + assert chosen["target_faces"] == 200_000 + assert chosen["technical_safety_target"] is False + + def test_raw_export_preserves_full_topology_and_writes_vertex_normals(tmp_path: Path): vertices = torch.tensor( [