osu: reuse ticks buffer for all sliders
This commit is contained in:
@@ -28,11 +28,11 @@ const NORMALIZED_RADIUS: f32 = 52.0;
|
|||||||
/// This version is considerably more efficient than `all_included` since
|
/// This version is considerably more efficient than `all_included` since
|
||||||
/// processing stack leniency is relatively expensive.
|
/// processing stack leniency is relatively expensive.
|
||||||
pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
||||||
let attributes = map.attributes().mods(mods);
|
let map_attributes = map.attributes().mods(mods);
|
||||||
|
|
||||||
let mut diff_attributes = DifficultyAttributes {
|
let mut diff_attributes = DifficultyAttributes {
|
||||||
ar: attributes.ar,
|
ar: map_attributes.ar,
|
||||||
od: attributes.od,
|
od: map_attributes.od,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,8 +40,8 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
|||||||
return diff_attributes;
|
return diff_attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
let section_len = SECTION_LEN * attributes.clock_rate;
|
let section_len = SECTION_LEN * map_attributes.clock_rate;
|
||||||
let radius = OBJECT_RADIUS * (1.0 - 0.7 * (attributes.cs - 5.0) / 5.0) / 2.0;
|
let radius = OBJECT_RADIUS * (1.0 - 0.7 * (map_attributes.cs - 5.0) / 5.0) / 2.0;
|
||||||
let mut scaling_factor = NORMALIZED_RADIUS / radius;
|
let mut scaling_factor = NORMALIZED_RADIUS / radius;
|
||||||
|
|
||||||
if radius < 30.0 {
|
if radius < 30.0 {
|
||||||
@@ -50,11 +50,18 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut slider_state = SliderState::new(&map);
|
let mut slider_state = SliderState::new(&map);
|
||||||
|
let mut ticks_buf = Vec::new();
|
||||||
|
|
||||||
let mut hit_objects = map
|
let mut hit_objects = map.hit_objects.iter().map(|h| {
|
||||||
.hit_objects
|
OsuObject::new(
|
||||||
.iter()
|
h,
|
||||||
.map(|h| OsuObject::new(h, map, radius, &mut diff_attributes, &mut slider_state));
|
map,
|
||||||
|
radius,
|
||||||
|
&mut ticks_buf,
|
||||||
|
&mut diff_attributes,
|
||||||
|
&mut slider_state,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
let mut aim = Skill::new(SkillKind::Aim);
|
let mut aim = Skill::new(SkillKind::Aim);
|
||||||
let mut speed = Skill::new(SkillKind::Speed);
|
let mut speed = Skill::new(SkillKind::Speed);
|
||||||
@@ -74,7 +81,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
|||||||
&prev,
|
&prev,
|
||||||
prev_vals,
|
prev_vals,
|
||||||
prev_prev,
|
prev_prev,
|
||||||
attributes.clock_rate,
|
map_attributes.clock_rate,
|
||||||
scaling_factor,
|
scaling_factor,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -92,7 +99,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
|||||||
&prev,
|
&prev,
|
||||||
prev_vals,
|
prev_vals,
|
||||||
prev_prev,
|
prev_prev,
|
||||||
attributes.clock_rate,
|
map_attributes.clock_rate,
|
||||||
scaling_factor,
|
scaling_factor,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ impl OsuObject {
|
|||||||
h: &HitObject,
|
h: &HitObject,
|
||||||
map: &Beatmap,
|
map: &Beatmap,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
|
ticks: &mut Vec<f32>,
|
||||||
attributes: &mut DifficultyAttributes,
|
attributes: &mut DifficultyAttributes,
|
||||||
slider_state: &mut SliderState,
|
slider_state: &mut SliderState,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -106,7 +107,7 @@ impl OsuObject {
|
|||||||
let time_add = duration * (tick_distance / (pixel_len * *repeats as f32));
|
let time_add = duration * (tick_distance / (pixel_len * *repeats as f32));
|
||||||
|
|
||||||
let target = pixel_len - tick_distance / 8.0;
|
let target = pixel_len - tick_distance / 8.0;
|
||||||
let mut ticks = Vec::with_capacity((target / tick_distance) as usize);
|
ticks.reserve((target / tick_distance) as usize);
|
||||||
|
|
||||||
// Tick of the first span
|
// Tick of the first span
|
||||||
if current_distance < target {
|
if current_distance < target {
|
||||||
@@ -146,6 +147,8 @@ impl OsuObject {
|
|||||||
.max(final_span_start_time + span_duration - LEGACY_LAST_TICK_OFFSET);
|
.max(final_span_start_time + span_duration - LEGACY_LAST_TICK_OFFSET);
|
||||||
compute_vertex(final_span_end_time);
|
compute_vertex(final_span_end_time);
|
||||||
|
|
||||||
|
ticks.clear();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
time: h.start_time,
|
time: h.start_time,
|
||||||
pos: h.pos,
|
pos: h.pos,
|
||||||
|
|||||||
Reference in New Issue
Block a user