feat(simulation): optimize and persist collision viewing

This commit is contained in:
DCCONSTRUCTIONS
2026-08-26 15:18:34 +03:00
parent 5e97fa293f
commit a65ae9c285
13 changed files with 662 additions and 65 deletions
+62 -2
View File
@@ -201,7 +201,7 @@ def test_service_materializes_world_manifest_and_deletes_both_copies(tmp_path: P
1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1,
]
assert ready["world_manifest"]["transforms"]["world_from_collision"] == [
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1,
]
assert provider.upload_calls == 1
assert provider.submit_calls == 1
@@ -216,7 +216,7 @@ def test_service_materializes_world_manifest_and_deletes_both_copies(tmp_path: P
"seed_position": [0, 1, 0],
"capsule_height": 1.6,
"capsule_radius": 0.2,
"voxel_size": 0.05,
"voxel_size": 0.1,
"mesh_shape": "smooth",
}
service.delete(project["project_id"])
@@ -281,6 +281,41 @@ def test_failed_project_retries_from_retained_source_and_releases_old_job(tmp_pa
assert queued["source"]["uploaded_byte_length"] == queued["source"]["total_byte_length"]
def test_ready_project_rebuilds_from_retained_source_and_preserves_viewer_settings(
tmp_path: Path,
) -> None:
store = SimulationProjectStore(tmp_path)
project = store.create(
name="Rebuild scene",
scene_type="outdoor",
source_kind="folder",
files=_folder_files(),
)
_upload_all(store, project)
store.begin_build(project["project_id"])
provider = _ReadyProvider()
service = SimulationProjectService(
store,
provider_factory=lambda: provider,
) # type: ignore[arg-type]
service.process(project["project_id"])
settings = {
"schema_version": "missioncore.simulation-viewer-settings/v1",
"quality": "medium",
"visual": {"inverted": True, "axis": "z"},
"collision": {"inverted": True, "axis": "y"},
"camera": {"invert_horizontal": False, "invert_vertical": True},
}
store.update_viewer_settings(project["project_id"], settings)
queued = service.begin_build(project["project_id"])
assert provider.deleted == ["gsp-20260826000000-deadbeef"]
assert queued["status"] == "queued"
assert queued["viewer_settings"] == settings
assert queued["source"]["uploaded_byte_length"] == queued["source"]["total_byte_length"]
def test_api_exposes_same_origin_resumable_upload_contract(tmp_path: Path) -> None:
store = SimulationProjectStore(tmp_path)
service = SimulationProjectService(store, provider_factory=lambda: None)
@@ -296,6 +331,13 @@ def test_api_exposes_same_origin_resumable_upload_contract(tmp_path: Path) -> No
})
assert created.status_code == 201
project = created.json()
assert project["viewer_settings"] == {
"schema_version": "missioncore.simulation-viewer-settings/v1",
"quality": "high",
"visual": {"inverted": True, "axis": "x"},
"collision": {"inverted": True, "axis": "y"},
"camera": {"invert_horizontal": True, "invert_vertical": False},
}
source_file = project["source"]["files"][0]
upload_url = (
f"/api/v1/simulation-worlds/projects/{project['project_id']}"
@@ -311,3 +353,21 @@ def test_api_exposes_same_origin_resumable_upload_contract(tmp_path: Path) -> No
assert second.status_code == 204
catalog = client.get("/api/v1/simulation-worlds/projects").json()
assert catalog["projects"][0]["project_id"] == project["project_id"]
settings = {
"schema_version": "missioncore.simulation-viewer-settings/v1",
"quality": "medium",
"visual": {"inverted": True, "axis": "z"},
"collision": {"inverted": False, "axis": "x"},
"camera": {"invert_horizontal": False, "invert_vertical": True},
}
saved = client.put(
f"/api/v1/simulation-worlds/projects/{project['project_id']}/viewer-settings",
json=settings,
)
assert saved.status_code == 200
assert saved.json()["viewer_settings"] == settings
persisted = client.get(
f"/api/v1/simulation-worlds/projects/{project['project_id']}"
).json()
assert persisted["viewer_settings"] == settings