clamp catch values to playfield

This commit is contained in:
MaxOhn
2024-02-13 11:41:08 +01:00
parent a7027f4972
commit f628405a95
+6 -2
View File
@@ -5,7 +5,7 @@ use rosu_map::section::hit_objects::{
}; };
use crate::{ use crate::{
catch::{attributes::CatchDifficultyAttributesBuilder, convert::CatchBeatmap}, catch::{attributes::CatchDifficultyAttributesBuilder, convert::CatchBeatmap, PLAYFIELD_WIDTH},
model::{ model::{
control_point::{DifficultyPoint, TimingPoint}, control_point::{DifficultyPoint, TimingPoint},
hit_object::Slider, hit_object::Slider,
@@ -120,7 +120,7 @@ impl<'a> JuiceStream<'a> {
}; };
let nested = NestedJuiceStreamObject { let nested = NestedJuiceStreamObject {
pos: x + path.position_at(e.path_progress).x, pos: Self::clamp_to_playfield(x + path.position_at(e.path_progress).x),
start_time: e.time, start_time: e.time,
kind, kind,
}; };
@@ -133,6 +133,10 @@ impl<'a> JuiceStream<'a> {
nested_objects: bufs.nested_objects.drain(..), nested_objects: bufs.nested_objects.drain(..),
} }
} }
fn clamp_to_playfield(value: f32) -> f32 {
value.clamp(0.0, PLAYFIELD_WIDTH)
}
} }
pub struct NestedJuiceStreamObject { pub struct NestedJuiceStreamObject {