From 0b4d3c9e20dffa6c5355532fa0bf74c505e5ee16 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 30 Oct 2022 00:12:28 +0100 Subject: [PATCH] Fixed scaling of airships --- common/src/states/utils.rs | 2 +- common/systems/src/phys.rs | 18 ++++++++++-------- server/src/state_ext.rs | 1 - voxygen/anim/src/ship/mod.rs | 3 ++- voxygen/src/scene/figure/mod.rs | 22 +++++++++++++++++----- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 68c8e06641..df50cd136b 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -220,7 +220,7 @@ impl Body { _ => 2.0, }, Body::Ship(ship) if ship.has_water_thrust() => 0.1, - Body::Ship(_) => 0.035, + Body::Ship(_) => 0.12, Body::Arthropod(_) => 3.5, } } diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index 6c738fa675..b1f2a63a2c 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -1102,19 +1102,21 @@ impl<'a> PhysicsData<'a> { // TODO: Cache the matrices here to avoid recomputing - let transform_last_from = Mat4::::translation_3d( - previous_cache_other.pos.unwrap_or(*pos_other).0 - - previous_cache.pos.unwrap_or(Pos(wpos)).0, - ) * Mat4::from( - previous_cache_other.ori, - ) * Mat4::::translation_3d( - voxel_collider.translation, - ); + let transform_last_from = + Mat4::::translation_3d( + previous_cache_other.pos.unwrap_or(*pos_other).0 + - previous_cache.pos.unwrap_or(Pos(wpos)).0, + ) * Mat4::from(previous_cache_other.ori) + * Mat4::::scaling_3d(previous_cache_other.scale) + * Mat4::::translation_3d( + voxel_collider.translation, + ); let transform_last_to = transform_last_from.inverted(); let transform_from = Mat4::::translation_3d(pos_other.0 - wpos) * Mat4::from(ori_other.to_quat()) + * Mat4::::scaling_3d(previous_cache_other.scale) * Mat4::::translation_3d( voxel_collider.translation, ); diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index b58167357e..e6a953013e 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -351,7 +351,6 @@ impl StateExt for State { .with(body.density()) .with(make_collider(ship)) .with(body) - .with(comp::Scale(comp::ship::AIRSHIP_SCALE)) .with(comp::Controller::default()) .with(Inventory::with_empty()) .with(comp::CharacterState::default()) diff --git a/voxygen/anim/src/ship/mod.rs b/voxygen/anim/src/ship/mod.rs index 81c9b33f2c..d1d0c4e679 100644 --- a/voxygen/anim/src/ship/mod.rs +++ b/voxygen/anim/src/ship/mod.rs @@ -31,7 +31,8 @@ impl Skeleton for ShipSkeleton { buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], body: Self::Body, ) -> Offsets { - let scale_mat = Mat4::scaling_3d(1.0 / 11.0); + // Ships are normal scale + let scale_mat = Mat4::scaling_3d(1.0); let bone0_mat = base_mat * scale_mat * Mat4::::from(self.bone0); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 7d2bb1cb49..e7eeac8d0c 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -33,7 +33,7 @@ use common::{ comp::{ inventory::slot::EquipSlot, item::{tool::AbilityContext, Hands, ItemKind, ToolKind}, - Body, CharacterState, Collider, Controller, Health, Inventory, Item, ItemKey, Last, + ship, Body, CharacterState, Collider, Controller, Health, Inventory, Item, ItemKey, Last, LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, SkillSet, Stance, Vel, }, @@ -6709,10 +6709,22 @@ impl FigureMgr { } { let model_entry = model_entry?; - let figure_low_detail_distance = - figure_lod_render_distance * scale.map_or(1.0, |s| s.0) * 0.75; - let figure_mid_detail_distance = - figure_lod_render_distance * scale.map_or(1.0, |s| s.0) * 0.5; + let figure_low_detail_distance = figure_lod_render_distance + * if matches!(body, Body::Ship(_)) { + ship::AIRSHIP_SCALE + } else { + 1.0 + } + * scale.map_or(1.0, |s| s.0) + * 0.75; + let figure_mid_detail_distance = figure_lod_render_distance + * if matches!(body, Body::Ship(_)) { + ship::AIRSHIP_SCALE + } else { + 1.0 + } + * scale.map_or(1.0, |s| s.0) + * 0.5; let model = if pos.distance_squared(cam_pos) > figure_low_detail_distance.powi(2) { model_entry.lod_model(2)