forked from 1b-agent/opencadstudio-upstream
style: apply cargo fmt across workspace (as on main)
Formats the branch the way main's 9cf9ff2 did, so merging main only
conflicts where the code itself differs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013RyGiMXcsf9HTKfqDxaQGt
This commit is contained in:
532 files changed
+56995
-33416
No files matched your search
@@ -16,9 +16,7 @@ use codec::types::{Vector2, Vector3};
|
||||
use codec::{CadDocument, EntityType, Handle};
|
||||
|
||||
use harness::BenchmarkRunner;
|
||||
use OpenCADStudio::modules::draw::modify::explode::{
|
||||
apply_explode_replacements, explode_batch,
|
||||
};
|
||||
use OpenCADStudio::modules::draw::modify::explode::{apply_explode_replacements, explode_batch};
|
||||
use OpenCADStudio::modules::draw::modify::flatten;
|
||||
use OpenCADStudio::scene::Scene;
|
||||
|
||||
@@ -79,10 +77,8 @@ fn push_fixture_entities(doc: &mut CadDocument, quick: bool) -> Vec<Handle> {
|
||||
let mut pl = LwPolyline::new();
|
||||
pl.vertices = (0..VERTS_PER_POLYLINE)
|
||||
.map(|k| {
|
||||
let mut v = LwVertex::new(Vector2::new(
|
||||
base + k as f64 * 2.0,
|
||||
(k % 5) as f64 * 0.75,
|
||||
));
|
||||
let mut v =
|
||||
LwVertex::new(Vector2::new(base + k as f64 * 2.0, (k % 5) as f64 * 0.75));
|
||||
if k % 2 == 1 {
|
||||
v.bulge = 0.5;
|
||||
}
|
||||
@@ -101,13 +97,13 @@ fn push_fixture_entities(doc: &mut CadDocument, quick: bool) -> Vec<Handle> {
|
||||
for i in 0..n_dim {
|
||||
let x = (i % 100) as f64 * 12.0;
|
||||
let y = (i / 100) as f64 * 12.0;
|
||||
let mut d = DimensionLinear::new(
|
||||
Vector3::new(x, y, 0.0),
|
||||
Vector3::new(x + 10.0, y, 0.0),
|
||||
);
|
||||
let mut d = DimensionLinear::new(Vector3::new(x, y, 0.0), Vector3::new(x + 10.0, y, 0.0));
|
||||
d.definition_point = Vector3::new(x + 5.0, y + 3.0, 0.0);
|
||||
d.base.text_middle_point = Vector3::new(x + 5.0, y + 4.0, 0.0);
|
||||
handles.push(doc.add_entity(EntityType::Dimension(Dimension::Linear(d))).unwrap());
|
||||
handles.push(
|
||||
doc.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
for i in 0..n_ml {
|
||||
@@ -121,7 +117,10 @@ fn push_fixture_entities(doc: &mut CadDocument, quick: bool) -> Vec<Handle> {
|
||||
Vector3::new(x + 8.0, y + 8.0, 0.0),
|
||||
Vector3::new(x + 12.0, y + 8.0, 0.0),
|
||||
];
|
||||
handles.push(doc.add_entity(EntityType::MLine(MLine::from_points(&pts))).unwrap());
|
||||
handles.push(
|
||||
doc.add_entity(EntityType::MLine(MLine::from_points(&pts)))
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
handles
|
||||
@@ -274,7 +273,8 @@ fn push_flatten_fixture(doc: &mut CadDocument, quick: bool) -> Vec<Handle> {
|
||||
handles.push(doc.add_entity(EntityType::Line(line)).unwrap());
|
||||
}
|
||||
for i in 0..n_circle {
|
||||
let mut c = Circle::from_center_radius(Vector3::new(i as f64, 0.0, 1.0 + (i % 3) as f64), 2.0);
|
||||
let mut c =
|
||||
Circle::from_center_radius(Vector3::new(i as f64, 0.0, 1.0 + (i % 3) as f64), 2.0);
|
||||
if i % 2 == 1 {
|
||||
c.normal = Vector3::new(0.0, 0.6, 0.8); // tilted → ellipse
|
||||
}
|
||||
@@ -296,7 +296,8 @@ fn push_flatten_fixture(doc: &mut CadDocument, quick: bool) -> Vec<Handle> {
|
||||
let mut pl = Polyline2D::new();
|
||||
pl.elevation = 3.0 + (i % 5) as f64;
|
||||
for k in 0..6 {
|
||||
pl.vertices.push(Vertex2D::new(Vector3::new(k as f64, i as f64, 0.0)));
|
||||
pl.vertices
|
||||
.push(Vertex2D::new(Vector3::new(k as f64, i as f64, 0.0)));
|
||||
}
|
||||
handles.push(doc.add_entity(EntityType::Polyline2D(pl)).unwrap());
|
||||
}
|
||||
@@ -321,7 +322,10 @@ fn push_flatten_fixture(doc: &mut CadDocument, quick: bool) -> Vec<Handle> {
|
||||
handles.push(doc.add_entity(EntityType::Solid(s)).unwrap());
|
||||
}
|
||||
for i in 0..n_ray {
|
||||
let r = Ray::new(Vector3::new(i as f64, 0.0, 5.0), Vector3::new(0.0, 0.0, 1.0));
|
||||
let r = Ray::new(
|
||||
Vector3::new(i as f64, 0.0, 5.0),
|
||||
Vector3::new(0.0, 0.0, 1.0),
|
||||
);
|
||||
handles.push(doc.add_entity(EntityType::Ray(r)).unwrap());
|
||||
}
|
||||
for i in 0..n_flat {
|
||||
|
||||
@@ -59,8 +59,8 @@ use OpenCADStudio::scene::{ChangeKind, Scene};
|
||||
use OpenCADStudio::snap::Snapper;
|
||||
use OpenCADStudio::ui::icons::{self, CHECK};
|
||||
use OpenCADStudio::ui::overlay::{
|
||||
grid_segments, selection_overlay, should_reuse, CrosshairOptions, GridCanvasState,
|
||||
GridKey, GridParams, GridStyle, GripMarker, NavCursor, OstTrackPoint, SelectionVisualOptions,
|
||||
grid_segments, selection_overlay, should_reuse, CrosshairOptions, GridCanvasState, GridKey,
|
||||
GridParams, GridStyle, GripMarker, NavCursor, OstTrackPoint, SelectionVisualOptions,
|
||||
UcsIconParams,
|
||||
};
|
||||
use OpenCADStudio::ui::properties::LinetypeItem;
|
||||
@@ -914,10 +914,26 @@ fn bench_ui_grid_geometry(runner: &mut BenchmarkRunner) {
|
||||
if runner.should_run("ui_grid_geometry_uncached") {
|
||||
for _ in 0..10 {
|
||||
let _ = black_box(grid_segments(
|
||||
view_rot1, eye1, bounds1, step1, step1, major_every, origin1, axes1, limits1,
|
||||
view_rot1,
|
||||
eye1,
|
||||
bounds1,
|
||||
step1,
|
||||
step1,
|
||||
major_every,
|
||||
origin1,
|
||||
axes1,
|
||||
limits1,
|
||||
));
|
||||
let _ = black_box(grid_segments(
|
||||
view_rot2, eye2, bounds2, step2, step2, major_every, origin2, axes2, limits2,
|
||||
view_rot2,
|
||||
eye2,
|
||||
bounds2,
|
||||
step2,
|
||||
step2,
|
||||
major_every,
|
||||
origin2,
|
||||
axes2,
|
||||
limits2,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -928,8 +944,28 @@ fn bench_ui_grid_geometry(runner: &mut BenchmarkRunner) {
|
||||
for _ in 0..runs {
|
||||
let t0 = Instant::now();
|
||||
for _ in 0..n {
|
||||
let g1 = grid_segments(view_rot1, eye1, bounds1, step1, step1, major_every, origin1, axes1, limits1);
|
||||
let g2 = grid_segments(view_rot2, eye2, bounds2, step2, step2, major_every, origin2, axes2, limits2);
|
||||
let g1 = grid_segments(
|
||||
view_rot1,
|
||||
eye1,
|
||||
bounds1,
|
||||
step1,
|
||||
step1,
|
||||
major_every,
|
||||
origin1,
|
||||
axes1,
|
||||
limits1,
|
||||
);
|
||||
let g2 = grid_segments(
|
||||
view_rot2,
|
||||
eye2,
|
||||
bounds2,
|
||||
step2,
|
||||
step2,
|
||||
major_every,
|
||||
origin2,
|
||||
axes2,
|
||||
limits2,
|
||||
);
|
||||
black_box(g1);
|
||||
black_box(g2);
|
||||
}
|
||||
@@ -1302,7 +1338,10 @@ fn bench_ui_grip_budget(runner: &mut BenchmarkRunner) {
|
||||
),
|
||||
"µs",
|
||||
samples,
|
||||
Some(((capped_grips.len() as f64) / (median_us / 1_000_000.0), "grips/s")),
|
||||
Some((
|
||||
(capped_grips.len() as f64) / (median_us / 1_000_000.0),
|
||||
"grips/s",
|
||||
)),
|
||||
Some(500.0), // Target threshold < 500 µs (measured ~132 µs quick / ~147 µs full)
|
||||
);
|
||||
|
||||
@@ -1337,7 +1376,10 @@ fn bench_ui_grip_budget(runner: &mut BenchmarkRunner) {
|
||||
),
|
||||
"µs",
|
||||
build_samples,
|
||||
Some(((n_fixture_grips as f64) / (build_median_us / 1_000_000.0), "grips/s")),
|
||||
Some((
|
||||
(n_fixture_grips as f64) / (build_median_us / 1_000_000.0),
|
||||
"grips/s",
|
||||
)),
|
||||
Some(7_000.0), // Target < 7 ms (selection-change hitch budget; measured ~2.36 ms full / ~0.30 ms quick, ~3x headroom)
|
||||
);
|
||||
}
|
||||
@@ -1386,18 +1428,13 @@ fn bench_ui_constraint_glyphs(runner: &mut BenchmarkRunner) {
|
||||
let vp = (1920.0_f32, 1080.0_f32);
|
||||
|
||||
// Prime the cache so every timed call below is a hit (same key, same Arc).
|
||||
let primed =
|
||||
scene.cached_glyph_placements(ParametricScope::ModelSpace, vp, true, 3, 4095);
|
||||
assert!(
|
||||
!primed.is_empty(),
|
||||
"glyph fixture must yield placements"
|
||||
);
|
||||
let primed = scene.cached_glyph_placements(ParametricScope::ModelSpace, vp, true, 3, 4095);
|
||||
assert!(!primed.is_empty(), "glyph fixture must yield placements");
|
||||
let n_glyphs = primed.len();
|
||||
|
||||
// Warm-up for allocator settling.
|
||||
for _ in 0..10 {
|
||||
let hit =
|
||||
scene.cached_glyph_placements(ParametricScope::ModelSpace, vp, true, 3, 4095);
|
||||
let hit = scene.cached_glyph_placements(ParametricScope::ModelSpace, vp, true, 3, 4095);
|
||||
black_box(hit);
|
||||
}
|
||||
|
||||
@@ -1499,7 +1536,12 @@ fn build_selection_overlay_element(
|
||||
.collect();
|
||||
let ucs_icons = vec![UcsIconParams {
|
||||
view_proj: Mat4::IDENTITY,
|
||||
bounds: Rectangle { x: 0.0, y: 0.0, width: 1920.0, height: 1080.0 },
|
||||
bounds: Rectangle {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
width: 1920.0,
|
||||
height: 1080.0,
|
||||
},
|
||||
axes: (Vec3::X, Vec3::Y, Vec3::Z),
|
||||
origin_screen: None,
|
||||
hover: false,
|
||||
@@ -1516,7 +1558,9 @@ fn build_selection_overlay_element(
|
||||
None,
|
||||
None,
|
||||
ucs_icons,
|
||||
vec![OstTrackPoint { screen: Point::new(500.0, 500.0) }],
|
||||
vec![OstTrackPoint {
|
||||
screen: Point::new(500.0, 500.0),
|
||||
}],
|
||||
vec![(Point::new(0.0, 0.0), Point::new(100.0, 100.0))],
|
||||
None,
|
||||
true,
|
||||
|
||||
Reference in new issue
Block a user