From 4b9b5f5182695b586fdf264715c6295dc41090f5 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 16 Sep 2024 15:46:52 -0700 Subject: [PATCH] update common --- src/map.rs | 2 +- src/newtypes/aabb.rs | 8 ++--- src/newtypes/gameplay_attributes.rs | 46 ++++++++++++++--------------- src/newtypes/gameplay_style.rs | 44 +++++++++++++-------------- src/newtypes/model.rs | 28 +++++++++--------- 5 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/map.rs b/src/map.rs index 1eed566..02f8868 100644 --- a/src/map.rs +++ b/src/map.rs @@ -357,7 +357,7 @@ pub fn write_map(mut writer:W,map:strafesnet_common::map::Comple let mesh=map.meshes.get(model.mesh.get() as usize).ok_or(Error::InvalidMeshId(model.mesh))?; let mut aabb=strafesnet_common::aabb::Aabb::default(); for &pos in &mesh.unique_pos{ - aabb.grow(model.transform.transform_point3(pos)); + aabb.grow(model.transform.transform_point3(pos).fix_1()); } Ok(((model::ModelId::new(model_id as u32),model.into()),aabb)) }).collect::,_>>()?; diff --git a/src/newtypes/aabb.rs b/src/newtypes/aabb.rs index ae8cb52..4443e55 100644 --- a/src/newtypes/aabb.rs +++ b/src/newtypes/aabb.rs @@ -8,16 +8,16 @@ pub struct Aabb{ impl Into for Aabb{ fn into(self)->strafesnet_common::aabb::Aabb{ strafesnet_common::aabb::Aabb::new( - strafesnet_common::integer::Planar64Vec3::raw_array(self.min), - strafesnet_common::integer::Planar64Vec3::raw_array(self.max), + strafesnet_common::integer::vec3::raw_array(self.min), + strafesnet_common::integer::vec3::raw_array(self.max), ) } } impl From for Aabb{ fn from(value:strafesnet_common::aabb::Aabb)->Self{ Self{ - max:value.max().get().to_array(), - min:value.min().get().to_array(), + max:value.max().map(|t|t.to_raw()).to_array(), + min:value.min().map(|t|t.to_raw()).to_array(), } } } diff --git a/src/newtypes/gameplay_attributes.rs b/src/newtypes/gameplay_attributes.rs index a0082cd..6a758fb 100644 --- a/src/newtypes/gameplay_attributes.rs +++ b/src/newtypes/gameplay_attributes.rs @@ -84,16 +84,16 @@ impl Into for Interse strafesnet_common::gameplay_attributes::IntersectingWater{ viscosity:strafesnet_common::integer::Planar64::raw(self.viscosity), density:strafesnet_common::integer::Planar64::raw(self.density), - velocity:strafesnet_common::integer::Planar64Vec3::raw_array(self.velocity), + velocity:strafesnet_common::integer::vec3::raw_array(self.velocity), } } } impl From for IntersectingWater{ fn from(value:strafesnet_common::gameplay_attributes::IntersectingWater)->Self{ Self{ - viscosity:value.viscosity.get(), - density:value.density.get(), - velocity:value.velocity.get().to_array(), + viscosity:value.viscosity.to_raw(), + density:value.density.to_raw(), + velocity:value.velocity.map(|t|t.to_raw()).to_array(), } } } @@ -106,14 +106,14 @@ pub struct Accelerator{ impl Into for Accelerator{ fn into(self)->strafesnet_common::gameplay_attributes::Accelerator{ strafesnet_common::gameplay_attributes::Accelerator{ - acceleration:strafesnet_common::integer::Planar64Vec3::raw_array(self.acceleration) + acceleration:strafesnet_common::integer::vec3::raw_array(self.acceleration) } } } impl From for Accelerator{ fn from(value:strafesnet_common::gameplay_attributes::Accelerator)->Self{ Self{ - acceleration:value.acceleration.get().to_array(), + acceleration:value.acceleration.map(|t|t.to_raw()).to_array(), } } } @@ -136,11 +136,11 @@ impl Into for Booster{ match self{ Booster::Velocity(velocity)=> strafesnet_common::gameplay_attributes::Booster::Velocity( - strafesnet_common::integer::Planar64Vec3::raw_array(velocity) + strafesnet_common::integer::vec3::raw_array(velocity) ), Booster::Energy{direction,energy}=> strafesnet_common::gameplay_attributes::Booster::Energy{ - direction:strafesnet_common::integer::Planar64Vec3::raw_array(direction), + direction:strafesnet_common::integer::vec3::raw_array(direction), energy:strafesnet_common::integer::Planar64::raw(energy) }, Booster::AirTime(time)=> @@ -158,16 +158,16 @@ impl From for Booster{ fn from(value:strafesnet_common::gameplay_attributes::Booster)->Self{ match value{ strafesnet_common::gameplay_attributes::Booster::Velocity(velocity)=> - Booster::Velocity(velocity.get().to_array()), + Booster::Velocity(velocity.map(|t|t.to_raw()).to_array()), strafesnet_common::gameplay_attributes::Booster::Energy{direction,energy}=> Booster::Energy{ - direction:direction.get().to_array(), - energy:energy.get(), + direction:direction.map(|t|t.to_raw()).to_array(), + energy:energy.to_raw(), }, strafesnet_common::gameplay_attributes::Booster::AirTime(time)=> Booster::AirTime(time.get()), strafesnet_common::gameplay_attributes::Booster::Height(height)=> - Booster::Height(height.get()), + Booster::Height(height.to_raw()), } } } @@ -235,23 +235,23 @@ impl Into for SetTrajecto ), SetTrajectory::DotVelocity{direction,dot}=> strafesnet_common::gameplay_attributes::SetTrajectory::DotVelocity{ - direction:strafesnet_common::integer::Planar64Vec3::raw_array(direction), + direction:strafesnet_common::integer::vec3::raw_array(direction), dot:strafesnet_common::integer::Planar64::raw(dot), }, SetTrajectory::TargetPointTime{target_point,time}=> strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointTime{ - target_point:strafesnet_common::integer::Planar64Vec3::raw_array(target_point), + target_point:strafesnet_common::integer::vec3::raw_array(target_point), time:strafesnet_common::integer::Time::raw(time), }, SetTrajectory::TargetPointSpeed{target_point,speed,trajectory_choice}=> strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointSpeed{ - target_point:strafesnet_common::integer::Planar64Vec3::raw_array(target_point), + target_point:strafesnet_common::integer::vec3::raw_array(target_point), speed:strafesnet_common::integer::Planar64::raw(speed), trajectory_choice:trajectory_choice.into(), }, SetTrajectory::Velocity(velocity)=> strafesnet_common::gameplay_attributes::SetTrajectory::Velocity( - strafesnet_common::integer::Planar64Vec3::raw_array(velocity) + strafesnet_common::integer::vec3::raw_array(velocity) ), } } @@ -265,27 +265,27 @@ impl From for SetTrajecto ), strafesnet_common::gameplay_attributes::SetTrajectory::Height(height)=> SetTrajectory::Height( - height.get() + height.to_raw() ), strafesnet_common::gameplay_attributes::SetTrajectory::DotVelocity{direction,dot}=> SetTrajectory::DotVelocity{ - direction:direction.get().to_array(), - dot:dot.get(), + direction:direction.map(|t|t.to_raw()).to_array(), + dot:dot.to_raw(), }, strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointTime{target_point,time}=> SetTrajectory::TargetPointTime{ - target_point:target_point.get().to_array(), + target_point:target_point.map(|t|t.to_raw()).to_array(), time:time.get(), }, strafesnet_common::gameplay_attributes::SetTrajectory::TargetPointSpeed{target_point,speed,trajectory_choice}=> SetTrajectory::TargetPointSpeed{ - target_point:target_point.get().to_array(), - speed:speed.get(), + target_point:target_point.map(|t|t.to_raw()).to_array(), + speed:speed.to_raw(), trajectory_choice:trajectory_choice.into(), }, strafesnet_common::gameplay_attributes::SetTrajectory::Velocity(velocity)=> SetTrajectory::Velocity( - velocity.get().to_array() + velocity.map(|t|t.to_raw()).to_array() ), } } diff --git a/src/newtypes/gameplay_style.rs b/src/newtypes/gameplay_style.rs index 64d98b9..9033700 100644 --- a/src/newtypes/gameplay_style.rs +++ b/src/newtypes/gameplay_style.rs @@ -68,9 +68,9 @@ impl TryInto for StyleModifie walk:self.walk.map(Into::into), ladder:self.ladder.map(Into::into), swim:self.swim.map(Into::into), - gravity:strafesnet_common::integer::Planar64Vec3::raw_array(self.gravity), + gravity:strafesnet_common::integer::vec3::raw_array(self.gravity), hitbox:self.hitbox.into(), - camera_offset:strafesnet_common::integer::Planar64Vec3::raw_array(self.camera_offset), + camera_offset:strafesnet_common::integer::vec3::raw_array(self.camera_offset), mass:strafesnet_common::integer::Planar64::raw(self.mass), }) } @@ -94,10 +94,10 @@ impl From for StyleModifiers{ walk:value.walk.map(Into::into), ladder:value.ladder.map(Into::into), swim:value.swim.map(Into::into), - gravity:value.gravity.get().to_array(), + gravity:value.gravity.map(|t|t.to_raw()).to_array(), hitbox:value.hitbox.into(), - camera_offset:value.camera_offset.get().to_array(), - mass:value.mass.get(), + camera_offset:value.camera_offset.map(|t|t.to_raw()).to_array(), + mass:value.mass.to_raw(), } } } @@ -148,9 +148,9 @@ impl From for JumpImpulse{ fn from(value:strafesnet_common::gameplay_style::JumpImpulse)->Self{ match value{ strafesnet_common::gameplay_style::JumpImpulse::Time(time)=>JumpImpulse::Time(time.get()), - strafesnet_common::gameplay_style::JumpImpulse::Height(height)=>JumpImpulse::Height(height.get()), - strafesnet_common::gameplay_style::JumpImpulse::Linear(deltav)=>JumpImpulse::Linear(deltav.get()), - strafesnet_common::gameplay_style::JumpImpulse::Energy(energy)=>JumpImpulse::Energy(energy.get()), + strafesnet_common::gameplay_style::JumpImpulse::Height(height)=>JumpImpulse::Height(height.to_raw()), + strafesnet_common::gameplay_style::JumpImpulse::Linear(deltav)=>JumpImpulse::Linear(deltav.to_raw()), + strafesnet_common::gameplay_style::JumpImpulse::Energy(energy)=>JumpImpulse::Energy(energy.to_raw()), } } } @@ -223,8 +223,8 @@ impl From for StrafeSettings{ Self{ header, enable:value.enable.into(), - mv:value.mv.get(), - air_accel_limit:value.air_accel_limit.map(|a|a.get()), + mv:value.mv.to_raw(), + air_accel_limit:value.air_accel_limit.map(|a|a.to_raw()), tick_rate:value.tick_rate.into(), } } @@ -245,7 +245,7 @@ impl Into for PropulsionS impl From for PropulsionSettings{ fn from(value:strafesnet_common::gameplay_style::PropulsionSettings)->Self{ Self{ - magnitude:value.magnitude.get(), + magnitude:value.magnitude.to_raw(), } } } @@ -300,9 +300,9 @@ impl From for JumpSettings{ fn from(value:strafesnet_common::gameplay_style::JumpSettings)->Self{ let (impulse,impulse_header)=match value.impulse{ strafesnet_common::gameplay_style::JumpImpulse::Time(impulse)=>(impulse.get(),0), - strafesnet_common::gameplay_style::JumpImpulse::Height(impulse)=>(impulse.get(),1), - strafesnet_common::gameplay_style::JumpImpulse::Linear(impulse)=>(impulse.get(),2), - strafesnet_common::gameplay_style::JumpImpulse::Energy(impulse)=>(impulse.get(),3), + strafesnet_common::gameplay_style::JumpImpulse::Height(impulse)=>(impulse.to_raw(),1), + strafesnet_common::gameplay_style::JumpImpulse::Linear(impulse)=>(impulse.to_raw(),2), + strafesnet_common::gameplay_style::JumpImpulse::Energy(impulse)=>(impulse.to_raw(),3), }; let calculation_header=match value.calculation{ strafesnet_common::gameplay_style::JumpCalculation::Max=>0, @@ -337,8 +337,8 @@ impl Into for AccelerateS impl From for AccelerateSettings{ fn from(value:strafesnet_common::gameplay_style::AccelerateSettings)->Self{ Self{ - accel:value.accel.get(), - topspeed:value.topspeed.get(), + accel:value.accel.to_raw(), + topspeed:value.topspeed.to_raw(), } } } @@ -365,9 +365,9 @@ impl From for WalkSettings{ fn from(value:strafesnet_common::gameplay_style::WalkSettings)->Self{ Self{ accelerate:value.accelerate.into(), - static_friction:value.static_friction.get(), - kinetic_friction:value.kinetic_friction.get(), - surf_dot:value.surf_dot.get(), + static_friction:value.static_friction.to_raw(), + kinetic_friction:value.kinetic_friction.to_raw(), + surf_dot:value.surf_dot.to_raw(), } } } @@ -390,7 +390,7 @@ impl From for LadderSettings{ fn from(value:strafesnet_common::gameplay_style::LadderSettings)->Self{ Self{ accelerate:value.accelerate.into(), - dot:value.dot.get(), + dot:value.dot.to_raw(), } } } @@ -427,7 +427,7 @@ pub struct Hitbox{ impl Into for Hitbox{ fn into(self)->strafesnet_common::gameplay_style::Hitbox{ strafesnet_common::gameplay_style::Hitbox{ - halfsize:strafesnet_common::integer::Planar64Vec3::raw_array(self.halfsize), + halfsize:strafesnet_common::integer::vec3::raw_array(self.halfsize), mesh:self.mesh.into(), } } @@ -435,7 +435,7 @@ impl Into for Hitbox{ impl From for Hitbox{ fn from(value:strafesnet_common::gameplay_style::Hitbox)->Self{ Self{ - halfsize:value.halfsize.get().to_array(), + halfsize:value.halfsize.map(|t|t.to_raw()).to_array(), mesh:value.mesh.into(), } } diff --git a/src/newtypes/model.rs b/src/newtypes/model.rs index 6b874d0..0caeb44 100644 --- a/src/newtypes/model.rs +++ b/src/newtypes/model.rs @@ -153,8 +153,8 @@ pub struct Mesh{ impl Into for Mesh{ fn into(self)->strafesnet_common::model::Mesh{ strafesnet_common::model::Mesh{ - unique_pos:self.unique_pos.into_iter().map(strafesnet_common::integer::Planar64Vec3::raw_array).collect(), - unique_normal:self.unique_normal.into_iter().map(strafesnet_common::integer::Planar64Vec3::raw_array).collect(), + unique_pos:self.unique_pos.into_iter().map(strafesnet_common::integer::vec3::raw_array).collect(), + unique_normal:self.unique_normal.into_iter().map(strafesnet_common::integer::vec3::raw_array).collect(), unique_tex:self.unique_tex.into_iter().map(strafesnet_common::model::TextureCoordinate::from_array).collect(), unique_color:self.unique_color.into_iter().map(strafesnet_common::model::Color4::from_array).collect(), unique_vertices:self.unique_vertices.into_iter().map(|vert|strafesnet_common::model::IndexedVertex{ @@ -200,10 +200,10 @@ impl From for Mesh{ physics_groups:value.physics_groups.len() as u32, }, unique_pos:value.unique_pos.into_iter() - .map(|pos|pos.get().to_array()) + .map(|pos|pos.map(|t|t.to_raw()).to_array()) .collect(), unique_normal:value.unique_normal.into_iter() - .map(|normal|normal.get().to_array()) + .map(|normal|normal.map(|t|t.to_raw()).to_array()) .collect(), unique_tex:value.unique_tex.into_iter() .map(|tex|tex.to_array()) @@ -243,12 +243,12 @@ impl Into for Model{ attributes:strafesnet_common::gameplay_attributes::CollisionAttributesId::new(self.attributes), color:strafesnet_common::model::Color4::from_array(self.color), transform:strafesnet_common::integer::Planar64Affine3::new( - strafesnet_common::integer::Planar64Mat3::from_cols( - strafesnet_common::integer::Planar64Vec3::raw_xyz(_0,_1,_2), - strafesnet_common::integer::Planar64Vec3::raw_xyz(_3,_4,_5), - strafesnet_common::integer::Planar64Vec3::raw_xyz(_6,_7,_8) - ), - strafesnet_common::integer::Planar64Vec3::raw_xyz(_9,_a,_b) + strafesnet_common::integer::Planar64Mat3::from_rows([ + strafesnet_common::integer::vec3::raw_xyz(_0,_1,_2), + strafesnet_common::integer::vec3::raw_xyz(_3,_4,_5), + strafesnet_common::integer::vec3::raw_xyz(_6,_7,_8) + ]), + strafesnet_common::integer::vec3::raw_xyz(_9,_a,_b) ), } } @@ -261,10 +261,10 @@ impl From for Model{ [_6,_7,_8], [_9,_a,_b] )=( - value.transform.matrix3.x_axis.get().to_array(), - value.transform.matrix3.y_axis.get().to_array(), - value.transform.matrix3.z_axis.get().to_array(), - value.transform.translation.get().to_array() + value.transform.matrix3.x_axis.map(|t|t.to_raw()).to_array(), + value.transform.matrix3.y_axis.map(|t|t.to_raw()).to_array(), + value.transform.matrix3.z_axis.map(|t|t.to_raw()).to_array(), + value.transform.translation.map(|t|t.to_raw()).to_array() ); Self{ mesh:value.mesh.get(),