5620347ffe
Keep authored JSON separate from generated output. Export rotated model bounds for SDK-free navigation and check grazing voxel corners. Include unretouched in-game before/after captures and explicit art/performance limits; pilots are an intermediate pass, not completion of the full asset set. Co-Authored-By: Codex <noreply@openai.com>
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
import json
|
|
import math
|
|
from pathlib import Path
|
|
import tempfile
|
|
import unittest
|
|
|
|
from airdef_assets.bounds import model_bounds, write_rust_bounds
|
|
from airdef_assets.pipeline import overlay_sources
|
|
|
|
|
|
class BoundsTests(unittest.TestCase):
|
|
def test_rotated_wheel_bounds_include_the_corners_outside_its_original_box(self):
|
|
lo, hi = model_bounds({"elements": [{"from": [-1, -1, -1], "to": [1, 1, 1],
|
|
"rotation": {"axis": "x", "angle": 45, "origin": [0, 0, 0]}}]})
|
|
self.assertAlmostEqual(hi[1], math.sqrt(2))
|
|
self.assertAlmostEqual(lo[2], -math.sqrt(2))
|
|
self.assertEqual((lo[0], hi[0]), (-1, 1))
|
|
|
|
def test_final_authored_override_controls_exported_bounds(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
rel = Path("assets/airdef/models/block/test.json")
|
|
stage, source = root / "stage", root / "source"
|
|
for folder, extent in [(stage, 1), (source, 30)]:
|
|
(folder / rel).parent.mkdir(parents=True)
|
|
(folder / rel).write_text(json.dumps({"elements": [{"from": [0, 0, 0], "to": [extent, 2, 3]}]}))
|
|
overlay_sources(stage, source)
|
|
write_rust_bounds(stage)
|
|
text = (stage / "src/sim/generated_bounds.rs").read_text()
|
|
self.assertIn('"airdef:test"', text)
|
|
self.assertIn("[30.0, 2.0, 3.0]", text)
|
|
self.assertEqual(json.loads((source / rel).read_text())["elements"][0]["to"][0], 30)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|