From 4719a1e7a4274a469c191f1d0b81a863fd8fed13 Mon Sep 17 00:00:00 2001 From: nofyso <1052470899@qq.com> Date: Thu, 6 Aug 2026 23:58:41 +0800 Subject: [PATCH 1/2] fix: fix wrong line_y calc --- src/lib.rs | 1 + src/states_initializing.rs | 21 ++++++++++++++++++++- src/states_lines.rs | 19 +++++++++++-------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e532fef..5700cb1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,6 +53,7 @@ pub use states_initializing::clear_states; pub use states_initializing::init_line_states; pub use states_initializing::init_line_states_from_json; pub use states_initializing::init_world_rect; +pub use states_initializing::recalculate_floor_position; pub use states_input::clear_touch; pub use states_input::set_touch_down; diff --git a/src/states_initializing.rs b/src/states_initializing.rs index 73284e9..d10c972 100644 --- a/src/states_initializing.rs +++ b/src/states_initializing.rs @@ -3,11 +3,12 @@ use std::{collections::HashSet, default::Default}; use crate::{ CHART_STATISTICS, FLATTEN_NOTE_INDEX, HIT_EFFECT_POOL, LINE_STATES, SOUND_POOL, SPLASH_EFFECT_POOL, TOUCH_STATES, WORLD_RECT, - chart::{self, ChartRaw, JudgeLine, WithTimeRange}, + chart::{self, ChartRaw, Event1, JudgeLine, WithTimeRange}, input::TouchInfo, math::Rect, states::{LineData, LineState, Metadata, NoteState, get_seconds_per_tick}, states_effect::{HitEffect, SoundEffect, SplashEffect}, + states_lines::get_line_y_direct, states_statistics::{self, ChartStatistics}, }; @@ -94,6 +95,24 @@ pub fn init_line_states(chart_raw: chart::ChartRaw) -> Metadata { metadata } +/// Ignore present value, then re calculate [`floor_position`] +pub fn recalculate_floor_position() { + fn process_half(states: &mut [NoteState], bpm: f64, speed_event: &[Event1]) { + for note_state in states { + let note = &mut note_state.note; + let line_y = get_line_y_direct(note.time.into(), bpm, speed_event); + note.floor_position = line_y; + } + } + LINE_STATES.with_borrow_mut(|state| { + for line in state { + let bpm = line.bpm; + process_half(&mut line.notes_below_state, bpm, &line.speed_events); + process_half(&mut line.notes_above_state, bpm, &line.speed_events); + } + }); +} + /// Initialize world rect from width and height pub fn init_world_rect(width: f64, height: f64) { WORLD_RECT.with_borrow_mut(|world_height| { diff --git a/src/states_lines.rs b/src/states_lines.rs index 80b178d..71c6134 100644 --- a/src/states_lines.rs +++ b/src/states_lines.rs @@ -1,6 +1,6 @@ use crate::{ LINE_STATES, - chart::{self, TimeState, WithTimeRange, WithValue}, + chart::{self, Event1, TimeState, WithTimeRange, WithValue}, math::{self, Rect}, states::LineData, }; @@ -14,22 +14,25 @@ pub fn tick_lines(time_in_second: f64, world_rect: &Rect) { } fn get_line_y(tick_time: f64, line: &LineData) -> f64 { + get_line_y_direct(tick_time, line.bpm, &line.speed_events) +} + +pub fn get_line_y_direct(tick_time: f64, bpm: f64, speed_events: &[Event1]) -> f64 { let mut t = 0.0; - let seconds_per_tick = 60.0 / line.bpm / 32.0; - let speed_events = &line.speed_events; + let seconds_per_tick = 60.0 / bpm / 32.0; for event in speed_events { - if event.end_time > tick_time && event.start_time > tick_time { - break; - } - if event.start_time < tick_time && tick_time < event.end_time { + if event.start_time <= tick_time && tick_time <= event.end_time { let duration = event.end_time - event.start_time; let percent = (tick_time - event.start_time) / duration; t = (duration * percent).mul_add(event.value, t); break; } - if event.end_time < tick_time { + if event.end_time <= tick_time { t = (event.end_time - event.start_time).mul_add(event.value, t); } + if event.end_time > tick_time && event.start_time > tick_time { + break; + } } t * seconds_per_tick } From 63fa3de122f5f83e9d60b60951cd0ad525107e11 Mon Sep 17 00:00:00 2001 From: nofyso <1052470899@qq.com> Date: Thu, 6 Aug 2026 23:59:02 +0800 Subject: [PATCH 2/2] fix: change version code --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb045a2..9b33e94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "phasetida-core" -version = "0.1.17" +version = "0.1.18" dependencies = [ "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 9f73e35..d89602f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "phasetida-core" -version = "0.1.17" +version = "0.1.18" edition = "2024" [lib]