applied recent changes to all mode feature combinations
This commit is contained in:
@@ -6,8 +6,10 @@
|
||||
|
||||
use std::mem;
|
||||
|
||||
use self::osu_object::ObjectParameters;
|
||||
|
||||
use super::super::DifficultyAttributes;
|
||||
use crate::parse::Pos2;
|
||||
use crate::{curve::CurveBuffers, parse::Pos2};
|
||||
|
||||
mod difficulty_object;
|
||||
mod osu_object;
|
||||
@@ -79,21 +81,21 @@ pub fn stars(
|
||||
scaling_factor *= 1.0 + small_circle_bonus;
|
||||
}
|
||||
|
||||
let mut slider_state = SliderState::new(map);
|
||||
let mut ticks_buf = Vec::new();
|
||||
let mut params = ObjectParameters {
|
||||
map,
|
||||
radius,
|
||||
scaling_factor,
|
||||
attributes: &mut diff_attributes,
|
||||
slider_state: SliderState::new(map),
|
||||
ticks: Vec::new(),
|
||||
curve_bufs: CurveBuffers::default(),
|
||||
};
|
||||
|
||||
let hit_objects_iter = map.hit_objects.iter().take(take).filter_map(|h| {
|
||||
OsuObject::new(
|
||||
h,
|
||||
map,
|
||||
radius,
|
||||
scaling_factor,
|
||||
hr,
|
||||
&mut ticks_buf,
|
||||
&mut diff_attributes,
|
||||
&mut slider_state,
|
||||
)
|
||||
});
|
||||
let hit_objects_iter = map
|
||||
.hit_objects
|
||||
.iter()
|
||||
.take(take)
|
||||
.filter_map(|h| OsuObject::new(h, hr, &mut params));
|
||||
|
||||
let mut hit_objects = Vec::with_capacity(take);
|
||||
hit_objects.extend(hit_objects_iter);
|
||||
@@ -277,21 +279,20 @@ pub fn strains(map: &Beatmap, mods: impl Mods) -> Strains {
|
||||
scaling_factor *= 1.0 + small_circle_bonus;
|
||||
}
|
||||
|
||||
let mut slider_state = SliderState::new(map);
|
||||
let mut ticks_buf = Vec::new();
|
||||
let mut params = ObjectParameters {
|
||||
map,
|
||||
radius,
|
||||
scaling_factor,
|
||||
attributes: &mut diff_attributes,
|
||||
slider_state: SliderState::new(map),
|
||||
ticks: Vec::new(),
|
||||
curve_bufs: CurveBuffers::default(),
|
||||
};
|
||||
|
||||
let hit_objects_iter = map.hit_objects.iter().filter_map(|h| {
|
||||
OsuObject::new(
|
||||
h,
|
||||
map,
|
||||
radius,
|
||||
scaling_factor,
|
||||
hr,
|
||||
&mut ticks_buf,
|
||||
&mut diff_attributes,
|
||||
&mut slider_state,
|
||||
)
|
||||
});
|
||||
let hit_objects_iter = map
|
||||
.hit_objects
|
||||
.iter()
|
||||
.filter_map(|h| OsuObject::new(h, hr, &mut params));
|
||||
|
||||
let mut hit_objects = Vec::with_capacity(map.hit_objects.len());
|
||||
hit_objects.extend(hit_objects_iter);
|
||||
|
||||
@@ -2,12 +2,13 @@ use super::super::super::DifficultyAttributes;
|
||||
use super::slider_state::SliderState;
|
||||
|
||||
use crate::{
|
||||
curve::Curve,
|
||||
curve::{Curve, CurveBuffers},
|
||||
parse::{HitObject, HitObjectKind, Pos2},
|
||||
Beatmap,
|
||||
};
|
||||
|
||||
const LEGACY_LAST_TICK_OFFSET: f32 = 36.0;
|
||||
const BASE_SCORING_DISTANCE: f32 = 100.0;
|
||||
|
||||
pub(crate) struct OsuObject {
|
||||
pub(crate) time: f32,
|
||||
@@ -29,18 +30,29 @@ enum OsuObjectKind {
|
||||
},
|
||||
}
|
||||
|
||||
pub(crate) struct ObjectParameters<'a> {
|
||||
pub(crate) map: &'a Beatmap,
|
||||
pub(crate) radius: f32,
|
||||
pub(crate) scaling_factor: f32,
|
||||
pub(crate) attributes: &'a mut DifficultyAttributes,
|
||||
pub(crate) ticks: Vec<f32>,
|
||||
pub(crate) slider_state: SliderState<'a>,
|
||||
pub(crate) curve_bufs: CurveBuffers,
|
||||
}
|
||||
|
||||
impl OsuObject {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn new(
|
||||
h: &HitObject,
|
||||
map: &Beatmap,
|
||||
radius: f32,
|
||||
scaling_factor: f32,
|
||||
hr: bool,
|
||||
ticks: &mut Vec<f32>,
|
||||
attributes: &mut DifficultyAttributes,
|
||||
slider_state: &mut SliderState,
|
||||
) -> Option<Self> {
|
||||
pub(crate) fn new(h: &HitObject, hr: bool, params: &mut ObjectParameters) -> Option<Self> {
|
||||
let ObjectParameters {
|
||||
map,
|
||||
radius,
|
||||
scaling_factor,
|
||||
attributes,
|
||||
ticks,
|
||||
slider_state,
|
||||
curve_bufs,
|
||||
} = params;
|
||||
|
||||
attributes.max_combo += 1; // hitcircle, slider head, or spinner
|
||||
let mut pos = h.pos;
|
||||
|
||||
@@ -58,8 +70,7 @@ impl OsuObject {
|
||||
HitObjectKind::Slider {
|
||||
pixel_len,
|
||||
repeats,
|
||||
curve_points,
|
||||
path_type,
|
||||
control_points,
|
||||
} => {
|
||||
// Key values which are computed here
|
||||
let mut lazy_end_pos = pos;
|
||||
@@ -68,21 +79,26 @@ impl OsuObject {
|
||||
// Responsible for timing point values
|
||||
slider_state.update(h.start_time);
|
||||
|
||||
let approx_follow_circle_radius = radius * 3.0;
|
||||
let mut tick_distance = 100.0 * map.sv / map.tick_rate;
|
||||
let span_count = (*repeats + 1) as f32;
|
||||
|
||||
let approx_follow_circle_radius = *radius * 3.0;
|
||||
let mut tick_dist = 100.0 * map.slider_mult / map.tick_rate;
|
||||
|
||||
if map.version >= 8 {
|
||||
tick_distance /=
|
||||
(100.0 / slider_state.speed_mult).max(10.0).min(1000.0) / 100.0;
|
||||
tick_dist /=
|
||||
(100.0 / slider_state.slider_velocity).max(10.0).min(1000.0) / 100.0;
|
||||
}
|
||||
|
||||
let duration = *repeats as f32 * slider_state.beat_len * pixel_len
|
||||
/ (map.sv * slider_state.speed_mult)
|
||||
/ 100.0;
|
||||
let span_duration = duration / *repeats as f32;
|
||||
|
||||
// Build the curve w.r.t. the curve points
|
||||
let curve = Curve::new(curve_points, *path_type);
|
||||
let curve = Curve::new(control_points, *pixel_len, curve_bufs);
|
||||
|
||||
let velocity =
|
||||
(BASE_SCORING_DISTANCE * map.slider_mult * slider_state.slider_velocity)
|
||||
/ slider_state.beat_len;
|
||||
|
||||
let end_time = h.start_time + span_count * curve.dist() / velocity;
|
||||
let duration = end_time - h.start_time;
|
||||
let span_duration = duration / span_count;
|
||||
|
||||
// Called on each slider object except for the head.
|
||||
// Increases combo and adjusts `end_pos` and `travel_dist`
|
||||
@@ -98,8 +114,8 @@ impl OsuObject {
|
||||
progress %= 1.0;
|
||||
}
|
||||
|
||||
let curr_dist = pixel_len * progress;
|
||||
let mut curr_pos = curve.point_at_distance(curr_dist);
|
||||
// TODO: Correct addition?
|
||||
let mut curr_pos = h.pos + curve.position_at(progress);
|
||||
|
||||
if hr {
|
||||
curr_pos.y = 384.0 - curr_pos.y;
|
||||
@@ -109,17 +125,18 @@ impl OsuObject {
|
||||
let mut dist = diff.length();
|
||||
|
||||
if dist > approx_follow_circle_radius {
|
||||
// * The cursor would be outside the follow circle, we need to move it
|
||||
dist -= approx_follow_circle_radius;
|
||||
lazy_end_pos += diff.normalize() * dist;
|
||||
travel_dist += dist;
|
||||
}
|
||||
};
|
||||
|
||||
let mut current_distance = tick_distance;
|
||||
let time_add = duration * (tick_distance / (pixel_len * *repeats as f32));
|
||||
let mut current_distance = tick_dist;
|
||||
let time_add = duration * (tick_dist / (pixel_len * span_count));
|
||||
|
||||
let target = pixel_len - tick_distance / 8.0;
|
||||
ticks.reserve((target / tick_distance) as usize);
|
||||
let target = pixel_len - tick_dist / 8.0;
|
||||
ticks.reserve((target / tick_dist) as usize);
|
||||
|
||||
// Tick of the first span
|
||||
if current_distance < target {
|
||||
@@ -127,7 +144,7 @@ impl OsuObject {
|
||||
let time = h.start_time + time_add * tick_idx as f32;
|
||||
compute_vertex(time);
|
||||
ticks.push(time);
|
||||
current_distance += tick_distance;
|
||||
current_distance += tick_dist;
|
||||
|
||||
if current_distance >= target {
|
||||
break;
|
||||
@@ -161,9 +178,10 @@ impl OsuObject {
|
||||
|
||||
ticks.clear();
|
||||
|
||||
travel_dist *= scaling_factor;
|
||||
|
||||
let mut end_pos = curve.point_at_distance(*pixel_len);
|
||||
// TODO: what if reversing odd amount?
|
||||
// TODO: Correct addition?
|
||||
let mut end_pos = h.pos + curve.position_at(1.0);
|
||||
travel_dist *= *scaling_factor;
|
||||
|
||||
if hr {
|
||||
end_pos.y = 384.0 - end_pos.y;
|
||||
|
||||
@@ -4,7 +4,7 @@ pub(crate) struct SliderState<'p> {
|
||||
control_points: ControlPointIter<'p>,
|
||||
next: Option<ControlPoint>,
|
||||
pub(crate) beat_len: f32,
|
||||
pub(crate) speed_mult: f32,
|
||||
pub(crate) slider_velocity: f32,
|
||||
}
|
||||
|
||||
impl<'p> SliderState<'p> {
|
||||
@@ -12,9 +12,11 @@ impl<'p> SliderState<'p> {
|
||||
pub(crate) fn new(map: &'p Beatmap) -> Self {
|
||||
let mut control_points = ControlPointIter::new(map);
|
||||
|
||||
let (beat_len, speed_mult) = match control_points.next() {
|
||||
let (beat_len, slider_velocity) = match control_points.next() {
|
||||
Some(ControlPoint::Timing { beat_len, .. }) => (beat_len, 1.0),
|
||||
Some(ControlPoint::Difficulty { speed_mult, .. }) => (1000.0, speed_mult),
|
||||
Some(ControlPoint::Difficulty {
|
||||
slider_velocity, ..
|
||||
}) => (1000.0, slider_velocity),
|
||||
None => (1000.0, 1.0),
|
||||
};
|
||||
|
||||
@@ -22,7 +24,7 @@ impl<'p> SliderState<'p> {
|
||||
next: control_points.next(),
|
||||
control_points,
|
||||
beat_len,
|
||||
speed_mult,
|
||||
slider_velocity,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +34,11 @@ impl<'p> SliderState<'p> {
|
||||
match next {
|
||||
ControlPoint::Timing { beat_len, .. } => {
|
||||
self.beat_len = *beat_len;
|
||||
self.speed_mult = 1.0;
|
||||
self.slider_velocity = 1.0;
|
||||
}
|
||||
ControlPoint::Difficulty { speed_mult, .. } => self.speed_mult = *speed_mult,
|
||||
ControlPoint::Difficulty {
|
||||
slider_velocity, ..
|
||||
} => self.slider_velocity = *slider_velocity,
|
||||
}
|
||||
|
||||
self.next = self.control_points.next();
|
||||
@@ -88,10 +92,10 @@ mod test {
|
||||
|
||||
state.update(3.0);
|
||||
assert_eq!(state.beat_len, 20.0);
|
||||
assert_eq!(state.speed_mult, 1.0);
|
||||
assert_eq!(state.slider_velocity, 1.0);
|
||||
|
||||
state.update(5.0);
|
||||
assert_eq!(state.beat_len, 30.0);
|
||||
assert_eq!(state.speed_mult, 45.0);
|
||||
assert_eq!(state.slider_velocity, 45.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,9 @@ impl OsuObject {
|
||||
|
||||
ticks.clear();
|
||||
|
||||
let end_pos = curve.position_at(1.0); // TODO: what if reversing odd amount?
|
||||
// TODO: what if reversing odd amount?
|
||||
// TODO: + h.pos?
|
||||
let end_pos = curve.position_at(1.0);
|
||||
travel_dist *= *scaling_factor;
|
||||
|
||||
Self {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::f32::NEG_INFINITY;
|
||||
|
||||
use crate::{Beatmap, ControlPoint, ControlPointIter};
|
||||
|
||||
pub(crate) struct SliderState<'p> {
|
||||
@@ -12,7 +14,7 @@ impl<'p> SliderState<'p> {
|
||||
pub(crate) fn new(map: &'p Beatmap) -> Self {
|
||||
Self {
|
||||
control_points: ControlPointIter::new(map),
|
||||
next_time: std::f32::NEG_INFINITY,
|
||||
next_time: NEG_INFINITY,
|
||||
px_per_beat: 1.0,
|
||||
prev_sv: 1.0,
|
||||
}
|
||||
@@ -26,16 +28,19 @@ impl<'p> SliderState<'p> {
|
||||
map: &Beatmap,
|
||||
) -> usize {
|
||||
while time >= self.next_time {
|
||||
self.px_per_beat = map.sv * 100.0 * self.prev_sv;
|
||||
self.px_per_beat = map.slider_mult * 100.0 * self.prev_sv;
|
||||
|
||||
match self.control_points.next() {
|
||||
Some(ControlPoint::Timing { time, .. }) => {
|
||||
self.next_time = time;
|
||||
self.prev_sv = 1.0;
|
||||
}
|
||||
Some(ControlPoint::Difficulty { time, speed_mult }) => {
|
||||
Some(ControlPoint::Difficulty {
|
||||
time,
|
||||
slider_velocity,
|
||||
}) => {
|
||||
self.next_time = time;
|
||||
self.prev_sv = speed_mult;
|
||||
self.prev_sv = slider_velocity;
|
||||
}
|
||||
None => break,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user