Skip to main content

draco_core/
keyframe_animation_decoder.rs

1//! Decoder for [`KeyframeAnimation`].
2//!
3//! Mirrors C++ Draco's `KeyframeAnimationDecoder`, a thin wrapper around the
4//! sequential point-cloud decoder.
5
6use crate::decoder_buffer::DecoderBuffer;
7use crate::keyframe_animation::KeyframeAnimation;
8use crate::point_cloud::PointCloud;
9use crate::point_cloud_decoder::PointCloudDecoder;
10use crate::status::Status;
11
12/// Decodes a Draco bitstream into [`KeyframeAnimation`] data.
13#[derive(Debug, Default)]
14pub struct KeyframeAnimationDecoder;
15
16impl KeyframeAnimationDecoder {
17    /// Creates a new keyframe animation decoder.
18    pub fn new() -> Self {
19        Self
20    }
21
22    /// Decodes `in_buffer` into `animation`. Mirrors C++
23    /// `KeyframeAnimationDecoder::Decode`.
24    pub fn decode(
25        &mut self,
26        in_buffer: &mut DecoderBuffer,
27        animation: &mut KeyframeAnimation,
28    ) -> Status {
29        let mut point_cloud = PointCloud::new();
30        let mut decoder = PointCloudDecoder::new();
31        decoder.decode(in_buffer, &mut point_cloud)?;
32        *animation = KeyframeAnimation::from_point_cloud(point_cloud);
33        Ok(())
34    }
35}