Fix ledge transitions and root motion loops (#91)
## Summary - resolve each ledge action to the walkable segment on the stage-interior side - preserve repeating root-motion displacement across every animation cycle - add regression coverage for left/right ledge segments and multiple root-motion wraps - Implement ledge intangibility Reviewed-on: #91 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #91.
This commit is contained in:
@@ -487,7 +487,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repeating_root_motion_preserves_cycle_displacement_at_wrap() {
|
||||
fn repeating_root_motion_preserves_cycle_displacement_at_every_wrap() {
|
||||
let names = ["root".into()];
|
||||
let parents = [None];
|
||||
let pose = |x| FixedMat4::IDENTITY.with_translation(FGVec3::lit(x, "0", "0"));
|
||||
@@ -498,7 +498,13 @@ mod tests {
|
||||
repeat: true,
|
||||
};
|
||||
|
||||
for (frame_number, x) in [(0, "0"), (1, "1")] {
|
||||
for (frame_number, x, expected_delta) in [
|
||||
(0, "0", FGVec3::ZERO),
|
||||
(1, "1", FGVec3::lit("1", "0", "0")),
|
||||
(2, "0", FGVec3::lit("1", "0", "0")),
|
||||
(3, "1", FGVec3::lit("1", "0", "0")),
|
||||
(4, "0", FGVec3::lit("1", "0", "0")),
|
||||
] {
|
||||
matrices.set_pose_with_frame(
|
||||
frame(frame_number),
|
||||
Some(0),
|
||||
@@ -511,20 +517,8 @@ mod tests {
|
||||
&[pose(x)],
|
||||
FGi32::ONE,
|
||||
);
|
||||
assert_eq!(matrices.root_motion_delta(), expected_delta);
|
||||
}
|
||||
matrices.set_pose_with_frame(
|
||||
frame(2),
|
||||
Some(0),
|
||||
Some(FGVec3::ZERO),
|
||||
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]
|
||||
|
||||
@@ -110,6 +110,9 @@ impl BakedFighterAnimations {
|
||||
.get(&kind)
|
||||
.and_then(|index| self.clips.get(*index))
|
||||
}
|
||||
pub fn get_animation_duration(&self, kind: AnimKind) -> Option<usize> {
|
||||
self.clip(kind).map(|clip| clip.frames.len())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component, Clone, Debug, Default, Hash)]
|
||||
@@ -411,7 +414,9 @@ impl FighterBoneMatrices {
|
||||
previous.kind == animation_frame.kind
|
||||
&& previous.frame.saturating_add(1) == animation_frame.frame
|
||||
})
|
||||
&& root_motion_loop_frame_count == Some(animation_frame.frame)
|
||||
&& root_motion_loop_frame_count.is_some_and(|loop_frame_count| {
|
||||
loop_frame_count > 0 && animation_frame.frame % loop_frame_count == 0
|
||||
})
|
||||
{
|
||||
delta = delta + root_motion_cycle_delta;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user