Implement hitbox viewer (#81)
CI / build-and-test (push) Successful in 1m26s
CI / production-build (push) Successful in 12m55s

Reviewed-on: #81
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #81.
This commit is contained in:
2026-10-04 11:32:28 +00:00
committed by EIREXE
parent 02d444f749
commit 04aceb05a9
12 changed files with 1232 additions and 167 deletions
+43
View File
@@ -55,6 +55,29 @@ impl BakedFighterAnimations {
pub fn frame_count(&self, kind: AnimKind) -> Option<u32> {
self.clip(kind).map(|clip| clip.frames.len() as u32)
}
/// Samples one bone in model space without depending on the runtime's
/// previous-frame buffers. Tooling uses this when the user scrubs between
/// unrelated frames.
pub fn sample_bone_model_transform(
&self,
frame: &FighterAnimationFrame,
bone: &str,
model_scale: FGi32,
) -> Option<FixedMat4> {
let local = self.sample_pose(frame)?;
let index = self.bone_names.iter().position(|name| name == bone)?;
let mut model = vec![None; local.len()];
resolve_model_transform(index, &self.parents, local, &mut model).ok()?;
let scale = FixedMat4 {
cols: [
[model_scale, FGi32::ZERO, FGi32::ZERO, FGi32::ZERO],
[FGi32::ZERO, model_scale, FGi32::ZERO, FGi32::ZERO],
[FGi32::ZERO, FGi32::ZERO, model_scale, FGi32::ZERO],
[FGi32::ZERO, FGi32::ZERO, FGi32::ZERO, FGi32::ONE],
],
};
Some(scale.mul(model[index]?))
}
pub(super) fn clip(&self, kind: AnimKind) -> Option<&BakedAnimationClip> {
self.clip_indices
.get(&kind)
@@ -78,6 +101,26 @@ pub struct FighterBoneMatrices {
pub struct FighterBoneIndexMap(pub HashMap<String, usize>);
impl FighterBoneMatrices {
/// Samples a baked pose for a preview or other non-gameplay caller.
pub fn sample_baked_pose(
&mut self,
baked: &BakedFighterAnimations,
frame: &FighterAnimationFrame,
model_scale: FGi32,
) -> bool {
let Some(pose) = baked.sample_pose(frame) else {
return false;
};
self.set_pose(
frame.kind,
&baked.bone_names,
&baked.parents,
pose,
model_scale,
);
true
}
#[cfg(test)]
pub(super) fn buffer_capacities(&self) -> [usize; 5] {
[