makepad/libs/model/tests/review_geometry.rs
Admin d2130e6550 libs: model, mesh_edit, csg, scene, sim, render, xr
Squash of 25 work commits (Sep 1–12):
  237da90  render: the sprite lane hands the screen draw back the way it found it
  895b9a7  particles: an emitter can ride a body's own frame
  914471f  ai-hub: a feed session whose last socket left ends on its idle timeout; skin: parent, skinned centroid and a nodes-only rig for retargets
  3fcccf3  sim: the whole world is implicitly editable, and one seam says where the ground is
  5692fab  sim: the landform world proves itself — walker through the tunnel included
  f4af6df  sim: terrain knows who changed it — a plan layer over player history
  adbb078  render: a water volume can be physics without a picture
  c17480f  render: a non-rigid body may carry its own orientation
  acad401  sim: an agent with no route holds and retries instead of walking into the wall
  22b2bf9  sim + chat: the composed world surface takes a map floor; the chat gets plan tools
  faf8112  web path: the tessellator's lap timer, the trace span and the fusion cycle timer have no clock on the web
  d3472eb  tsdf: the clock-taking XR helpers are native-only — the browser has no depth camera and no Instant
  4946c9e  sim + render: a repaint is not a world edit — colour and glow restyles never rebake the lightmap
  4317f58  sim + render + chat: walk decks as a surface, the filmed body is no obstruction, the brief never asks
  9791279  render: support rigged models and custom materials across viewers
  3ce2792  sim: 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>
2026-09-15 13:40:31 +02:00

30 lines
2.9 KiB
Rust

use makepad_model::*;
fn apply(doc:&mut Document,id:&str,ops:Vec<Operation>){doc.apply(Transaction{request_id:id.into(),expected:doc.head(),operations:ops},None).unwrap();}
fn parsed(doc:&Document,json:&str)->Vec<Operation>{parse_operations(&json::parse_depth(json.as_bytes(),24).unwrap(),doc.limits()).unwrap()}
fn node(object:&str,translation:[f64;3],scale:[f64;3])->Operation{Operation::Scene(SceneOperation::Node{object:object.into(),node:SceneNode{transform:Transform{translation,scale,..Default::default()},..Default::default()}})}
fn bake(doc:&mut Document,object:&str,matrix:transform::Matrix4){let vertices=doc.object(object).unwrap().vertices().iter().map(|v|v.id).collect();apply(doc,&format!("bake-{object}"),vec![Operation::Transform{object:object.into(),vertices,matrix}]);}
#[test]
fn boolean_and_remesh_node_frames_match_baked_sources(){
for command in [r#"[{"op":"boolean","object":"result","a":"a","b":"b","mode":"union"}]"#,r#"[{"op":"voxel_remesh","object":"result","source":"a","resolution":8}]"#]{
let mut placed=Document::new(Limits::default()).unwrap();let mut baked=Document::new(Limits::default()).unwrap();
for doc in [&mut placed,&mut baked]{apply(doc,"meshes",vec![Operation::Cube{object:"a".into(),size:[1.;3]},Operation::Cube{object:"b".into(),size:[1.;3]}]);}
apply(&mut placed,"place",vec![node("a",[4.,2.,-3.],[1.,2.,1.]),node("b",[7.,2.,-3.],[1.;3])]);
for object in ["a","b"]{bake(&mut baked,object,placed.scene().world_matrix(object).unwrap());}
let source_a=placed.object("a").unwrap().clone();
let ops=parsed(&placed,command);apply(&mut placed,"derive",ops);let ops=parsed(&baked,command);apply(&mut baked,"derive",ops);
assert_eq!(placed.object("result"),baked.object("result"));assert_eq!(placed.object("a"),Some(&source_a));
assert_eq!(placed.scene().world_matrix("result").unwrap(),transform::IDENTITY_MATRIX);
assert!(placed.object("result").unwrap().vertices().iter().all(|v|v.position[0]>3.));
}
}
#[test]
fn direct_shrinkwrap_maps_reference_into_transformed_owner_frame(){
let mut doc=Document::new(Limits::default()).unwrap();
apply(&mut doc,"meshes",vec![Operation::Plane{object:"owner".into(),size:[1.;2]},Operation::Plane{object:"reference".into(),size:[4.;2]},node("owner",[3.,4.,0.],[2.,1.,2.]),node("reference",[3.,2.,0.],[1.;3])]);
let ids=doc.object("owner").unwrap().vertices().iter().map(|v|format!("\"{}\"",v.id.0)).collect::<Vec<_>>().join(",");
let command=format!(r#"[{{"op":"shrinkwrap","object":"owner","vertices":[{ids}],"reference":"reference","max_distance":3,"offset":0}}]"#);
let ops=parsed(&doc,&command);apply(&mut doc,"wrap",ops);
assert!(doc.object("owner").unwrap().vertices().iter().all(|v|(v.position[1]+2.).abs()<1e-12));
assert_eq!(doc.scene().world_matrix("owner").unwrap()[1][3],4.);
let bytes=doc.to_bytes(None).unwrap();assert_eq!(Document::from_bytes(&bytes,Limits::default(),None).unwrap().head(),doc.head());
}