aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-animation
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-14 09:48:48 +0300
committerValentin Popov <valentin@popov.link>2026-11-14 09:48:48 +0300
commite116199498486545a188582a44942c02786aab07 (patch)
treeaf63b3630f979d6ab241260c90233866d034bdf6 /crates/fparkan-animation
parent6b48c7130acbaa8eb72335e6736913b7838e19b3 (diff)
downloadfparkan-e116199498486545a188582a44942c02786aab07.tar.xz
fparkan-e116199498486545a188582a44942c02786aab07.zip
feat(runtime): capture neutral buildings at communicators
Diffstat (limited to 'crates/fparkan-animation')
-rw-r--r--crates/fparkan-animation/src/lib.rs16
1 files changed, 10 insertions, 6 deletions
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<u8>, value: f32) {
}
fn compose_pose(parent: Pose, child: Pose) -> Result<Pose, AnimationError> {
- 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))?,
})
}