diff --git a/assets/server/manifests/ship_manifest.ron b/assets/server/manifests/ship_manifest.ron index d964d990b4..36184ce50f 100644 --- a/assets/server/manifests/ship_manifest.ron +++ b/assets/server/manifests/ship_manifest.ron @@ -47,4 +47,26 @@ central: ("air_balloon.rudder"), ), ), + SailBoat: ( + bone0: ( + offset: (-6.5, -15.5, 0.0), + phys_offset: (0.0, 0.0, 0.0), + central: ("sail_boat.structure"), + ), + bone1: ( + offset: (0.0, 0.0, 0.0), + phys_offset: (0.0, 0.0, 0.0), + central: ("empty"), + ), + bone2: ( + offset: (0.0, 0.0, 0.0), + phys_offset: (0.0, 0.0, 0.0), + central: ("empty"), + ), + bone3: ( + offset: (-1.5, -6.0, -5.0), + phys_offset: (0.0, 0.0, 0.0), + central: ("empty"), + ), + ), }) diff --git a/assets/server/voxel/sail_boat/structure.vox b/assets/server/voxel/sail_boat/structure.vox new file mode 100644 index 0000000000..023d62b9c6 --- /dev/null +++ b/assets/server/voxel/sail_boat/structure.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17cef56b0257883c2b7ea898a04860706d2c6ec7b18f5c1e9c965164af05ae7c +size 5524 diff --git a/assets/world/manifests/shrubs.ron b/assets/world/manifests/shrubs.ron index 61cc9d34b6..b8cf355e61 100644 --- a/assets/world/manifests/shrubs.ron +++ b/assets/world/manifests/shrubs.ron @@ -7,26 +7,26 @@ ), ( specifier: "world.shrub.jungle-bush-0", - center: (5, 5, 1), + center: (5, 5, 3), ), ( specifier: "world.shrub.jungle-bush-1", - center: (5, 5, 1), + center: (5, 5, 2), ), ( specifier: "world.shrub.jungle-bush-2", - center: (5, 5, 1), + center: (5, 5, 3), ), ( specifier: "world.shrub.jungle-bush-3", - center: (5, 5, 1), + center: (5, 5, 3), ), ( specifier: "world.shrub.jungle-bush-4", - center: (5, 5, 1), + center: (5, 5, 4), ), ( specifier: "world.shrub.jungle-bush-5", - center: (5, 5, 1), + center: (5, 5, 5), ), ] diff --git a/assets/world/shrub/jungle-bush-0.vox b/assets/world/shrub/jungle-bush-0.vox index f445225da7..d6fcb4d105 100644 --- a/assets/world/shrub/jungle-bush-0.vox +++ b/assets/world/shrub/jungle-bush-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2bc247549fcbc390901805090bfea823569e309346074681efa907fa37b8d590 -size 2360 +oid sha256:35c228f2bd6b4e4b11e62016e37e910eeb81f51d1cdf9329a9dbfcf6565e1f5e +size 2444 diff --git a/assets/world/shrub/jungle-bush-1.vox b/assets/world/shrub/jungle-bush-1.vox index 02fb9d4948..298ef524d1 100644 --- a/assets/world/shrub/jungle-bush-1.vox +++ b/assets/world/shrub/jungle-bush-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a30a82f591fca867ab6287122da46f7e9a55796fea9f352a5faeb932e4671fae -size 1788 +oid sha256:dab85c0bf1c791d0b91038723b9cc79b2f58d2a4832f3d60436e0c1ab3c123f9 +size 2192 diff --git a/assets/world/shrub/jungle-bush-2.vox b/assets/world/shrub/jungle-bush-2.vox index dd98838c4c..32894f9c3a 100644 --- a/assets/world/shrub/jungle-bush-2.vox +++ b/assets/world/shrub/jungle-bush-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e08629bd301f83ed496deba2d1e4c44944e9e96e211d851d9ab161e59129ec4 -size 2456 +oid sha256:3ab454267e0f243faef48831e81f511df30e3ad0589a34180674a37dd509cfea +size 2012 diff --git a/assets/world/shrub/jungle-bush-3.vox b/assets/world/shrub/jungle-bush-3.vox index 2944795071..23d3b19535 100644 --- a/assets/world/shrub/jungle-bush-3.vox +++ b/assets/world/shrub/jungle-bush-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c1f54371219692b3f9aedc071d198f4541c6bfdef16626349a3728eaddfc993 -size 1672 +oid sha256:4673b924a97166c519d8e22a1c6d1839cd570c877cd4b7ecd1469adbf88e37eb +size 1968 diff --git a/assets/world/shrub/jungle-bush-4.vox b/assets/world/shrub/jungle-bush-4.vox index 58028b2599..1fe19a7154 100644 --- a/assets/world/shrub/jungle-bush-4.vox +++ b/assets/world/shrub/jungle-bush-4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73a2e29737c98f68f8ff7c6af66fbf0dfb8d8fa4c942bb1d3e474d0935cba6f7 -size 1640 +oid sha256:280c83933dc0e7d98d17564c33efa95fe2416150171a677975ddc2073d25ce26 +size 2020 diff --git a/assets/world/shrub/jungle-bush-5.vox b/assets/world/shrub/jungle-bush-5.vox index 61807b4219..6b51e26884 100644 --- a/assets/world/shrub/jungle-bush-5.vox +++ b/assets/world/shrub/jungle-bush-5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3304b2e8270fa81f714e5fc940e616ec81f17ec2b136ee6e9538f3622eea74f4 -size 2664 +oid sha256:9f05fbe323c57abd5ce550b83f807ed7af3ea297f4eb284cd3b42b48f336f88c +size 3784 diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index d09d78b460..45982c3557 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -854,6 +854,7 @@ impl Body { Body::Ship(ship) => match ship { ship::Body::DefaultAirship => [0.0, 0.0, 10.0], ship::Body::AirBalloon => [0.0, 0.0, 5.0], + ship::Body::SailBoat => [-2.0, -5.0, 4.0], }, _ => [0.0, 0.0, 0.0], } diff --git a/common/src/comp/body/ship.rs b/common/src/comp/body/ship.rs index 09bae038e0..375645db08 100644 --- a/common/src/comp/body/ship.rs +++ b/common/src/comp/body/ship.rs @@ -1,13 +1,13 @@ use crate::{ comp::{Density, Mass}, - consts::AIR_DENSITY, + consts::{AIR_DENSITY, WATER_DENSITY}, make_case_elim, }; use rand::prelude::SliceRandom; use serde::{Deserialize, Serialize}; use vek::Vec3; -pub const ALL_BODIES: [Body; 2] = [Body::DefaultAirship, Body::AirBalloon]; +pub const ALL_BODIES: [Body; 3] = [Body::DefaultAirship, Body::AirBalloon, Body::SailBoat]; make_case_elim!( body, @@ -16,6 +16,7 @@ make_case_elim!( pub enum Body { DefaultAirship = 0, AirBalloon = 1, + SailBoat = 2, } ); @@ -35,6 +36,7 @@ impl Body { match self { Body::DefaultAirship => "airship_human.structure", Body::AirBalloon => "air_balloon.structure", + Body::SailBoat => "sail_boat.structure", } } @@ -42,15 +44,21 @@ impl Body { match self { Body::DefaultAirship => Vec3::new(25.0, 50.0, 40.0), Body::AirBalloon => Vec3::new(25.0, 50.0, 40.0), + Body::SailBoat => Vec3::new(13.0, 31.0, 6.0), } } fn balloon_vol(&self) -> f32 { - let spheroid_vol = |equat_d: f32, polar_d: f32| -> f32 { - (std::f32::consts::PI / 6.0) * equat_d.powi(2) * polar_d - }; - let dim = self.dimensions(); - spheroid_vol(dim.z, dim.y) + match self { + Body::DefaultAirship | Body::AirBalloon => { + let spheroid_vol = |equat_d: f32, polar_d: f32| -> f32 { + (std::f32::consts::PI / 6.0) * equat_d.powi(2) * polar_d + }; + let dim = self.dimensions(); + spheroid_vol(dim.z, dim.y) + }, + _ => 0.0, + } } fn hull_vol(&self) -> f32 { @@ -66,15 +74,25 @@ impl Body { Density(ratio * oak_density + (1.0 - ratio) * AIR_DENSITY) } - pub fn density(&self) -> Density { Density(AIR_DENSITY) } + pub fn density(&self) -> Density { + match self { + Body::DefaultAirship | Body::AirBalloon => Density(AIR_DENSITY), + _ => Density(AIR_DENSITY * 0.75 + WATER_DENSITY * 0.25), // Most boats should be buoyant + } + } pub fn mass(&self) -> Mass { Mass((self.hull_vol() + self.balloon_vol()) * self.density().0) } pub fn can_fly(&self) -> bool { match self { Body::DefaultAirship | Body::AirBalloon => true, + _ => false, } } + + pub fn has_water_thrust(&self) -> bool { + !self.can_fly() // TODO: Differentiate this more carefully + } } /// Terrain is 11.0 scale relative to small-scale voxels, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 9d1d4ffb69..5f7b20790f 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -200,6 +200,8 @@ impl Body { Body::QuadrupedLow(_) => Some(300.0 * self.mass().0), Body::QuadrupedMedium(_) => Some(300.0 * self.mass().0), Body::QuadrupedSmall(_) => Some(300.0 * self.mass().0), + Body::Ship(ship) if ship.has_water_thrust() => Some(500.0 * self.mass().0), + _ => None, } } diff --git a/voxygen/anim/src/ship/mod.rs b/voxygen/anim/src/ship/mod.rs index afecb5e600..a1afe338fa 100644 --- a/voxygen/anim/src/ship/mod.rs +++ b/voxygen/anim/src/ship/mod.rs @@ -31,7 +31,9 @@ impl Skeleton for ShipSkeleton { buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], body: Self::Body, ) -> Offsets { - let bone0_mat = base_mat * Mat4::scaling_3d(1.0 / 11.0) * Mat4::::from(self.bone0); + let scale_mat = Mat4::scaling_3d(1.0 / 11.0); + + let bone0_mat = base_mat * scale_mat * Mat4::::from(self.bone0); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ make_bone(bone0_mat), @@ -43,10 +45,12 @@ impl Skeleton for ShipSkeleton { lantern: None, // TODO: see quadruped_medium for how to animate this mount_bone: Transform { - position: common::comp::Body::Ship(body) - .mountee_offset() - .into_tuple() - .into(), + position: (base_mat * scale_mat).mul_point( + common::comp::Body::Ship(body) + .mountee_offset() + .into_tuple() + .into(), + ), ..Default::default() }, } @@ -89,18 +93,22 @@ impl<'a> From<&'a Body> for SkeletonAttr { bone0: match body { DefaultAirship => (0.0, 0.0, 0.0), AirBalloon => (0.0, 0.0, 0.0), + SailBoat => (0.0, 0.0, 0.0), }, bone1: match body { DefaultAirship => (-13.0, -25.0, 10.0), AirBalloon => (0.0, 0.0, 0.0), + SailBoat => (0.0, 0.0, 0.0), }, bone2: match body { DefaultAirship => (13.0, -25.0, 10.0), AirBalloon => (0.0, 0.0, 0.0), + SailBoat => (0.0, 0.0, 0.0), }, bone3: match body { DefaultAirship => (0.0, -27.5, 8.5), AirBalloon => (0.0, -9.0, 8.0), + SailBoat => (0.0, 0.0, 0.0), }, } }