diff --git a/src/lib.rs b/src/lib.rs index 65b8015..18dfbde 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -342,19 +342,6 @@ pub struct GvasFile { pub properties: HashableIndexMap, } -trait GvasHeaderTrait { - fn use_large_world_coordinates(&self) -> bool; -} - -impl GvasHeaderTrait for GvasHeader { - fn use_large_world_coordinates(&self) -> bool { - match self { - GvasHeader::Version2 { .. } => false, - GvasHeader::Version3 { .. } => true, - } - } -} - impl GvasFile { /// Read GvasFile from a binary file /// @@ -476,7 +463,6 @@ impl GvasFile { let mut options = PropertyOptions { hints, properties_stack: &mut vec![], - large_world_coordinates: header.use_large_world_coordinates(), custom_versions: header.get_custom_versions(), }; @@ -536,7 +522,6 @@ impl GvasFile { let mut options = PropertyOptions { hints: &HashMap::new(), properties_stack: &mut vec![], - large_world_coordinates: self.header.use_large_world_coordinates(), custom_versions: self.header.get_custom_versions(), }; diff --git a/src/properties/mod.rs b/src/properties/mod.rs index d26c9b7..0f1321f 100644 --- a/src/properties/mod.rs +++ b/src/properties/mod.rs @@ -441,8 +441,6 @@ pub struct PropertyOptions<'a> { pub properties_stack: &'a mut Vec, /// Custom versions pub custom_versions: &'a HashableIndexMap, - /// Enables large world coordinates. - pub large_world_coordinates: bool, } impl PropertyOptions<'_> { diff --git a/src/properties/struct_property.rs b/src/properties/struct_property.rs index 6ee8a34..3b641d6 100644 --- a/src/properties/struct_property.rs +++ b/src/properties/struct_property.rs @@ -9,11 +9,11 @@ use indexmap::IndexMap; use crate::{ cursor_ext::{ReadExt, WriteExt}, + custom_version::FUE5ReleaseStreamObjectVersion, error::{DeserializeError, Error, SerializeError}, properties::{name_property::NameProperty, struct_types::LinearColor}, scoped_stack_entry::ScopedStackEntry, - types::map::HashableIndexMap, - types::Guid, + types::{map::HashableIndexMap, Guid}, }; use super::{ @@ -238,7 +238,8 @@ impl PropertyTrait for StructPropertyValue { match self { StructPropertyValue::Vector2F(vector) => { validate!( - !options.large_world_coordinates, + !options + .supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates), "Vector2F not supported when LWC is enabled, use Vector2D", ); cursor.write_f32::(vector.x.0)?; @@ -247,7 +248,7 @@ impl PropertyTrait for StructPropertyValue { } StructPropertyValue::Vector2D(vector) => { validate!( - options.large_world_coordinates, + options.supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates), "Vector2D not supported when LWC is disabled, use Vector2F", ); cursor.write_f64::(vector.x.0)?; @@ -256,7 +257,8 @@ impl PropertyTrait for StructPropertyValue { } StructPropertyValue::VectorF(vector) => { validate!( - !options.large_world_coordinates, + !options + .supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates), "VectorF not supported when LWC is enabled, use VectorD", ); cursor.write_f32::(vector.x.0)?; @@ -266,7 +268,7 @@ impl PropertyTrait for StructPropertyValue { } StructPropertyValue::VectorD(vector) => { validate!( - options.large_world_coordinates, + options.supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates), "VectorD not supported when LWC is disabled, use VectorF", ); cursor.write_f64::(vector.x.0)?; @@ -276,7 +278,8 @@ impl PropertyTrait for StructPropertyValue { } StructPropertyValue::RotatorF(rotator) => { validate!( - !options.large_world_coordinates, + !options + .supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates), "RotatorF not supported when LWC is enabled, use RotatorD", ); cursor.write_f32::(rotator.pitch.0)?; @@ -286,7 +289,7 @@ impl PropertyTrait for StructPropertyValue { } StructPropertyValue::RotatorD(rotator) => { validate!( - options.large_world_coordinates, + options.supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates), "RotatorD not supported when LWC is disabled, use RotatorF", ); cursor.write_f64::(rotator.pitch.0)?; @@ -296,7 +299,8 @@ impl PropertyTrait for StructPropertyValue { } StructPropertyValue::QuatF(quat) => { validate!( - !options.large_world_coordinates, + !options + .supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates), "QuatF not supported when LWC is enabled, use QuatD", ); cursor.write_f32::(quat.x.0)?; @@ -307,7 +311,7 @@ impl PropertyTrait for StructPropertyValue { } StructPropertyValue::QuatD(quat) => { validate!( - options.large_world_coordinates, + options.supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates), "QuatD not supported when LWC is disabled, use QuatF", ); cursor.write_f64::(quat.x.0)?; @@ -412,7 +416,7 @@ impl StructPropertyValue { cursor: &mut R, options: &mut PropertyOptions, ) -> Result { - match options.large_world_coordinates { + match options.supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates) { true => Ok(Self::QuatD(QuatD::new( cursor.read_f64::()?, cursor.read_f64::()?, @@ -432,7 +436,7 @@ impl StructPropertyValue { cursor: &mut R, options: &mut PropertyOptions, ) -> Result { - match options.large_world_coordinates { + match options.supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates) { true => Ok(Self::RotatorD(RotatorD::new( cursor.read_f64::()?, cursor.read_f64::()?, @@ -450,7 +454,7 @@ impl StructPropertyValue { cursor: &mut R, options: &mut PropertyOptions, ) -> Result { - match options.large_world_coordinates { + match options.supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates) { true => Ok(Self::Vector2D(Vector2D::new( cursor.read_f64::()?, cursor.read_f64::()?, @@ -466,7 +470,7 @@ impl StructPropertyValue { cursor: &mut R, options: &mut PropertyOptions, ) -> Result { - match options.large_world_coordinates { + match options.supports_version(FUE5ReleaseStreamObjectVersion::LargeWorldCoordinates) { true => Ok(Self::VectorD(VectorD::new( cursor.read_f64::()?, cursor.read_f64::()?, diff --git a/tests/gvas_tests/errors.rs b/tests/gvas_tests/errors.rs index c7752d1..667f1b1 100644 --- a/tests/gvas_tests/errors.rs +++ b/tests/gvas_tests/errors.rs @@ -70,7 +70,6 @@ fn test_invalid_array_index() { let mut options = PropertyOptions { hints: &HashMap::new(), properties_stack: &mut Vec::new(), - large_world_coordinates: false, custom_versions: &HashableIndexMap::new(), }; @@ -156,7 +155,6 @@ fn test_invalid_terminator() { let mut options = PropertyOptions { hints: &HashMap::new(), properties_stack: &mut Vec::new(), - large_world_coordinates: false, custom_versions: &HashableIndexMap::new(), }; @@ -265,7 +263,6 @@ fn test_invalid_length() { let mut options = PropertyOptions { hints: &HashMap::new(), properties_stack: &mut Vec::new(), - large_world_coordinates: false, custom_versions: &HashableIndexMap::new(), }; diff --git a/tests/gvas_tests/name_arrayindex.rs b/tests/gvas_tests/name_arrayindex.rs index 1346cca..3dc928a 100644 --- a/tests/gvas_tests/name_arrayindex.rs +++ b/tests/gvas_tests/name_arrayindex.rs @@ -32,7 +32,6 @@ fn name_property_with_array_index() { let mut options = PropertyOptions { hints: &HashMap::new(), properties_stack: &mut Vec::new(), - large_world_coordinates: false, custom_versions: &HashableIndexMap::new(), }; let mut writer = Cursor::new(Vec::new()); diff --git a/tests/gvas_tests/test_property.rs b/tests/gvas_tests/test_property.rs index 654612f..1f61c60 100644 --- a/tests/gvas_tests/test_property.rs +++ b/tests/gvas_tests/test_property.rs @@ -32,7 +32,6 @@ macro_rules! test_property { let mut options = PropertyOptions { hints: &HashMap::new(), properties_stack: &mut Vec::new(), - large_world_coordinates: false, custom_versions: &HashableIndexMap::new(), };