From e116199498486545a188582a44942c02786aab07 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 10:48:48 +0400 Subject: feat(runtime): capture neutral buildings at communicators --- crates/fparkan-animation/src/lib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'crates/fparkan-animation/src/lib.rs') diff --git a/crates/fparkan-animation/src/lib.rs b/crates/fparkan-animation/src/lib.rs index ab606ad0..beb8b981 100644 --- a/crates/fparkan-animation/src/lib.rs +++ b/crates/fparkan-animation/src/lib.rs @@ -38,6 +38,15 @@ impl Default for Pose { } } +impl Pose { + /// Transforms a local point by this pose's unit quaternion and translation. + #[must_use] + pub fn transform_point(self, point: [f32; 3]) -> [f32; 3] { + let rotated = rotate_point(self.rotation, point); + std::array::from_fn(|axis| rotated[axis] + self.translation[axis]) + } +} + /// Scalar animation key. #[derive(Clone, Copy, Debug, PartialEq)] pub struct ScalarKey { @@ -767,13 +776,8 @@ fn write_f32_bits(out: &mut Vec, value: f32) { } fn compose_pose(parent: Pose, child: Pose) -> Result { - let translated = rotate_point(parent.rotation, child.translation); Ok(Pose { - translation: [ - parent.translation[0] + translated[0], - parent.translation[1] + translated[1], - parent.translation[2] + translated[2], - ], + translation: parent.transform_point(child.translation), rotation: normalize_quat(mul_quat(parent.rotation, child.rotation))?, }) } -- cgit v1.2.3