smpl_core/common/
smpl_params.rs

1use super::types::{Gender, SmplType};
2use crate::codec::codec::SmplCodec;
3/// Params that will influence various components. For example `pose_corrective`
4/// will influence animation, Pose, `PoseDestination`
5#[derive(Clone)]
6pub struct SmplParams {
7    pub smpl_type: SmplType,
8    pub gender: Gender,
9    pub enable_pose_corrective: bool,
10}
11impl Default for SmplParams {
12    fn default() -> Self {
13        Self {
14            smpl_type: SmplType::SmplX,
15            gender: Gender::Neutral,
16            enable_pose_corrective: false,
17        }
18    }
19}
20impl SmplParams {
21    pub fn new(smpl_type: SmplType, gender: Gender, enable_pose_corrective: bool) -> Self {
22        Self {
23            smpl_type,
24            gender,
25            enable_pose_corrective,
26        }
27    }
28    pub fn new_from_smpl_codec(codec: &SmplCodec) -> Self {
29        Self {
30            smpl_type: codec.smpl_type(),
31            gender: codec.gender(),
32            enable_pose_corrective: true,
33        }
34    }
35    #[cfg(not(target_arch = "wasm32"))]
36    #[allow(clippy::cast_possible_truncation)]
37    pub fn new_from_smpl_file(path: &str) -> Self {
38        let codec = SmplCodec::from_file(path);
39        Self::new_from_smpl_codec(&codec)
40    }
41}