various minor adjustments
This commit is contained in:
@@ -65,6 +65,7 @@ impl Debug for OsuGradualDifficultyAttributes {
|
||||
.field("attrs", &self.attrs)
|
||||
.field("diff_objects", &self.diff_objects)
|
||||
.field("skills", &"<cannot be displayed>")
|
||||
.field("hit_window", &self.hit_window)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
@@ -107,13 +108,11 @@ impl OsuGradualDifficultyAttributes {
|
||||
curve_bufs: CurveBuffers::default(),
|
||||
};
|
||||
|
||||
let hit_objects_iter = map
|
||||
let mut hit_objects: Vec<_> = map
|
||||
.hit_objects
|
||||
.iter()
|
||||
.filter_map(|h| OsuObject::new(h, &mut params));
|
||||
|
||||
let mut hit_objects = Vec::with_capacity(map.hit_objects.len());
|
||||
hit_objects.extend(hit_objects_iter);
|
||||
.map(|h| OsuObject::new(h, &mut params))
|
||||
.collect();
|
||||
|
||||
attrs.n_circles = 0;
|
||||
attrs.n_sliders = 0;
|
||||
|
||||
+3
-5
@@ -274,14 +274,12 @@ fn calculate_skills(params: OsuStars<'_>) -> ([Box<dyn Skill>; 4], OsuDifficulty
|
||||
curve_bufs: CurveBuffers::default(),
|
||||
};
|
||||
|
||||
let hit_objects_iter = map
|
||||
let mut hit_objects: Vec<_> = map
|
||||
.hit_objects
|
||||
.iter()
|
||||
.take(take)
|
||||
.filter_map(|h| OsuObject::new(h, &mut params));
|
||||
|
||||
let mut hit_objects = Vec::with_capacity(take.min(map.hit_objects.len()));
|
||||
hit_objects.extend(hit_objects_iter);
|
||||
.map(|h| OsuObject::new(h, &mut params))
|
||||
.collect();
|
||||
|
||||
let stack_threshold = time_preempt * map.stack_leniency as f64;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ pub(crate) struct ObjectParameters<'a> {
|
||||
}
|
||||
|
||||
impl OsuObject {
|
||||
pub(crate) fn new(h: &HitObject, params: &mut ObjectParameters<'_>) -> Option<Self> {
|
||||
pub(crate) fn new(h: &HitObject, params: &mut ObjectParameters<'_>) -> Self {
|
||||
let ObjectParameters {
|
||||
map,
|
||||
attrs,
|
||||
@@ -103,7 +103,7 @@ impl OsuObject {
|
||||
attrs.max_combo += 1; // hitcircle, slider head, or spinner
|
||||
let pos = h.pos;
|
||||
|
||||
let obj = match &h.kind {
|
||||
match &h.kind {
|
||||
HitObjectKind::Circle => {
|
||||
attrs.n_circles += 1;
|
||||
|
||||
@@ -317,7 +317,7 @@ impl OsuObject {
|
||||
kind: OsuObjectKind::Slider(slider),
|
||||
}
|
||||
}
|
||||
HitObjectKind::Spinner { end_time } => {
|
||||
HitObjectKind::Spinner { end_time } | HitObjectKind::Hold { end_time } => {
|
||||
attrs.n_spinners += 1;
|
||||
|
||||
Self {
|
||||
@@ -330,10 +330,7 @@ impl OsuObject {
|
||||
},
|
||||
}
|
||||
}
|
||||
HitObjectKind::Hold { .. } => return None,
|
||||
};
|
||||
|
||||
Some(obj)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn end_time(&self) -> f64 {
|
||||
|
||||
+2
-2
@@ -21,8 +21,8 @@ use crate::{
|
||||
/// let pp_result = OsuPP::new(&map)
|
||||
/// .mods(8 + 64) // HDDT
|
||||
/// .combo(1234)
|
||||
/// .accuracy(98.5)
|
||||
/// .n_misses(1)
|
||||
/// .accuracy(98.5) // should be set last
|
||||
/// .calculate();
|
||||
///
|
||||
/// println!("PP: {} | Stars: {}", pp_result.pp(), pp_result.stars());
|
||||
@@ -199,7 +199,7 @@ impl<'map> OsuPP<'map> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Specify the accuracy of a play between `0` and `100`.
|
||||
/// Specify the accuracy of a play between `0.0` and `100.0`.
|
||||
/// This will be used to generate matching hitresults.
|
||||
#[inline]
|
||||
pub fn accuracy(mut self, acc: f64) -> Self {
|
||||
|
||||
@@ -37,6 +37,7 @@ impl Aim {
|
||||
}
|
||||
|
||||
impl Skill for Aim {
|
||||
#[inline]
|
||||
fn process(
|
||||
&mut self,
|
||||
curr: &OsuDifficultyObject<'_>,
|
||||
@@ -46,36 +47,44 @@ impl Skill for Aim {
|
||||
<Self as StrainSkill>::process(self, curr, diff_objects, hit_window)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn difficulty_value(&mut self) -> f64 {
|
||||
<Self as OsuStrainSkill>::difficulty_value(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn take_strain_peaks(&mut self) -> Vec<f64> {
|
||||
mem::take(&mut self.strain_peaks)
|
||||
}
|
||||
}
|
||||
|
||||
impl StrainSkill for Aim {
|
||||
#[inline]
|
||||
fn strain_peaks_mut(&mut self) -> &mut Vec<f64> {
|
||||
&mut self.strain_peaks
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn curr_section_peak(&mut self) -> &mut f64 {
|
||||
&mut self.curr_section_peak
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn curr_section_end(&mut self) -> &mut f64 {
|
||||
&mut self.curr_section_end
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn strain_value_at(
|
||||
&mut self,
|
||||
curr: &OsuDifficultyObject<'_>,
|
||||
@@ -89,6 +98,7 @@ impl StrainSkill for Aim {
|
||||
self.curr_strain
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn calculate_initial_strain(
|
||||
&self,
|
||||
time: f64,
|
||||
@@ -98,6 +108,7 @@ impl StrainSkill for Aim {
|
||||
self.curr_strain * Self::strain_decay(time - previous_start_time(diff_objects, curr.idx, 0))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn difficulty_value(&mut self) -> f64 {
|
||||
<Self as OsuStrainSkill>::difficulty_value(self)
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ impl Flashlight {
|
||||
}
|
||||
|
||||
impl Skill for Flashlight {
|
||||
#[inline]
|
||||
fn process(
|
||||
&mut self,
|
||||
curr: &OsuDifficultyObject<'_>,
|
||||
@@ -51,18 +52,22 @@ impl Skill for Flashlight {
|
||||
<Self as StrainSkill>::process(self, curr, diff_objects, hit_window)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn difficulty_value(&mut self) -> f64 {
|
||||
<Self as StrainSkill>::difficulty_value(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn take_strain_peaks(&mut self) -> Vec<f64> {
|
||||
mem::take(&mut self.strain_peaks)
|
||||
}
|
||||
@@ -71,18 +76,22 @@ impl Skill for Flashlight {
|
||||
impl StrainSkill for Flashlight {
|
||||
const DECAY_WEIGHT: f64 = 0.9;
|
||||
|
||||
#[inline]
|
||||
fn strain_peaks_mut(&mut self) -> &mut Vec<f64> {
|
||||
&mut self.strain_peaks
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn curr_section_peak(&mut self) -> &mut f64 {
|
||||
&mut self.curr_section_peak
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn curr_section_end(&mut self) -> &mut f64 {
|
||||
&mut self.curr_section_end
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn strain_value_at(
|
||||
&mut self,
|
||||
curr: &OsuDifficultyObject<'_>,
|
||||
@@ -102,6 +111,7 @@ impl StrainSkill for Flashlight {
|
||||
self.curr_strain
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn calculate_initial_strain(
|
||||
&self,
|
||||
time: f64,
|
||||
@@ -111,6 +121,7 @@ impl StrainSkill for Flashlight {
|
||||
self.curr_strain * Self::strain_decay(time - previous_start_time(diff_objects, curr.idx, 0))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn difficulty_value(&mut self) -> f64 {
|
||||
self.get_curr_strain_peaks().into_iter().sum::<f64>() * Self::DIFFICULTY_MULTIPLER
|
||||
}
|
||||
|
||||
@@ -70,11 +70,13 @@ pub(crate) trait StrainSkill: Skill + Sized {
|
||||
.max(*self.curr_section_peak());
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn save_curr_peak(&mut self) {
|
||||
let peak = *self.curr_section_peak();
|
||||
self.strain_peaks_mut().push(peak);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn start_new_section_from(
|
||||
&mut self,
|
||||
time: f64,
|
||||
@@ -89,6 +91,7 @@ pub(crate) trait StrainSkill: Skill + Sized {
|
||||
|
||||
fn difficulty_value(&mut self) -> f64;
|
||||
|
||||
#[inline]
|
||||
fn get_curr_strain_peaks(&mut self) -> Vec<f64> {
|
||||
let curr_peak = *self.curr_section_peak();
|
||||
let mut strain_peaks = mem::take(self.strain_peaks_mut());
|
||||
|
||||
@@ -48,6 +48,7 @@ impl Speed {
|
||||
}
|
||||
|
||||
impl Skill for Speed {
|
||||
#[inline]
|
||||
fn process(
|
||||
&mut self,
|
||||
curr: &OsuDifficultyObject<'_>,
|
||||
@@ -57,36 +58,44 @@ impl Skill for Speed {
|
||||
<Self as StrainSkill>::process(self, curr, diff_objects, hit_window)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn difficulty_value(&mut self) -> f64 {
|
||||
<Self as OsuStrainSkill>::difficulty_value(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn take_strain_peaks(&mut self) -> Vec<f64> {
|
||||
mem::take(&mut self.strain_peaks)
|
||||
}
|
||||
}
|
||||
|
||||
impl StrainSkill for Speed {
|
||||
#[inline]
|
||||
fn strain_peaks_mut(&mut self) -> &mut Vec<f64> {
|
||||
&mut self.strain_peaks
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn curr_section_peak(&mut self) -> &mut f64 {
|
||||
&mut self.curr_section_peak
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn curr_section_end(&mut self) -> &mut f64 {
|
||||
&mut self.curr_section_end
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn strain_value_at(
|
||||
&mut self,
|
||||
curr: &OsuDifficultyObject<'_>,
|
||||
@@ -104,6 +113,7 @@ impl StrainSkill for Speed {
|
||||
total_strain
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn calculate_initial_strain(
|
||||
&self,
|
||||
time: f64,
|
||||
@@ -114,6 +124,7 @@ impl StrainSkill for Speed {
|
||||
* Self::strain_decay(time - previous_start_time(diff_objects, curr.idx, 0))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn difficulty_value(&mut self) -> f64 {
|
||||
<Self as OsuStrainSkill>::difficulty_value(self)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user