Squash of 25 work commits (Sep 1–12):237da90render: the sprite lane hands the screen draw back the way it found it895b9a7particles: an emitter can ride a body's own frame914471fai-hub: a feed session whose last socket left ends on its idle timeout; skin: parent, skinned centroid and a nodes-only rig for retargets3fcccf3sim: the whole world is implicitly editable, and one seam says where the ground is5692fabsim: the landform world proves itself — walker through the tunnel includedf4af6dfsim: terrain knows who changed it — a plan layer over player historyadbb078render: a water volume can be physics without a picturec17480frender: a non-rigid body may carry its own orientationacad401sim: an agent with no route holds and retries instead of walking into the wall22b2bf9sim + chat: the composed world surface takes a map floor; the chat gets plan toolsfaf8112web path: the tessellator's lap timer, the trace span and the fusion cycle timer have no clock on the webd3472ebtsdf: the clock-taking XR helpers are native-only — the browser has no depth camera and no Instant4946c9esim + render: a repaint is not a world edit — colour and glow restyles never rebake the lightmap4317f58sim + render + chat: walk decks as a surface, the filmed body is no obstruction, the brief never asks9791279render: support rigged models and custom materials across viewers3ce2792sim: use deck geometry for collision and sensing c8b79ff Add portable PBR, rig and soft-body authoring support 108d423 Add transactional polygon modeling and editable asset documents 38f4d3b Refine editable modeling and firm yarn character behavior 08a2637 sim: add entity-owned lights and vehicle headlights 00d96a7 render: add clustered lights, local shadows and incremental GI cf916af render: import glTF asset extensions and wire clustered GI c6d2cca model: cut transaction memory and raise capacity limits 41af47a raytrace: add a CPU probe-ray BVH budget example c963d0a libs: the game sim splits into makepad-scene and makepad-soft-body; render, model, fab and the asset importer retarget Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
70 lines
4.5 KiB
Rust
70 lines
4.5 KiB
Rust
use makepad_model::{json::{self, Value}, *};
|
|
fn args(v:&str)->Value {json::parse(v.as_bytes()).unwrap()}
|
|
|
|
#[test]
|
|
fn missing_subdivision_level_reports_the_field_and_allows_an_atomic_retry() {
|
|
let mut engine=Engine::new(Limits::default());
|
|
engine.open("d",None,None).unwrap();
|
|
let head=engine.document("d").unwrap().head();
|
|
let before=engine.document("d").unwrap().to_bytes(None).unwrap();
|
|
let batch=|id,operations|json::obj(vec![("document",json::s("d")),
|
|
("request_id",json::s(id)),("expected",head_json(head)),("operations",operations)]);
|
|
let error=engine.execute("model.apply",&batch("bad",args(r#"[
|
|
{"op":"cube","object":"head","size":[0.88,0.83,0.52]},
|
|
{"op":"subdivide","object":"head"}]"#)),None).unwrap_err().to_string();
|
|
assert!(error.contains("levels") && error.contains("subdivide"),"{error}");
|
|
assert_eq!(engine.document("d").unwrap().to_bytes(None).unwrap(),before);
|
|
engine.execute("model.apply",&batch("corrected",args(r#"[
|
|
{"op":"cube","object":"head","size":[0.88,0.83,0.52]},
|
|
{"op":"subdivide","object":"head","levels":2}]"#)),None).unwrap();
|
|
assert_ne!(engine.document("d").unwrap().head(),head);
|
|
assert!(engine.document("d").unwrap().object("head").is_some());
|
|
}
|
|
|
|
#[test]
|
|
fn overview_reports_complete_transformed_dimensions_without_editing_source() {
|
|
let mut engine=Engine::new(Limits::default());
|
|
assert_eq!(engine.open("d",None,None).unwrap().get("bounds"),Some(&Value::Null));
|
|
apply(&mut engine,"shape",args(r#"[{"op":"cube","object":"body","size":[2,1,4]},{"op":"object_node","object":"body","node":{"transform":{"translation":[3,2,-1]}}}]"#));
|
|
let head=engine.document("d").unwrap().head();
|
|
let overview=engine.open("d",None,None).unwrap();
|
|
assert_eq!(overview.get("bounds").unwrap(),&args("[[2.0,1.5,-3.0],[4.0,2.5,1.0]]"));
|
|
assert_eq!(overview.get("dimensions").unwrap(),&args("[2.0,1.0,4.0]"));
|
|
assert_eq!(engine.document("d").unwrap().head(),head);
|
|
assert!(overview.to_json().len()<12*1024);
|
|
}
|
|
fn apply(engine:&mut Engine,id:&str,ops:Value)->Value {
|
|
engine.execute("model.apply",&json::obj(vec![("document",json::s("d")),("expected",head_json(engine.document("d").unwrap().head())),
|
|
("request_id",json::s(id)),("operations",ops)]),None).unwrap()
|
|
}
|
|
#[test]
|
|
fn primitives_are_closed_outward_and_have_seam_uvs() {
|
|
let mut engine=Engine::new(Limits::default()); engine.open("d",None,None).unwrap();
|
|
apply(&mut engine,"create",args(r#"[{"op":"sphere","object":"ball","radius":1,"segments":12,"rings":6},{"op":"cylinder","object":"barrel","radius":0.5,"height":2,"segments":12}]"#));
|
|
for name in ["ball","barrel"] {
|
|
let mesh=engine.document("d").unwrap().object(name).unwrap();
|
|
assert!(mesh.validate(&mut mesh::Context::default()).unwrap().is_closed_manifold);
|
|
let tri=mesh.triangulate(&mut mesh::Context::default()).unwrap();
|
|
let mut volume=0.0;
|
|
for t in &tri.triangles {
|
|
let [a,b,c]=t.indices.map(|i|tri.vertices[i as usize].position);
|
|
volume+=(a[0]*(b[1]*c[2]-b[2]*c[1])+a[1]*(b[2]*c[0]-b[0]*c[2])+a[2]*(b[0]*c[1]-b[1]*c[0]))/6.0;
|
|
}
|
|
assert!(volume>0.0,"{name} volume {volume}");
|
|
assert!(mesh.corners().iter().any(|c|c.uv[0]==1.0));
|
|
}
|
|
}
|
|
#[test]
|
|
fn paged_corner_lookup_and_exact_id_protocol() {
|
|
let mut engine=Engine::new(Limits::default()); engine.open("d",None,None).unwrap();
|
|
apply(&mut engine,"cube",args(r#"[{"op":"cube","object":"body","size":[1,1,1]}]"#));
|
|
let page=engine.execute("model.inspect",&args(r#"{"document":"d","object":"body","domain":"corners","offset":2,"limit":3}"#),None).unwrap();
|
|
assert_eq!(page.get("items").unwrap().as_arr().unwrap().len(),3); assert_eq!(page.get("next_offset").unwrap().as_u64(),Some(5));
|
|
assert!(parse_operations(&args(r#"[{"op":"extrude","object":"body","face":1,"offset":[0,1,0]}]"#),&Limits::default()).is_err());
|
|
assert!(parse_operations(&args(r#"[{"op":"extrude","object":"body","face":"01","offset":[0,1,0]}]"#),&Limits::default()).is_err());
|
|
assert!(parse_operations(&args(r#"[{"op":"cube","object":"other","size":[1,1,1],"typo":true}]"#),&Limits::default()).is_err());
|
|
let source=engine.document("d").unwrap().to_bytes(None).unwrap();
|
|
assert!(engine.execute("model.apply",&json::obj(vec![("document",json::s("d")),("request_id",json::s("cancel")),
|
|
("expected",head_json(engine.document("d").unwrap().head())),("operations",args(r#"[{"op":"cube","object":"cancelled","size":[1,1,1]}]"#))]),Some(&||true)).is_err());
|
|
assert_eq!(engine.document("d").unwrap().to_bytes(None).unwrap(),source);
|
|
}
|