Removed branching
This commit is contained in:
@@ -71,6 +71,7 @@ pub(crate) fn point_at_distance(array: &[Pos2], distance: f32) -> Pos2 {
|
|||||||
let mut current_distance = 0.0;
|
let mut current_distance = 0.0;
|
||||||
let mut new_distance = 0.0;
|
let mut new_distance = 0.0;
|
||||||
|
|
||||||
|
// TODO: Optimize
|
||||||
while i < array.len() - 2 {
|
while i < array.len() - 2 {
|
||||||
new_distance = (array[i] - array[i + 1]).length();
|
new_distance = (array[i] - array[i + 1]).length();
|
||||||
current_distance += new_distance;
|
current_distance += new_distance;
|
||||||
@@ -90,11 +91,7 @@ pub(crate) fn point_at_distance(array: &[Pos2], distance: f32) -> Pos2 {
|
|||||||
let angle = angle_from_points(array[i], array[i + 1]);
|
let angle = angle_from_points(array[i], array[i + 1]);
|
||||||
let cart = cart_from_pol(distance - current_distance, angle);
|
let cart = cart_from_pol(distance - current_distance, angle);
|
||||||
|
|
||||||
if array[i].x > array[i + 1].x {
|
array[i] + cart * ((array[i].x <= array[i + 1].x) as i8 * 2 - 1) as f32
|
||||||
array[i] - cart
|
|
||||||
} else {
|
|
||||||
array[i] + cart
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,21 +129,4 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn wack_map() {
|
|
||||||
let file = match File::open("E:/Games/osu!/beatmaps/1443309.osu") {
|
|
||||||
Ok(file) => file,
|
|
||||||
Err(why) => panic!("Could not open file: {}", why),
|
|
||||||
};
|
|
||||||
|
|
||||||
let map = match Beatmap::parse(file) {
|
|
||||||
Ok(map) => map,
|
|
||||||
Err(why) => panic!("Error while parsing map: {}", why),
|
|
||||||
};
|
|
||||||
|
|
||||||
let stars = stars(&map, 0);
|
|
||||||
|
|
||||||
println!("Stars: {}", stars);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ impl Strain {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn save_current_peak(&mut self) {
|
pub(crate) fn save_current_peak(&mut self) {
|
||||||
|
// TODO: Remove branching
|
||||||
if self.prev_time.is_some() {
|
if self.prev_time.is_some() {
|
||||||
self.strain_peaks.push(self.current_section_peak);
|
self.strain_peaks.push(self.current_section_peak);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ mod tests {
|
|||||||
let margin = 0.005;
|
let margin = 0.005;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
// TODO: More mods
|
||||||
let data = vec![
|
let data = vec![
|
||||||
(1851299, 1 << 8, 4.23514130038547), // HT
|
(1851299, 1 << 8, 4.23514130038547), // HT
|
||||||
(1851299, 0, 5.356786475158158), // NM
|
(1851299, 0, 5.356786475158158), // NM
|
||||||
|
|||||||
@@ -90,11 +90,7 @@ pub(crate) fn point_at_distance(array: &[Pos2], distance: f32) -> Pos2 {
|
|||||||
let angle = angle_from_points(array[i], array[i + 1]);
|
let angle = angle_from_points(array[i], array[i + 1]);
|
||||||
let cart = cart_from_pol(distance - current_distance, angle);
|
let cart = cart_from_pol(distance - current_distance, angle);
|
||||||
|
|
||||||
if array[i].x > array[i + 1].x {
|
array[i] + cart * ((array[i].x <= array[i + 1].x) as i8 * 2 - 1) as f32
|
||||||
array[i] - cart
|
|
||||||
} else {
|
|
||||||
array[i] + cart
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(unused)]
|
||||||
|
|
||||||
use super::curve::Curve;
|
use super::curve::Curve;
|
||||||
|
|
||||||
use parse::{Beatmap, BeatmapAttributes, HitObject, HitObjectKind, PathType, Pos2};
|
use parse::{Beatmap, BeatmapAttributes, HitObject, HitObjectKind, PathType, Pos2};
|
||||||
@@ -315,10 +317,9 @@ impl SliderTick {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::fmt;
|
// TODO: Remove
|
||||||
|
impl std::fmt::Debug for SliderTick {
|
||||||
impl fmt::Debug for SliderTick {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "{{pos={:?} | time={}}}", self.pos, self.time)
|
write!(f, "{{pos={:?} | time={}}}", self.pos, self.time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ impl<T: PartialOrd> LimitedQueue<T> {
|
|||||||
pub(crate) fn min(&self) -> Option<&T> {
|
pub(crate) fn min(&self) -> Option<&T> {
|
||||||
let mut iter = self.queue.iter();
|
let mut iter = self.queue.iter();
|
||||||
|
|
||||||
if let Some(first) = iter.next() {
|
let first = iter.next()?;
|
||||||
let min = iter.fold(first, |min, next| match min.partial_cmp(next) {
|
let min = iter.fold(first, |min, next| match min.partial_cmp(next) {
|
||||||
Some(Ordering::Less) => min,
|
Some(Ordering::Less) => min,
|
||||||
Some(Ordering::Equal) => min,
|
Some(Ordering::Equal) => min,
|
||||||
@@ -67,9 +67,6 @@ impl<T: PartialOrd> LimitedQueue<T> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Some(min)
|
Some(min)
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ impl Skill {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn skill_multiplier(&self) -> f32 {
|
fn skill_multiplier(&self) -> f32 {
|
||||||
|
// TODO: Use constants
|
||||||
match self.kind {
|
match self.kind {
|
||||||
SkillKind::Color { .. } => 1.0,
|
SkillKind::Color { .. } => 1.0,
|
||||||
SkillKind::Rhythm { .. } => 10.0,
|
SkillKind::Rhythm { .. } => 10.0,
|
||||||
@@ -78,6 +79,7 @@ impl Skill {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn strain_decay_base(&self) -> f32 {
|
fn strain_decay_base(&self) -> f32 {
|
||||||
|
// TODO: Use constants
|
||||||
match self.kind {
|
match self.kind {
|
||||||
SkillKind::Color { .. } => 0.4,
|
SkillKind::Color { .. } => 0.4,
|
||||||
SkillKind::Rhythm { .. } => 0.0,
|
SkillKind::Rhythm { .. } => 0.0,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ pub(crate) trait StaminaCheeseDetector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl StaminaCheeseDetector for Beatmap {
|
impl StaminaCheeseDetector for Beatmap {
|
||||||
|
// TODO: Optimize
|
||||||
fn find_cheese(&self) -> Vec<bool> {
|
fn find_cheese(&self) -> Vec<bool> {
|
||||||
let mut cheese = vec![false; self.hit_objects.len()];
|
let mut cheese = vec![false; self.hit_objects.len()];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user