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
|
||||
/// processing stack leniency is relatively expensive.
|
||||
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 {
|
||||
ar: attributes.ar,
|
||||
od: attributes.od,
|
||||
ar: map_attributes.ar,
|
||||
od: map_attributes.od,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -40,8 +40,8 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
||||
return diff_attributes;
|
||||
}
|
||||
|
||||
let section_len = SECTION_LEN * attributes.clock_rate;
|
||||
let radius = OBJECT_RADIUS * (1.0 - 0.7 * (attributes.cs - 5.0) / 5.0) / 2.0;
|
||||
let section_len = SECTION_LEN * map_attributes.clock_rate;
|
||||
let radius = OBJECT_RADIUS * (1.0 - 0.7 * (map_attributes.cs - 5.0) / 5.0) / 2.0;
|
||||
let mut scaling_factor = NORMALIZED_RADIUS / radius;
|
||||
|
||||
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 ticks_buf = Vec::new();
|
||||
|
||||
let mut hit_objects = map
|
||||
.hit_objects
|
||||
.iter()
|
||||
.map(|h| OsuObject::new(h, map, radius, &mut diff_attributes, &mut slider_state));
|
||||
let mut hit_objects = map.hit_objects.iter().map(|h| {
|
||||
OsuObject::new(
|
||||
h,
|
||||
map,
|
||||
radius,
|
||||
&mut ticks_buf,
|
||||
&mut diff_attributes,
|
||||
&mut slider_state,
|
||||
)
|
||||
});
|
||||
|
||||
let mut aim = Skill::new(SkillKind::Aim);
|
||||
let mut speed = Skill::new(SkillKind::Speed);
|
||||
@@ -74,7 +81,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
||||
&prev,
|
||||
prev_vals,
|
||||
prev_prev,
|
||||
attributes.clock_rate,
|
||||
map_attributes.clock_rate,
|
||||
scaling_factor,
|
||||
);
|
||||
|
||||
@@ -92,7 +99,7 @@ pub fn stars(map: &Beatmap, mods: impl Mods) -> DifficultyAttributes {
|
||||
&prev,
|
||||
prev_vals,
|
||||
prev_prev,
|
||||
attributes.clock_rate,
|
||||
map_attributes.clock_rate,
|
||||
scaling_factor,
|
||||
);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ impl OsuObject {
|
||||
h: &HitObject,
|
||||
map: &Beatmap,
|
||||
radius: f32,
|
||||
ticks: &mut Vec<f32>,
|
||||
attributes: &mut DifficultyAttributes,
|
||||
slider_state: &mut SliderState,
|
||||
) -> Self {
|
||||
@@ -106,7 +107,7 @@ impl OsuObject {
|
||||
let time_add = duration * (tick_distance / (pixel_len * *repeats as f32));
|
||||
|
||||
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
|
||||
if current_distance < target {
|
||||
@@ -146,6 +147,8 @@ impl OsuObject {
|
||||
.max(final_span_start_time + span_duration - LEGACY_LAST_TICK_OFFSET);
|
||||
compute_vertex(final_span_end_time);
|
||||
|
||||
ticks.clear();
|
||||
|
||||
Self {
|
||||
time: h.start_time,
|
||||
pos: h.pos,
|
||||
|
||||
Reference in New Issue
Block a user