Skip to content

Commit f533658

Browse files
authored
fix: ensure reversed tween for ctrl events (#682)
2 parents 0b2ab58 + e287982 commit f533658

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

prpr/src/parse/rpe.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,19 @@ async fn parse_notes(
414414
Ok(notes)
415415
}
416416

417+
fn reverse_tween(id: u8) -> u8 {
418+
if id < 3 {
419+
id
420+
} else {
421+
let rem = (id - 3) % 3;
422+
match rem {
423+
0 => id + 1,
424+
1 => id - 1,
425+
_ => id,
426+
}
427+
}
428+
}
429+
417430
fn parse_ctrl_events(rpe: &[RPECtrlEvent], key: &str) -> AnimFloat {
418431
let vals: Vec<_> = rpe.iter().map(|it| it.value[key]).collect();
419432
if rpe.is_empty() || (rpe.len() == 2 && rpe[0].easing == 1 && (vals[0] - 1.).abs() < 1e-4) {
@@ -422,7 +435,9 @@ fn parse_ctrl_events(rpe: &[RPECtrlEvent], key: &str) -> AnimFloat {
422435
AnimFloat::new(
423436
rpe.iter()
424437
.zip(vals)
425-
.map(|(it, val)| Keyframe::new(it.x, val, RPE_TWEEN_MAP.get(it.easing.max(1) as usize).copied().unwrap_or(RPE_TWEEN_MAP[0])))
438+
.map(|(it, val)| {
439+
Keyframe::new(it.x, val, reverse_tween(RPE_TWEEN_MAP.get(it.easing.max(1) as usize).copied().unwrap_or(RPE_TWEEN_MAP[0])))
440+
})
426441
.collect(),
427442
)
428443
}

0 commit comments

Comments
 (0)