1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::common::BlockRef;

use super::ni_interp_controller::NiInterpController;
use binrw::{
    io::{Read, Seek},
    BinRead, BinReaderExt,
};

#[derive(Debug, PartialEq, BinRead)]
pub struct NiGeomMorpherController {
    pub base: NiInterpController,
    pub morpher_flags: GeomMorpherFlags,
    pub data_ref: BlockRef,
    pub always_update: u8,
    pub num_interpolators: u32,
    #[br(count = num_interpolators)]
    pub interpolator_refs: Vec<BlockRef>,
}

#[derive(Debug, PartialEq, BinRead)]
pub enum GeomMorpherFlags {
    #[br(magic = 0u16)]
    UpdateNormalsDisabled,
    #[br(magic = 1u16)]
    UpdateNormalsEnabled,
}

impl NiGeomMorpherController {
    pub fn parse<R: Read + Seek>(reader: &mut R) -> anyhow::Result<Self> {
        Ok(reader.read_le()?)
    }
}