Skip to content

Commit 87c51ae

Browse files
author
sjfhsjfh
committed
fix: adjust offset calculation and limit correlation curve points
1 parent 48846a5 commit 87c51ae

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

prpr/src/scene/game.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -852,13 +852,11 @@ impl GameScene {
852852
let clip = self.res.music.clone();
853853
let pcm: Vec<f32> = clip.frames().iter().map(|f| (f.0 + f.1) / 2.0).collect();
854854
let sample_rate = clip.sample_rate();
855-
let author_offset = self.chart.offset + self.res.config.offset;
856-
857-
// 3. Build config
855+
// 3. Build config — search centered on chart's own offset
858856
let config = AlignConfig {
859857
search_range_sec: 0.30,
860858
sampling_interval_sec: 0.005,
861-
search_center_sec: author_offset as f64,
859+
search_center_sec: self.chart.offset as f64,
862860
};
863861

864862
// 4. Create shared result slot
@@ -909,10 +907,11 @@ impl GameScene {
909907
let v_pad = 0.08;
910908
let inner = Rect::new(rect.x, rect.y + rect.h * v_pad, rect.w, rect.h * (1.0 - 2.0 * v_pad));
911909

912-
// Correlation curve: keep point density roughly constant regardless of rect width
913-
let pt_spacing = rect.w as f64 / 55.0;
914-
let step = ((curve.len() as f64 * pt_spacing) / rect.w as f64).ceil() as usize;
915-
let step = step.max(1);
910+
// Correlation curve — limit path points to stay within geometry budget.
911+
// lyon stroke tessellation generates 30-60 vertices per segment; with
912+
// other UI elements, ~70 path points keeps total well under the drawcall cap.
913+
let max_pts = 70usize;
914+
let step = ((curve.len() as f64) / (max_pts as f64)).ceil() as usize;
916915
let mut path_builder = lyon::path::Path::builder();
917916
let mut first = true;
918917
for i in (0..curve.len()).step_by(step) {
@@ -968,7 +967,6 @@ impl GameScene {
968967
mb.end(false);
969968
ui.stroke_path(&mb.build(), marker_line_w, Color::new(0.0, 0.5, 1.0, 0.5));
970969
}
971-
972970
}
973971

974972
fn tweak_offset(&mut self, ui: &mut Ui, ita: bool) {
@@ -1041,8 +1039,7 @@ impl GameScene {
10411039
let o_range = (max_o - min_o).max(1e-6);
10421040
let content_width = width * GRAPH_CONTENT_RATIO;
10431041
let green_x = ((result.offset - min_o) / o_range) as f32 * content_width;
1044-
self.scroll.x_scroller.offset =
1045-
(green_x - width / 2.0).clamp(0.0, content_width - width);
1042+
self.scroll.x_scroller.offset = (green_x - width / 2.0).clamp(0.0, content_width - width);
10461043
self.scroll_centered = true;
10471044
}
10481045
ui.dy(graph_rect.h);

0 commit comments

Comments
 (0)