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>
51 lines
3.9 KiB
Rust
51 lines
3.9 KiB
Rust
use makepad_model::*;
|
|
fn cube() -> Operation { Operation::Cube { object:"body".into(),size:[1.0;3] } }
|
|
fn apply(doc:&mut Document,id:&str,operations:Vec<Operation>)->Applied {
|
|
doc.apply(Transaction { request_id:id.into(),expected:doc.head(),operations },None).unwrap()
|
|
}
|
|
#[test]
|
|
fn transaction_rollback_undo_branch_and_retry() {
|
|
let mut doc=Document::new(Limits::default()).unwrap(); let empty=doc.head();
|
|
let tx=Transaction { request_id:"cube".into(),expected:empty,operations:vec![cube()] };
|
|
let first=doc.apply(tx.clone(),None).unwrap(); let source=doc.to_bytes(None).unwrap();
|
|
assert_eq!(doc.apply(tx.clone(),None).unwrap().committed,first.committed);
|
|
assert!(doc.apply(tx.clone(),None).unwrap().replayed);
|
|
assert_eq!(doc.to_bytes(None).unwrap(),source);
|
|
let failure=Transaction { request_id:"failure".into(),expected:doc.head(),operations:vec![
|
|
Operation::Plane { object:"new".into(),size:[1.0;2] },Operation::DeleteObject { object:"absent".into() }] };
|
|
assert!(doc.apply(failure,None).is_err()); assert_eq!(doc.to_bytes(None).unwrap(),source);
|
|
let undo=doc.undo(doc.head(),None).unwrap(); assert_eq!(undo.content,empty.content); assert!(undo.generation>first.committed.generation);
|
|
let redo=doc.redo(undo,None).unwrap(); assert_eq!(redo.content,first.committed.content);
|
|
doc.undo(redo,None).unwrap(); apply(&mut doc,"branch",vec![Operation::Plane { object:"ground".into(),size:[2.0;2] }]);
|
|
assert!(doc.object("body").is_none()); assert!(doc.redo(doc.head(),None).is_err());
|
|
let old=doc.apply(tx,None).unwrap(); assert!(old.replayed); assert_eq!(old.committed,first.committed); assert_eq!(old.current,doc.head());
|
|
let encoded=doc.to_bytes(None).unwrap(); let reopened=Document::from_bytes(&encoded,Limits::default(),None).unwrap();
|
|
assert_eq!(reopened.to_bytes(None).unwrap(),encoded); assert_eq!(reopened.head(),doc.head());
|
|
}
|
|
#[test]
|
|
fn cancellation_and_conflicting_request_ids_are_atomic() {
|
|
let mut doc=Document::new(Limits::default()).unwrap(); let before=doc.to_bytes(None).unwrap();
|
|
let tx=Transaction { request_id:"same".into(),expected:doc.head(),operations:vec![cube()] };
|
|
assert!(matches!(doc.apply(tx.clone(),Some(&||true)),Err(Error::Mesh(mesh::MeshError::Cancelled))));
|
|
assert_eq!(doc.to_bytes(None).unwrap(),before);
|
|
doc.apply(tx.clone(),None).unwrap();
|
|
let mut changed=tx; changed.operations=vec![Operation::Plane { object:"new".into(),size:[1.0;2] }];
|
|
assert_eq!(doc.apply(changed,None).unwrap_err(),Error::RequestIdReused);
|
|
}
|
|
#[test]
|
|
fn source_roundtrip_preserves_uv_material_and_export() {
|
|
let mut doc=Document::new(Limits::default()).unwrap(); apply(&mut doc,"create",vec![cube()]);
|
|
let corner=doc.object("body").unwrap().corners()[0].id;
|
|
let face=doc.object("body").unwrap().faces()[0].id;
|
|
let png=Texture::solid(2,2,[42,78,123],doc.limits()).unwrap().to_png(doc.limits()).unwrap();
|
|
apply(&mut doc,"paint",vec![Operation::SetMaterial { material:7,value:Material {color:[0.5,1.0,0.25],base_color_png:png.clone()} },
|
|
Operation::AssignMaterial { object:"body".into(),faces:vec![face],material:7 },
|
|
Operation::SetUv { object:"body".into(),corner,uv:[0.25,0.75] }]);
|
|
let compiled=doc.compile(None).unwrap(); assert_eq!(compiled.triangles,12); assert_eq!(compiled.primitives.len(),2);
|
|
let parsed=makepad_gltf::parse_glb_bytes(&compiled.glb).unwrap();
|
|
assert_eq!(parsed.document.meshes.as_ref().unwrap().len(),1);
|
|
let bytes=doc.to_bytes(None).unwrap(); let opened=Document::from_bytes(&bytes,Limits::default(),None).unwrap();
|
|
assert_eq!(opened.materials()[&7].base_color_png,png); assert_eq!(opened.compile(None).unwrap().glb,compiled.glb);
|
|
for n in [0,1,7,12,bytes.len()-1] { assert!(Document::from_bytes(&bytes[..n],Limits::default(),None).is_err()); }
|
|
let mut extra=bytes; extra.push(0); assert!(Document::from_bytes(&extra,Limits::default(),None).is_err());
|
|
}
|