makepad/libs/game/render/examples/model_probe.rs
andodeki 435135ed50 feat(arcade): port makepad game libs + arcade from makepad-internal onto the fork
Reintroduce apps/arcade and the ten game crates that were ripped out of
the fork (assets, audio, blocks, coedit, gen, net, pkg, render, script,
session), from makepad-internal/dev. Reconcile against the fork's layout:

- makepad-game-sim/math come from the fork's existing libs/sim + sim/math;
  the copied internal libs/game/{sim,math} are dropped and the kept game
  crates plus arcade point at ../../sim and ../../sim/math.
- arcade AI is rewritten off the removed makepad-ai agent API onto the
  makepad-ai-hub headless ChatProvider worker (example/cad pattern):
  AiWorker{send,cancel,poll}, ai_worker_loop driving
  ClaudeApiChatProvider(ClaudeCli), AiWorkerEvent availability/delta/
  done/error mapped into the chat feed and authoring land_edit, with
  main.rs send_message/cancel_request/event-drain rebuilt around it.
- the game-script sandbox is adapted to the fork's jailed splash storage:
  every isolate gets mod.fs = splash_storage jail; splaes splash_storage
  set_root_for_heap is now public so the ScriptHost (or Splash) can grant
  a per-game jail root. ENT font: build.rs/dispatch.rs entities fill new
  fork sim Entity/Part fields via ..Default::default(); world_raycast now
  borrows mutably and returns the material id.

cargo check -p makepad-arcade and the game + arcade test suites pass.
2026-09-05 05:49:12 +03:00

32 lines
1.4 KiB
Rust

// Parse real Kenney GLBs and report what came out.
use makepad_game_render::model::StaticModel;
fn main() {
let root = std::path::Path::new("apps/arcade/resources/models/kenney");
let mut total = 0usize;
let mut ok = 0usize;
let mut tris = 0usize;
let mut fails: Vec<String> = Vec::new();
for pack in std::fs::read_dir(root).unwrap().flatten() {
let p = pack.path();
if !p.is_dir() { continue; }
for f in std::fs::read_dir(&p).unwrap().flatten() {
let fp = f.path();
if fp.extension().and_then(|e| e.to_str()) != Some("glb") { continue; }
total += 1;
match StaticModel::parse_glb(&std::fs::read(&fp).unwrap()) {
Ok(m) => {
ok += 1;
tris += m.triangle_count();
if ok <= 5 {
println!("{:40} v={:5} t={:5} h={:.2} tex={:?}",
fp.file_name().unwrap().to_string_lossy(),
m.vertex_count(), m.triangle_count(), m.height(), m.texture_uri);
}
}
Err(e) => if fails.len() < 5 { fails.push(format!("{}: {e}", fp.display())) },
}
}
}
println!("\nparsed {ok}/{total}, {tris} triangles total, avg {} tris/model", tris / ok.max(1));
for f in &fails { println!("FAIL {f}"); }
}