use osu's bezier approximation

This commit is contained in:
MaxOhn
2021-11-04 21:37:54 +01:00
parent 3f8d023e71
commit 8cb14d88ba
11 changed files with 298 additions and 54 deletions
+1 -1
View File
@@ -346,7 +346,7 @@ impl OsuPPInner {
PerformanceAttributes {
attributes: self.attributes,
pp_acc: aim_value,
pp_acc: acc_value,
pp_aim: aim_value,
pp_flashlight: flashlight_value,
pp_speed: speed_value,
+24
View File
@@ -337,3 +337,27 @@ pub fn strains(map: &Beatmap, mods: impl Mods) -> Strains {
strains,
}
}
#[test]
fn custom_osu() {
let file = std::fs::File::open("E:Games/osu!/beatmaps/2753127_.osu").unwrap();
// let file = std::fs::File::open("E:Games/osu!/beatmaps/2571051.osu").unwrap();
let map = Beatmap::parse(file).unwrap();
let start = std::time::Instant::now();
let result = crate::OsuPP::new(&map).mods(0).calculate();
let iters = 500;
let accum = start.elapsed();
// let mut accum = accum;
// for _ in 0..iters {
// let start = std::time::Instant::now();
// let _result = crate::OsuPP::new(&map).mods(0).calculate();
// accum += start.elapsed();
// }
println!("{:#?}", result);
println!("Average: {:?}", accum / iters);
}
+2 -1
View File
@@ -70,7 +70,7 @@ impl OsuObject {
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(curve_points, *path_type, *pixel_len);
// Called on each slider object except for the head.
// Increases combo and adjusts `end_pos` and `travel_dist`
@@ -95,6 +95,7 @@ impl OsuObject {
if dist > approx_follow_circle_radius {
dist -= approx_follow_circle_radius;
lazy_end_pos += diff.normalize() * dist;
travel_dist += dist;
}
};
+1 -1
View File
@@ -70,7 +70,7 @@ impl Skill {
self.strain_peaks
.sort_unstable_by(|a, b| b.partial_cmp(a).unwrap_or(Ordering::Equal));
for &strain in &self.strain_peaks {
for &strain in self.strain_peaks.iter() {
difficulty += strain * weight;
weight *= decay_weight;
}
+3 -3
View File
@@ -159,9 +159,9 @@ impl SkillKind {
let mut small_dist_nerf = 1.0;
let mut result = 0.0;
let mut cumulative_strain_time = 0.0;
let mut history = history.iter();
let mut history_iter = history.iter();
if let Some(prev) = history.next() {
if let Some(prev) = history_iter.next() {
// Handle first entry distinctly for slight optimization
if !prev.is_spinner {
let jump_dist = (curr.base.pos - prev.end_pos).length();
@@ -180,7 +180,7 @@ impl SkillKind {
let factors = iter::successors(Some(0.8), |s| Some(s * 0.8));
for (factor, prev) in factors.zip(history) {
for (factor, prev) in factors.zip(history_iter) {
if !prev.is_spinner {
let jump_dist = (curr.base.pos - prev.end_pos).length();
cumulative_strain_time += prev.strain_time;