Skip to main content

rpfm_lib/files/rigidmodel/materials/
collision_shape.rs

1//---------------------------------------------------------------------------//
2// Copyright (c) 2017-2026 Ismael Gutiérrez González. All rights reserved.
3//
4// This file is part of the Rusted PackFile Manager (RPFM) project,
5// which can be found here: https://github.com/Frodo45127/rpfm.
6//
7// This file is licensed under the MIT license, which can be found here:
8// https://github.com/Frodo45127/rpfm/blob/master/LICENSE.
9//---------------------------------------------------------------------------//
10
11use super::*;
12
13//---------------------------------------------------------------------------//
14//                            Implementation
15//---------------------------------------------------------------------------//
16
17/// Collision shape materials: the default material, followed by the sphere around the shape.
18impl Material {
19    pub fn read_collision_shape<R: ReadBytes>(data: &mut R, version: u32) -> Result<Self> {
20        let mut material = Self::read_default(data, version)?;
21        material.uk_1 = data.read_u32()?;
22        material.sphere_center = Vector3::new(data.read_f32()?, data.read_f32()?, data.read_f32()?);
23        material.sphere_radius = data.read_f32()?;
24
25        Ok(material)
26    }
27
28    pub fn write_collision_shape<W: WriteBytes>(&self, data: &mut W, version: u32) -> Result<()> {
29        self.write_default(data, version)?;
30        data.write_u32(self.uk_1)?;
31        data.write_f32(self.sphere_center.x)?;
32        data.write_f32(self.sphere_center.y)?;
33        data.write_f32(self.sphere_center.z)?;
34        data.write_f32(self.sphere_radius)?;
35
36        Ok(())
37    }
38}