Implement animation root motion deltas (#84)
Implements root motion and adds a dash attack. Reviewed-on: #84 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #84.
This commit is contained in:
@@ -326,6 +326,115 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn root_motion_delta_is_scaled_and_zero_on_initial_sample() {
|
||||
let names = ["root".into()];
|
||||
let parents = [None];
|
||||
let mut first = FixedMat4::IDENTITY;
|
||||
first.translate(FGVec3::lit("1", "0", "0"));
|
||||
let mut second = FixedMat4::IDENTITY;
|
||||
second.translate(FGVec3::lit("3", "0", "0"));
|
||||
let mut matrices = FighterBoneMatrices::default();
|
||||
let frame = crate::fighter::animation::FighterAnimationFrame::new(AnimKind::Wait, false);
|
||||
|
||||
matrices.set_pose_with_frame(
|
||||
frame,
|
||||
"root",
|
||||
FGVec3::ZERO,
|
||||
None,
|
||||
AnimKind::Wait,
|
||||
&names,
|
||||
&parents,
|
||||
&[first],
|
||||
FGi32::lit("2"),
|
||||
);
|
||||
assert_eq!(matrices.root_motion_delta(), FGVec3::ZERO);
|
||||
|
||||
matrices.set_pose_with_frame(
|
||||
crate::fighter::animation::FighterAnimationFrame { frame: 1, ..frame },
|
||||
"root",
|
||||
FGVec3::ZERO,
|
||||
None,
|
||||
AnimKind::Wait,
|
||||
&names,
|
||||
&parents,
|
||||
&[second],
|
||||
FGi32::lit("2"),
|
||||
);
|
||||
assert_eq!(matrices.root_motion_delta(), FGVec3::lit("4", "0", "0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn root_motion_translation_is_removed_from_published_pose() {
|
||||
let names = ["root".into(), "hand".into()];
|
||||
let parents = [None, Some(0)];
|
||||
let mut root = FixedMat4::IDENTITY;
|
||||
root.translate(FGVec3::lit("3", "4", "5"));
|
||||
let mut hand = FixedMat4::IDENTITY;
|
||||
hand.translate(FGVec3::lit("1", "2", "0"));
|
||||
let mut matrices = FighterBoneMatrices::default();
|
||||
let frame = crate::fighter::animation::FighterAnimationFrame::new(AnimKind::Wait, false);
|
||||
|
||||
matrices.set_pose_with_frame(
|
||||
frame,
|
||||
"root",
|
||||
FGVec3::ZERO,
|
||||
None,
|
||||
AnimKind::Wait,
|
||||
&names,
|
||||
&parents,
|
||||
&[root, hand],
|
||||
FGi32::ONE,
|
||||
);
|
||||
|
||||
assert_eq!(matrices.root_motion_delta(), FGVec3::ZERO);
|
||||
assert_eq!(matrices.local(0).unwrap().get_translation(), FGVec3::ZERO);
|
||||
assert_eq!(matrices.get_current("root").unwrap().get_translation(), FGVec3::ZERO);
|
||||
assert_eq!(
|
||||
matrices.get_current("hand").unwrap().get_translation(),
|
||||
FGVec3::lit("1", "2", "0")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repeating_root_motion_preserves_cycle_displacement_at_wrap() {
|
||||
let names = ["root".into()];
|
||||
let parents = [None];
|
||||
let pose = |x| FixedMat4::IDENTITY.with_translation(FGVec3::lit(x, "0", "0"));
|
||||
let mut matrices = FighterBoneMatrices::default();
|
||||
let frame = |frame| crate::fighter::animation::FighterAnimationFrame {
|
||||
kind: AnimKind::Wait,
|
||||
frame,
|
||||
repeat: true,
|
||||
};
|
||||
|
||||
for (frame_number, x) in [(0, "0"), (1, "1")] {
|
||||
matrices.set_pose_with_frame(
|
||||
frame(frame_number),
|
||||
"root",
|
||||
FGVec3::lit("2", "0", "0"),
|
||||
Some(2),
|
||||
AnimKind::Wait,
|
||||
&names,
|
||||
&parents,
|
||||
&[pose(x)],
|
||||
FGi32::ONE,
|
||||
);
|
||||
}
|
||||
matrices.set_pose_with_frame(
|
||||
frame(2),
|
||||
"root",
|
||||
FGVec3::lit("2", "0", "0"),
|
||||
Some(2),
|
||||
AnimKind::Wait,
|
||||
&names,
|
||||
&parents,
|
||||
&[pose("0")],
|
||||
FGi32::ONE,
|
||||
);
|
||||
assert_eq!(matrices.root_motion_delta(), FGVec3::lit("1", "0", "0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fixed_matrix_transforms_points() {
|
||||
let transform = FixedMat4 {
|
||||
|
||||
Reference in New Issue
Block a user