Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -630,10 +630,14 @@ pub(crate) fn cmd_bench_open(args: &[String]) -> Result<(), String> {
|
||||
}
|
||||
let t = std::time::Instant::now();
|
||||
let st = s.world_state();
|
||||
let place_ms = t.elapsed().as_secs_f64() * 1000.0;
|
||||
// As the desktop app prepares a design it opened.
|
||||
st.warm_meshes(|| true);
|
||||
let triangles: usize = st.bodies.iter().map(|b| b.mesh().triangles.len()).sum();
|
||||
println!("{}", json!({"step": "mesh", "ms": t.elapsed().as_secs_f64() * 1000.0, "bodies": st.bodies.len(), "triangles": triangles}));
|
||||
println!(
|
||||
"{}",
|
||||
json!({"step": "mesh", "ms": t.elapsed().as_secs_f64() * 1000.0, "place_ms": place_ms, "bodies": st.bodies.len(), "triangles": triangles})
|
||||
);
|
||||
// `--display LEVEL`: the display plans the viewport draws at that display quality, made as
|
||||
// the GPU viewport makes them; `--edit NAME EXPR` then changes a parameter and times the
|
||||
// evaluation and the plans of the bodies it changed.
|
||||
|
||||
+24
-6
@@ -5765,21 +5765,39 @@ pub fn world_state_reusing(doc: &Document, st: &ModelState, placed_before: &mut
|
||||
path
|
||||
};
|
||||
let mut out = ModelState { body_counter: st.body_counter, ..Default::default() };
|
||||
for (comp, path, m) in doc.placements() {
|
||||
let placements = doc.placements();
|
||||
// A body moved in from another component keeps its place (its offset).
|
||||
let body_matrix = |b: &ModelBody, m: &crate::Mat| doc.model_body_offset(b).map(|o| crate::mat_mul(m, o)).unwrap_or(*m);
|
||||
// Every body placed elsewhere than its definition, placed on all cores: a large assembly
|
||||
// places hundreds of parts, each a B-rep transform.
|
||||
let mut jobs = Vec::new();
|
||||
for (comp, path, m) in &placements {
|
||||
for b in st.bodies.iter().filter(|b| doc.model_body_component(b) == *comp) {
|
||||
let bm = body_matrix(b, m);
|
||||
if !crate::is_identity(&bm) {
|
||||
jobs.push((b, bm, doc.world_body_name(st, &b.name, *comp, path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut moved = kernel::map_on_threads(&jobs, 16, |(b, bm, name)| placed_before.placed(b, bm, name.clone())).into_iter().zip(&jobs);
|
||||
for (comp, path, m) in placements {
|
||||
let primary = path == first_path(comp);
|
||||
let ident = crate::is_identity(&m);
|
||||
for b in st.bodies.iter().filter(|b| doc.model_body_component(b) == comp) {
|
||||
let name = doc.world_body_name(st, &b.name, comp, &path);
|
||||
// A body moved in from another component keeps its place (its offset).
|
||||
let bm = doc.model_body_offset(b).map(|o| crate::mat_mul(&m, o)).unwrap_or(m);
|
||||
let bm = body_matrix(b, &m);
|
||||
// Identical geometry also shares its display mesh cell with the definition.
|
||||
// A changed placement keeps a distinct mesh, at that placement's coordinates.
|
||||
let mut placed = if crate::is_identity(&bm) {
|
||||
let mut placed = b.clone();
|
||||
placed.name = name;
|
||||
placed.name = doc.world_body_name(st, &b.name, comp, &path);
|
||||
placed
|
||||
} else {
|
||||
let placed = placed_before.placed(b, &bm, name);
|
||||
// The same order as the jobs: this body's, made above (again here if it failed).
|
||||
let placed = match moved.next() {
|
||||
Some((Some(placed), _)) => placed,
|
||||
Some((None, (_, _, name))) => placed_before.placed(b, &bm, name.clone()),
|
||||
None => placed_before.placed(b, &bm, doc.world_body_name(st, &b.name, comp, &path)),
|
||||
};
|
||||
placed_now.by_source.insert(placed_key(b, &bm), (b.clone(), placed.clone()));
|
||||
placed
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user