feat: establish android particle field rendering loop
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
27
tools/generate_particle_fixture_f32.py
Normal file
27
tools/generate_particle_fixture_f32.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate deterministic v1 little-endian OfflineFixture field payloads."""
|
||||
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
|
||||
GRID = 16
|
||||
ROOT = Path(__file__).resolve().parents[1] / "particle-fixtures"
|
||||
|
||||
|
||||
def velocity(fixture: str, x: int, y: int) -> tuple[float, float]:
|
||||
if fixture == "uniform-east":
|
||||
return 1.0, 0.0
|
||||
if fixture == "uniform-north":
|
||||
return 0.0, 1.0
|
||||
local_x = (x + 0.5) / GRID - 0.5
|
||||
local_y = (y + 0.5) / GRID - 0.5
|
||||
return -2.0 * local_y, 2.0 * local_x
|
||||
|
||||
|
||||
for fixture in ("uniform-east", "uniform-north", "vortex"):
|
||||
payload = bytearray()
|
||||
for y in range(GRID):
|
||||
for x in range(GRID):
|
||||
payload.extend(struct.pack("<ff", *velocity(fixture, x, y)))
|
||||
(ROOT / fixture / "field.f32").write_bytes(payload)
|
||||
Reference in New Issue
Block a user