Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions prpr/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ impl BinaryData for JudgeLine {
0 => None,
x => Some(x as usize - 1),
};
let show_below = r.read()?;
let flags = r.read::<u8>()?;
let show_below = flags & 1 != 0;
let rot_with_parent = flags & 2 != 0;
let cache = JudgeLineCache::new(&mut notes);
let attach_ui = UIElement::from_u8(r.read()?);
let ctrl_obj = RefCell::new(r.read()?);
Expand All @@ -402,6 +404,7 @@ impl BinaryData for JudgeLine {
notes,
color,
parent,
rot_with_parent,
show_below,

attach_ui,
Expand Down Expand Up @@ -440,7 +443,7 @@ impl BinaryData for JudgeLine {
None => 0,
Some(index) => index as u64 + 1,
})?;
w.write_val(self.show_below)?;
w.write_val(self.show_below as u8 + self.rot_with_parent as u8 * 2)?;
w.write_val(self.attach_ui.map_or(0, |it| it as u8))?;
w.write(self.ctrl_obj.borrow().deref())?;
w.write(&self.incline)?;
Expand Down
5 changes: 3 additions & 2 deletions prpr/src/core/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ impl Chart {
}
// TODO optimize
let trs = self.lines.iter().map(|it| it.now_transform(res, &self.lines)).collect::<Vec<_>>();
for (line, tr) in self.lines.iter_mut().zip(trs) {
line.update(res, tr);
let rotations = self.lines.iter().map(|it| it.fetch_rot(&self.lines)).collect::<Vec<_>>();
for ((line, tr), rot) in self.lines.iter_mut().zip(trs).zip(rotations) {
line.update(res, tr, rot);
}
for effect in &mut self.extra.effects {
effect.update(res);
Expand Down
25 changes: 18 additions & 7 deletions prpr/src/core/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub struct JudgeLine {
pub notes: Vec<Note>,
pub color: Anim<Color>,
pub parent: Option<usize>,
pub rot_with_parent: bool,
pub z_index: i32,
/// Whether to show notes below the line, here below is defined in the time axis, which means the note should already be judged
///
Expand All @@ -157,15 +158,14 @@ pub struct JudgeLine {
}

impl JudgeLine {
pub fn update(&mut self, res: &mut Resource, tr: Matrix) {
pub fn update(&mut self, res: &mut Resource, tr: Matrix, parent_rot: f32) {
// self.object.set_time(res.time); // this is done by chart, chart has to calculate transform for us
let rot = self.object.rotation.now();
self.height.set_time(res.time);
let line_height = self.height.now();
let mut ctrl_obj = self.ctrl_obj.borrow_mut();
self.cache.update_order.retain(|id| {
let note = &mut self.notes[*id as usize];
note.update(res, rot, &tr, &mut ctrl_obj, line_height);
note.update(res, parent_rot, &tr, &mut ctrl_obj, line_height);
!note.dead()
});
drop(ctrl_obj);
Expand Down Expand Up @@ -208,18 +208,29 @@ impl JudgeLine {
});
}

pub fn fetch_rot(&self, lines: &[JudgeLine]) -> f32 {
let mut rot = self.object.rotation.now();
if self.rot_with_parent {
if let Some(parent) = self.parent {
rot += lines[parent].fetch_rot(lines);
}
}
rot
}

pub fn fetch_pos(&self, res: &Resource, lines: &[JudgeLine]) -> Vector {
if let Some(parent) = self.parent {
let parent = &lines[parent];
let mut parent_translation = parent.fetch_pos(res, lines);
parent_translation += Rotation2::new(parent.object.rotation.now().to_radians()) * self.object.now_translation(res);
return parent_translation;
let parent_translation = parent.fetch_pos(res, lines);
return parent_translation + Rotation2::new(parent.fetch_rot(lines).to_radians()) * self.object.now_translation(res);
}
self.object.now_translation(res)
}

pub fn now_transform(&self, res: &Resource, lines: &[JudgeLine]) -> Matrix {
self.object.now_rotation().append_translation(&self.fetch_pos(res, lines))
Rotation2::new(self.fetch_rot(lines).to_radians())
.to_homogeneous()
.append_translation(&self.fetch_pos(res, lines))
}

pub fn render(&self, ui: &mut Ui, res: &mut Resource, lines: &[JudgeLine], bpm_list: &mut BpmList, settings: &ChartSettings, id: usize) {
Expand Down
1 change: 1 addition & 0 deletions prpr/src/parse/pec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ fn parse_judge_line(mut pec: PECJudgeLine, id: usize, max_time: f32) -> Result<J
notes: pec.notes,
color: Anim::default(),
parent: None,
rot_with_parent: false,
z_index: 0,
show_below: false,
attach_ui: None,
Expand Down
1 change: 1 addition & 0 deletions prpr/src/parse/pgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ fn parse_judge_line(pgr: PgrJudgeLine, max_time: f32, format_version: u32) -> Re
notes,
color: Anim::default(),
parent: None,
rot_with_parent: false,
z_index: 0,
show_below: false,
attach_ui: None,
Expand Down
2 changes: 2 additions & 0 deletions prpr/src/parse/rpe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct RPEJudgeLine {
texture: String,
#[serde(rename = "father")]
parent: Option<isize>,
rotate_with_father: Option<bool>,
event_layers: Vec<Option<RPEEventLayer>>,
extended: Option<RPEExtendedEvents>,
notes: Option<Vec<RPENote>>,
Expand Down Expand Up @@ -582,6 +583,7 @@ async fn parse_judge_line(
Some(parent as usize)
}
},
rot_with_parent: rpe.rotate_with_father.unwrap_or(false),
z_index: rpe.z_order,
show_below: rpe.is_cover != 1,
attach_ui: rpe.attach_ui,
Expand Down